/* === Unit 10 game: kill site header offset (empty top band) === */
.arcade-header-bar,
.arcade-nav,
.nav-profile,
.profile-fab,
[data-theme-toggle],
.theme-toggle,
body > header,
.site-footer {
  display: none !important;
}
html, body {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  margin: 0 !important;
}
body.game-page,
body[data-type="game"] {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

/* Sound Match Picture — MrSheyhaki.ir Learning Arcade
   Soft circular listen button; balanced 4x4 image grid. */

:root {
  --violet: #6937d8;
  --violet-dark: #4e23af;
  --violet-light: #eee8ff;
  --cream: #fffaf2;
  --ink: #2c2450;
  --muted: #746e8d;
  --green: #27a76f;
  --red: #e85065;
  --gold: #ffbd42;
  --card-shadow: 0 8px 0 rgba(72, 42, 143, 0.12), 0 14px 28px rgba(45, 31, 88, 0.1);
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  background: var(--violet-light);
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  font-family: "Source Sans 3", Inter, system-ui, sans-serif;
  background:
    radial-gradient(circle at 12% 6%, rgba(255,255,255,.82) 0 2px, transparent 2.7px) 0 0 / 32px 32px,
    radial-gradient(circle at 90% 2%, rgba(136,92,225,.15) 0 1px, transparent 1.6px) 0 0 / 25px 25px,
    var(--violet-light);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; }
button:focus-visible { outline: 3px solid #ffbd42; outline-offset: 3px; }

.app-shell {
  width: min(100%, 640px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: clamp(14px, 3.5vw, 28px) clamp(12px, 3.2vw, 22px) 22px;
  display: grid;
  align-items: center;
}

.screen { width: 100%; }
.hidden { display: none !important; }

.start-screen,
.finish-screen {
  text-align: center;
  max-width: 460px;
  margin: auto;
}

.brand-chip,
.skill-strip,
.round-pill,
.score-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: "Nunito", Inter, sans-serif;
  font-weight: 900;
}

.brand-chip {
  gap: 7px;
  padding: 7px 13px;
  border-radius: 10px;
  font-size: 0.77rem;
  letter-spacing: .045em;
  text-transform: uppercase;
  color: var(--violet-dark);
  background: #fff;
  box-shadow: 0 4px 0 rgba(86, 45, 174, .13);
}

.brand-chip span { font-size: 1.2rem; line-height: .7; }

.speaker-orbit {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 28px auto 18px;
  display: grid;
  place-items: center;
}

.speaker-core {
  position: relative;
  z-index: 2;
  width: 82px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-family: "Nunito", sans-serif;
  font-size: 2.5rem;
  background: linear-gradient(145deg, #7e4be7, #5425b8);
  box-shadow: 0 9px 0 #3e1c91, 0 18px 24px rgba(71, 34, 158, .27);
}

.sound-wave {
  position: absolute;
  border: 3px solid rgba(105, 55, 216, .26);
  border-radius: 50%;
}
.wave-one { inset: 4px; }
.wave-two { inset: -10px; border-color: rgba(105, 55, 216, .13); }

h1, h2, p { margin-top: 0; }
h1, h2 { font-family: "Nunito", Inter, sans-serif; font-weight: 900; letter-spacing: -.04em; }
h1 { margin-bottom: 12px; font-size: clamp(2.3rem, 9vw, 3.8rem); line-height: .92; }
h1 span { color: var(--violet); }
h2 { margin-bottom: 8px; font-size: clamp(1.35rem, 5vw, 1.85rem); line-height: 1.05; }

.intro-copy {
  margin: 0 auto;
  max-width: 320px;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
}

.skill-strip {
  gap: 9px;
  margin: 20px 0 24px;
  color: var(--muted);
  font-size: .82rem;
}
.skill-strip i { width: 5px; height: 5px; border-radius: 2px; background: var(--gold); }

.primary-button {
  width: min(100%, 320px);
  min-height: 56px;
  padding: 12px 20px;
  border: 0;
  border-radius: 16px;
  cursor: pointer;
  color: #fff;
  background: var(--violet);
  box-shadow: 0 6px 0 var(--violet-dark), 0 12px 18px rgba(74, 34, 162, .2);
  font-family: "Nunito", sans-serif;
  font-weight: 900;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 150ms var(--ease), box-shadow 150ms var(--ease), background 150ms var(--ease);
}

.primary-button:hover {
  background: #7542e6;
  transform: translateY(-2px);
  box-shadow: 0 8px 0 var(--violet-dark), 0 16px 22px rgba(74, 34, 162, .24);
}

.primary-button:active {
  transform: translateY(4px) scale(.98);
  box-shadow: 0 2px 0 var(--violet-dark);
}

.button-icon {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--violet);
  background: #fff;
  font-size: .8rem;
}

/* ========== GAME ========== */
.game-screen { padding-top: 2px; }

.game-header {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}

.round-pill {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  color: var(--violet-dark);
  background: #fff;
  box-shadow: 0 3px 0 rgba(78,35,175,.14);
  font-size: 1.2rem;
  transition: transform 140ms var(--ease), box-shadow 140ms var(--ease);
}

.round-pill:active {
  transform: translateY(2px) scale(.96);
  box-shadow: 0 1px 0 rgba(78,35,175,.14);
}

.progress-area { min-width: 0; }
.progress-area p {
  margin: 0 0 5px;
  font-family: "Nunito", sans-serif;
  font-size: .78rem;
  font-weight: 900;
}
.progress-track {
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: rgba(105,55,216,.15);
}
.progress-track span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #6937d8, #a17cf7);
  transition: width 280ms var(--ease);
}

.score-pill {
  gap: 4px;
  min-width: 50px;
  height: 36px;
  padding: 0 10px;
  border-radius: 999px;
  color: #815300;
  background: #fff1c8;
  box-shadow: 0 3px 0 rgba(218,159,32,.14);
  font-size: .85rem;
}
.score-pill span { color: #e6a219; }

.listen-panel {
  padding: 16px 16px 14px;
  text-align: center;
  border-radius: 20px;
  background: var(--cream);
  box-shadow: var(--card-shadow);
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--violet);
  font-family: "Nunito", sans-serif;
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.listen-panel h2 {
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 12px;
}

/* Soft-round circle listen-again button with icon */
.listen-button {
  width: 64px;
  height: 64px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(145deg, #7e4be7, var(--violet));
  box-shadow: 0 5px 0 var(--violet-dark), 0 12px 18px rgba(74, 34, 162, .22);
  display: inline-grid;
  place-items: center;
  transition: transform 150ms var(--ease), box-shadow 150ms var(--ease), background 150ms var(--ease);
}

.listen-button:hover {
  background: linear-gradient(145deg, #8b5cf0, #7542e6);
  transform: translateY(-2px);
  box-shadow: 0 7px 0 var(--violet-dark), 0 14px 20px rgba(74, 34, 162, .26);
}

.listen-button:active {
  transform: translateY(3px) scale(.96);
  box-shadow: 0 2px 0 var(--violet-dark);
}

.listen-button .listen-icon {
  width: 28px;
  height: 28px;
  display: block;
}

.feedback {
  min-height: 1.2em;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 700;
}
.feedback.correct { color: var(--green); }
.feedback.incorrect { color: var(--red); }

/* ========== 4x4 PICTURE GRID — balanced size ========== */
.grid-wrap { margin-top: 14px; }

.picture-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(6px, 1.6vw, 10px);
}

.picture-card {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 14px;
  cursor: pointer;
  background: #f3efff;
  box-shadow: 0 4px 0 rgba(78,35,175,.14), 0 8px 14px rgba(58,31,125,.08);
  transition: transform 140ms var(--ease), box-shadow 140ms var(--ease), border-color 140ms var(--ease);
}

.picture-card:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 rgba(78,35,175,.16), 0 12px 16px rgba(58,31,125,.12);
}

.picture-card:active:not(:disabled) {
  transform: translateY(2px) scale(.97);
  box-shadow: 0 2px 0 rgba(78,35,175,.14);
}

/* Full-bleed picture — fills the soft-square card */
.picture-card img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
  background: #f3efff;
  transition: filter 200ms ease, opacity 200ms ease;
}

.picture-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border: 1px solid rgba(255,255,255,.4);
  border-radius: 12px;
}

.picture-card.matched {
  cursor: default;
  border-color: var(--green);
  box-shadow: 0 3px 0 #1e8155, 0 7px 12px rgba(32,147,96,.14);
  pointer-events: none;
}

/* Mute the matched picture */
.picture-card.matched img {
  filter: grayscale(0.85) brightness(0.72);
  opacity: 0.55;
}

.picture-card.matched::before {
  content: "✓";
  position: absolute;
  z-index: 2;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--green);
  font-family: "Nunito", sans-serif;
  font-size: 0.75rem;
  font-weight: 900;
  box-shadow: 0 2px 0 #1e8155;
}

.picture-card.wrong {
  border-color: var(--red);
  animation: nudge 270ms ease-in-out;
}

.picture-card.wrong::before {
  content: "×";
  position: absolute;
  z-index: 2;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--red);
  font-family: "Nunito", sans-serif;
  font-size: 0.95rem;
  font-weight: 900;
}

/* ========== FINISH ========== */
.trophy {
  width: 80px;
  aspect-ratio: 1;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #865900;
  background: linear-gradient(145deg, #ffd770, #ffbd42);
  box-shadow: 0 8px 0 #d99716, 0 16px 24px rgba(205,142,24,.22);
  font-family: "Nunito", sans-serif;
  font-size: 2.4rem;
}

.finish-screen h2 { font-size: clamp(1.9rem, 8vw, 3rem); }
.finish-score { margin: 16px 0 8px; color: var(--muted); font-weight: 700; }
.finish-score strong {
  margin-left: 4px;
  color: var(--violet);
  font-family: "Nunito", sans-serif;
  font-size: 1.4rem;
}

.finish-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-top: 24px;
}

.icon-button {
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  color: var(--violet);
  background: #fff;
  box-shadow: 0 5px 0 rgba(78,35,175,.14), 0 10px 16px rgba(58,31,125,.1);
  font-family: "Nunito", sans-serif;
  font-size: 1.5rem;
  transition: transform 140ms var(--ease), box-shadow 140ms var(--ease);
}

.icon-button:hover { transform: translateY(-2px); background: #faf8ff; }
.icon-button:active {
  transform: translateY(3px) scale(.96);
  box-shadow: 0 2px 0 rgba(78,35,175,.14);
}

.icon-button-primary {
  color: #fff;
  background: var(--violet);
  box-shadow: 0 5px 0 var(--violet-dark), 0 10px 16px rgba(58,31,125,.16);
}
.icon-button-primary:hover { background: #7542e6; }

@keyframes nudge {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-4px); }
  70% { transform: translateX(4px); }
}

@media (min-width: 520px) {
  .picture-grid { gap: 12px; }
  .picture-card { border-radius: 16px; }
  .listen-button { width: 72px; height: 72px; }
  .listen-button .listen-icon { width: 32px; height: 32px; }
}

@media (max-width: 380px) {
  .game-header { gap: 6px; }
  .round-pill { width: 36px; height: 36px; font-size: 1.05rem; }
  .picture-grid { gap: 5px; }
  .picture-card { border-radius: 11px; }
  .listen-button { width: 56px; height: 56px; }
  .listen-button .listen-icon { width: 24px; height: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .001ms !important;
  }
}

/* Floating back to parent folder — sits just left of the home control with a small gap */
.game-back {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  z-index: 50;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(105, 55, 216, 0.18);
  background: rgba(255, 255, 255, 0.95);
  color: #5425b8;
  font-family: Inter, system-ui, sans-serif;
  font-size: 0.85rem;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 3px 0 rgba(84, 37, 184, 0.12), 0 6px 14px rgba(32, 38, 54, 0.08);
  backdrop-filter: blur(10px);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.game-back span { display: none; }
.game-back svg { width: 18px; height: 18px; }
.game-back:hover { transform: translateY(-1px); }
.game-back:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(84, 37, 184, 0.12); }

/* Small room between fixed Back and the Home button in the header */
.game-screen {
  padding-top: 4px;
}
.game-header {
  /* back is 40px + left 10px + small gap 8px ≈ 58px */
  padding-left: calc(40px + 8px);
  margin-left: max(0px, calc(env(safe-area-inset-left) + 10px - 12px));
}


.score-submit {
  margin: 18px auto 8px;
  max-width: 320px;
  text-align: left;
}
.score-submit label {
  display: block;
  font-size: 0.75rem;
  font-weight: 900;
  color: var(--violet);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-family: "Nunito", sans-serif;
}
.score-submit-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.score-submit input {
  flex: 1;
  min-width: 120px;
  border: 2px solid #e8e0ff;
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  font-weight: 700;
}
.score-submit .primary-button {
  width: auto;
  min-height: 44px;
  padding: 8px 16px;
  font-size: 0.9rem;
}
.score-submit-status {
  margin: 8px 0 0;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--muted);
  min-height: 1.2em;
}
.score-submit-status.is-ok { color: var(--green); }
.score-submit-status.is-err { color: var(--red); }
.score-leaderboard-link {
  display: inline-block;
  margin-top: 10px;
  font-weight: 800;
  color: var(--violet);
  text-decoration: none;
}


.finish-stars {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 8px 0 4px;
  font-size: 1.85rem;
  color: #d8d0ea;
}
.finish-stars .star.is-filled { color: #f5b942; }


/* ===== Dark / light theme (Unit 4B) ===== */
html[data-theme="dark"] {
  color-scheme: dark;
}
html[data-theme="dark"] body {
  background: #0f1220 !important;
  color: #e8ecf4 !important;
}
html[data-theme="dark"] .app,
html[data-theme="dark"] .card,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .home-card,
html[data-theme="dark"] .result-card,
html[data-theme="dark"] .prompt-card,
html[data-theme="dark"] .a-card,
html[data-theme="dark"] .b-card,
html[data-theme="dark"] .finish,
html[data-theme="dark"] .hub,
html[data-theme="dark"] .game,
html[data-theme="dark"] .screen,
html[data-theme="dark"] .modal,
html[data-theme="dark"] .overlay .modal,
html[data-theme="dark"] .start-screen,
html[data-theme="dark"] .board,
html[data-theme="dark"] .tile-card,
html[data-theme="dark"] .match-card,
html[data-theme="dark"] .choice-card {
  background: #1a1f2e !important;
  color: #e8ecf4 !important;
  border-color: #2d3548 !important;
  box-shadow: 0 12px 32px rgba(0,0,0,0.35) !important;
}
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] .prompt,
html[data-theme="dark"] .title,
html[data-theme="dark"] strong {
  color: #f1f5f9 !important;
}
html[data-theme="dark"] p,
html[data-theme="dark"] .muted,
html[data-theme="dark"] .lead,
html[data-theme="dark"] .instruction,
html[data-theme="dark"] .hint,
html[data-theme="dark"] .eyebrow,
html[data-theme="dark"] .label-sm {
  color: #94a3b8 !important;
}
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: #12161f !important;
  color: #e8ecf4 !important;
  border-color: #2d3548 !important;
}
html[data-theme="dark"] .word-chip,
html[data-theme="dark"] .chip,
html[data-theme="dark"] .tile,
html[data-theme="dark"] .card-face,
html[data-theme="dark"] .choice,
html[data-theme="dark"] .mode-btn,
html[data-theme="dark"] .part-btn,
html[data-theme="dark"] .start-mode-btn {
  background: #243044 !important;
  color: #e8ecf4 !important;
  border-color: #3d4a63 !important;
}
html[data-theme="dark"] .picture-grid button,
html[data-theme="dark"] .picture-tile,
html[data-theme="dark"] .grid button {
  background: #1e2433 !important;
  border-color: #3d4a63 !important;
}
html[data-theme="dark"] .pill,
html[data-theme="dark"] .score-pill,
html[data-theme="dark"] .stat-value,
html[data-theme="dark"] .mini-stat {
  background: #243044 !important;
  color: #e8ecf4 !important;
}
html[data-theme="dark"] .back,
html[data-theme="dark"] a.back,
html[data-theme="dark"] .game-back {
  background: #243044 !important;
  color: #e8ecf4 !important;
}
html[data-theme="dark"] .progress,
html[data-theme="dark"] .progress-track {
  background: rgba(148,163,184,0.2) !important;
}
.theme-fab {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 10070;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #8b5cf6, #6d28d9);
  color: #fff;
  box-shadow: 0 6px 0 #4c1d95, 0 10px 20px rgba(109,40,217,0.35);
}
.theme-fab:active { transform: translateY(2px); box-shadow: 0 3px 0 #4c1d95; }
html[data-theme="dark"] .theme-fab {
  background: linear-gradient(180deg, #fbbf24, #d97706);
  box-shadow: 0 6px 0 #92400e, 0 10px 20px rgba(217,119,6,0.35);
  color: #1e1b4b;
}

html[data-theme="dark"] body {
  background: #0f1220 !important;
}
html[data-theme="dark"] .prompt-panel,
html[data-theme="dark"] .listen-card,
html[data-theme="dark"] .question-card {
  background: #1e2433 !important;
  color: #e8ecf4 !important;
}
html[data-theme="dark"] .picture-grid .picture-btn,
html[data-theme="dark"] .picture-grid button {
  background: #1a1f2e !important;
  border-color: #3d4a63 !important;
}
html[data-theme="dark"] .finish-screen,
html[data-theme="dark"] .finish-card {
  background: #1a1f2e !important;
  color: #e8ecf4 !important;
}


/* ===== Mobile optimization (Unit 4B) ===== */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
img, video {
  max-width: 100%;
  height: auto;
}
button, a, input, select, textarea {
  touch-action: manipulation;
  font-size: 16px; /* prevents iOS zoom on focus */
}

@media (max-width: 700px) {
  html, body {
    max-width: 100vw;
    overflow-x: hidden !important;
  }
  body.no-profile-fab {
    padding: max(8px, env(safe-area-inset-top))
             max(10px, env(safe-area-inset-right))
             max(10px, env(safe-area-inset-bottom))
             max(10px, env(safe-area-inset-left)) !important;
  }
  .app, .shell, .home-card, .start-card, .intro-card, .phone-frame {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 16px !important;
    min-height: auto !important;
  }
  h1 { font-size: clamp(1.35rem, 6vw, 1.75rem) !important; }
  h2 { font-size: clamp(1.15rem, 5vw, 1.4rem) !important; }
  p, .lead, .instruction, .hint { font-size: 0.95rem !important; }

  /* Touch targets ≥ 44px */
  button, .btn, .primary-button, .main-btn, .part-btn,
  .start-mode-btn, .mode-btn, .choice, .chip, .word-chip,
  .check-btn, .submit-btn, .tile, .picture-grid button {
    min-height: 48px !important;
    min-width: 44px;
  }
  .site-theme-fab, .theme-fab, [data-theme-toggle],
  .game-back, .back, a.back {
    min-width: 44px !important;
    min-height: 44px !important;
  }
  /* Theme button clear of notches */
  .site-theme-fab, .theme-fab, [data-theme-toggle] {
    top: max(10px, env(safe-area-inset-top)) !important;
    right: max(10px, env(safe-area-inset-right)) !important;
  }
  /* Picture grids */
  .picture-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }
  .picture-grid button,
  .picture-grid .picture-btn {
    aspect-ratio: 1;
    padding: 4px !important;
  }
  .picture-grid img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
  }
  /* Match boards */
  .board, .match-board {
    gap: 8px !important;
  }
  /* Stack actions */
  .actions, .finish-actions, .btn-row {
    flex-wrap: wrap;
    gap: 10px;
  }
  .actions .btn, .actions button {
    flex: 1 1 auto;
  }
  /* Inputs full width */
  input[type="text"], input[type="email"], input[type="number"], select, textarea {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }
  /* Reduce heavy shadows on small screens */
  .app, .card, .panel, .home-card {
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12) !important;
  }
}

@media (max-width: 380px) {
  .picture-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
  h1 { font-size: 1.25rem !important; }
  .part-btn small { display: none; }
}

/* Landscape phones: tighter vertical use */
@media (max-height: 480px) and (orientation: landscape) {
  body.no-profile-fab {
    padding: 6px 10px !important;
  }
  .home-card, .intro-card, .start-card {
    max-height: 96dvh;
    overflow: auto;
  }
  .picture-grid {
    grid-template-columns: repeat(8, minmax(0, 1fr)) !important;
  }
}

/* No-scroll shell — fit one screen (phone + desktop) */
html, body {
  height: 100% !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  overflow: hidden !important;
  margin: 0;
}
body {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

.app-shell {
  max-height: 100dvh !important;
  overflow: hidden !important;
  box-sizing: border-box;
}

.app {
  max-height: 100dvh !important;
  overflow: hidden !important;
  box-sizing: border-box;
}

@media (max-height: 780px) {
  .pic-wrap img, .scene-img, .card-img, img.scene {
    max-height: 28vh !important;
  }
  .main, .content, .panel, .game-card {
    padding-bottom: 8px !important;
  }
}

/* ===== Food Sound Match Picture overrides ===== */
.arcade-header-bar, .arcade-nav, .site-footer, body > header {
  display: none !important;
}

/* Kill global header offset on game pages */
html, body {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  margin: 0 !important;
}
body.game-page,
body[data-type="game"] {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}



html, body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  background: #f4f6fb !important;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
html[data-theme="dark"] body {
  background: #0f1220 !important;
  color: #e8ecf4 !important;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 0 14px 24px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
}
.back {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: #fff;
  color: #334155;
  text-decoration: none;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 8px rgba(15,23,42,0.06);
  flex-shrink: 0;
}
html[data-theme="dark"] .back {
  background: rgba(255,255,255,0.06);
  border-color: rgba(148,163,184,0.25);
  color: #e2e8f0;
}
.title {
  flex: 1;
  font-size: 13px;
  font-weight: 700;
  color: #64748b;
}
.badge {
  font-size: 12px;
  font-weight: 800;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(99,102,241,0.12);
  color: #6366f1;
}

.start-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px 8px;
}
.hero {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: linear-gradient(145deg, #34d399, #6366f1);
  display: grid;
  place-items: center;
  font-size: 34px;
  margin-bottom: 14px;
  box-shadow: 0 10px 28px rgba(99,102,241,0.3);
}
.start-body h1 {
  margin: 0 0 6px;
  font-size: 1.5rem;
  font-weight: 900;
}
.lead { margin: 0 0 4px; color: #64748b; font-weight: 600; }
.muted { margin: 0 0 20px; color: #94a3b8; font-size: 0.9rem; }
.primary-btn {
  appearance: none;
  border: none;
  border-radius: 14px;
  padding: 14px 36px;
  font-weight: 800;
  font: inherit;
  background: linear-gradient(145deg, #818cf8, #6366f1);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(99,102,241,0.35);
}

.progress {
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 12px;
}
html[data-theme="dark"] .progress { background: rgba(148,163,184,0.2); }
.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #818cf8, #6366f1);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.listen-panel {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 12px;
  box-shadow: 0 4px 14px rgba(15,23,42,0.05);
}
html[data-theme="dark"] .listen-panel {
  background: #1a1f2e;
  border-color: #2d3548;
}
.listen-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.listen-text strong { font-size: 0.95rem; }
.listen-text-msg, .listen-text span {
  font-size: 0.85rem;
  color: #64748b;
  font-weight: 600;
}
.listen-text-msg.ok { color: #16a34a !important; }
.listen-text-msg.bad { color: #dc2626 !important; }

/* Nationalities-style play button */
.play-btn {
  position: relative;
  overflow: visible;
  width: 56px;
  height: 56px;
  min-width: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35);
  flex-shrink: 0;
  padding: 0;
}
.play-btn:hover { transform: scale(1.05); }
.play-btn.playing { box-shadow: 0 0 0 5px rgba(99, 102, 241, 0.25); }
.play-btn svg {
  position: relative;
  z-index: 2;
  transition: opacity 0.2s, transform 0.2s;
}
.play-btn .wave {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(99, 102, 241, 0.45);
  opacity: 0;
  pointer-events: none;
}
.play-btn.playing .wave { animation: smp-ripple 1.25s ease-out infinite; }
.play-btn.playing .wave:nth-child(2) { animation-delay: 0.3s; }
.play-btn.playing .wave:nth-child(3) { animation-delay: 0.6s; }
@keyframes smp-ripple {
  0% { transform: scale(0.85); opacity: 0.65; }
  100% { transform: scale(1.55); opacity: 0; }
}
.play-btn .eq {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  opacity: 0;
  pointer-events: none;
  z-index: 2;
}
.play-btn .eq span {
  width: 3px;
  height: 12px;
  background: #fff;
  border-radius: 2px;
}
.play-btn.playing svg { opacity: 0; transform: scale(0.5); }
.play-btn.playing .eq { opacity: 1; }
.play-btn.playing .eq span:nth-child(1) { animation: smp-eq 0.55s ease-in-out infinite; }
.play-btn.playing .eq span:nth-child(2) { animation: smp-eq 0.55s ease-in-out infinite 0.1s; }
.play-btn.playing .eq span:nth-child(3) { animation: smp-eq 0.55s ease-in-out infinite 0.2s; }
.play-btn.playing .eq span:nth-child(4) { animation: smp-eq 0.55s ease-in-out infinite 0.15s; }
@keyframes smp-eq {
  0%, 100% { transform: scaleY(0.45); }
  50% { transform: scaleY(1.15); }
}

/* 10-picture grid */
.picture-grid {
  display: grid !important;
  grid-template-columns: repeat(5, 1fr) !important;
  gap: 8px !important;
  flex: 1;
  align-content: start;
}
.picture-card {
  appearance: none;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  background: #fff;
  padding: 6px;
  cursor: pointer;
  aspect-ratio: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(15,23,42,0.05);
  transition: none;
}
html[data-theme="dark"] .picture-card {
  background: #1a1f2e;
  border-color: #2d3548;
}
.picture-card img {
  width: 100%;
  height: 100%;
  object-fit: contain !important;
  object-position: center;
  display: block;
  pointer-events: none;
}
.picture-card.matched {
  opacity: 0.4;
  pointer-events: none;
  border-color: #81c784;
  background: #e8f5e9;
}
.picture-card.wrong {
  border-color: #ef4444;
  background: #fee2e2;
}

@media (max-width: 420px) {
  .picture-grid {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 6px !important;
  }
  .play-btn {
    width: 50px;
    height: 50px;
    min-width: 50px;
  }
}

@media (min-width: 900px) {
  .app { max-width: 680px !important; padding: 0 20px 32px; }
  .picture-grid {
    grid-template-columns: repeat(5, 1fr) !important;
    gap: 12px !important;
  }
  .play-btn {
    width: 64px;
    height: 64px;
    min-width: 64px;
  }
  .picture-card {
    border-radius: 16px;
    padding: 8px;
  }
}

@media (max-height: 700px) {
  .picture-grid { gap: 6px !important; }
  .listen-panel { padding: 10px 12px; margin-bottom: 8px; }
}


/* ===== Visual reward animations ===== */
.picture-card {
  position: relative;
  overflow: visible;
}
.picture-card.matched {
  opacity: 0.42;
  pointer-events: none;
  border-color: #81c784 !important;
  background: #e8f5e9 !important;
  animation: smp-matchPop 0.5s ease forwards;
}
.picture-card.just-matched {
  z-index: 3;
}
@keyframes smp-matchPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.12); }
  70% { transform: scale(0.96); }
  100% { transform: scale(1); opacity: 0.42; }
}
.picture-card.matched::after {
  content: "✓";
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 13px;
  font-weight: 800;
  color: #4caf50;
  animation: smp-checkIn 0.35s ease 0.12s both;
  z-index: 4;
}
@keyframes smp-checkIn {
  0% { transform: scale(0) rotate(-30deg); opacity: 0; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.smp-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  overflow: visible;
}
.smp-particle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: smp-particleFly 0.75s ease-out forwards;
}
@keyframes smp-particleFly {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(0);
    opacity: 0;
  }
}

.listen-panel.reward-flash {
  animation: smp-panelFlash 0.65s ease;
}
@keyframes smp-panelFlash {
  0% { box-shadow: 0 4px 14px rgba(15,23,42,0.05); }
  40% { box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.35), 0 8px 24px rgba(76, 175, 80, 0.2); border-color: #81c784; }
  100% { box-shadow: 0 4px 14px rgba(15,23,42,0.05); }
}

.listen-text-msg.ok {
  animation: smp-textPop 0.4s ease;
}
@keyframes smp-textPop {
  0% { transform: scale(0.92); opacity: 0.5; }
  60% { transform: scale(1.04); }
  100% { transform: scale(1); opacity: 1; }
}

html[data-theme="dark"] .picture-card.matched {
  background: rgba(76, 175, 80, 0.18) !important;
}


/* ===== One set of 20 + 5A play button + responsive grid ===== */

/* Match Food Match / Flashcards play button */
.play-btn {
  background: linear-gradient(135deg, #38bdf8, #6366f1) !important;
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35) !important;
}
.play-btn.playing {
  box-shadow: 0 0 0 5px rgba(99, 102, 241, 0.28) !important;
}
.play-btn .wave {
  border-color: rgba(56, 189, 248, 0.55) !important;
}

/* Single checkmark only */
.picture-card.matched::after {
  content: "✓" !important;
  background: none !important;
  box-shadow: none !important;
  border: none !important;
  width: auto !important;
  height: auto !important;
  line-height: 1 !important;
}

/* 20-picture grid */
.picture-grid {
  display: grid !important;
  grid-template-columns: repeat(5, 1fr) !important;
  gap: 8px !important;
  align-content: start !important;
}
.picture-card {
  aspect-ratio: 1 !important;
  min-height: 0 !important;
  padding: 5px !important;
  border-radius: 12px !important;
}
.picture-card img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  object-position: center !important;
}

/* Compact listen panel so 20 tiles fit */
.listen-panel {
  padding: 10px 12px !important;
  margin-bottom: 10px !important;
}
.play-btn {
  width: 52px !important;
  height: 52px !important;
  min-width: 52px !important;
}

.app {
  max-width: 560px !important;
}

/* Phone: 4 columns */
@media (max-width: 480px) {
  .picture-grid {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 6px !important;
  }
  .play-btn {
    width: 48px !important;
    height: 48px !important;
    min-width: 48px !important;
  }
  .listen-panel {
    gap: 10px !important;
    padding: 8px 10px !important;
  }
}

/* Narrow phones: still 4 col */
@media (max-width: 360px) {
  .picture-grid {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 5px !important;
  }
  .picture-card {
    padding: 3px !important;
    border-radius: 10px !important;
  }
}

/* Desktop: wider, 5 columns, larger tiles */
@media (min-width: 900px) {
  .app {
    max-width: 720px !important;
    padding: 0 24px 36px !important;
  }
  .picture-grid {
    grid-template-columns: repeat(5, 1fr) !important;
    gap: 12px !important;
  }
  .picture-card {
    padding: 8px !important;
    border-radius: 16px !important;
  }
  .play-btn {
    width: 64px !important;
    height: 64px !important;
    min-width: 64px !important;
  }
  .listen-panel {
    padding: 14px 16px !important;
  }
}

/* Short screens: tighter spacing */
@media (max-height: 720px) {
  .picture-grid {
    gap: 6px !important;
  }
  .listen-panel {
    margin-bottom: 8px !important;
    padding: 8px 10px !important;
  }
  .progress {
    margin-bottom: 8px !important;
  }
}

/* Force perfect circle play button (not oval) */
.play-btn,
button.play-btn,
#playBtn {
  width: 56px !important;
  height: 56px !important;
  min-width: 56px !important;
  min-height: 56px !important;
  max-width: 56px !important;
  max-height: 56px !important;
  aspect-ratio: 1 / 1 !important;
  border-radius: 50% !important;
  flex: 0 0 56px !important;
  align-self: center !important;
  padding: 0 !important;
  box-sizing: border-box !important;
}
.listen-panel {
  align-items: center !important;
}
@media (min-width: 900px) {
  .play-btn,
  button.play-btn,
  #playBtn {
    width: 64px !important;
    height: 64px !important;
    min-width: 64px !important;
    min-height: 64px !important;
    max-width: 64px !important;
    max-height: 64px !important;
    flex: 0 0 64px !important;
  }
}
@media (max-width: 480px) {
  .play-btn,
  button.play-btn,
  #playBtn {
    width: 52px !important;
    height: 52px !important;
    min-width: 52px !important;
    min-height: 52px !important;
    max-width: 52px !important;
    max-height: 52px !important;
    flex: 0 0 52px !important;
  }
}

/* Only one corner check — remove the extra ::before badge */
.picture-card.matched::before {
  content: none !important;
  display: none !important;
  background: none !important;
  width: 0 !important;
  height: 0 !important;
  opacity: 0 !important;
}
.picture-card.matched::after {
  content: "✓" !important;
  position: absolute !important;
  top: 4px !important;
  right: 6px !important;
  left: auto !important;
  bottom: auto !important;
  inset: auto !important;
  width: auto !important;
  height: auto !important;
  font-size: 14px !important;
  font-weight: 800 !important;
  color: #4caf50 !important;
  background: none !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  display: block !important;
  z-index: 5 !important;
  pointer-events: none !important;
}


/* ===== Lives: 3 hearts ===== */
.hearts {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}
html[data-theme="dark"] .hearts {
  background: rgba(255,255,255,0.06);
  border-color: rgba(148,163,184,0.25);
}
.heart {
  font-size: 1.15rem;
  line-height: 1;
  display: inline-block;
  /* pixel-ish look */
  image-rendering: pixelated;
  filter: contrast(1.1);
  transform-origin: center;
}
.heart.is-full {
  color: #ef4444;
  text-shadow: 0 1px 0 #b91c1c;
}
.heart.is-broken {
  color: #cbd5e1;
  opacity: 0.85;
  transform: scale(0.95);
}
html[data-theme="dark"] .heart.is-broken {
  color: #64748b;
}
.heart.is-breaking {
  color: #ef4444;
  animation: heartBreak 0.48s ease forwards;
}
@keyframes heartBreak {
  0% { transform: scale(1) rotate(0deg); opacity: 1; filter: none; }
  25% { transform: scale(1.25) rotate(-12deg); }
  50% { transform: scale(1.1) rotate(10deg); filter: grayscale(0.3); }
  75% { transform: scale(0.9) rotate(-6deg); opacity: 0.7; filter: grayscale(0.7); }
  100% { transform: scale(0.95) rotate(0deg); opacity: 0.85; color: #cbd5e1; filter: grayscale(1); }
}
