/* ===== What's Missing? =====
   Style: Claymorphism (matches PTV Games)
   Fonts: Baloo 2 + Comic Neue
   Brand: #01311F / #BF9E69 / #F4F2EE
   ========================= */

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Brand */
  --primary: #01311F;
  --primary-mid: #0A5438;
  --primary-light: #3D8B6B;
  --primary-bg: #E2EDE7;
  --accent: #BF9E69;
  --accent-light: #D4BC8E;
  --accent-bg: #F5F0E5;
  --cream: #F4F2EE;

  /* Feedback */
  --success: #3D8B6B;
  --error: #C45B5B;

  /* Text */
  --text: #1A2A22;
  --text-muted: #5E6E64;
  --bg: var(--cream);
  --white: #FFFFFF;

  /* Tokens */
  --radius: 20px;
  --radius-sm: 12px;
  --shadow-clay: 6px 6px 12px rgba(1, 49, 31, 0.06), -2px -2px 8px rgba(255, 255, 255, 0.9);
  --shadow-clay-hover: 8px 8px 16px rgba(1, 49, 31, 0.10), -3px -3px 10px rgba(255, 255, 255, 0.95);
  --shadow-clay-inset: inset 2px 2px 4px rgba(1, 49, 31, 0.05), inset -1px -1px 3px rgba(255, 255, 255, 0.7);
  --font-display: 'Baloo 2', cursive, sans-serif;
  --font-body: 'Comic Neue', cursive, sans-serif;
  --transition: 250ms ease;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-font-smoothing: antialiased;
}

a {
  text-decoration: none;
  color: inherit;
}

.hidden {
  display: none !important;
}

/* --- Page container --- */
.page {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 16px;
  position: relative;
}

/* --- Back Link --- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-muted);
  padding: 8px 0;
  margin-bottom: 8px;
  cursor: pointer;
  transition: color var(--transition);
}

.back-link:hover {
  color: var(--primary);
}

/* ==================
   INTRO SCREEN
   ================== */
.intro-card {
  background: var(--white);
  border-radius: var(--radius);
  border: 3px solid rgba(1, 49, 31, 0.06);
  box-shadow: var(--shadow-clay);
  padding: 40px 28px 32px;
  text-align: center;
}

.intro-icon {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-bg);
  border-radius: 50%;
  margin: 0 auto 16px;
  box-shadow: var(--shadow-clay-inset);
}

.eyebrow {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  margin-bottom: 4px;
}

.intro-card h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
}

.lead {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 360px;
  margin: 0 auto 28px;
}

/* Mode picker */
.mode-picker {
  margin-bottom: 24px;
}

.mode-picker h2 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}

.mode-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.mode-buttons--4col {
  grid-template-columns: repeat(4, 1fr);
}

.mode-buttons--3col {
  grid-template-columns: repeat(3, 1fr);
}

.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--bg);
  border: 2px solid rgba(1, 49, 31, 0.06);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-clay-inset);
}

.mode-btn:hover {
  border-color: var(--accent-light);
  background: var(--accent-bg);
}

.mode-btn.selected {
  border-color: var(--primary);
  background: var(--primary-bg);
  box-shadow: var(--shadow-clay);
}

.mode-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}

.mode-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Compact mode buttons in 4-col grid */
.mode-buttons--4col .mode-btn {
  padding: 8px 4px;
}

.mode-buttons--4col .mode-label {
  font-size: 0.8rem;
}

.mode-buttons--4col .mode-desc {
  font-size: 0.65rem;
}

/* Compact cat buttons in 3-col grid */
.mode-buttons--3col .mode-btn {
  padding: 10px 6px;
}

.mode-buttons--3col .mode-label {
  font-size: 0.85rem;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  border: 3px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 12px 28px;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}

.btn:focus-visible {
  outline: 3px solid var(--accent-light);
  outline-offset: 2px;
}

.btn--primary {
  background: var(--primary);
  color: var(--white);
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: var(--shadow-clay), inset 0 -3px 0 rgba(0, 0, 0, 0.15);
  width: 100%;
}

.btn--primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-clay-hover), inset 0 -3px 0 rgba(0, 0, 0, 0.15);
  background: #024A2E;
}

.btn--primary:active {
  transform: translateY(1px);
  box-shadow: var(--shadow-clay-inset);
}

.btn--ghost {
  background: var(--bg);
  color: var(--text);
  border-color: rgba(1, 49, 31, 0.08);
  box-shadow: var(--shadow-clay);
}

.btn--ghost:hover {
  background: var(--white);
  transform: translateY(-1px);
}

/* ==================
   GAME SCREEN
   ================== */

/* HUD */
.hud {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.hud__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--white);
  border-radius: var(--radius-sm);
  border: 2px solid rgba(1, 49, 31, 0.05);
  box-shadow: var(--shadow-clay-inset);
  padding: 8px 16px;
  min-width: 72px;
}

.hud__item--status {
  flex: 1;
  min-width: 100px;
}

.hud__label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.hud__value {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--text);
  line-height: 1.1;
}

.hud__status {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent);
  text-align: center;
}

.hud__status.memorize {
  color: var(--accent);
}

.hud__status.recall {
  color: var(--success);
}

.hud__status.wrong {
  color: var(--error);
}

.hud__status.loading {
  color: var(--text-muted);
}

/* ==================
   TIMER BAR
   ================== */
.timer-bar {
  width: 100%;
  height: 8px;
  background: var(--white);
  border-radius: 4px;
  border: 2px solid rgba(1, 49, 31, 0.05);
  box-shadow: var(--shadow-clay-inset);
  margin-bottom: 16px;
  overflow: hidden;
}

.timer-bar__fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--primary-light), var(--accent));
  border-radius: 4px;
  transition: width 50ms linear;
}

.timer-bar__fill.warning {
  background: linear-gradient(90deg, var(--error), #E8A040);
}

/* ==================
   IMAGE GRID
   ================== */
.image-grid {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.image-grid[data-cols="2"] { grid-template-columns: repeat(2, 1fr); }
.image-grid[data-cols="3"] { grid-template-columns: repeat(3, 1fr); }
.image-grid[data-cols="4"] { grid-template-columns: repeat(4, 1fr); }

.image-card {
  aspect-ratio: 1;
  border-radius: var(--radius);
  border: 4px solid rgba(1, 49, 31, 0.08);
  overflow: hidden;
  position: relative;
  background: var(--white);
  box-shadow: var(--shadow-clay);
  transition: transform 300ms ease, opacity 300ms ease;
}

.image-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Blackout phase: cards fade to dark before reveal */
.image-card.blackout {
  opacity: 0;
  transform: scale(0.92);
}

/* Missing slot placeholder */
.image-card.missing-slot {
  background: var(--accent-bg);
  border-color: var(--accent-light);
  border-style: dashed;
  display: flex;
  align-items: center;
  justify-content: center;
}

.missing-slot__icon {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--accent);
  opacity: 0.7;
  line-height: 1;
}

/* Correct highlight on answered card */
.image-card.correct-highlight {
  border-color: var(--success);
  box-shadow: 0 0 16px 2px rgba(61, 139, 107, 0.35);
}

/* Wrong highlight */
.image-card.wrong-highlight {
  border-color: var(--error);
  animation: wrongShake 400ms ease;
}

@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* ==================
   ANSWER PANEL
   ================== */
.answer-panel {
  margin-bottom: 16px;
}

.answer-panel__label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  text-align: center;
  margin-bottom: 10px;
}

.answer-panel__choices {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.answer-choice {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-sm);
  border: 3px solid rgba(1, 49, 31, 0.08);
  overflow: hidden;
  cursor: pointer;
  background: var(--white);
  box-shadow: var(--shadow-clay);
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
  padding: 0;
}

.answer-choice:hover {
  transform: scale(1.08);
  border-color: var(--accent-light);
  box-shadow: var(--shadow-clay-hover);
}

.answer-choice img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.answer-choice.chosen-correct {
  border-color: var(--success);
  box-shadow: 0 0 12px 2px rgba(61, 139, 107, 0.35);
  transform: scale(1.1);
}

.answer-choice.chosen-wrong {
  border-color: var(--error);
  opacity: 0.6;
  transform: scale(0.95);
}

.answer-choice.reveal-correct {
  border-color: var(--success);
  box-shadow: 0 0 12px 2px rgba(61, 139, 107, 0.35);
  animation: pulseCorrect 600ms ease;
}

@keyframes pulseCorrect {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

.answer-choice.disabled {
  pointer-events: none;
}

/* ==================
   GAME CONTROLS
   ================== */
.game-controls {
  display: flex;
  gap: 10px;
}

.ctrl-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--white);
  border: 2px solid rgba(1, 49, 31, 0.06);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-clay-inset);
}

.ctrl-btn:hover {
  color: var(--primary);
  border-color: var(--primary-light);
  background: var(--primary-bg);
}

/* ==================
   OVERLAY (Game Over)
   ================== */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(26, 42, 34, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 16px;
}

.overlay__card {
  background: var(--white);
  border-radius: var(--radius);
  border: 3px solid rgba(1, 49, 31, 0.06);
  box-shadow: var(--shadow-clay-hover);
  padding: 36px 32px 28px;
  text-align: center;
  max-width: 360px;
  width: 100%;
  animation: popIn 300ms ease;
}

@keyframes popIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.overlay__icon {
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-bg);
  border-radius: 50%;
  margin: 0 auto 16px;
}

.overlay__card h2 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.overlay__score {
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 4px;
}

.overlay__detail {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.overlay__answer {
  margin-bottom: 20px;
}

.overlay__answer p {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.overlay__missing-img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 3px solid var(--accent-light);
  box-shadow: var(--shadow-clay);
}

.overlay__actions {
  display: flex;
  gap: 10px;
}

.overlay__actions .btn {
  flex: 1;
}

/* ==================
   TOAST
   ================== */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--white);
  background: var(--success);
  padding: 10px 24px;
  border-radius: 50px;
  box-shadow: 0 4px 16px rgba(1, 49, 31, 0.25);
  animation: toastIn 300ms ease, toastOut 300ms ease 1.2s forwards;
}

@keyframes toastIn {
  from { transform: translateX(-50%) translateY(-20px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

/* ==================
   FULLSCREEN MODE
   ================== */
.is-fullscreen {
  background: var(--bg);
}

.is-fullscreen .page {
  max-width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 16px 24px;
}

.is-fullscreen .screen--game {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.is-fullscreen .image-grid {
  flex: 1;
  min-height: 0;
  margin-bottom: 12px;
  margin-left: auto;
  margin-right: auto;
  align-content: center;
}

.is-fullscreen .image-card {
  aspect-ratio: 1;
}

.is-fullscreen .back-link {
  display: none;
}

/* ==================
   RESPONSIVE
   ================== */

/* Phones */
@media (max-width: 480px) {
  .page {
    padding: 12px;
  }

  .intro-card {
    padding: 28px 20px 24px;
  }

  .intro-card h1 {
    font-size: 1.6rem;
  }

  .hud__item {
    padding: 6px 10px;
    min-width: 60px;
  }

  .hud__value {
    font-size: 1.1rem;
  }

  .image-grid {
    gap: 6px;
  }

  .image-card {
    border-radius: 14px;
    border-width: 3px;
  }

  .answer-choice {
    width: 56px;
    height: 56px;
  }

  .mode-buttons--4col {
    grid-template-columns: repeat(2, 1fr);
  }

  .mode-buttons--4col .mode-btn {
    padding: 10px 8px;
  }

  .mode-buttons--4col .mode-label {
    font-size: 0.9rem;
  }

  .mode-buttons--4col .mode-desc {
    font-size: 0.7rem;
  }

  .ctrl-btn {
    padding: 8px 10px;
    font-size: 0.78rem;
    gap: 4px;
  }

  .is-fullscreen .page {
    padding: 10px 12px;
  }

  .is-fullscreen .hud {
    gap: 4px;
    margin-bottom: 10px;
  }

  .is-fullscreen .image-grid {
    gap: 4px;
    margin-bottom: 8px;
  }

  .is-fullscreen .image-card {
    border-width: 2px;
    border-radius: 10px;
  }

  .is-fullscreen .answer-choice {
    width: 48px;
    height: 48px;
  }

  .is-fullscreen .game-controls {
    gap: 6px;
  }
}

/* Small phones (iPhone SE, 320-374px) */
@media (max-width: 374px) {
  .intro-card {
    padding: 20px 14px 18px;
  }

  .intro-card h1 {
    font-size: 1.4rem;
  }

  .lead {
    font-size: 0.95rem;
    margin-bottom: 20px;
  }

  .image-grid {
    gap: 4px;
  }

  .image-card {
    border-radius: 10px;
    border-width: 2px;
  }

  .answer-choice {
    width: 48px;
    height: 48px;
  }

  .missing-slot__icon {
    font-size: 1.8rem;
  }
}

/* Tablets portrait (iPad Mini, iPad, etc.) */
@media (min-width: 481px) and (max-width: 1024px) {
  .page {
    max-width: 600px;
  }

  .image-grid {
    gap: 12px;
  }

  .answer-choice {
    width: 80px;
    height: 80px;
  }

  .is-fullscreen .page {
    max-width: 100%;
    padding: 20px 32px;
  }

  .is-fullscreen .image-grid {
    gap: 10px;
  }
}

/* Tablets landscape / large tablets */
@media (min-width: 1025px) {
  .is-fullscreen .page {
    padding: 20px 48px;
  }

  .is-fullscreen .image-grid {
    gap: 12px;
  }

  .answer-choice {
    width: 88px;
    height: 88px;
  }
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  .image-card,
  .answer-choice,
  .toast,
  .overlay__card {
    animation: none;
    transition: none;
  }
}
