:root {
  color-scheme: light;
  --ink: #191522;
  --muted: #675f72;
  --paper: #fff3d7;
  --panel: #ffffff;
  --line: #241d2d;
  --teal: #00a7a7;
  --teal-dark: #007070;
  --coral: #ff4b5f;
  --amber: #ffc928;
  --green: #22b85f;
  --violet: #6c52ff;
  --blue: #2267ff;
  --pink: #ff4fa3;
  --orange: #ff7a21;
  --shadow: 0 18px 0 rgba(25, 21, 34, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    repeating-linear-gradient(135deg, rgba(255, 79, 163, 0.16) 0 12px, transparent 12px 32px),
    linear-gradient(160deg, #fff8d9 0%, #e5fff9 42%, #ffe8f3 100%);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button {
  font: inherit;
}

.app {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 22px 0 32px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.top-actions {
  display: grid;
  gap: 10px;
  justify-items: end;
}

.round-jump {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 5px 5px 0 rgba(25, 21, 34, 0.14);
}

.round-jump span {
  padding: 0 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
  white-space: nowrap;
}

.round-shortcut {
  display: grid;
  place-items: center;
  width: 38px;
  height: 34px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--amber);
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
  box-shadow: 3px 3px 0 var(--line);
  transition:
    transform 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.round-shortcut:hover,
.round-shortcut.active {
  background: var(--pink);
  color: #ffffff;
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--line);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  max-width: 690px;
  font-size: 4.5rem;
  line-height: 0.9;
  letter-spacing: 0;
  text-shadow: 4px 4px 0 var(--amber);
}

h1 span {
  display: block;
  margin-top: 8px;
  color: var(--pink);
  font-size: 0.46em;
  line-height: 1;
  text-shadow: 3px 3px 0 #ffffff;
}

h2 {
  margin: 0 0 8px;
  font-size: 1.7rem;
  line-height: 1.08;
  letter-spacing: 0;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(4, minmax(78px, 1fr));
  gap: 8px;
  min-width: min(100%, 490px);
}

.scoreboard div {
  min-height: 70px;
  padding: 12px;
  border: 2px solid var(--line);
  background: var(--panel);
  box-shadow: 6px 6px 0 rgba(25, 21, 34, 0.14);
}

.scoreboard div:nth-child(1) {
  border-bottom: 7px solid var(--pink);
}

.scoreboard div:nth-child(2) {
  border-bottom: 7px solid var(--teal);
}

.scoreboard div:nth-child(3) {
  border-bottom: 7px solid var(--amber);
}

.scoreboard div:nth-child(4) {
  border-bottom: 7px solid var(--violet);
}

.scoreboard span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.scoreboard strong {
  display: block;
  margin-top: 5px;
  font-size: 1.6rem;
  line-height: 1;
}

.game-shell {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 3px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 201, 40, 0.82), rgba(0, 167, 167, 0.72)),
    #fff;
  box-shadow: var(--shadow);
}

.mission {
  margin: 0;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 950;
  line-height: 1.1;
  text-align: center;
  box-shadow: 4px 4px 0 rgba(25, 21, 34, 0.16);
}

.controls {
  display: grid;
  grid-template-columns: max-content max-content minmax(180px, 1fr);
  align-items: center;
  gap: 10px;
}

.primary-action,
.ghost-action {
  min-height: 44px;
  border: 2px solid var(--line);
  padding: 0 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  transition:
    transform 160ms ease,
    background 160ms ease,
    border-color 160ms ease;
}

.primary-action {
  background: var(--pink);
  color: #fff;
  box-shadow: 4px 4px 0 var(--line);
}

.primary-action:hover:not(:disabled),
.ghost-action:hover:not(:disabled) {
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 var(--line);
}

.primary-action:disabled,
.ghost-action:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.ghost-action {
  background: var(--amber);
  color: var(--ink);
  box-shadow: 4px 4px 0 var(--line);
}

.timer {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.timer span {
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  text-align: right;
  color: #ffffff;
  text-shadow: 2px 2px 0 var(--line);
}

.timer-track {
  height: 14px;
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #fff;
}

.timer-fill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transform-origin: left center;
}

.arena {
  position: relative;
  display: grid;
  place-items: center;
}

.arena.show-feedback::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: 8px;
  background: rgba(25, 21, 34, 0.32);
  pointer-events: none;
}

.image-grid {
  --grid-size: 2;
  display: grid;
  grid-template-columns: repeat(var(--grid-size), minmax(0, 1fr));
  gap: clamp(5px, 0.9vw, 10px);
  width: min(100%, 84vh, 920px);
  aspect-ratio: 1;
  margin: 0 auto;
}

.tile {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  aspect-ratio: 1;
  overflow: hidden;
  border: 3px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: #d7c0a0;
  box-shadow: 5px 5px 0 rgba(25, 21, 34, 0.16);
  cursor: pointer;
}

.tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.025);
  transition:
    filter 180ms ease,
    transform 180ms ease;
}

.tile::after {
  position: absolute;
  right: 6px;
  bottom: 6px;
  min-width: 28px;
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1;
  opacity: 0;
  transform: translateY(4px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.tile:focus-visible {
  outline: 4px solid #171a19;
  outline-offset: 2px;
}

.tile.selected {
  border-color: var(--pink);
  box-shadow: 0 0 0 4px var(--amber), 5px 5px 0 rgba(25, 21, 34, 0.18);
}

.tile.selected img {
  filter: saturate(1.18) contrast(1.05);
  transform: scale(1.08);
}

.image-grid.revealed .tile {
  cursor: default;
}

.image-grid.revealed .tile img {
  filter: saturate(0.82) contrast(0.95);
}

.image-grid.revealed .tile.hit {
  border-color: var(--green);
  box-shadow: 0 0 0 4px #b4ff4f, 5px 5px 0 rgba(25, 21, 34, 0.18);
}

.image-grid.revealed .tile.hit::after {
  content: "found";
  color: var(--green);
}

.image-grid.revealed .tile.missed {
  border-color: var(--amber);
  box-shadow: 0 0 0 4px #fff2a6, 5px 5px 0 rgba(25, 21, 34, 0.18);
}

.image-grid.revealed .tile.missed::after {
  content: "missed";
  color: #8b5a00;
}

.image-grid.revealed .tile.false-positive {
  border-color: var(--coral);
  box-shadow: 0 0 0 4px #ffc0c9, 5px 5px 0 rgba(25, 21, 34, 0.18);
}

.image-grid.revealed .tile.false-positive::after {
  content: "muffin";
  color: var(--coral);
}

.image-grid.revealed .tile.hit::after,
.image-grid.revealed .tile.missed::after,
.image-grid.revealed .tile.false-positive::after {
  opacity: 1;
  transform: translateY(0);
}

.feedback-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  display: grid;
  width: min(520px, calc(100% - 28px));
  gap: 12px;
  padding: 22px;
  border: 3px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 10px 10px 0 rgba(25, 21, 34, 0.22);
  text-align: center;
  transform: translate(-50%, -50%) rotate(-1deg);
  animation: feedback-pop 220ms cubic-bezier(0.2, 1.35, 0.35, 1) both;
}

.feedback-panel[hidden] {
  display: none;
}

.feedback-panel .eyebrow {
  margin: 0;
  color: var(--pink);
}

.feedback-panel p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.48;
}

.feedback-panel .primary-action {
  justify-self: center;
  margin-top: 4px;
  background: var(--teal);
}

@keyframes feedback-pop {
  from {
    opacity: 0;
    transform: translate(-50%, -46%) rotate(2deg) scale(0.86);
  }

  to {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(-1deg) scale(1);
  }
}

@media (max-width: 820px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    justify-items: stretch;
  }

  .round-jump {
    justify-content: center;
  }

  .scoreboard {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 0;
  }

  .controls {
    grid-template-columns: 1fr 1fr;
  }

  .timer {
    grid-column: 1 / -1;
  }

  h1 {
    font-size: 3.2rem;
  }
}

@media (max-width: 520px) {
  .app {
    width: min(100vw - 18px, 1180px);
    padding-top: 12px;
  }

  .game-shell {
    padding: 9px;
  }

  .primary-action,
  .ghost-action {
    padding: 0 10px;
  }

  .scoreboard div {
    min-height: 62px;
    padding: 10px;
  }

  .scoreboard strong {
    font-size: 1.3rem;
  }

  h1 {
    font-size: 2.55rem;
  }

  h2 {
    font-size: 1.35rem;
  }

  .feedback-panel {
    padding: 16px;
  }
}
