:root {
  --bg: #0f1226;
  --panel: #1a1f3d;
  --board-bg: #151a35;
  --cell: #1f2648;
  --cell-line: #2b3566;
  --accent: #6c7bff;
  --accent-soft: rgba(108, 123, 255, 0.25);
  --text: #eef1ff;
  --muted: #9aa3d0;
  --lock: #2fe6a0;

  --c-triangle: #ff7a7a;
  --c-star: #ffd166;
  --c-heart: #ff6fb5;
  --c-square: #58c7ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
  background: radial-gradient(1200px 800px at 50% -10%, #1b2150, var(--bg));
  color: var(--text);
  display: flex;
  justify-content: center;
  padding: 24px 16px 48px;
}

.app {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.topbar {
  text-align: center;
}

.topbar h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 0.5px;
}

.subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--panel);
  padding: 12px 14px;
  border-radius: 14px;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.control-group label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}

select {
  background: var(--cell);
  color: var(--text);
  border: 1px solid var(--cell-line);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 14px;
  cursor: pointer;
}

.stats {
  display: flex;
  gap: 18px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
}

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease;
}

.btn:hover {
  filter: brightness(1.08);
}

.btn:active {
  transform: scale(0.96);
}

.board-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
}

.board {
  position: absolute;
  inset: 0;
  background: var(--board-bg);
  border: 2px solid var(--cell-line);
  border-radius: 16px;
  padding: 8px;
  display: grid;
  gap: 6px;
}

.cell {
  position: relative;
  background: var(--cell);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cell .shadow {
  width: 62%;
  height: 62%;
  opacity: 0.22;
}

.cell .shadow svg {
  width: 100%;
  height: 100%;
  fill: #ffffff;
}

/* Pieces layer */
.piece {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: left 0.18s cubic-bezier(0.25, 0.9, 0.3, 1),
              top 0.18s cubic-bezier(0.25, 0.9, 0.3, 1),
              transform 0.12s ease, box-shadow 0.15s ease;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.piece svg {
  width: 68%;
  height: 68%;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.4));
}

.piece.selected {
  outline: 3px solid var(--accent);
  outline-offset: -2px;
  box-shadow: 0 0 0 6px var(--accent-soft), 0 6px 18px rgba(0, 0, 0, 0.45);
  z-index: 5;
}

.piece.locked {
  cursor: default;
  background: rgba(47, 230, 160, 0.12);
  box-shadow: 0 0 0 3px rgba(47, 230, 160, 0.5), 0 4px 14px rgba(0, 0, 0, 0.35);
}

.piece.locked::after {
  content: "✓";
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  background: var(--lock);
  color: #06301f;
  font-size: 13px;
  font-weight: 800;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.p-triangle svg { fill: var(--c-triangle); }
.p-star svg { fill: var(--c-star); }
.p-heart svg { fill: var(--c-heart); }
.p-square svg { fill: var(--c-square); }

.dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  user-select: none;
}

.dpad-mid {
  display: flex;
  gap: 60px;
}

.dir-btn {
  width: 58px;
  height: 58px;
  border-radius: 14px;
  border: 1px solid var(--cell-line);
  background: var(--panel);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
}

.dir-btn:hover {
  background: #232a52;
}

.dir-btn:active {
  transform: scale(0.92);
  background: var(--accent);
}

.hint {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
}

.win-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 12, 30, 0.78);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  z-index: 20;
}

.win-overlay.hidden {
  display: none;
}

.win-card {
  background: var(--panel);
  padding: 28px 32px;
  border-radius: 18px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: pop 0.3s ease;
}

.win-card h2 {
  margin: 0 0 8px;
  font-size: 26px;
}

.win-card p {
  margin: 0 0 18px;
  color: var(--muted);
}

@keyframes pop {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
