/* Angel Fish Game — brand teal accents */

/* Classes below set display (flex, inline-block), which beats the hidden attribute.
   The game hides its play buttons, tap hint and "New best" badge with hidden, so hidden must win. */
.angel-fish-page [hidden] {
  display: none !important;
}

/* ============================================================
   STANDALONE APP MODE (native iOS app / installed PWA)
   Triggered by <html class="app-standalone">. Hides the site
   chrome so it feels like a dedicated game app, and respects the
   device safe area (notch / Dynamic Island). The website page adds
   two more classes: af-web (the game sits inside a website page)
   and af-bar (the site's top bar is showing). See WEBSITE MODE at the
   end of this file.
   ============================================================ */
html.app-standalone {
  /* Safe area (notch / home indicator). */
  --sat: 0px;
  --sab: 0px;
  --sal: 0px;
  --sar: 0px;
  --sat: constant(safe-area-inset-top, 0px);
  --sab: constant(safe-area-inset-bottom, 0px);
  --sal: constant(safe-area-inset-left, 0px);
  --sar: constant(safe-area-inset-right, 0px);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);

  /* ---- One UX measure for the whole app ----
     --af-ui is set by JS from the same screen size as the canvas (phone ≈ 1,
     tablet up to 1.5). Every menu, button, HUD chip and icon uses these tokens
     so phone and iPad stay proportionally matched. */
  --af-ui: 1;
  --af-space-1: calc(4px * var(--af-ui));
  --af-space-2: calc(8px * var(--af-ui));
  --af-space-3: calc(12px * var(--af-ui));
  --af-space-4: calc(16px * var(--af-ui));
  --af-space-5: calc(22px * var(--af-ui));
  --af-space-6: calc(28px * var(--af-ui));
  --af-edge: calc(12px * var(--af-ui));
  --af-menu-w: calc(360px * var(--af-ui));
  --af-menu-pad-x: calc(18px * var(--af-ui));
  --af-menu-pad-y: calc(18px * var(--af-ui));
  --af-menu-radius: calc(28px * var(--af-ui));
  --af-btn-h: calc(46px * var(--af-ui));
  --af-btn-max: calc(280px * var(--af-ui));
  --af-btn-font: calc(16px * var(--af-ui));
  --af-btn-pad-x: calc(24px * var(--af-ui));
  --af-btn-gap: calc(5px * var(--af-ui));
  --af-icon: calc(44px * var(--af-ui));
  --af-icon-font: calc(1.05rem * var(--af-ui));
  --af-hud-font: calc(22px * var(--af-ui));
  --af-hud-best: calc(14px * var(--af-ui));
  --af-hud-min: calc(88px * var(--af-ui));
  --af-hud-star: calc(18px * var(--af-ui));
  --af-title-w: calc(220px * var(--af-ui));
  --af-tagline: calc(0.88rem * var(--af-ui));
  --af-choose: calc(0.85rem * var(--af-ui));
  --af-h2: calc(1.35rem * var(--af-ui));
  --af-h2-pad-y: calc(8px * var(--af-ui));
  --af-h2-pad-x: calc(26px * var(--af-ui));
  --af-tile-h: calc(58px * var(--af-ui));
  --af-tile-label: calc(0.58rem * var(--af-ui));
  --af-help-w: calc(380px * var(--af-ui));
  --af-border: calc(3px * var(--af-ui));
  --af-diff-max: calc(260px * var(--af-ui));

  color-scheme: light;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
/* The app has no web fonts (it never goes online), so name the phone's own clean
   font. Without this, plain text falls back to an old serif font and the buttons
   do not: two different fonts on one screen. */
html.app-standalone body,
html.app-standalone button {
  font-family: ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN", "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
}
html.app-standalone,
html.app-standalone body {
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  touch-action: manipulation;
}
html.app-standalone:not(.af-bar) .diamond-mini-bar,
html.app-standalone:not(.af-bar) .angel-fish-back {
  display: none !important;
}
html.app-standalone .game-container {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  display: block;
}
html.app-standalone #gameCanvas {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: #7ec8ea;
}
html.app-standalone .game-ui {
  top: calc(var(--sat) + var(--af-edge));
  left: calc(var(--sal) + var(--af-edge));
  right: calc(var(--sar) + var(--af-icon) + var(--af-space-4));
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
  gap: var(--af-space-1) var(--af-space-2);
}
html.app-standalone .game-ui .score-display,
html.app-standalone .game-ui .level-chip,
html.app-standalone .game-ui .lives-chip,
html.app-standalone .game-ui .combo-chip,
html.app-standalone .game-ui .magic-chip {
  flex: 0 0 auto;
  white-space: nowrap;
}
html.app-standalone .game-controls {
  top: calc(var(--sat) + var(--af-edge));
  right: calc(var(--sar) + var(--af-edge));
  gap: var(--af-space-2);
}
/* Cards, buttons, HUD — all from --af-* tokens (JS sets --af-ui on resize). */
html.app-standalone .game-menu {
  width: min(var(--af-menu-w), calc(100% - var(--sal) - var(--sar) - var(--af-space-6)));
  max-height: calc(100% - var(--sat) - var(--sab) - var(--af-space-5));
  box-sizing: border-box;
  padding: var(--af-menu-pad-y) var(--af-menu-pad-x) var(--af-space-5);
  border-radius: var(--af-menu-radius);
  border-width: calc(6px * var(--af-ui));
}
html.app-standalone .game-help {
  top: calc(var(--sat) + var(--af-edge)) !important;
  bottom: calc(var(--sab) + var(--af-space-3)) !important;
  max-height: calc(100% - var(--sat) - var(--sab) - var(--af-space-6)) !important;
  transform: translateX(-50%) !important;
  width: min(94%, var(--af-help-w));
  padding: var(--af-space-5) var(--af-space-4) max(var(--af-space-3), var(--sab));
}
html.app-standalone .btn-diff,
html.app-standalone .game-over .btn-game,
html.app-standalone .game-pause .btn-game,
html.app-standalone .game-settings .btn-game,
html.app-standalone .game-continue .btn-game,
html.app-standalone .game-rate .btn-game,
html.app-standalone .game-missions .btn-game,
html.app-standalone .game-gift .btn-game,
html.app-standalone .game-help .btn-game {
  width: 100%;
  max-width: var(--af-btn-max);
  height: var(--af-btn-h);
  margin: var(--af-btn-gap) auto;
  padding: 0 var(--af-btn-pad-x);
  font-size: var(--af-btn-font);
  border-width: var(--af-border);
  box-sizing: border-box;
}
html.app-standalone .difficulty-select {
  max-width: var(--af-diff-max);
  gap: var(--af-space-3);
}
html.app-standalone .game-title-img {
  width: min(88%, var(--af-title-w));
}
html.app-standalone .game-menu .game-tagline {
  font-size: var(--af-tagline);
  margin: 0 0 var(--af-space-2);
}
html.app-standalone .game-menu .game-choose {
  font-size: var(--af-choose);
  margin: var(--af-space-1) 0 var(--af-space-3);
}
html.app-standalone .game-menu > h2,
html.app-standalone .chars-title h2 {
  font-size: var(--af-h2);
  padding: var(--af-h2-pad-y) var(--af-h2-pad-x);
  border-width: var(--af-border);
}
html.app-standalone .menu-tile {
  min-height: var(--af-tile-h);
}
html.app-standalone .game-icon-btn {
  width: var(--af-icon);
  height: var(--af-icon);
  font-size: var(--af-icon-font);
  border-width: var(--af-border);
}
html.app-standalone .score-display--hero {
  font-size: var(--af-hud-font);
  min-width: var(--af-hud-min);
  display: inline-flex;
  align-items: center;
  gap: var(--af-space-1);
  padding: calc(8px * var(--af-ui)) calc(14px * var(--af-ui));
}
html.app-standalone .score-display--best {
  font-size: var(--af-hud-best);
  padding: calc(6px * var(--af-ui)) calc(12px * var(--af-ui));
}
html.app-standalone .hud-star {
  width: var(--af-hud-star);
  height: var(--af-hud-star);
  display: block;
}
html.app-standalone .level-chip,
html.app-standalone .lives-chip,
html.app-standalone .combo-chip,
html.app-standalone .magic-chip {
  font-size: calc(0.85rem * var(--af-ui));
  padding: calc(6px * var(--af-ui)) calc(12px * var(--af-ui));
}
html.app-standalone .menu-coins {
  font-size: calc(1rem * var(--af-ui));
}
html.app-standalone .game-menu.game-chars.show {
  height: min(calc(720px * var(--af-ui)), calc(100% - 2 * max(var(--sat), var(--sab)) - var(--af-space-5)));
}
html.app-standalone .char-preview {
  width: calc(80px * var(--af-ui));
  height: calc(80px * var(--af-ui));
}
html.app-standalone .skin-row {
  gap: var(--af-space-2);
}
html.app-standalone .settings-row {
  min-height: calc(48px * var(--af-ui));
  font-size: calc(1rem * var(--af-ui));
}
html.app-standalone .tap-hint-text {
  font-size: calc(1.05rem * var(--af-ui));
}
html.app-standalone .final-score {
  font-size: calc(1.9rem * var(--af-ui));
}

/* Sky-over-water scene backdrop (sky: #00B4DB→#0083B0, water: #02AAB0→#00CDAC).
   Wispy clouds in the sky half, soft god-rays in the water half, horizon at 50%. */
body.angel-fish-page {
  overflow: hidden;
  background-color: #0083B0;
  background-image:
    radial-gradient(70px 24px at 20% 14%, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 70%),
    radial-gradient(95px 30px at 68% 9%, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0) 72%),
    radial-gradient(55px 20px at 42% 22%, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0) 70%),
    radial-gradient(120px 30px at 86% 30%, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0) 72%),
    repeating-linear-gradient(108deg, rgba(255, 255, 255, 0.10) 0 5px, rgba(255, 255, 255, 0) 5px 34px),
    linear-gradient(to bottom, #00b4db 0%, #0083b0 50%, #02aab0 50%, #00cdac 100%);
  background-repeat: no-repeat;
  background-size: auto, auto, auto, auto, 100% 50%, 100% 100%;
  background-position: 0 0, 0 0, 0 0, 0 0, center bottom, 0 0;
  background-attachment: scroll;
}

/* Keep the scene bright in dark mode too (it's game art, not page chrome) */
body.angel-fish-page.dark-mode,
body.angel-fish-page[data-theme="dark"] {
  background-color: #0083b0;
}

body.angel-fish-page.page-has-bg::before,
body.angel-fish-page.page-has-bg::after {
  display: none;
}

.angel-fish-back {
  position: fixed;
  top: 72px;
  left: 16px;
  z-index: 200;
  background: rgba(255, 255, 255, 0.95);
  padding: 10px 20px;
  border-radius: 16px 20px 14px 18px;
  border: 2.5px solid #ffffff;
  text-decoration: none;
  color: var(--brand-teal, var(--brand-teal, #0a86b8));
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow:
    0 3px 0 rgba(255, 174, 24, 0.35),
    0 6px 16px rgba(0, 0, 0, 0.18);
  transition: transform 0.16s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}
.angel-fish-back:hover {
  transform: translateY(-2px);
}

.game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-top: 56px;
}

#gameCanvas {
  background: linear-gradient(to bottom, #87ceeb 0%, #98d8c8 50%, #87ceeb 100%);
  border: 3px solid #fff;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  max-width: 100%;
  max-height: calc(100vh - 80px);
  touch-action: none;
}

.game-ui {
  position: absolute;
  top: 72px;
  left: 12px;
  right: 12px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  z-index: 10;
  pointer-events: none;
}

.score-display,
.level-display {
  background: rgba(255, 255, 255, 0.95);
  padding: 9px 16px;
  border-radius: 16px 18px 14px 16px;
  border: 2.5px solid #ffffff;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--af-ink, #16343f);
  box-shadow:
    0 3px 0 rgba(255, 174, 24, 0.35),
    0 6px 14px rgba(0, 0, 0, 0.14);
}
/* Halo = bubble: score pill wears the same gold ring as the angel's halo. */
.score-display--hero {
  box-shadow:
    0 0 0 3px rgba(255, 201, 51, 0.45),
    0 3px 0 rgba(255, 174, 24, 0.35),
    0 6px 14px rgba(0, 0, 0, 0.14);
}
.menu-best {
  margin: 0 0 8px;
  font-size: 0.88rem;
  font-weight: 800;
  color: #0a86b8;
  letter-spacing: 0.01em;
}
.menu-best[hidden] {
  display: none !important;
}
/* Dive wipe when a run starts — a thin waterline band sweeps down. */
.af-dive-wipe {
  position: absolute;
  left: 0;
  right: 0;
  top: 42%;
  height: 0;
  pointer-events: none;
  z-index: 90;
  opacity: 0;
  background:
    linear-gradient(180deg,
      rgba(255, 201, 51, 0) 0%,
      rgba(255, 201, 51, 0.55) 35%,
      rgba(56, 189, 248, 0.65) 55%,
      rgba(10, 134, 184, 0) 100%);
}
.af-dive-wipe.is-on {
  animation: af-dive-wipe 0.48s ease-out forwards;
}
@keyframes af-dive-wipe {
  0% { top: 18%; height: 10px; opacity: 0.95; }
  55% { top: 48%; height: 28px; opacity: 0.8; }
  100% { top: 88%; height: 6px; opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .af-dive-wipe.is-on { animation: none; opacity: 0; }
}

.game-menu {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  /* White card with a sky → sea → lagoon sticker border */
  background:
    linear-gradient(#ffffff, #ffffff) padding-box,
    linear-gradient(165deg, #7fd0f5 0%, #0a86b8 52%, #14b0ac 100%) border-box;
  border: 6px solid transparent;
  padding: 22px 20px 18px;
  border-radius: 28px;
  text-align: center;
  z-index: 100;
  box-shadow:
    0 18px 44px rgba(0, 0, 0, 0.30);
  max-width: 92%;
  max-height: 86vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Sea sticker title — only the card’s own title (not help-body headings).
   Kept inside the card (no big negative margin) so list items never scroll under it. */
.game-menu > h2 {
  display: inline-block;
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: 0.01em;
  text-transform: none;
  color: #ffffff;
  background: linear-gradient(180deg, #3aa8d8 0%, #0a86b8 55%, #075f84 100%);
  border: 3px solid #ffffff;
  border-radius: 20px 26px 18px 24px;
  padding: 9px 30px;
  margin: 4px auto 12px;
  text-shadow: 0 2px 0 rgba(4, 50, 72, 0.45);
  box-shadow:
    0 5px 0 rgba(5, 79, 111, 0.55),
    0 12px 22px rgba(0, 0, 0, 0.28);
}

.game-menu h1 {
  font-size: 2rem;
  color: var(--brand-teal, var(--brand-teal, #0a86b8));
  margin: 0 0 12px;
}

/* Bubbly arcade game title — glossy gradient fill + white sticker outline */
.game-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  margin: 0 0 8px;
  font-family: 'Arial Rounded MT Bold', 'Baloo 2', 'Fredoka', 'Trebuchet MS', system-ui, sans-serif;
  font-weight: 900;
  text-transform: none;
  line-height: 0.9;
  letter-spacing: 0.01em;
  animation: gameTitlePop 0.45s cubic-bezier(0.18, 0.89, 0.32, 1.28) both;
}

/* Logo picture. Its background is see-through and it brings its own white sticker
   outline and soft shadow, so it sits right on the card. The light shadow here only
   lets the white outline show on the white card. */
.game-title-img {
  display: block;
  width: min(78%, 220px);
  height: auto;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.16));
}

/* Fallback CSS wordmark (used only if the image is replaced by text) */
.game-title span {
  display: block;
  font-size: clamp(2.6rem, 13vw, 3.6rem);
  background: linear-gradient(180deg, #ffe23d 0%, #ffae18 48%, #ff6a1f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: #ff8a00;
  -webkit-text-fill-color: transparent;
  -webkit-text-stroke: 6px #ffffff;
  paint-order: stroke fill;
  filter: drop-shadow(0 3px 0 rgba(193, 78, 0, 0.45))
    drop-shadow(0 7px 9px rgba(0, 0, 0, 0.28));
}

.game-title .game-title__l2 {
  transform: rotate(-3deg);
  margin-top: -4px;
}

.game-tagline {
  color: #555;
  margin: 0 0 8px;
  line-height: 1.35;
  font-weight: 600;
}

@keyframes gameTitlePop {
  from {
    transform: scale(0.7) translateY(8px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .game-title {
    animation: none;
  }
}

.game-menu p {
  color: #555;
  margin: 0 0 20px;
  line-height: 1.55;
}

/* Angel Fish buttons — halo-gold sticker with a white rim and chunky 3D base. */
.btn-game {
  position: relative;
  background: linear-gradient(180deg, #ffe680 0%, #ffd23d 48%, #ffb81c 100%);
  color: #5a3800;
  border: 3px solid #ffffff;
  padding: 15px 34px;
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: 0.01em;
  text-transform: none;
  border-radius: 22px 26px 20px 24px;
  cursor: pointer;
  margin: 8px;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
  box-shadow:
    0 6px 0 #c47705,
    0 12px 22px rgba(196, 119, 5, 0.35),
    inset 0 2px 0 rgba(255, 255, 255, 0.7);
  transition: transform 0.16s cubic-bezier(0.18, 0.89, 0.32, 1.28),
              box-shadow 0.2s ease, filter 0.2s ease;
}
/* Halo→bubble press ring (gold outer, teal inner). */
.btn-game::after {
  content: "";
  position: absolute;
  inset: -7px;
  border-radius: inherit;
  border: 2px solid transparent;
  box-shadow: 0 0 0 0 rgba(255, 201, 51, 0);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}
.btn-game:active::after {
  opacity: 1;
  border-color: rgba(56, 189, 248, 0.75);
  box-shadow: 0 0 0 4px rgba(255, 201, 51, 0.35);
}

@media (hover: hover) {
  .btn-game:hover {
    filter: brightness(1.05);
    transform: translateY(-3px);
    box-shadow:
      0 9px 0 #c47705,
      0 18px 30px rgba(196, 119, 5, 0.4),
      inset 0 2px 0 rgba(255, 255, 255, 0.8);
  }
}

.btn-game:active {
  transform: translateY(3px);
  box-shadow:
    0 2px 0 #c47705,
    0 6px 14px rgba(196, 119, 5, 0.35),
    inset 0 2px 0 rgba(255, 255, 255, 0.55);
}

/* Secondary action — foam white (gold stays the one main CTA). */
.btn-game--muted {
  background: linear-gradient(180deg, #ffffff 0%, #eef8fd 100%);
  color: #16343f;
  text-shadow: none;
  box-shadow:
    0 5px 0 #b6cfdc,
    0 10px 18px rgba(7, 60, 85, 0.14),
    inset 0 2px 0 rgba(255, 255, 255, 0.8);
}
@media (hover: hover) {
  .btn-game--muted:hover {
    box-shadow:
      0 7px 0 #b6cfdc,
      0 14px 24px rgba(7, 60, 85, 0.18),
      inset 0 2px 0 rgba(255, 255, 255, 0.9);
  }
}
.btn-game--muted:active {
  box-shadow:
    0 2px 0 #b6cfdc,
    0 4px 10px rgba(7, 60, 85, 0.14),
    inset 0 2px 0 rgba(255, 255, 255, 0.7);
}

/* ---- Difficulty chooser (Easy / Medium / Hard) ---- */
.game-choose {
  font-weight: 800;
  color: #16343f;
  text-transform: none;
  letter-spacing: 0.01em;
  margin: 4px 0 12px;
  font-size: 0.9rem;
}

.difficulty-select {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  max-width: 260px;
  margin: 0 auto 4px;
}

.btn-diff {
  width: 100%;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

/* Difficulty = depth: Easy sky → Medium lagoon → Hard night sea (never hazard red). */
.btn-diff--easy {
  background: linear-gradient(180deg, #5ec4ef 0%, #36b2ea 50%, #0f6f9e 100%);
  color: #ffffff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
  box-shadow:
    0 6px 0 #0a5a80,
    0 12px 22px rgba(15, 111, 158, 0.35),
    inset 0 2px 0 rgba(255, 255, 255, 0.5);
}
@media (hover: hover) {
  .btn-diff--easy:hover {
    box-shadow:
      0 9px 0 #0a5a80,
      0 18px 30px rgba(15, 111, 158, 0.4),
      inset 0 2px 0 rgba(255, 255, 255, 0.6);
  }
}
.btn-diff--easy:active {
  box-shadow:
    0 2px 0 #0a5a80,
    0 6px 14px rgba(15, 111, 158, 0.35),
    inset 0 2px 0 rgba(255, 255, 255, 0.4);
}

.btn-diff--medium {
  background: linear-gradient(180deg, #5fdcd2 0%, #14b0ac 50%, #0e8a86 100%);
  color: #ffffff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
  box-shadow:
    0 6px 0 #0a6b68,
    0 12px 22px rgba(8, 105, 107, 0.35),
    inset 0 2px 0 rgba(255, 255, 255, 0.45);
}
@media (hover: hover) {
  .btn-diff--medium:hover {
    box-shadow:
      0 9px 0 #0a6b68,
      0 18px 30px rgba(8, 105, 107, 0.4),
      inset 0 2px 0 rgba(255, 255, 255, 0.55);
  }
}
.btn-diff--medium:active {
  box-shadow:
    0 2px 0 #0a6b68,
    0 6px 14px rgba(8, 105, 107, 0.35),
    inset 0 2px 0 rgba(255, 255, 255, 0.35);
}

.btn-diff--hard {
  background: linear-gradient(180deg, #3a5eb5 0%, #23468f 50%, #162a5c 100%);
  color: #ffffff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
  box-shadow:
    0 6px 0 #0d1d48,
    0 12px 22px rgba(13, 29, 72, 0.4),
    inset 0 2px 0 rgba(255, 255, 255, 0.35);
}
@media (hover: hover) {
  .btn-diff--hard:hover {
    box-shadow:
      0 9px 0 #0d1d48,
      0 18px 30px rgba(13, 29, 72, 0.45),
      inset 0 2px 0 rgba(255, 255, 255, 0.45);
  }
}
.btn-diff--hard:active {
  box-shadow:
    0 2px 0 #0d1d48,
    0 6px 14px rgba(13, 29, 72, 0.4),
    inset 0 2px 0 rgba(255, 255, 255, 0.3);
}

@media (prefers-reduced-motion: reduce) {
  .btn-game { transition: none; }
}

/* ---- Circular glossy icon buttons (pause / sound) ---- */
.game-controls {
  position: fixed;
  top: 118px;
  right: 14px;
  z-index: 150;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.game-icon-btn svg,
.game-menu-gear svg {
  width: 22px;
  height: 22px;
  display: block;
  pointer-events: none;
}
.game-icon-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid #ffffff;
  background: linear-gradient(180deg, #3aa8d8 0%, #0a86b8 55%, #075f84 100%);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 5px 0 #054f6f,
    0 9px 16px rgba(5, 80, 111, 0.35),
    inset 0 2px 0 rgba(255, 255, 255, 0.35);
  transition: transform 0.16s cubic-bezier(0.18, 0.89, 0.32, 1.28),
              box-shadow 0.18s ease;
}
@media (hover: hover) {
  .game-icon-btn:hover {
    transform: translateY(-2px);
    box-shadow:
      0 7px 0 #054f6f,
      0 12px 20px rgba(5, 80, 111, 0.4),
      inset 0 2px 0 rgba(255, 255, 255, 0.45);
  }
}
.game-icon-btn:active {
  transform: translateY(3px);
  box-shadow:
    0 2px 0 #054f6f,
    0 5px 12px rgba(5, 80, 111, 0.35),
    inset 0 2px 0 rgba(255, 255, 255, 0.25);
}
.game-icon-btn.is-muted {
  background: linear-gradient(180deg, #a9bcc6 0%, #7d93a0 55%, #627885 100%);
  box-shadow:
    0 5px 0 #4d6170,
    0 9px 16px rgba(60, 80, 95, 0.35),
    inset 0 2px 0 rgba(255, 255, 255, 0.3);
}
/* One sound icon at a time. The JS hidden property has no effect on SVG, so use the is-muted class. */
.game-icon-btn--sound .icon-off,
.game-icon-btn--sound.is-muted .icon-on {
  display: none;
}
.game-icon-btn--sound.is-muted .icon-off {
  display: block;
}

/* (The website's game column repeats these three values: see WEBSITE MODE at the end.) */
@media (max-width: 480px) {
  .game-icon-btn { width: 44px; height: 44px; font-size: 1rem; }
}

/* ---- New best sticker on Game Over ---- */
.new-best-badge {
  display: inline-block;
  margin: 2px 0 10px;
  padding: 6px 18px;
  border-radius: 16px 20px 14px 18px;
  font-weight: 900;
  font-size: 0.9rem;
  letter-spacing: 0.01em;
  text-transform: none;
  color: #7a4a00;
  background: linear-gradient(180deg, #ffe14d 0%, #ffc21e 100%);
  border: 2.5px solid #ffffff;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
  box-shadow:
    0 4px 0 #d4870a,
    0 8px 16px rgba(212, 135, 10, 0.4);
  animation: newBestPop 0.5s cubic-bezier(0.18, 0.89, 0.32, 1.28) both;
}
@keyframes newBestPop {
  0% { transform: scale(0.7) rotate(-4deg); opacity: 0; }
  60% { transform: scale(1.05) rotate(1deg); }
  100% { transform: scale(1) rotate(-1deg); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .new-best-badge { animation: none; }
}

/* ---- Coins ---- */
/* The coin is an SVG (not an emoji), so it looks the same on iPhone and Android:
   reeded gold edge, raised rim, and the Angel Fish halo + fish struck in as a watermark.
   The gradient under it shows only if the image ever fails to load. */
.coin-dot {
  display: inline-block;
  flex: 0 0 auto;
  box-sizing: border-box;
  width: 1.45em;
  height: 1.45em;
  margin-right: 0.32em;
  vertical-align: -0.36em;
  border-radius: 50%;
  background:
    url('../images/coin.svg') center / contain no-repeat,
    radial-gradient(circle at 35% 30%, #fff6c4 0%, #ffd23d 45%, #f0a500 100%);
  filter: drop-shadow(0 0.06em 0 rgba(140, 84, 0, 0.45));
}

/* Coin count: top left of the start menu, and on the Characters screen */
.menu-coins {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 14px 0 10px;
  border-radius: 14px 18px 12px 16px;
  font-weight: 900;
  font-size: 1rem;
  color: #7a4a00;
  background: linear-gradient(180deg, #fff3cf 0%, #ffe49a 100%);
  border: 2.5px solid #ffffff;
  box-shadow:
    0 3px 0 rgba(212, 135, 10, 0.35),
    0 6px 14px rgba(212, 135, 10, 0.25);
  box-sizing: border-box;
}
.menu-coins--inline {
  position: static;
  height: 32px;
  font-size: 0.95rem;
}

/* Game Over: the coins won, an arrow, and the coin counter they fly into */
.coins-earned-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 8px;
  font-weight: 800;
  color: #b07d12;
  margin: 4px 0 14px;
}
.coins-won {
  display: inline-block;
  white-space: nowrap;
}
.coins-arrow {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  color: #d9a93a;
}
.menu-coins.over-wallet {
  height: 28px;
  padding: 0 11px 0 8px;
  font-size: 0.9rem;
  border-width: 2px;
  box-shadow: 0 2px 0 rgba(212, 135, 10, 0.3);
}
/* A coin in the air (see flyCoins() in the JS) */
.fly-coin {
  position: fixed;
  z-index: 400;
  width: 26px;
  height: 26px;
  margin: 0;
  font-size: 18px;
  pointer-events: none;
  will-change: transform;
}
.coins-bonus-line {
  font-size: 0.85rem;
  font-weight: 700;
  color: #8a6a1a;
  margin: -8px 0 12px;
}

/* ---- Start menu: Characters and Missions tiles ---- */
/* Room at the top for the coin count (left) and the settings gear (right).
   Keep the home card dense so logo + difficulty + tiles fit without scrolling. */
#startMenu {
  padding-top: 48px;
  padding-bottom: 16px;
  overflow-y: auto;
}
html.app-standalone #startMenu {
  padding-top: calc(var(--af-icon) + var(--af-edge) + var(--af-space-1));
  padding-bottom: var(--af-space-3);
  max-height: calc(100% - var(--sat) - var(--sab) - var(--af-space-3));
}
html.app-standalone #startMenu .game-title {
  margin: 0 0 var(--af-space-1);
}
html.app-standalone #startMenu .game-title-img {
  width: min(78%, var(--af-title-w));
}
html.app-standalone #startMenu .game-tagline {
  margin: 0 auto var(--af-space-1);
  line-height: 1.35;
  max-width: 22em;
  text-wrap: balance;
  text-align: center;
  /* Keep each phrase together so "red." never sits alone on a line. */
  hyphens: none;
}
html.app-standalone #startMenu .menu-best {
  margin: 0 0 var(--af-space-2);
  font-size: calc(0.85rem * var(--af-ui));
}
html.app-standalone #startMenu .difficulty-select {
  gap: var(--af-space-2);
  margin-bottom: 0;
}
html.app-standalone #startMenu .btn-diff {
  height: var(--af-btn-h);
  margin: 0 auto;
}
html.app-standalone .menu-tiles {
  gap: var(--af-space-2);
  max-width: var(--af-btn-max);
  margin: var(--af-space-2) auto 0;
  padding: 10px 8px 4px;
}
.menu-tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  gap: 8px;
  max-width: 280px;
  margin: 10px auto 0;
}
.menu-tile {
  min-width: 0;
  min-height: 64px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 3px 5px;
  /* Keep overflow visible so the red "buy" dot is never clipped. */
  overflow: visible;
  border-radius: 18px;
  border: 3px solid #cfe0f5;
  background: linear-gradient(180deg, #ffffff 0%, #e6f0ff 100%);
  color: var(--af-ink, #16343f);
  font: inherit;
  font-weight: 800;
  font-size: 0.68rem;
  letter-spacing: 0.01em;
  text-transform: none;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(77, 120, 190, 0.3);
  transition: transform 0.16s cubic-bezier(0.18, 0.89, 0.32, 1.28), box-shadow 0.18s ease;
}
.menu-tile:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(77, 120, 190, 0.3);
}
.menu-tile-label {
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  padding: 0 1px;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.15;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}
html.app-standalone .menu-tile-label {
  font-size: var(--af-tile-label);
}
.menu-tile-icon {
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.menu-tile-icon .skin-face {
  font-size: 1.45rem;
  line-height: 1;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.skin-face img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  display: block;
}
.menu-tile-icon svg {
  width: 24px;
  height: 24px;
  display: block;
}
@media (prefers-reduced-motion: reduce) {
  .menu-tile { transition: none; }
}

/* ---- Characters screen ---- */
/* The card is a column: the top part and the Done button stay, the list scrolls. */
.game-menu.game-chars.show {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* The card sits in the middle of the screen, so the bigger of the two safe areas
     (notch at the top, home bar at the bottom) counts on both sides. */
  height: min(720px, calc(100% - 2 * max(var(--sat, 0px), var(--sab, 0px)) - 20px));
}
.game-chars > * {
  flex: 0 0 auto;
}
.chars-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 10px;
}
.chars-note {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--af-dusk-700, #4a32a6);
  text-align: right;
  line-height: 1.2;
}
.char-detail {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 18px;
  border: 2.5px solid #cfe0f5;
  background: linear-gradient(180deg, #ffffff 0%, var(--af-sky-100, #e3f4fd) 100%);
  text-align: left;
}
.char-face {
  flex: 0 0 auto;
  width: 88px;
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: inset 0 0 0 2px #dbe6f7;
}
.char-face .skin-face {
  font-size: 2.2rem;
  line-height: 1;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.char-preview {
  width: 80px;
  height: 80px;
  display: block;
  border-radius: 50%;
}
.char-detail-text {
  flex: 1 1 auto;
  min-width: 0;
}
.char-name {
  font-size: 1.05rem;
  font-weight: 900;
  color: var(--af-ink, #16343f);
  line-height: 1.2;
}
.char-magic {
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.01em;
  text-transform: none;
  line-height: 1.3;
}
.char-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0 2px;
}
.char-meta .skin-cat {
  font-size: 9px;
}
.char-info {
  font-size: 0.82rem;
  font-weight: 600;
  color: #4a5753;
  line-height: 1.3;
  min-height: 2.6em; /* two lines, so the screen does not jump from one character to the next */
}
html.app-standalone .game-over .btn-game.char-action {
  flex: 0 0 auto;
  height: calc(46px * var(--af-ui));
  margin: var(--af-space-2) auto;
  padding: 0 var(--af-space-3);
  font-size: calc(15px * var(--af-ui));
  max-width: var(--af-btn-max);
}
.btn-game:disabled {
  filter: grayscale(0.65);
  opacity: 0.6;
  cursor: default;
  transform: none;
}
.btn-game:disabled:hover,
.btn-game:disabled:active {
  transform: none;
  filter: grayscale(0.65);
}

/* ---- Character list ---- */
.skin-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 280px;
  margin: 0 auto 18px;
}
.game-chars .skin-row {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 300px;
  margin: 0 auto 8px;
  padding: 4px 4px 6px;
  box-sizing: border-box;
  align-content: start;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
/* The emoji fish look to the left; turn them to face the way they swim. */
.skin-face--flip {
  display: inline-block;
  transform: scaleX(-1);
}

.skin-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 4px 8px;
  border-radius: 18px;
  cursor: pointer;
  border: 3px solid #dfe7e4;
  background: linear-gradient(180deg, #ffffff 0%, #eef3f1 100%);
  transition: transform 0.16s cubic-bezier(0.18, 0.89, 0.32, 1.28),
              border-color 0.2s ease, box-shadow 0.2s ease;
}
@media (hover: hover) {
  .skin-cell:hover {
    transform: translateY(-2px);
  }
}
.skin-cell .skin-face {
  font-size: 1.9rem;
  line-height: 1;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}
.skin-name {
  font-size: 11px;
  font-weight: 800;
  color: var(--af-ink, #16343f);
  line-height: 1.1;
}
.skin-magic {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.01em;
  text-transform: none;
  color: var(--af-dusk-700, #4a32a6);
  line-height: 1.1;
}
.skin-cat {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.01em;
  text-transform: none;
  line-height: 1.1;
  padding: 1px 6px;
  border-radius: 8px 10px 7px 9px;
  color: #3a4a5c;
  background: rgba(10, 134, 184, 0.12);
}
.skin-cat--celestial {
  color: #a07820;
  background: rgba(255, 184, 28, 0.18);
}
.skin-cat--aquatic {
  color: #075f84;
  background: rgba(58, 168, 216, 0.28);
}
.skin-cat--hero {
  color: #3d5a9e;
  background: #e2e9f8;
}
.skin-cat--mythical {
  color: var(--af-dusk-700, #4a32a6);
  background: var(--af-dusk-wash, #eef4fb);
}
.skin-cat--cute {
  color: #b8325a;
  background: rgba(240, 82, 90, 0.14);
}
.skin-star {
  font-size: 10px;
  font-weight: 900;
  color: #a07820;
  background: rgba(255, 243, 207, 0.95);
  border: 1px solid #e0a82e;
  border-radius: 8px 10px 7px 9px;
  padding: 1px 6px;
  line-height: 1.1;
}
.almost-line {
  width: 100%;
  max-width: 260px;
  margin: 0 auto 14px;
  text-align: center;
}
.almost-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 800;
  color: #5a3d12;
  margin-bottom: 6px;
}
.almost-bar {
  display: block;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 180, 60, 0.28);
  border: 1px solid rgba(255, 160, 40, 0.45);
  overflow: hidden;
}
.almost-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffd23d, #ff8a00);
  transition: width 0.35s ease;
}
.level-chip {
  background: rgba(255, 255, 255, 0.92);
  color: #16324a;
  font-weight: 900;
  font-size: 13px;
  border: 2px solid #ffffff;
  border-radius: 14px 18px 12px 16px;
  padding: 4px 10px;
  box-shadow: 0 3px 0 rgba(22, 50, 74, 0.18);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.level-chip .level-label {
  opacity: 0.72;
  font-weight: 800;
}
.lives-chip {
  background: #ffe4ec;
  color: #b4234a;
  font-weight: 900;
  font-size: 13px;
  border: 2px solid #ffffff;
  border-radius: 14px 18px 12px 16px;
  padding: 4px 10px;
  box-shadow: 0 3px 0 rgba(180, 35, 74, 0.28);
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.lives-chip .lives-heart {
  color: var(--af-coral-500, #f0525a);
  font-size: 1.05em;
  line-height: 1;
}
.combo-chip {
  background: var(--af-dusk-500, #6b4fd8);
  color: #fff;
  font-weight: 900;
  font-size: 14px;
  border: 2px solid #fff;
  border-radius: 14px 18px 12px 16px;
  padding: 4px 10px;
  box-shadow: 0 3px 0 var(--af-dusk-700, #4a32a6);
}
.magic-chip {
  background: #ffffff;
  border: 2px solid #ffffff;
  border-radius: 14px 18px 12px 16px;
  padding: 4px 10px;
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 0.01em;
  text-transform: none;
  box-shadow: 0 3px 0 rgba(90, 60, 180, 0.28);
}
.skin-cell.is-locked {
  filter: grayscale(0.55);
  opacity: 0.92;
}
.skin-cell.is-selected {
  border-color: #14b0ac;
  background: linear-gradient(180deg, #ffffff 0%, #d8f7f5 100%);
  box-shadow: 0 4px 0 rgba(8, 105, 107, 0.28), 0 8px 16px rgba(8, 105, 107, 0.16);
}
/* A locked character the player is looking at (shown in the box at the top) */
.skin-cell.is-focus {
  border-color: #ffb01e;
  filter: none;
  opacity: 1;
  box-shadow: 0 0 0 3px rgba(255, 176, 30, 0.3);
}

.skin-tag {
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.01em;
  padding: 2px 8px;
  border-radius: 8px 10px 7px 9px;
  white-space: nowrap;
}
.skin-tag--sel {
  background: #14b0ac;
  color: #fff;
  font-size: 0.8rem;
  padding: 1px 9px;
}
.skin-tag--use {
  background: #0a86b8;
  color: #fff;
}
.skin-tag--cost {
  background: #fff3cf;
  color: #7a4a00;
  border: 1px solid #ffd874;
}

/* ---- Missions ---- */
.missions-note {
  font-size: 0.88rem;
  font-weight: 600;
}
.game-menu p.missions-note {
  margin: 0 0 14px;
  line-height: 1.4;
}
.mission-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 300px;
  margin: 0 auto 16px;
  text-align: left;
}
.mission-row {
  padding: 10px 12px;
  border-radius: 14px 18px 12px 16px;
  border: 2.5px solid #cfe0f5;
  background: linear-gradient(180deg, #ffffff 0%, var(--af-sky-100, #e3f4fd) 100%);
}
.mission-text {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--af-ink, #16343f);
  line-height: 1.25;
  margin-bottom: 7px;
}
.mission-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}
.mission-bar {
  flex: 1 1 auto;
  min-width: 30px;
  height: 10px;
  border-radius: 999px;
  background: #cfd9e6;
  overflow: hidden;
}
.mission-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(180deg, #5fdcd2 0%, #14b0ac 100%);
}
.mission-count {
  font-size: 0.76rem;
  font-weight: 800;
  color: #4a5753;
  white-space: nowrap;
}
.mission-prize {
  display: inline-flex;
  align-items: center;
  font-size: 0.82rem;
  font-weight: 900;
  color: #7a4a00;
  background: #fff3cf;
  border: 1px solid #ffd874;
  border-radius: 10px 12px 9px 11px;
  padding: 2px 8px 2px 6px;
  white-space: nowrap;
}
/* A goal finished in the run, shown on the Game Over card */
.mission-done-list {
  max-width: 280px;
  margin: 0 auto 12px;
}
.mission-done-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.84rem;
  font-weight: 800;
  color: #0a6b68;
  background: #e6faf9;
  border: 1.5px solid #9fe3de;
  border-radius: 12px 14px 10px 12px;
  padding: 6px 8px 6px 10px;
  margin: 6px 0;
  line-height: 1.25;
  text-align: left;
}

/* ---- Continue after a crash ---- */
/* The coin count in the middle of a card */
.card-coins {
  display: flex;
  justify-content: center;
  margin: 0 0 10px;
}
.game-menu p.continue-note {
  margin: 0 0 12px;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.35;
}
/* The time left to answer: a bar that runs empty */
.continue-bar {
  max-width: 250px;
  height: 10px;
  margin: 0 auto 12px;
  border-radius: 999px;
  background: #cfd9e6;
  overflow: hidden;
}
.continue-fill {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffd23d 0%, #f0a500 100%);
  transition: width 0.1s linear;
}
/* A button that spends coins: the picture, the word and the price stay on one line */
html.app-standalone .game-over .btn-game.btn-game--price,
.btn-game.btn-game--price {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  white-space: nowrap;
}
.btn-game--price .btn-icon {
  flex: 0 0 auto;
}
.btn-price {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  margin-left: 10px;
  padding: 2px 9px 2px 6px;
  border-radius: 10px 12px 9px 11px;
  font-size: 0.86em;
  letter-spacing: 0;
  color: #7a4a00;
  background: #fff3cf;
  border: 1px solid #ffd874;
  text-shadow: none;
  vertical-align: 1px;
  pointer-events: none;
}
/* The two buttons wake up a moment after the card comes (the game does not take
   a tap before that), so a finger still tapping in the game cannot buy by accident. */
.game-continue.show .continue-actions {
  animation: continueWake 0.6s linear both;
}
@keyframes continueWake {
  0%, 75% { opacity: 0.45; }
  100% { opacity: 1; }
}

/* ---- Daily gift ---- */
/* The gift button on the start menu, left of the settings gear */
.game-menu-gear.game-menu-gift {
  right: 60px;
  background: linear-gradient(180deg, #ff9cc0 0%, #ff5d8f 55%, #e0457a 100%);
  box-shadow:
    0 4px 0 #b83263,
    0 7px 14px rgba(184, 50, 99, 0.35),
    inset 0 2px 0 rgba(255, 255, 255, 0.4);
}
.game-menu-gear.game-menu-gift svg {
  width: 24px;
  height: 24px;
  display: block;
}
/* Red dot: today's gift has not been opened yet */
.game-menu-gift.has-dot::after {
  content: '';
  position: absolute;
  top: -5px;
  right: -5px;
  box-sizing: border-box;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--af-coral-500, #f0525a);
  border: 2.5px solid #ffffff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
  animation: dotPulse 1.3s ease-in-out infinite;
}
.game-menu-gift.has-dot svg {
  animation: giftWiggle 2.6s ease-in-out infinite;
}
@keyframes giftWiggle {
  0%, 70%, 100% { transform: rotate(0deg); }
  76% { transform: rotate(-12deg); }
  82% { transform: rotate(10deg); }
  88% { transform: rotate(-7deg); }
  94% { transform: rotate(4deg); }
}
/* The gift card */
.gift-box {
  width: 84px;
  height: 84px;
  margin: 0 auto 4px;
}
.gift-box svg {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 4px 5px rgba(160, 40, 90, 0.3));
}
.gift-box.is-open svg {
  filter: grayscale(0.5);
  opacity: 0.55;
}
.gift-line {
  font-size: 1.05rem;
  font-weight: 900;
  color: #b0600a;
  line-height: 1.3;
  margin: 0 0 10px;
}
/* The seven gifts in a row */
.gift-days {
  display: flex;
  justify-content: center;
  gap: 4px;
  max-width: 280px;
  margin: 0 auto 10px;
}
.gift-day {
  flex: 1 1 0;
  min-width: 0;
  padding: 6px 0 5px;
  border-radius: 10px;
  border: 2px solid var(--af-line, #d5e3ea);
  background: var(--af-sky-50, #f2faff);
  font-size: 0.78rem;
  font-weight: 900;
  color: var(--af-ink-soft, #4a6472);
  line-height: 1.1;
}
.gift-day.is-done {
  border-color: #9fe3de;
  background: #e6faf9;
  color: #0a6b68;
}
.gift-day.is-today {
  border-color: #ffb01e;
  background: #fff3cf;
  color: #7a4a00;
  box-shadow: 0 0 0 2px rgba(255, 176, 30, 0.3);
}
.game-menu p.gift-note {
  margin: 0 0 12px;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.35;
}

/* ---- Surprise box (first cell of the character list) ---- */
.box-art {
  display: block;
  width: 1em;
  height: 1em;
}
.skin-cell--box {
  border-color: var(--af-dusk-300, #9b85f0);
  background: linear-gradient(180deg, #ffffff 0%, var(--af-dusk-wash, #eef4fb) 100%);
}

/* ---- Settings gear on the start-menu card ---- */
.game-menu-gear {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid #ffffff;
  background: linear-gradient(180deg, #3aa8d8 0%, #0a86b8 55%, #075f84 100%);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 4px 0 #054f6f,
    0 7px 14px rgba(5, 80, 111, 0.35),
    inset 0 2px 0 rgba(255, 255, 255, 0.35);
  transition: transform 0.16s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  z-index: 2;
}
@media (hover: hover) {
  .game-menu-gear:hover {
    transform: translateY(-2px) rotate(20deg);
  }
}

/* ---- Settings panel rows + toggle switches ---- */
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 290px;
  margin: 8px auto 20px;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 12px 16px;
  border-radius: 16px;
  border: 2.5px solid #cfe0f5;
  background: linear-gradient(180deg, #ffffff 0%, var(--af-sky-100, #e3f4fd) 100%);
  cursor: pointer;
}
.settings-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  color: var(--af-ink, #16343f);
  font-size: 0.98rem;
}
.settings-label i {
  color: var(--brand-teal, #0a86b8);
  width: 20px;
  text-align: center;
}
.switch {
  position: relative;
  flex: 0 0 auto;
  width: 52px;
  height: 28px;
  border-radius: 999px;
  background: #c3d3dc;
  border: 2px solid #ffffff;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.22);
  transition: background 0.2s ease;
}
.switch-knob {
  position: absolute;
  top: 50%;
  left: 3px;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  transition: left 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}
.settings-row[aria-checked="true"] .switch {
  background: linear-gradient(180deg, #5fdcd2 0%, #14b0ac 100%);
}
.settings-row[aria-checked="true"] .switch-knob {
  left: 27px;
}
@media (prefers-reduced-motion: reduce) {
  .switch-knob { transition: none; }
}
.settings-note {
  max-width: 290px;
  font-size: 0.8rem;
}
.game-menu p.settings-note {
  margin: 0 auto 10px;
  line-height: 1.4;
}
.settings-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  max-width: 290px;
  margin: 0 auto 10px;
  width: 100%;
}
html.app-standalone .settings-links {
  gap: var(--af-space-2);
  max-width: calc(290px * var(--af-ui));
  margin: 0 auto var(--af-space-2);
}
.settings-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--af-sky-50, #f2faff);
  border: 2px solid var(--af-line, #d5e3ea);
  color: var(--af-ink, #16343f);
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
  box-shadow: 0 2px 0 #c1d6e2;
}
html.app-standalone .settings-link {
  min-height: calc(44px * var(--af-ui));
  padding: calc(10px * var(--af-ui)) calc(12px * var(--af-ui));
  border-radius: calc(12px * var(--af-ui));
  font-size: calc(0.95rem * var(--af-ui));
}
.settings-link:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 #c1d6e2;
}
.settings-link:hover {
  color: var(--af-ink, #16343f);
  background: var(--af-sky-100, #e3f4fd);
}
.settings-link:last-child {
  grid-column: 1 / -1;
}
.settings-version {
  margin: 0 auto 8px;
  max-width: 290px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #6a7f78;
  text-align: center;
}
.game-menu .btn-game.settings-reset {
  max-width: 290px;
  height: 44px;
  margin: 0 auto 10px;
  font-size: 0.9rem;
}

/* Soft “Having fun?” card after a few runs / new best.
   Sits above Game Over but the card below is dimmed so NEW BEST stays readable (P8). */
.game-rate {
  z-index: 500;
  top: 58%;
}
.game-over.dimmed-for-rate {
  opacity: 0.38;
  pointer-events: none;
  filter: saturate(0.85);
  transition: opacity 0.25s ease;
}
.game-rate .rate-note {
  max-width: 260px;
  margin: 0 auto 16px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--af-ink-soft, #4a6472);
  line-height: 1.4;
  text-align: center;
}

/* Dim everything under Help so Settings links don't show through */
.help-backdrop {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 540;
  background: rgba(8, 28, 40, 0.62);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.help-backdrop.show {
  display: block;
}

/* In-app help / legal sheet — pinned below the notch, not vertically centered */
.game-help {
  z-index: 560;
  display: none;
  flex-direction: column;
  align-items: stretch;
  top: max(16px, calc(env(safe-area-inset-top, 0px) + 12px));
  bottom: max(12px, calc(env(safe-area-inset-bottom, 0px) + 8px));
  left: 50%;
  /* Only shift X — never -50% Y (that shoved the card under the Dynamic Island). */
  transform: translateX(-50%);
  width: min(94%, 380px);
  height: auto;
  max-height: calc(100% - max(28px, env(safe-area-inset-top, 0px) + env(safe-area-inset-bottom, 0px) + 20px));
  margin: 0;
  padding: 20px 18px max(14px, env(safe-area-inset-bottom, 0px));
  overflow: hidden;
  box-sizing: border-box;
}
.game-over.game-help.show {
  display: flex;
}
/* Title stays fully inside the card (never under the Dynamic Island).
   Override .game-menu > h2 { margin: -52px } which pulled HELP above the card. */
.game-help > h2,
.game-menu.game-help > h2 {
  flex: 0 0 auto;
  align-self: center;
  margin: 0 0 12px !important;
  padding: 10px 22px;
  font-size: 1.15rem;
  line-height: 1.2;
  color: #ffffff !important;
  background: linear-gradient(180deg, #3aa8d8 0%, #0a86b8 55%, #075f84 100%);
  border: 3px solid #ffffff;
  border-radius: 18px 22px 16px 20px;
  text-shadow: 0 2px 0 rgba(4, 50, 72, 0.45);
  box-shadow:
    0 4px 0 rgba(5, 79, 111, 0.5),
    0 8px 16px rgba(0, 0, 0, 0.2);
}
.help-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  text-align: left;
  width: 100%;
  max-width: none;
  margin: 0 0 12px;
  padding: 6px 4px 10px;
  font-size: 1rem;
  font-weight: 600;
  color: #142822;
  line-height: 1.55;
  /* No text selection — avoids iOS edit-menu / RTI console noise on tap. */
  -webkit-user-select: none;
  user-select: none;
}
.help-body .card {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
}
.help-body .back {
  display: none !important;
}
/* Section headings: sky-mist stickers — never forest green or purple pills */
.help-body h1,
.help-body h2,
.game-help .help-body h1,
.game-help .help-body h2 {
  display: block !important;
  font-size: 0.95rem !important;
  font-weight: 900 !important;
  letter-spacing: 0.01em;
  text-transform: none !important;
  color: var(--af-ink, #16343f) !important;
  background: var(--af-sky-100, #e3f4fd) !important;
  border: 2px solid var(--af-sky-200, #bfe8ff) !important;
  border-radius: 12px 14px 11px 13px !important;
  padding: 8px 12px !important;
  margin: 14px 0 8px !important;
  text-shadow: none !important;
  box-shadow: none !important;
  line-height: 1.25 !important;
}
.help-body h1:first-child,
.help-body h2:first-child {
  margin-top: 0 !important;
}
.help-body p,
.help-body li {
  margin: 0.45rem 0;
  color: var(--af-ink, #16343f);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.55;
}
.help-body strong {
  color: var(--af-sea-700, #05506f);
  font-weight: 900;
}
.help-body ul {
  padding-left: 1.2rem;
  margin: 0.4rem 0 0.6rem;
}
.help-body .note {
  font-size: 0.8rem;
  color: var(--af-ink-soft, #4a6472);
  margin-top: 12px;
}
.help-body pre {
  background: var(--af-sky-50, #f2faff);
  color: var(--af-ink, #16343f);
  padding: 0.65rem 0.75rem;
  overflow: auto;
  font-size: 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--af-line, #d5e3ea);
  white-space: pre-wrap;
}
.help-body a {
  color: #1f6b52 !important;
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.game-help .btn-game {
  flex: 0 0 auto;
  width: 100%;
  max-width: none;
  color: #ffffff !important;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}

/* ---- Install (Add to Home Screen) button + iOS hint ---- */
.btn-game--install {
  background: linear-gradient(180deg, #4da6ff 0%, #2e7ce0 55%, #1f5fc0 100%);
  color: #fff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
  box-shadow:
    0 6px 0 #184c9c,
    0 12px 22px rgba(24, 76, 156, 0.4),
    inset 0 2px 0 rgba(255, 255, 255, 0.4);
}
.btn-game--install:hover {
  box-shadow:
    0 9px 0 #184c9c,
    0 18px 30px rgba(24, 76, 156, 0.45),
    inset 0 2px 0 rgba(255, 255, 255, 0.5);
}
.btn-game--install:active {
  box-shadow:
    0 2px 0 #184c9c,
    0 6px 14px rgba(24, 76, 156, 0.4),
    inset 0 2px 0 rgba(255, 255, 255, 0.3);
}
.ios-install-hint {
  margin: 6px auto 4px;
  max-width: 260px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--af-ink, #16343f);
  background: var(--af-sky-100, #e3f4fd);
  border-radius: 12px 14px 11px 13px;
  padding: 8px 12px;
}
.ios-install-hint i {
  color: var(--af-sea-600, #075f84);
}

/* ---- First-time tap onboarding hint ---- */
.tap-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 60;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  transition: opacity 0.3s ease;
}
.tap-hint.is-hiding {
  opacity: 0;
}
.tap-hint-hand {
  animation: tapHintBob 1.1s ease-in-out infinite;
}
.tap-hint-hand svg {
  width: 54px;
  height: 54px;
  display: block;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.35));
  /* Default: tip down. Flip for "go up" so it stays a straight geometric arrow. */
  transform-origin: 50% 50%;
}
.tap-hint.is-up .tap-hint-hand svg {
  transform: rotate(180deg);
}
.tap-hint-text {
  font-weight: 900;
  color: #ffffff;
  background: linear-gradient(180deg, #3aa8d8 0%, #0a86b8 55%, #075f84 100%);
  border: 3px solid #ffffff;
  border-radius: 16px 20px 14px 18px;
  padding: 8px 18px;
  font-size: 0.95rem;
  text-shadow: 0 2px 0 rgba(4, 50, 72, 0.45);
  box-shadow:
    0 4px 0 rgba(5, 79, 111, 0.5),
    0 8px 18px rgba(0, 0, 0, 0.28);
}
.tap-hint-sub {
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.01em;
  color: #16324a;
  background: rgba(255, 255, 255, 0.92);
  border: 2px solid #ffffff;
  border-radius: 14px 18px 12px 16px;
  padding: 5px 12px;
  box-shadow: 0 3px 0 rgba(22, 50, 74, 0.18);
}
@keyframes tapHintBob {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(10px) scale(0.92); }
}
@media (prefers-reduced-motion: reduce) {
  .tap-hint-hand { animation: none; }
}

.controls-info {
  margin-top: 16px;
  padding: 12px;
  background: rgba(59, 107, 94, 0.1);
  border-radius: 10px;
  font-size: 0.88rem;
  color: #444;
}

/* The menu cards are always white, so keep their text dark even in dark mode
   (overrides the global body.dark-mode heading/paragraph colors). */
body.dark-mode .game-menu h1 {
  color: var(--brand-teal, var(--brand-teal, #0a86b8));
}
body.dark-mode .game-menu > h2 {
  color: #ffffff;
}
body.dark-mode .game-menu p,
body.dark-mode .game-menu .controls-info,
body.dark-mode .game-menu .controls-info p {
  color: #555;
}

.game-over {
  display: none;
}

.game-over.show {
  display: block;
}

.final-score {
  font-size: 1.9rem;
  font-weight: 900;
  margin: 12px 0;
  background: linear-gradient(180deg, #ffc21e 0%, #ff8a00 60%, #ff6a1f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: #ff8a00;
  -webkit-text-fill-color: transparent;
  /* The white rim is a shadow, not a text outline: an outline drew white
     lines inside letters such as "e" and "2" with the phone's own font. */
  filter: drop-shadow(0 1px 0 #ffffff) drop-shadow(0 2px 0 rgba(193, 78, 0, 0.4));
}

.game-case-study-link {
  display: inline-block;
  margin-top: 12px;
  font-size: 0.9rem;
  color: var(--brand-teal, var(--brand-teal, #0a86b8));
}

/* ============================================================
   BUTTON FEEL AND SMALL MOTIONS
   Every button answers a touch: it squashes when pressed and
   springs back when let go. The main button of a screen breathes
   and shines, so a child sees where to tap. Screens pop in.
   All of it is switched off when the phone asks for less motion
   (see the end of this part).
   ============================================================ */

/* Pressed: a quick squash. Let go: the slower, bouncy transition
   each button already has brings it back. */
.btn-game:active {
  transform: translateY(3px) scale(0.96);
  transition-duration: 0.06s;
}
.game-icon-btn:active {
  transform: translateY(3px) scale(0.92);
  transition-duration: 0.06s;
}
.game-menu-gear:active {
  transform: scale(0.9);
  transition-duration: 0.06s;
}
.menu-tile:active {
  transform: translateY(3px) scale(0.96);
  transition-duration: 0.06s;
}
.skin-cell:active {
  transform: scale(0.95);
  transition-duration: 0.06s;
}
.settings-row {
  transition: transform 0.16s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}
.settings-row:active {
  transform: scale(0.97);
  transition-duration: 0.06s;
}

/* The button to tap next: "Play again", "Resume". (Difficulty uses glow, not scale.) */
.btn-game--cta {
  position: relative;
  animation: ctaPulse 1.8s ease-in-out infinite;
}
/* The shine: a soft white band painted on a layer that has the shape of the button.
   The band is part of a picture three times as wide as the button; sliding the
   picture moves the band across. Nothing sticks out of the button. */
.btn-game--cta::after,
.btn-diff.is-last::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  border-radius: inherit;
  background: linear-gradient(100deg, rgba(255, 255, 255, 0) 45%, rgba(255, 255, 255, 0.45) 50%, rgba(255, 255, 255, 0) 55%) no-repeat;
  background-size: 300% 100%;
  background-position: 92% 0;
  animation: ctaShine 3.4s ease-in-out infinite;
  pointer-events: none;
}
.btn-game--cta:active,
.btn-diff.is-last:active {
  animation: none;
}
/* Scale only the CTA (Play again / Resume). Difficulty keeps a glow so
   Easy / Medium / Hard stay the same width. */
@keyframes ctaPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.015); }
}
@keyframes diffLastPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.03); }
}
.btn-diff.is-last {
  animation: diffLastPulse 1.8s ease-in-out infinite;
}
@keyframes ctaShine {
  0%, 70% { background-position: 92% 0; }
  92%, 100% { background-position: 8% 0; }
}

/* Small pictures on buttons */
.btn-icon {
  width: 20px;
  height: 20px;
  margin-right: 8px;
  vertical-align: -4px;
  pointer-events: none;
}
/* One, two or three stars at the right end of Easy, Medium, Hard.
   The word stays in the middle of the button. */
.btn-diff {
  position: relative;
}
.diff-stars {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  display: flex;
  gap: 1px;
  opacity: 0.8;
  pointer-events: none;
}
.diff-stars svg {
  width: 14px;
  height: 14px;
  display: block;
}
.settings-label svg {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  color: var(--brand-teal, #0a86b8);
}

/* A screen pops in.
   Help is edge-pinned (safe-area top/bottom) — do NOT use the centered menuPop
   transform, or animation-fill-mode:both keeps translate(-50%,-50%) and the
   tall sheet slides under the Dynamic Island (iPhone notch). */
.game-over.show:not(.game-help),
#startMenu {
  animation: menuPop 0.26s cubic-bezier(0.18, 0.89, 0.32, 1.28) both;
}
.game-over.game-help.show {
  animation: helpPop 0.26s cubic-bezier(0.18, 0.89, 0.32, 1.28) both;
}
@keyframes menuPop {
  from { transform: translate(-50%, -50%) scale(0.88); opacity: 0; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
@keyframes helpPop {
  from { transform: translateX(-50%) scale(0.96); opacity: 0; }
  to { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* One-time effects, started by the game (see bump() in the JS) */
.is-bump {
  animation: uiBump 0.26s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}
.is-win {
  animation: uiWin 0.55s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}
.is-shake {
  animation: uiShake 0.34s ease-in-out;
}
@keyframes uiBump {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.08); }
}
@keyframes uiWin {
  0%, 100% { transform: scale(1) rotate(0deg); }
  30% { transform: scale(1.12) rotate(-4deg); }
  60% { transform: scale(0.98) rotate(2deg); }
}
@keyframes uiShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}

/* "New best" keeps wiggling a little after it has popped in */
.new-best-badge {
  animation: newBestPop 0.5s cubic-bezier(0.18, 0.89, 0.32, 1.28) both,
             newBestWiggle 1.6s ease-in-out 0.5s infinite;
}
@keyframes newBestWiggle {
  0%, 100% { transform: scale(1) rotate(-2deg); }
  50% { transform: scale(1.06) rotate(2deg); }
}

/* Red dot on the Characters tile: there is a character you can buy now */
.menu-tile {
  position: relative;
}
.menu-tile.has-dot::after {
  content: '';
  position: absolute;
  /* Fully inside the tile so .game-menu { overflow-y: auto } never clips it. */
  top: 5px;
  right: 5px;
  box-sizing: border-box;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--af-coral-500, #f0525a);
  border: 2px solid #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
  animation: dotPulse 1.3s ease-in-out infinite;
  transform-origin: center;
}
@keyframes dotPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

/* Not enough coins: the button looks switched off, but a tap still answers
   (it shakes and makes the "no" sound). */
.btn-game.is-short {
  filter: grayscale(0.65);
  opacity: 0.6;
}

/* Numbers that count up keep the same width, so nothing jumps sideways */
#score,
#menuCoins,
#charCoins,
#continueCoins,
#giftCoins,
#overCoins,
#coinsEarned,
#finalScore {
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
  .btn-game--cta,
  .btn-diff.is-last,
  .game-over.show,
  .game-over.game-help.show,
  #startMenu,
  .is-bump,
  .is-win,
  .is-shake,
  .new-best-badge,
  .menu-tile.has-dot::after,
  .game-menu-gift.has-dot::after,
  .game-menu-gift.has-dot svg,
  .game-continue.show .continue-actions {
    animation: none;
  }
  .btn-game--cta::after,
  .btn-diff.is-last::after {
    display: none;
  }
  .settings-row,
  .continue-fill {
    transition: none;
  }
}

/* ============================================================
   SHORT PHONES
   Every screen must fit without scrolling. Same look, only less
   empty space and slightly smaller parts.
   700px and less: iPhone SE / iPhone 8 (667) and small Androids (640).
   600px and less: the oldest small iPhones (568).
   ============================================================ */
@media (max-height: 700px) {
  html.app-standalone .game-menu {
    padding: calc(var(--af-menu-pad-y) * 0.85) calc(var(--af-menu-pad-x) * 0.85) var(--af-space-4);
  }
  html.app-standalone #startMenu {
    padding-top: calc(var(--af-icon) + var(--af-edge) + var(--af-space-2));
  }
  .game-title {
    margin-bottom: 8px;
  }
  html.app-standalone .game-title-img {
    width: min(84%, calc(var(--af-title-w) * 0.85));
  }
  .game-title-img {
    width: min(84%, 228px);
  }
  .game-menu .game-tagline {
    margin-bottom: 10px;
    font-size: 0.95rem;
    line-height: 1.35;
  }
  html.app-standalone .game-menu .game-tagline {
    font-size: calc(var(--af-tagline) * 0.95);
    margin-bottom: var(--af-space-2);
  }
  .game-menu .game-choose {
    margin: 0 0 8px;
    line-height: 1.3;
  }
  .difficulty-select {
    gap: 10px;
  }
  html.app-standalone .btn-diff {
    height: calc(var(--af-btn-h) * 0.92);
    margin: 0 auto;
  }
  .menu-tiles {
    margin-top: 12px;
  }
  .menu-tile {
    min-height: 62px;
  }
  html.app-standalone .menu-tile {
    min-height: calc(var(--af-tile-h) * 0.9);
  }
  /* Game Over, Paused, Settings, Missions */
  .final-score {
    font-size: 1.6rem;
    margin: 6px 0;
  }
  html.app-standalone .final-score {
    font-size: calc(1.6rem * var(--af-ui));
  }
  .new-best-badge {
    margin: 0 0 6px;
  }
  .coins-earned-line {
    margin: 2px 0 10px;
  }
  .coins-bonus-line {
    margin: -6px 0 8px;
  }
  .mission-done-list {
    margin-bottom: 8px;
  }
  .mission-done-line {
    margin: 4px 0;
    padding: 4px 8px 4px 10px;
  }
  html.app-standalone .game-over .btn-game,
  html.app-standalone .game-pause .btn-game,
  html.app-standalone .game-settings .btn-game {
    height: 48px;
    margin: 5px auto;
  }
}

@media (max-height: 600px) {
  html.app-standalone .game-menu {
    padding: calc(var(--af-menu-pad-y) * 0.72) calc(var(--af-menu-pad-x) * 0.72) var(--af-space-3);
  }
  html.app-standalone #startMenu {
    padding-top: calc(var(--af-icon) + var(--af-edge) + var(--af-space-1));
  }
  .game-menu > h2 {
    font-size: 1.25rem;
    padding: 7px 24px;
    margin: 2px auto 10px;
  }
  .game-help > h2,
  .game-menu.game-help > h2 {
    margin: 0 0 10px;
    padding: 8px 18px;
    font-size: 1.05rem;
  }
  .game-title {
    margin-bottom: 6px;
  }
  .game-title-img {
    width: min(80%, 188px);
  }
  .game-menu .game-tagline {
    margin-bottom: 8px;
    font-size: 0.86rem;
  }
  .game-menu .game-choose {
    margin: 0 0 6px;
    font-size: 0.8rem;
  }
  .difficulty-select {
    gap: 8px;
  }
  html.app-standalone .btn-diff {
    height: 46px;
    font-size: 16px;
  }
  .menu-tiles {
    margin-top: 10px;
  }
  .menu-tile {
    min-height: 56px;
    padding: 6px;
  }
  .menu-tile-icon {
    height: 26px;
  }
  .menu-tile-icon .skin-face {
    font-size: 1.45rem;
  }
  .menu-tile-icon svg {
    width: 25px;
    height: 25px;
  }
  /* Characters */
  .chars-top {
    margin-bottom: 6px;
  }
  .char-detail {
    padding: 6px 10px;
    gap: 10px;
  }
  .char-face {
    width: 72px;
    height: 72px;
  }
  .char-preview {
    width: 64px;
    height: 64px;
  }
  .char-face .skin-face {
    font-size: 1.8rem;
  }
  html.app-standalone .game-over .btn-game.char-action {
    height: 44px;
    margin: 6px auto;
  }
  /* Game Over, Paused, Settings, Missions */
  .final-score {
    font-size: 1.45rem;
    margin: 4px 0;
  }
  .coins-earned-line {
    margin: 2px 0 8px;
  }
  .mission-done-line {
    font-size: 0.8rem;
    margin: 3px 0;
  }
  html.app-standalone .game-over .btn-game,
  html.app-standalone .game-pause .btn-game,
  html.app-standalone .game-settings .btn-game {
    height: 46px;
    margin: 4px auto;
    font-size: 16px;
  }
  .settings-list {
    gap: 8px;
    margin: 4px auto 12px;
  }
  .settings-row {
    padding: 9px 14px;
  }
  .game-menu p.settings-note {
    margin-bottom: 6px;
    font-size: 0.72rem;
  }
  .settings-links {
    gap: 6px;
    margin-bottom: 6px;
  }
  .settings-link {
    font-size: 0.72rem;
  }
  .settings-version {
    margin-bottom: 4px;
    font-size: 0.68rem;
  }
  .game-menu .btn-game.settings-reset {
    height: 40px;
    margin-bottom: 6px;
    font-size: 0.84rem;
  }
  .game-menu p.missions-note {
    margin-bottom: 8px;
    font-size: 0.82rem;
  }
  .mission-list {
    gap: 7px;
    margin-bottom: 10px;
  }
  .mission-row {
    padding: 7px 10px;
  }
  .mission-text {
    font-size: 0.9rem;
    margin-bottom: 5px;
  }
}

/* ============================================================
   WEBSITE MODE
   The same game on the website page (public/angel-fish-game.html).
   Only that page puts these classes on <html>, so nothing in this
   part can change the phone app:
     af-web = the game sits inside the website page
     af-bar = the site's top bar is showing (a normal browser tab).
              Without af-bar (installed web app, ?app=1) the game
              fills the screen like the phone app.
   ============================================================ */

/* ---- Keep the site's own styles out of the game ----
   The website page also loads the style files of the whole site (styles.css and
   others). Some of their rules are written for every page, so they reach into the
   game too and would make it differ from the app: smaller text on phones, other
   line heights, other gaps and sizes. These rules give the game back what it has
   in the app. (:where() adds no weight, so every rule of the game still wins.) */

/* The site makes all text smaller on small screens (15px, 14px). The game's sizes
   are counted from 16px, as in the app. */
html.af-web {
  font-size: 16px;
}
/* What the game's parts take over from the page around them: the same as in the
   app. The game keeps its own colours when the site is in its dark theme. */
html.af-web .game-container {
  --text-color: var(--brand-black);
  color: var(--text-color);
  color-scheme: light;
  line-height: normal;
}
/* A coin in the air is put on the page itself, outside the game's box. */
html.af-web .fly-coin {
  color: var(--brand-black);
  color-scheme: light;
  line-height: normal;
}
/* The site's "* { box-sizing: border-box; margin: 0; padding: 0 }". */
:where(html.af-web .game-container, html.af-web .game-container *, html.af-web .fly-coin),
:where(html.af-web .game-container, html.af-web .game-container *, html.af-web .fly-coin)::before,
:where(html.af-web .game-container, html.af-web .game-container *, html.af-web .fly-coin)::after {
  box-sizing: revert;
  margin: revert;
  padding: revert;
}
/* The site's rules for a bare tag name: h1 to h6, p, img. */
:where(html.af-web .game-container) :is(h1, h2, h3, h4, h5, h6) {
  font-family: revert;
  font-size: revert;
  font-weight: revert;
  letter-spacing: revert;
  line-height: revert;
  margin: revert;
  transition: revert;
}
:where(html.af-web .game-container) p {
  margin: revert;
}
:where(html.af-web .game-container) img {
  max-width: revert;
  height: revert;
}
/* The site's focus rings (a ring after every click or tap). The game keeps the
   browser's own ring, which only shows for keyboard users. */
:where(html.af-web .game-container) :is(a, button, input, select, textarea, [tabindex]):focus,
:where(html.af-web .game-container) :focus,
:where(html.af-web .game-container) :focus-visible {
  outline: revert;
  outline-offset: revert;
}

/* ---- Website only: "Install app" in the Settings card ----
   The row and the iPhone hint are in public/angel-fish-game.html. The phone app
   does not have them: it is installed already. */
html.af-web .settings-go {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  margin: 4px 0;
  color: var(--brand-teal, #0a86b8);
}
html.af-web .settings-list .ios-install-hint {
  margin: 0;
  max-width: none;
  line-height: 1.4;
}

/* ---- The site's own parts on the page keep the site's look ----
   The app look (top of this file) names the phone's font and switches off text
   selection and the tap flash for the whole page. That is for the game only:
   the site's top bar and home pill stay as on every other page. */
html.af-web.af-bar .diamond-mini-bar,
html.af-web.af-bar .angel-fish-back {
  font-family: var(--font-primary);
  -webkit-tap-highlight-color: initial;
  -webkit-touch-callout: default;
  -webkit-user-select: auto;
  user-select: auto;
}
html.af-web.af-bar .diamond-mini-bar button {
  font-family: revert;
}
/* In the site's dark theme its link colour (white) lands on the white pill and
   the home pill label cannot be read. The pill keeps its own colour. */
html.af-web.af-bar body.dark-mode a.angel-fish-back,
html.af-web.af-bar body.dark-mode a.angel-fish-back:hover {
  color: var(--brand-teal, var(--brand-teal, #0a86b8));
}
/* Settings legal chips stay readable inside the light game card (site dark theme uses white links). */
html.af-web body.dark-mode .settings-link,
html.af-web body.dark-mode .settings-link:hover {
  color: var(--af-ink, #16343f);
  background: var(--af-sky-50, #f2faff);
}

/* ---- Where the game sits ---- */
html.af-web.af-bar {
  --af-bar: 60px; /* the height of the site's top bar */
}
html.af-web.af-bar .diamond-mini-bar {
  box-sizing: border-box;
  height: var(--af-bar);
}
/* The game's box starts under the top bar and goes to the bottom of the window. */
html.af-web.af-bar .game-container {
  top: var(--af-bar);
  right: 0;
  bottom: 0;
  left: 0;
  width: auto;
  height: auto;
  overflow: hidden;
}
/* Pause, sound and settings stay inside the game's box. */
html.af-web.af-bar .game-controls {
  position: absolute;
}
/* The home pill needs free room beside the game, so it is for a computer
   screen. On a smaller screen the "Projects" link in the top bar does the same job. */
html.af-web.af-bar .angel-fish-back {
  display: none;
}
@media (min-width: 1025px) {
  html.af-web.af-bar .angel-fish-back {
    display: inline-flex;
  }
}
/* A wide window (tablet, computer): the game is a phone-shaped column in the middle. */
@media (min-width: 600px) {
  html.af-web.af-bar .game-container {
    box-sizing: border-box;
    width: min(480px, max(360px, calc((100vh - var(--af-bar)) * 0.5625)));
    /* The same, as a whole (even) number of pixels, for browsers that know round(). */
    width: round(down, min(480px, max(360px, calc((100vh - var(--af-bar)) * 0.5625))), 2px);
    margin: 0 auto;
    border: 0 solid #ffffff;
    border-width: 0 3px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  }
  /* The column is never wider than 480px, so its play buttons have the size the
     game gives them on a screen that narrow. Keep these three values the same as
     in "@media (max-width: 480px)" higher up in this file. */
  html.af-web.af-bar .game-icon-btn {
    width: 44px;
    height: 44px;
    font-size: 1rem;
  }
}
/* A very short window: a small phone inside a browser, where the browser's own
   bars and the site's top bar take room that the app has for itself. The logo
   gives way (1px less logo for each 1px less window) so that the start card still
   fits without scrolling. (dvh = the part of the screen the browser really shows.) */
@media (max-height: 583px) {
  html.af-web.af-bar .game-title-img {
    width: auto;
    max-width: 80%;
    height: max(64px, calc(100vh - 452px));
    height: max(64px, calc(100dvh - 452px));
    object-fit: contain;
  }
}
/* A tall window: the column stops growing at 920px and floats in the middle. */
@media (min-width: 600px) and (min-height: 1004px) {
  html.af-web.af-bar .game-container {
    height: 920px;
    margin: auto;
    border-width: 3px;
    border-radius: 18px;
  }
}

/* Browser with no site bar (coralveil.studio/play): a wide window shows a phone.
   af-web is on the page itself. The native app removes it. A real phone stays full screen. */
.af-web-home { display: none; }
@media (min-width: 600px) {
  html.af-web:not(.af-bar),
  html.af-web:not(.af-bar) body.angel-fish-page {
    background: #06131a;
    background-image: none;
  }
  html.app-standalone.af-web:not(.af-bar) .game-container {
    position: fixed;
    inset: auto;
    top: 50%;
    left: 50%;
    right: auto;
    bottom: auto;
    width: min(400px, calc((100vh - 64px) * 0.5625), calc(100vw - 64px));
    width: min(400px, calc((100dvh - 64px) * 0.5625), calc(100vw - 64px));
    height: auto;
    aspect-ratio: 9 / 16;
    transform: translate(-50%, -50%);
    border-radius: 32px;
    overflow: hidden;
    box-shadow:
      0 0 0 1px rgba(255, 255, 255, 0.16),
      0 28px 80px rgba(0, 0, 0, 0.5);
  }
  html.app-standalone.af-web:not(.af-bar) .game-controls {
    position: absolute;
    right: var(--af-edge);
  }
  html.af-web:not(.af-bar) .af-web-home {
    display: inline-flex;
    align-items: center;
    position: fixed;
    z-index: 5;
    top: 22px;
    left: 28px;
    color: #d7efe4;
    font: 700 0.95rem/1 ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
    text-decoration: none;
    letter-spacing: 0.04em;
  }
}

/* ---- UX pass (v1.0.4): characters grid, Game Over, first-run tip ---- */
.game-chars .skin-row {
  max-width: calc(330px * var(--af-ui));
  gap: calc(10px * var(--af-ui));
}
.skin-cell {
  gap: calc(4px * var(--af-ui));
  padding: calc(10px * var(--af-ui)) calc(4px * var(--af-ui)) calc(9px * var(--af-ui));
  border-radius: calc(18px * var(--af-ui));
}
.skin-cell .skin-face {
  width: calc(56px * var(--af-ui));
  height: calc(56px * var(--af-ui));
}
.skin-name { font-size: calc(13px * var(--af-ui)); }
.skin-magic { font-size: calc(11px * var(--af-ui)); }
.skin-tag { font-size: calc(11px * var(--af-ui)); }
/* Locked characters show as a dark silhouette until you tap them. */
.skin-cell.is-locked .skin-face { filter: brightness(0) opacity(0.45); }
.skin-cell.is-locked.is-focus .skin-face { filter: none; }
.chars-note { font-size: calc(12px * var(--af-ui)); }

/* Game Over: score in dark ink, best beside the level, next goal in a chip. */
.game-over .final-score {
  background: none;
  -webkit-text-fill-color: currentColor;
  color: #1f3d33;
}
.game-over .final-score:not(.final-score--sub) { font-size: calc(2.3rem * var(--af-ui)); }
.over-best { color: #4a6472; }
.final-distance {
  margin-top: calc(-6px * var(--af-ui));
  margin-bottom: calc(8px * var(--af-ui));
  color: #4a6472;
  font-weight: 700;
}

/* Daily + Badges */
.daily-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--af-space-2);
  width: 100%;
  max-width: var(--af-btn-max);
  margin: 0 auto 14px;
}
.daily-stat {
  padding: 10px 6px;
  border-radius: 16px;
  border: 2.5px solid #cfe0f5;
  background: linear-gradient(180deg, #ffffff 0%, var(--af-sky-50, #f2faff) 100%);
  text-align: center;
}
.daily-stat-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  text-transform: none;
  color: #5a7a88;
  margin-bottom: 4px;
}
.daily-stat-val {
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--af-ink, #16343f);
}
.daily-status {
  font-size: 0.9rem;
  font-weight: 700;
  color: #3a8fb5;
  margin: 0 0 14px;
  min-height: 1.2em;
}
.log-tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 0 auto 12px;
  max-width: var(--af-btn-max);
}
.log-tab {
  flex: 1 1 0;
  min-height: 44px;
  border: 2.5px solid #cfe0f5;
  border-radius: 14px 18px 12px 16px;
  background: #f7fbfe;
  color: var(--af-ink, #16343f);
  font-weight: 800;
  font-size: 0.9rem;
}
.log-tab.is-on {
  background: linear-gradient(180deg, #19a3d8 0%, #0a86b8 100%);
  color: #fff;
  border-color: #fff;
}
.badge-list {
  width: 100%;
  max-width: var(--af-btn-max);
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow: auto;
  margin: 0 auto 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
/* Logbook / Badges: fixed title + tabs, list scrolls, Done stays visible. */
.game-menu.game-badges.show {
  display: flex !important;
  flex-direction: column;
  align-items: stretch;
  overflow: hidden;
  max-height: calc(100% - var(--sat, 0px) - var(--sab, 0px) - 24px);
}
.game-menu.game-badges > h2,
.game-menu.game-badges > .missions-note,
.game-menu.game-badges > .log-tabs {
  flex: 0 0 auto;
}
.game-menu.game-badges > .btn-game {
  flex: 0 0 auto;
  width: 100%;
  max-width: var(--af-btn-max);
  margin-left: auto;
  margin-right: auto;
}
/* Missions / Daily / Gift: shrink padding; card may scroll as a whole.
   Settings uses an internal .settings-scroll + sticky Done (see af-polish.css). */
.game-menu.game-missions.show,
.game-menu.game-daily.show,
.game-menu.game-gift.show {
  max-height: calc(100% - var(--sat, 0px) - var(--sab, 0px) - 24px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.mission-list {
  max-height: min(48vh, 360px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.badge-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  border: 2.5px solid #cfe0f5;
  background: #f7fbfe;
}
.badge-row.is-on {
  border-color: #e0a82e;
  background: linear-gradient(180deg, #fff8e8 0%, #fff1d0 100%);
}
.badge-icon {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 900;
  color: #fff;
  background: #9bb4c0;
}
.badge-row.is-on .badge-icon { background: #e0a82e; }
.badge-text { flex: 1 1 auto; min-width: 0; }
.badge-name { font-weight: 900; color: var(--af-ink, #16343f); font-size: 0.95rem; }
.badge-info { font-size: 0.78rem; font-weight: 650; color: #5a7a88; margin-top: 2px; }
.next-unlock {
  margin: calc(4px * var(--af-ui)) auto calc(12px * var(--af-ui));
  padding: calc(8px * var(--af-ui)) calc(14px * var(--af-ui));
  max-width: calc(280px * var(--af-ui));
  border-radius: calc(14px * var(--af-ui));
  background: var(--af-sky-100, #e3f4fd);
  color: #12313f;
  font-weight: 800;
  font-size: calc(14px * var(--af-ui));
  line-height: 1.3;
}
.next-unlock.is-ready {
  background: var(--af-lagoon-100, #e2f8f6);
  color: var(--af-lagoon-700, #08696b);
}
.run-highlights {
  margin: 0 auto 10px;
  max-width: calc(280px * var(--af-ui));
  padding: 6px 12px;
  border-radius: 14px 18px 12px 16px;
  background: var(--af-sky-100, #e3f4fd);
  color: var(--af-sea-600, #075f84);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}
.run-highlights[hidden] { display: none !important; }

/* Live badge unlock toast — floats above the game, auto-hides. */
.badge-toast {
  position: fixed;
  left: 50%;
  top: max(18px, env(safe-area-inset-top, 0px) + 12px);
  transform: translate(-50%, -12px);
  z-index: 800;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(92vw, 340px);
  padding: 10px 14px;
  border-radius: 18px 22px 16px 20px;
  border: 3px solid #ffffff;
  background: linear-gradient(180deg, #fff8e8 0%, #ffe7a8 100%);
  box-shadow: 0 6px 0 rgba(196, 119, 5, 0.35), 0 16px 28px rgba(0, 0, 0, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.28s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}
.badge-toast.is-on {
  opacity: 1;
  transform: translate(-50%, 0);
}
.badge-toast-star {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #ffd23d 0%, #ffb81c 100%);
  color: #5a3800;
  font-size: 1.1rem;
  font-weight: 900;
  box-shadow: 0 2px 0 #c47705;
}
.badge-toast-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  text-align: left;
  line-height: 1.2;
}
.badge-toast-copy strong {
  font-size: 0.78rem;
  letter-spacing: 0.01em;
  text-transform: none;
  color: #8a5a00;
}
.badge-toast-copy em {
  font-style: normal;
  font-weight: 900;
  font-size: 1rem;
  color: #16343f;
}
.badge-toast-copy small {
  font-size: 0.75rem;
  font-weight: 650;
  color: #5a7a88;
  margin-top: 2px;
}
@media (prefers-reduced-motion: reduce) {
  .badge-toast { transition: opacity 0.15s ease; }
}

/* First-run tip, step 2: the big line says it all, so drop the small line. */
.tap-hint.is-step2 .tap-hint-sub { display: none; }

/* ---- 10,000 friends: rarity rims and the More tile ---- */
.skin-cell.is-rare { border-color: var(--af-sea-400, #3aa8d8); }
.skin-cell.is-epic {
  border-color: var(--af-dusk-500, #6b4fd8);
  box-shadow: 0 0 0 2px rgba(107, 79, 216, 0.22);
}
.skin-cell.is-legendary {
  border-color: var(--af-halo-500, #ffb81c);
  box-shadow: 0 0 0 2px rgba(255, 184, 28, 0.35);
  background: linear-gradient(180deg, #fffaf0 0%, #fff1cc 100%);
}
.skin-cell--more {
  border-style: dashed;
  background: #f4f8fb;
  justify-content: center;
  min-height: calc(110px * var(--af-ui));
}

/* =====================================================================
   Design pass — one visual language for every card
   Palette: sea (frames, titles) · halo gold (main action) · foam white
   (secondary) · lagoon (done/yours) · dusk (magic) · coral (danger).
   ===================================================================== */
:root {
  --af-ink: #16343f;
  --af-ink-soft: #4a6472;
  --af-sea: #0a86b8;
  --af-sea-deep: #075f84;
  --af-line: #d5e3ea;
}
/* Card: solid white panel + sea-blue frame. No sky/sea wave stripe. */
.game-menu {
  position: absolute;
  background-color: #ffffff;
  background-image:
    linear-gradient(#ffffff, #ffffff),
    linear-gradient(170deg, #3cc0ee 0%, #0a86b8 55%, #075f84 100%);
  background-origin: padding-box, border-box;
  background-clip: padding-box, border-box;
  box-shadow: 0 4px 0 rgba(7, 95, 132, 0.35), 0 22px 48px rgba(4, 40, 60, 0.32);
}
.game-menu::before,
.game-menu::after {
  content: none !important;
  display: none !important;
  background: none !important;
}
/* Every card title is the same sea-blue sticker (Characters included). */
.game-menu > h2,
.game-menu .chars-title h2 {
  display: inline-block;
  color: #ffffff;
  background: linear-gradient(180deg, #19a3d8 0%, #0a86b8 55%, #075f84 100%);
  border: 3px solid #ffffff;
  border-radius: 20px 26px 18px 24px;
  text-transform: none;
  letter-spacing: 0.01em;
  font-weight: 900;
  text-shadow: 0 2px 0 rgba(4, 50, 72, 0.45);
  box-shadow: 0 5px 0 #05506f, 0 12px 22px rgba(0, 0, 0, 0.22);
}
.game-menu .chars-title h2 {
  font-size: calc(1.35rem * var(--af-ui));
  padding: calc(8px * var(--af-ui)) calc(26px * var(--af-ui));
  margin: 0 0 calc(10px * var(--af-ui));
}
/* Long titles (rate card) wrap neatly inside the sticker. */
#rateMenu > h2 {
  font-size: calc(1.1rem * var(--af-ui));
  line-height: 1.15;
  padding: calc(10px * var(--af-ui)) calc(22px * var(--af-ui));
  max-width: 86%;
}
/* Secondary actions: foam white with ink, so the gold CTA leads. */
.btn-game--muted {
  background: linear-gradient(180deg, #ffffff 0%, #f1f6f9 100%);
  color: var(--af-ink);
  text-shadow: none;
  border-color: var(--af-line);
  box-shadow: 0 5px 0 #b9ccd6, 0 10px 18px rgba(7, 60, 85, 0.14);
}
@media (hover: hover) {
  .btn-game--muted:hover {
    box-shadow: 0 7px 0 #b9ccd6, 0 14px 24px rgba(7, 60, 85, 0.18);
  }
}
.btn-game--muted:active {
  box-shadow: 0 2px 0 #b9ccd6, 0 4px 10px rgba(7, 60, 85, 0.14);
}
.btn-game--muted .btn-icon { color: var(--af-sea); }
/* Destructive: red ink, never the same look as a normal button. */
#settings-reset-btn { color: #c0262d; border-color: #f3c9cb; }
/* The lone "Play" word above the difficulty buttons added noise. */
.game-choose { display: none; }
/* Body copy: one ink colour, readable size. */
.game-menu p,
.chars-note,
.char-info { color: var(--af-ink-soft); }
.game-settings p { font-size: calc(12.5px * var(--af-ui)); line-height: 1.4; }

/* Traits + rarity in the character card. */
.char-traits {
  display: flex;
  flex-wrap: wrap;
  gap: calc(4px * var(--af-ui));
  margin-top: calc(6px * var(--af-ui));
}
.trait-chip {
  font-size: calc(10.5px * var(--af-ui));
  font-weight: 700;
  /* Long trait text wraps inside the card instead of running off its edge. */
  white-space: normal;
  max-width: 100%;
  box-sizing: border-box;
  overflow-wrap: anywhere;
  color: var(--af-ink);
  background: var(--af-sky-100, #e3f4fd);
  border: 1px solid var(--af-line);
  border-radius: 12px;
  padding: 2px 8px;
  line-height: 1.3;
}
.char-traits { min-width: 0; max-width: 100%; }
.trait-chip b { font-weight: 900; color: var(--af-sea-deep); }
.trait-chip--rare {
  background: var(--af-sky-100, #e3f4fd);
  border-color: var(--af-sea-400, #3aa8d8);
  color: var(--af-sea-600, #075f84);
  font-weight: 900;
}
.trait-chip--epic {
  background: var(--af-dusk-wash, #eef4fb);
  border-color: var(--af-dusk-500, #6b4fd8);
  color: var(--af-dusk-700, #4a32a6);
  font-weight: 900;
}
.trait-chip--legendary {
  background: var(--af-halo-100, #fff3cf);
  border-color: var(--af-halo-500, #ffb81c);
  color: var(--af-halo-ink, #5a3800);
  font-weight: 900;
}

/* ---- Menu polish (2026-11-22) ---- */
/* Tagline: wrap into even lines, never one word alone. */
.game-tagline,
.chars-note,
.continue-note,
.gift-note,
.missions-note,
.rate-note,
.settings-note,
.tap-hint-sub {
  text-wrap: balance;
}
/* 6 tiles: even 3×2 grid (Characters · Missions · Daily / Logbook · Badges · Worlds). */
.menu-tiles {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  box-sizing: border-box;
}
.menu-tile {
  grid-column: auto;
  overflow: visible; /* keep notification dot visible on the corner */
}
.menu-tile.has-dot::after {
  top: 5px;
  right: 5px;
  width: 12px;
  height: 12px;
  border-width: 2px;
  z-index: 2;
}
#startMenu {
  /* Scrollable, but leave gutter so corner dots aren't cut by the clip edge. */
  padding-left: max(16px, var(--af-menu-pad-x, 16px));
  padding-right: max(16px, var(--af-menu-pad-x, 16px));
}

/* ---- HUD row: always one line (2026-11-22) ----
   Score, Best, combo and magic must fit beside the pause/sound/settings column.
   When chips appear, the pills give up spare room instead of wrapping. */
html.app-standalone .game-ui {
  flex-wrap: nowrap;
  min-width: 0;
}
html.app-standalone .game-ui .score-display--best {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.game-ui:has(.combo-chip:not([hidden])) .score-display--hero,
.game-ui:has(.lives-chip:not([hidden])) .score-display--hero,
.game-ui:has(.magic-chip:not([hidden])) .score-display--hero {
  min-width: 0;
}
.game-ui:has(.combo-chip:not([hidden])):has(.magic-chip:not([hidden])) .best-label {
  display: none;
}
/* Drop the word "Best" as soon as any chip appears, so the number stays readable
   (a 4-digit best plus a magic chip did not fit, even in English). */
.game-ui:has(.combo-chip:not([hidden])) .best-label,
.game-ui:has(.lives-chip:not([hidden])) .best-label,
.game-ui:has(.magic-chip:not([hidden])) .best-label {
  display: none;
}

/* Seasonal event pill on the start menu (text set from seasons.js). */
.season-pill {
  display: inline-block;
  margin: 0 auto 8px;
  padding: 5px 12px;
  border-radius: 14px 18px 12px 16px;
  background: #fff;
  border: 2px solid var(--season, #0083b0);
  color: #1f3a4a;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.3;
}

/* Rewards waiting to be collected (Game Over card + menu). */
.reward-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 6px auto 8px;
  max-width: 320px;
  max-height: 132px;
  overflow-y: auto;
}
.reward-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 5px 10px;
  border-radius: 12px;
  background: #fff8e1;
  font-size: 14px;
  font-weight: 700;
  color: #3f2a00;
  text-align: left;
}
.reward-what {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-game.btn-collect {
  background: linear-gradient(180deg, #ffe066, #ffb703);
  color: #4a2c00;
  box-shadow: 0 5px 0 #c77d00;
  animation: collectPulse 1.4s ease-in-out infinite;
}
.collect-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin: 0 auto 8px;
  padding: 6px 8px 6px 12px;
  border: 0;
  border-radius: 18px 22px 16px 20px;
  background: #fff3c4;
  box-shadow: 0 3px 0 #e0a100;
  color: #4a2c00;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  animation: collectPulse 1.4s ease-in-out infinite;
}
.collect-pill[hidden] {
  display: none;
}
.collect-go {
  padding: 5px 12px;
  border-radius: 12px 14px 11px 13px;
  background: #ffb703;
  color: #3a2200;
}
/* Soft breathe only — polish may replace this with a grab bob. */
@keyframes collectPulse {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}
@media (prefers-reduced-motion: reduce) {
  .btn-game.btn-collect,
  .collect-pill { animation: none; }
}

/* Worlds screen: one row per land, a little sky-and-sea swatch on the left. */
.world-group {
  margin: 12px 4px 4px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.01em;
  text-transform: none;
  color: #3a6075;
  text-align: left;
}
.world-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px;
  margin: 6px 0;
  border-radius: 16px;
  border: 2px solid #cfe0f5;
  background: #f6fbff;
  text-align: left;
}
.world-row.is-on {
  border-color: #e0a82e;
  background: #fffaf0;
}
.world-row.is-here {
  box-shadow: 0 0 0 3px rgba(20, 176, 172, 0.45);
}
.world-swatch {
  position: relative;
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  overflow: hidden;
  border: 2px solid rgba(20, 40, 60, 0.25);
}
.world-row:not(.is-on) .world-swatch {
  filter: grayscale(1);
  opacity: 0.55;
}
.world-orb {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
}
.world-text {
  min-width: 0;
  flex: 1;
}
.world-name {
  font-weight: 900;
  font-size: 15px;
  color: #17324a;
}
.world-info {
  font-size: 12.5px;
  font-weight: 700;
  color: #4b6a80;
  line-height: 1.35;
}
.world-fact {
  font-size: 12.5px;
  font-weight: 600;
  color: #2c4a60;
  margin-top: 3px;
  line-height: 1.35;
}
.world-icons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}
.world-icons canvas {
  width: 34px;
  height: 34px;
}

/* Settings → Language picker. A label (unlike the button rows) adds its padding and
   border on top of 100% width, so size it the same way the buttons are. */
.settings-row--select {
  cursor: pointer;
  box-sizing: border-box;
  gap: 10px;
}
.settings-row--select .settings-select {
  max-width: 48%;
  min-width: 0;
  text-overflow: ellipsis;
  padding: 4px 10px;
}
.settings-select {
  max-width: 52%;
  font: inherit;
  font-weight: 800;
  font-size: 15px;
  color: var(--af-ink, #16343f);
  background: var(--af-sky-50, #f2faff);
  border: 2px solid var(--af-sky-200, #bfe8ff);
  border-radius: 12px 14px 11px 13px;
  padding: 6px 10px;
  -webkit-appearance: none;
  appearance: none;
}

/* Screen-reader-only text (spoken announcements). */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
/* Larger text: notes and lists read bigger too (the UI scale also grows). */
html.af-big-text .missions-note,
html.af-big-text .settings-note,
html.af-big-text .badge-text,
html.af-big-text .world-info,
html.af-big-text .world-fact,
html.af-big-text .reward-list {
  font-size: 1.12em;
}

/* First-run tip: the hand presses, and a ring spreads from the fingertip each time. */
.tap-hint-hand {
  position: relative;
}
.tap-hint-hand::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 34px;
  height: 34px;
  margin-left: -17px;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.3);
  animation: tapHintRing 1.1s ease-out infinite;
  pointer-events: none;
}
@keyframes tapHintRing {
  0%, 40% { opacity: 0; transform: scale(0.3); }
  50% { opacity: 1; transform: scale(0.5); }
  100% { opacity: 0; transform: scale(1.35); }
}
html.af-reduce-motion .tap-hint-hand,
html.af-reduce-motion .tap-hint-hand::after {
  animation: none;
}
@media (prefers-reduced-motion: reduce) {
  .tap-hint-hand::after { animation: none; }
}

/* What's new card */
.news-list {
  max-height: 52vh;
  overflow-y: auto;
  text-align: left;
  margin: 6px 0 10px;
}
.news-row {
  padding: 9px 12px;
  margin: 6px 0;
  border-radius: 14px 18px 12px 16px;
  background: var(--af-sky-50, #f2faff);
  border: 2px solid var(--af-line, #d5e3ea);
}
.news-title {
  font-weight: 900;
  font-size: 15px;
  color: var(--af-ink, #16343f);
}
.news-where {
  font-weight: 700;
  font-size: 12.5px;
  color: var(--af-ink-soft, #4a6472);
  margin-top: 2px;
}

/* Worlds: stars per world and the total */
.world-stars {
  color: #e0a82e;
  font-size: 13px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.world-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.world-actions .btn-game {
  flex: 1 1 auto;
  min-width: 0;
  padding: 8px 10px;
  font-size: 0.85rem;
}
.world-row.is-locked {
  opacity: 0.95;
}
.shop-wallet {
  margin: 0 auto 10px;
}
.shop-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0 14px;
  max-height: min(48vh, 360px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.shop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px 18px 12px 16px;
  border: 2px solid var(--af-line, #d5e3ea);
  background: var(--af-sky-50, #f2faff);
  text-align: left;
}
.shop-row-text {
  min-width: 0;
  flex: 1;
}
.shop-row-title {
  font-weight: 800;
  color: var(--af-ink, #16343f);
}
.shop-row-sub {
  font-size: 0.85rem;
  color: var(--af-ink-soft, #4a6472);
  margin-top: 2px;
}
.shop-row .btn-game {
  flex: 0 0 auto;
  padding: 8px 12px;
  font-size: 0.85rem;
}
.char-iap {
  margin-top: 6px;
}
#char-coins-btn {
  margin-top: 6px;
}
.world-row.is-cleared {
  border-color: #e0a82e;
  box-shadow: inset 0 0 0 1px rgba(224, 168, 46, 0.35);
}
.world-star-total {
  margin: 2px 0 6px;
  font-weight: 900;
  color: #b7791f;
  text-align: center;
}

/* Back up progress card */
.backup-code {
  display: block;
  width: 100%;
  box-sizing: border-box;
  font: 600 12px ui-monospace, Menlo, monospace;
  color: var(--af-ink, #16343f);
  background: var(--af-sky-50, #f2faff);
  border: 2px solid var(--af-line, #d5e3ea);
  border-radius: 12px 16px 12px 14px;
  padding: 8px 10px;
  resize: none;
  user-select: text;
  -webkit-user-select: text;
}
.backup-note {
  min-height: 1.2em;
  font-weight: 700;
  font-size: 13px;
  color: var(--af-lagoon-700, #08696b);
  margin: 6px 0;
}

/* Characters: choose the buddy that swims behind the fish */
.char-buddy,
html.app-standalone .game-over .btn-game.char-buddy {
  flex: 0 0 auto;
  width: auto;
  min-width: 0;
  max-width: 90%;
  height: calc(32px * var(--af-ui, 1));
  min-height: 0;
  margin: 0 auto 6px;
  padding: 0 calc(16px * var(--af-ui, 1));
  font-size: calc(12px * var(--af-ui, 1));
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 14px 18px 12px 16px;
}
.char-buddy.is-picking {
  background: #fff4cc;
  color: #7a4b00;
  box-shadow: 0 0 0 3px var(--af-halo-400, #ffcf4d) inset;
}

/* Weekly challenge box inside the Daily card */
.weekly-box {
  margin: 12px 0 8px;
  padding: 10px 10px 12px;
  border-radius: 16px 20px 14px 18px;
  background: linear-gradient(180deg, #ffffff 0%, var(--af-sky-100, #e3f4fd) 100%);
  border: 2px solid var(--af-sky-200, #bfe8ff);
}
.weekly-title {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.01em;
  color: var(--af-sea-600, #075f84);
}
.weekly-pips {
  display: flex;
  justify-content: center;
  gap: 6px;
  font-size: 20px;
  margin-bottom: 4px;
}
.weekly-pip { color: #c8d4e2; }
.weekly-pip.is-done { color: #f5b301; }

/* ---- Right-to-left (Arabic) ----
   i18n.js sets <html dir="rtl">. Menus and cards mirror (flex rows flip by
   themselves); the game canvas, score bar and side buttons stay left-to-right,
   because the fish always swims left to right. */
html[dir='rtl'] #gameCanvas,
html[dir='rtl'] .game-ui,
html[dir='rtl'] .game-controls,
html[dir='rtl'] .tap-hint {
  direction: ltr;
}
html[dir='rtl'] .char-detail,
html[dir='rtl'] .mission-list,
html[dir='rtl'] .mission-done-line,
html[dir='rtl'] .badge-list,
html[dir='rtl'] .badge-toast-copy,
html[dir='rtl'] .reward-row,
html[dir='rtl'] .world-group,
html[dir='rtl'] .world-row,
html[dir='rtl'] .news-list {
  text-align: right;
}
/* The help, privacy and terms pages are in English: keep them left-to-right. */
html[dir='rtl'] .help-body {
  direction: ltr;
  text-align: left;
}
/* Backup codes and version numbers read left-to-right in any language. */
html[dir='rtl'] .backup-code {
  direction: ltr;
  text-align: left;
}
/* Arabic letters join: extra letter-spacing pulls them apart, so turn it off. */
html[lang='ar'] body,
html[lang='ar'] body * {
  letter-spacing: 0 !important;
}
/* Arabic words run wider: keep the one-line score bar clear of the side buttons. */
html[lang='ar'] .game-ui .magic-chip,
html[lang='ar'] .game-ui .combo-chip {
  max-width: 6.5em;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Touch targets: at least 44 points (Apple HIG / Android 48dp guidance). */
.settings-row--select .settings-select {
  min-height: 44px;
}
/* Logbook tabs: keep "Sky page" / "Sea page" on one line so both tabs match. */
.log-tab {
  white-space: nowrap;
  padding-left: 14px;
  padding-right: 14px;
}
/* Badge toast placement: below the score row during play (it used to cover the
   pills), and at the bottom while a card such as Game Over is open (it used to
   cover the card's title). Older WebViews without :has() keep the play position. */
.badge-toast {
  top: calc(max(18px, env(safe-area-inset-top, 0px) + 12px) + 64px);
}
body:has(.game-menu.show) .badge-toast {
  top: auto;
  bottom: max(18px, env(safe-area-inset-bottom, 0px) + 12px);
  transform: translate(-50%, 12px);
}
body:has(.game-menu.show) .badge-toast.is-on {
  transform: translate(-50%, 0);
}
/* No Best pill in the score row during play: it crowded the row and got cut
   off ("1…"). Best shows on the menu and Game Over; "NEW BEST!" still pops. */
#gameHud .score-display--best {
  display: none !important;
}
