:root {
  color-scheme: dark;
  --bg: #0f172a;
  --panel: rgba(15, 23, 42, 0.75);
  --tile: #1e293b;
  --tile-back: linear-gradient(145deg, #334155, #1e293b);
  --tile-border: rgba(148, 163, 184, 0.22);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #22d3ee;
  --danger: #fb7185;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at top, rgba(34, 211, 238, 0.18), transparent 34%),
    radial-gradient(circle at bottom, rgba(168, 85, 247, 0.18), transparent 32%),
    var(--bg);
  color: var(--text);
}

.app-shell {
  width: min(92vw, 720px);
  padding: 24px;
}

.game-panel {
  padding: 28px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 28px;
  background: var(--panel);
  backdrop-filter: blur(12px);
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.45);
  text-align: center;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.75rem;
  font-weight: 700;
}

h1 {
  margin: 10px 0 12px;
  font-size: clamp(2rem, 4vw, 3rem);
}

.instructions,
.hud p {
  margin: 0;
  color: var(--muted);
}

.instructions {
  max-width: 56ch;
  margin-inline: auto;
  line-height: 1.5;
}

.hud {
  display: grid;
  gap: 8px;
  margin: 18px 0 22px;
}

.board-wrapper {
  position: relative;
  width: min(78vw, 420px);
  margin: 0 auto;
}

.board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.tile {
  position: relative;
  aspect-ratio: 1;
  border: 1px solid var(--tile-border);
  border-radius: 20px;
  background: var(--tile);
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.2s ease, opacity 0.2s ease, border-color 0.2s ease;
}

.tile:hover:not(:disabled),
.tile:focus-visible:not(:disabled) {
  transform: translateY(-2px);
  border-color: rgba(34, 211, 238, 0.55);
  outline: none;
}

.tile:disabled {
  cursor: default;
}

.tile-back,
.tile-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.tile-back {
  background: var(--tile-back);
}

.tile-back::before {
  content: "?";
  font-size: clamp(1.8rem, 4vw, 2.7rem);
  font-weight: 800;
  color: rgba(226, 232, 240, 0.7);
}

.tile-face {
  opacity: 0;
  transform: scale(0.88);
}

.tile.revealed .tile-back {
  opacity: 0;
}

.tile.revealed .tile-face {
  opacity: 1;
  transform: scale(1);
}

.tile.removed {
  opacity: 0.12;
  cursor: default;
}

.shape-svg {
  width: 62%;
  height: 62%;
  display: block;
}

.target-overlay {
  position: absolute;
  inset: 50% auto auto 50%;
  width: clamp(132px, 30%, 156px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%) scale(0.92);
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 6px;
  padding: 14px;
  border-radius: 24px;
  border: 1px solid rgba(226, 232, 240, 0.22);
  background: rgba(15, 23, 42, 0.92);
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.55);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.target-overlay.visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

.target-copy,
.target-label {
  margin: 0;
}

.target-copy {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.target-icon {
  width: 58%;
  color: var(--accent);
}

.target-icon .shape-svg {
  width: 100%;
  height: auto;
}

.target-label {
  font-weight: 700;
}

.restart-button {
  margin-top: 22px;
  padding: 12px 18px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), #818cf8);
  color: #0f172a;
  font-weight: 800;
  cursor: pointer;
}

.game-over #status {
  color: var(--danger);
}

@media (max-width: 520px) {
  .game-panel {
    padding: 22px;
  }

  .board {
    gap: 10px;
  }
}