/* =================================================================
   Theos Memory — Styles
   Brand look like "Eye of the Tiger" / Pieksolino: strong red, rounded
   buttons, warm paper tone, child-friendly (ages 6-12).
   ================================================================= */

@import url("https://fonts.googleapis.com/css2?family=Nunito:wght@700;800;900&display=swap");

:root {
  --brand-red: #c52a2a;
  --brand-red-dark: #9b1d1d;
  --brand-red-light: #e85c4a;
  --ink: #1f2430;
  --ink-soft: #3b4250;
  --muted: #6b7280;
  --paper: #fbf6ea;
  --paper-dark: #efe6d3;
  --card-face: #fffdf7;
  --gold: #f5b73a;
  --green: #2f9e57;
  --blue: #3e4a8c;
  --radius-lg: 22px;
  --radius-md: 14px;
  --shadow-1: 0 6px 20px rgba(0, 0, 0, 0.12);
  --shadow-2: 0 18px 50px rgba(0, 0, 0, 0.3);
  --font: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  --hud-h: clamp(56px, 9vh, 76px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background: #6fb7e2;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

button {
  font-family: inherit;
}

/* ---------- Background landscape ---------- */
.bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  pointer-events: none;
}
.bg-clouds {
  animation: drift 140s linear infinite;
}
.bg-birds {
  animation: birds 55s linear infinite;
}
.bg-blades {
  animation: spin 16s linear infinite;
}
@keyframes drift {
  to {
    transform: translateX(1600px);
  }
}
@keyframes birds {
  from {
    transform: translateX(-700px);
  }
  to {
    transform: translateX(1500px);
  }
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

#app {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}

/* ---------- Screen switching ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
}
.screen.is-active {
  display: flex;
}

/* Panel screens: centered paper-toned card (start, game over, leaderboard) */
.screen--panel {
  align-items: center;
  justify-content: center;
  padding: 0;
}
.panel {
  position: relative;
  width: 100%;
  max-width: 460px;
  height: 100%;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
@media (min-width: 700px) and (min-height: 700px) {
  .panel {
    height: min(880px, 92vh);
    border-radius: 28px;
    box-shadow: var(--shadow-2);
  }
}
@media (min-width: 700px) and (max-height: 699px) {
  /* Tablet / desktop landscape with little height: wider card, no frame */
  .panel {
    max-width: 560px;
  }
}

/* ---------- Topbar ---------- */
.topbar {
  background: var(--brand-red);
  color: #fff;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  padding-top: max(8px, env(safe-area-inset-top));
  flex: 0 0 auto;
  min-height: 52px;
}
.topbar__side {
  display: flex;
  align-items: center;
  gap: 4px;
}
.topbar__side--right {
  justify-content: flex-end;
}
.topbar__btn {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 24px;
  width: 42px;
  height: 42px;
  cursor: pointer;
  border-radius: 10px;
  padding: 0;
  line-height: 1;
}
.topbar__btn:active {
  background: rgba(255, 255, 255, 0.2);
}
.topbar__title {
  font-weight: 900;
  font-size: clamp(15px, 2.4vmin, 18px);
  letter-spacing: 0.08em;
  text-align: center;
  white-space: nowrap;
}
.topbar__pill {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border: none;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.06em;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  min-width: 44px;
  height: 32px;
}
.topbar__pill:active {
  background: rgba(255, 255, 255, 0.32);
}

/* ---------- Typography ---------- */
.game-title {
  font-size: clamp(30px, 7vw, 42px);
  font-weight: 900;
  margin: 0;
  color: var(--brand-red);
  line-height: 1.05;
  letter-spacing: -0.01em;
}
.muted {
  color: var(--muted);
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}
.muted.small {
  font-size: 13px;
}
h2 {
  margin: 0;
  font-size: clamp(22px, 5vw, 28px);
  font-weight: 900;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Buttons ---------- */
.btn {
  font-weight: 900;
  border: none;
  border-radius: 16px;
  padding: 14px 22px;
  font-size: 18px;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease, background 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--ink);
  background: #fff;
  min-height: 48px;
}
.btn:active {
  transform: scale(0.97);
}
.btn:disabled {
  opacity: 0.6;
  cursor: default;
  transform: none;
}
.btn-primary {
  background: var(--brand-red);
  color: #fff;
  box-shadow: 0 6px 0 var(--brand-red-dark);
}
.btn-primary:active {
  box-shadow: 0 2px 0 var(--brand-red-dark);
  transform: translateY(4px);
}
.btn-secondary {
  background: var(--ink);
  color: #fff;
}
.btn-block {
  width: 100%;
}
.btn-big {
  font-size: 22px;
  padding: 18px 28px;
}
.btn-start {
  font-size: 26px;
  padding: 18px 64px;
  margin-top: 6px;
  border-radius: 20px;
}
.btn-link {
  background: transparent;
  color: var(--brand-red);
  text-decoration: underline;
  padding: 8px 10px;
  font-weight: 800;
  font-size: 16px;
}

/* ---------- Start ---------- */
.start-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1.8vh, 14px);
  padding: clamp(14px, 3vh, 26px) 24px;
  text-align: center;
  overflow-y: auto;
}
.hero {
  position: relative;
  width: clamp(150px, 34vmin, 220px);
  height: clamp(150px, 34vmin, 220px);
  margin: 6px 0 4px;
}
.hero__img {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.2));
  animation: bob 4s ease-in-out infinite;
}
.hero__cards {
  position: absolute;
  inset: 0;
  z-index: 1;
}
.mini-card {
  position: absolute;
  width: 34%;
  aspect-ratio: 1;
  border-radius: 14%;
  background: var(--brand-red);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.2);
  border: 3px solid #fff;
  animation: float 5s ease-in-out infinite;
}
.mini-card--1 {
  left: -8%;
  top: 12%;
  transform: rotate(-14deg);
  animation-delay: -1s;
}
.mini-card--2 {
  right: -10%;
  top: 4%;
  transform: rotate(12deg);
  background: var(--gold);
  animation-delay: -2.5s;
}
.mini-card--3 {
  right: -2%;
  bottom: 6%;
  transform: rotate(-6deg);
  background: var(--green);
  animation-delay: -4s;
}
@keyframes bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}
@keyframes float {
  0%,
  100% {
    translate: 0 0;
  }
  50% {
    translate: 0 -8px;
  }
}
.best {
  margin: 0;
  color: var(--ink-soft);
  font-weight: 800;
}
.best strong {
  color: var(--brand-red);
  font-size: 1.2em;
}
.start-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 12px;
}

/* ---------- Overlays / dialogs ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(20, 24, 34, 0.55);
  backdrop-filter: blur(2px);
}
.overlay[hidden] {
  display: none;
}
.dialog {
  background: var(--paper);
  border-radius: var(--radius-lg);
  padding: 24px 22px;
  max-width: 420px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
  box-shadow: var(--shadow-2);
  animation: pop-in 0.25s ease;
}
.dialog h2 {
  color: var(--brand-red);
}
.dialog p {
  margin: 0;
  line-height: 1.5;
  font-weight: 700;
  color: var(--ink-soft);
}
.howto-icons {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.chip {
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 900;
  color: #fff;
  font-size: 14px;
}
.chip--green {
  background: var(--green);
}
.chip--gold {
  background: var(--gold);
  color: var(--ink);
}
.chip--red {
  background: var(--brand-red);
}
@keyframes pop-in {
  from {
    transform: scale(0.92);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* ---------- Game: HUD ---------- */
#screen-game {
  padding: 0;
}
.hud {
  position: relative;
  z-index: 5;
  flex: 0 0 auto;
  height: var(--hud-h);
  margin: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 0
    max(10px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(255, 253, 247, 0.92);
  border-radius: 18px;
  box-shadow: var(--shadow-1);
}
.hud__group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.hud__left {
  gap: 10px;
}
.hud__lives {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: clamp(20px, 3.6vmin, 30px);
  line-height: 1;
}
.star {
  color: var(--gold);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.18));
  transition: transform 0.2s ease, color 0.3s ease;
}
.star.is-lost {
  color: #d8d2c4;
  filter: none;
}
.star.is-pop {
  animation: star-pop 0.6s ease;
}
.star.is-gain {
  animation: star-gain 0.7s ease;
}
@keyframes star-gain {
  0% {
    transform: scale(0.2) rotate(-40deg);
    opacity: 0.2;
  }
  55% {
    transform: scale(1.6) rotate(10deg);
    opacity: 1;
  }
  100% {
    transform: scale(1);
  }
}
@keyframes star-pop {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(1.5) rotate(-12deg);
  }
  100% {
    transform: scale(1);
  }
}
/* Run towards the next streak bonus. The pill keeps the dots from reading as
   part of the star row next to them. */
.hud__combo {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.045);
}
.combo-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #e2d8c2;
  transition: background 0.2s ease, transform 0.2s ease;
}
.combo-dot.is-on {
  background: var(--brand-red);
}
.combo-dot.is-lit {
  animation: combo-lit 0.4s ease;
}
@keyframes combo-lit {
  45% {
    transform: scale(1.7);
  }
}
.hud__combo.is-full .combo-dot.is-on {
  background: var(--gold);
}
@media (max-width: 420px) {
  .hud__left {
    gap: 6px;
  }
  .combo-dot {
    width: 7px;
    height: 7px;
  }
}

.hud__score {
  flex-direction: column;
  gap: 0;
  align-items: center;
  justify-content: center;
}
.hud__score-value {
  font-weight: 900;
  font-size: clamp(24px, 4.4vmin, 34px);
  line-height: 1;
  color: var(--brand-red);
  font-variant-numeric: tabular-nums;
}
.hud__score-value.is-bump {
  animation: bump 0.35s ease;
}
@keyframes bump {
  40% {
    transform: scale(1.25);
  }
}
.hud__score-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.hud__right {
  justify-content: flex-end;
}
.hud__deck {
  font-weight: 800;
  color: var(--ink-soft);
  background: var(--paper-dark);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: clamp(12px, 2.2vmin, 15px);
  white-space: nowrap;
}
.hud__deck b {
  color: var(--brand-red);
}
.hud__deck.is-bump {
  animation: bump 0.4s ease;
}
.hud__btn {
  width: clamp(36px, 6vmin, 44px);
  height: clamp(36px, 6vmin, 44px);
  border-radius: 50%;
  border: none;
  background: var(--paper-dark);
  color: var(--ink);
  font-size: clamp(14px, 2.6vmin, 18px);
  cursor: pointer;
  display: grid;
  place-items: center;
  line-height: 1;
  flex: 0 0 auto;
}
.hud__btn:active {
  background: #e2d8c2;
}
@media (max-width: 420px) {
  .hud__deck span {
    display: none; /* number only */
  }
  .hud__deck::before {
    content: "#";
    color: var(--muted);
  }
}

/* ---------- Game: board ---------- */
.board-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(8px, 2vmin, 18px) max(10px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}
.board {
  --gap: clamp(6px, 1.6vmin, 14px);
  width: min(100%, calc(100dvh - var(--hud-h) - 44px), 640px);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: var(--gap);
  perspective: 1200px;
}

.board.is-preview .card {
  pointer-events: none;
  cursor: default;
}
.card {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 12%;
  touch-action: manipulation;
}
.card:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}
.card__inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.2, 0.7, 0.2, 1.1);
  border-radius: inherit;
}
.card.is-up .card__inner {
  transform: rotateY(180deg);
}
.card__face {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18);
}
/* Card back: red, faint tiger stripes, white paw */
.card__face--back {
  background-color: var(--brand-red);
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><g fill='white' fill-opacity='0.92'><ellipse cx='50' cy='63' rx='21' ry='17'/><circle cx='29' cy='40' r='9'/><circle cx='42' cy='27' r='9'/><circle cx='58' cy='27' r='9'/><circle cx='71' cy='40' r='9'/></g></svg>"),
    repeating-linear-gradient(
      -35deg,
      rgba(255, 255, 255, 0) 0 14px,
      rgba(255, 255, 255, 0.09) 14px 22px
    ),
    radial-gradient(circle at 50% 40%, var(--brand-red-light), var(--brand-red) 75%);
  background-repeat: no-repeat, repeat, no-repeat;
  background-size: 52% 52%, auto, auto;
  background-position: center 48%, 0 0, 0 0;
  border: 4px solid #fff;
  box-sizing: border-box;
}
.card:not(.is-up):hover .card__face--back {
  filter: brightness(1.06);
}
.card:not(.is-up):active .card__inner {
  transform: scale(0.96);
}
.card__face--front {
  background: var(--card-face);
  transform: rotateY(180deg);
  border: 4px solid var(--accent, #fff);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 6%;
  pointer-events: none;
  transition: transform 0.3s ease;
}
.card__name {
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: 6%;
  background: var(--accent, var(--brand-red));
  color: #fff;
  font-weight: 900;
  font-size: clamp(9px, 1.7vmin, 14px);
  line-height: 1.15;
  padding: 3px 6px;
  border-radius: 999px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}
.card.is-matched .card__name {
  opacity: 1;
  transform: translateY(0);
}
.card.is-matched {
  cursor: default;
}
.card.is-matched .card__inner {
  animation: matched 0.6s ease;
}
.card.is-matched .card__face--front {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.85), 0 10px 22px rgba(0, 0, 0, 0.18);
}
@keyframes matched {
  0% {
    transform: rotateY(180deg) scale(1);
  }
  40% {
    transform: rotateY(180deg) scale(1.1);
  }
  100% {
    transform: rotateY(180deg) scale(1);
  }
}
.card.is-wrong .card__inner {
  animation: shake 0.45s ease;
}
@keyframes shake {
  0%,
  100% {
    transform: rotateY(180deg) translateX(0);
  }
  20% {
    transform: rotateY(180deg) translateX(-7px);
  }
  40% {
    transform: rotateY(180deg) translateX(7px);
  }
  60% {
    transform: rotateY(180deg) translateX(-5px);
  }
  80% {
    transform: rotateY(180deg) translateX(5px);
  }
}
/* Dealing: cards come in one after another */
.card.is-dealing {
  animation: deal 0.45s cubic-bezier(0.2, 0.8, 0.2, 1.1) both;
}
@keyframes deal {
  from {
    opacity: 0;
    transform: translateY(-40px) scale(0.6) rotate(-8deg);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
/* Deck complete: cards fly away */
.card.is-leaving {
  animation: leave 0.5s ease both;
  pointer-events: none;
}
@keyframes leave {
  to {
    opacity: 0;
    transform: translateY(40px) scale(0.5) rotate(10deg);
  }
}

/* ---------- Toasts & score popups ---------- */
.toast-layer {
  position: absolute;
  z-index: 8;
  top: calc(var(--hud-h) + 24px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: rgba(31, 36, 48, 0.85);
  color: #fff;
  font-weight: 900;
  padding: clamp(8px, 1.6vmin, 12px) clamp(16px, 3vmin, 24px);
  border-radius: 16px;
  font-size: clamp(16px, 3vmin, 24px);
  animation: toast-rise 1.5s ease forwards;
  white-space: nowrap;
  box-shadow: var(--shadow-1);
}
.toast--bonus {
  background: var(--green);
}
.toast--deck {
  background: var(--gold);
  color: var(--ink);
  font-size: clamp(18px, 3.6vmin, 28px);
}
.toast--miss {
  background: var(--brand-red);
}
.toast--info {
  background: var(--blue);
}
@keyframes toast-rise {
  0% {
    opacity: 0;
    transform: translateY(14px) scale(0.9);
  }
  15% {
    opacity: 1;
    transform: translateY(0) scale(1.04);
  }
  25% {
    transform: scale(1);
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-16px);
  }
}
.score-pop {
  position: fixed;
  z-index: 9;
  pointer-events: none;
  font-weight: 900;
  font-size: clamp(18px, 3.6vmin, 28px);
  color: #fff;
  background: var(--green);
  padding: 4px 12px;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  animation: score-pop 1s ease forwards;
  box-shadow: var(--shadow-1);
}
@keyframes score-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -30%) scale(0.6);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -60%) scale(1.1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -160%) scale(1);
  }
}

/* ---------- Confetti ---------- */
.confetti-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  overflow: hidden;
}
.confetti-layer i {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 16px;
  border-radius: 3px;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  to {
    transform: translateY(110vh) rotate(720deg);
    opacity: 0.9;
  }
}

/* ---------- Game Over ---------- */
.go-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 22px max(18px, env(safe-area-inset-bottom));
  text-align: center;
}
.go-hero {
  width: clamp(80px, 16vmin, 120px);
  height: clamp(80px, 16vmin, 120px);
  object-fit: contain;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.18));
}
.final-score {
  font-size: clamp(52px, 12vmin, 76px);
  font-weight: 900;
  color: var(--brand-red);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.record-banner {
  background: var(--gold);
  color: var(--ink);
  font-weight: 900;
  padding: 8px 16px;
  border-radius: 999px;
  animation: pop-in 0.4s ease;
}
.go-stats {
  display: grid;
  /* Five tiles side by side where there is room, wrapping instead of shrinking
     into unreadable columns on a narrow phone. */
  grid-template-columns: repeat(auto-fit, minmax(58px, 1fr));
  gap: 8px;
  width: 100%;
  margin: 4px 0;
}
.go-stat {
  background: #fff;
  border-radius: 14px;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.go-stat dd {
  margin: 0;
  font-weight: 900;
  font-size: clamp(18px, 4.6vmin, 22px);
  color: var(--ink);
}
.go-stat dt {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.score-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}
.text-input {
  font-family: inherit;
  font-size: 18px;
  font-weight: 800;
  padding: 14px 16px;
  border-radius: 14px;
  border: 2px solid #e3dccb;
  background: #fff;
  color: var(--ink);
  text-align: center;
  width: 100%;
  min-height: 48px;
}
.text-input:focus {
  outline: none;
  border-color: var(--brand-red);
}
.go-body .btn-big {
  margin-top: 6px;
}

/* ---------- Leaderboard ---------- */
.lb-body {
  padding: 18px 20px max(18px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1 1 auto;
  min-height: 0;
}
.lb-tabs {
  display: flex;
  gap: 6px;
  background: var(--paper-dark);
  border-radius: 999px;
  padding: 4px;
  flex: 0 0 auto;
}
.lb-tab {
  flex: 1 1 0;
  font-size: 15px;
  font-weight: 900;
  padding: 10px 12px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--brand-red);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.lb-tab.is-active {
  background: var(--brand-red);
  color: #fff;
}
.lb-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.leaderboard {
  list-style: none;
  margin: 0;
  padding: 0;
}
.leaderboard li {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 800;
}
.leaderboard li:nth-child(odd) {
  background: #fff;
}
.lb-rank {
  font-weight: 900;
  color: var(--brand-red);
  text-align: center;
}
.lb-rank--1,
.lb-rank--2,
.lb-rank--3 {
  font-size: 20px;
}
.lb-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-name small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}
.lb-score {
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.leaderboard li.is-me {
  background: #fff0c2;
  box-shadow: inset 0 0 0 2px var(--gold);
}
.leaderboard li.lb-sep {
  display: block;
  text-align: center;
  background: transparent;
  color: var(--muted);
  padding: 0;
  letter-spacing: 3px;
}
.leaderboard li.is-pinned {
  position: sticky;
  bottom: 0;
  box-shadow: inset 0 0 0 2px var(--gold), 0 -6px 14px rgba(0, 0, 0, 0.15);
}
.lb-status {
  text-align: center;
  padding: 14px 0;
}

/* ---------- Footer & legal ---------- */
.legal-footer {
  flex: 0 0 auto;
  background: var(--paper-dark);
  color: var(--muted);
  display: flex;
  gap: clamp(8px, 2vw, 18px);
  justify-content: center;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  flex-wrap: wrap;
}
.legal-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: inherit;
  text-decoration: underline;
  cursor: pointer;
}
.panel--legal {
  background: #fff;
}
.legal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: clamp(16px, 4vmin, 28px);
  text-align: left;
  -webkit-overflow-scrolling: touch;
  -webkit-user-select: text;
  user-select: text;
}
.legal-body h2 {
  font-size: clamp(20px, 4.5vmin, 26px);
  margin: 0 0 12px;
  color: var(--brand-red);
}
.legal-body h3 {
  font-size: 16px;
  margin: 18px 0 6px;
}
.legal-body p,
.legal-body li {
  font-size: 14px;
  line-height: 1.55;
  font-weight: 600;
  color: var(--ink-soft);
  margin: 0 0 10px;
}
.legal-body ul {
  padding-left: 20px;
  margin: 0 0 10px;
}
.legal-contact__row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.contact-svg {
  height: 18px;
  width: auto;
  vertical-align: middle;
}
.legal-date {
  margin-top: 20px;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .bg-clouds,
  .bg-birds,
  .bg-blades,
  .hero__img,
  .mini-card {
    animation: none;
  }
  .card__inner {
    transition-duration: 0.15s;
  }
  .card.is-dealing,
  .card.is-leaving,
  .card.is-matched .card__inner,
  .card.is-wrong .card__inner {
    animation-duration: 0.01s;
  }
  .confetti-layer {
    display: none;
  }
}
