/* Self-hosted variable font (replaces the Google Fonts CDN link) */
@font-face {
  font-family: "Onest";
  src:
    url("../font/Onest-VariableFont_wght.ttf") format("truetype-variations"),
    url("../font/Onest-VariableFont_wght.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* Reset & Variables */
:root {
  /* Warm redesign palette (home + game screens) */
  --rj-bg: #faf6f0;
  --rj-hero-bg: #fbe4d6;
  --rj-accent: #e8703a;
  --rj-accent-dark: #d4602c;
  --rj-text: #1f1b17;
  --rj-text-muted: #8c8378;
  --rj-border: #ede6dc;
  --rj-dot: #c9bfb2;

  /* Header & wave heights (shared between natural size and .collapsing targets) */
  --hero-h: 163px;
  --header-h: 82px;
  --hero-wave-h: 34px;
  --game-wave-h: 26px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

html,
body {
  height: 100dvh;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
  background-color: var(--rj-bg);
  color: var(--rj-text);
  font-family: "Onest", sans-serif;
  touch-action: manipulation;
  /* Disables double-tap zoom and removes tap delay */
}

/* Page wrapper centering the game area on desktop, filling viewport on mobile */
.phone-wrapper {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--rj-bg);
}

.game-container {
  width: 100%;
  max-width: 480px;
  /* Keep mobile scale for layout */
  height: 100%;
  background: var(--rj-bg);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  /* Removed phone decorative frame, rounded corners and shadows */
  border: none;
  border-radius: 0;
  box-shadow: none;
  container-type: inline-size;
}

/* Header styles */
#game-screen {
  background: var(--rj-bg);
  font-family: "Onest", sans-serif;
}

.game-header {
  width: 100%;
  box-sizing: border-box;
  padding: 24px 18px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--rj-hero-bg);
  flex-shrink: 0;
  z-index: 10;
  position: relative;
  /* Establish positioning context for absolute centering */
  height: var(--header-h);
  transition: height 0.16s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Lands on .home-hero's real height when this header is exiting (game -> home) */
.game-header.collapsing {
  overflow: hidden;
  height: var(--hero-h);
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: none;
  background: #ffffff;
  color: var(--rj-text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.level-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.level-badge {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--rj-text);
  border: none;
  padding: 0;
  border-radius: 0;
}

.level-progress {
  display: flex;
  gap: 4px;
  width: auto;
  height: auto;
}

.progress-segment {
  flex: none;
  width: 16px;
  height: 8px;
  border: none;
  background: #ffffff;
  border-radius: 4px;
}

.progress-segment.active {
  background: var(--rj-accent);
}

.coins-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  border: none;
  padding: 7px 13px 7px 8px;
  border-radius: 999px;
  background: #ffffff;
  position: relative;
  /* Enabled for absolute positioning of decrement indicators */
}

.coin-dot {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--rj-accent);
  display: block;
  flex-shrink: 0;
}

.coins-value {
  font-family: "Onest", sans-serif;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--rj-text);
}

/* Wave divider under the compact game header, same tiling technique/pool as
   the home screen hero — see initWaveStrip() in app.js. */
.game-hero-wave-wrap {
  flex-shrink: 0;
  display: flex;
  width: 1200%;
  height: var(--game-wave-h);
  margin-top: -1px;
  animation: home-wave-scroll 54s linear infinite;
}

.game-hero-wave {
  display: block;
  flex: 1 0 0%;
  min-width: 0;
  height: 100%;
}

.game-hero-wave path {
  fill: var(--rj-hero-bg);
}

/* Rebus Area (Centered Main Element) */
.rebus-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 28px;
  padding: 0 14px;
  min-height: 0;
  position: relative;
  transition: gap 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.rebus-area.keyboard-open {
  gap: 24px;
}

.rebus-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-shrink: 0;
}

.rebus-card {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: inline-size;
}

.rebus-display {
  font-family: "Onest", sans-serif;
  /* Dynamically adjust font-size based on character length and card inline width (cqi) */
  font-size: min(3.4rem, calc(100cqi / (var(--rebus-length, 3) * 0.72)));
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--rj-text);
  gap: 0.12em;
  text-align: center;
  user-select: none;
  white-space: nowrap;
  height: 80px;
  /* Locked height to prevent vertical layout shifts */
  display: flex;
  align-items: center;
  justify-content: center;
  transition: font-size 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Shrink the rebus when the on-screen keyboard is open, to fit above it */
.rebus-area.keyboard-open .rebus-display {
  font-size: min(2.6rem, calc(100cqi / (var(--rebus-length, 3) * 0.72)));
  height: 64px;
}

/* SVG emoji images inside the rebus display */
.rebus-emoji {
  width: 1.5em;
  height: 1.5em;
  flex-shrink: 0;
  object-fit: contain;
  user-select: none;
  -webkit-user-select: none;
}

/* Mid-panel (Hints on left, Answer template next to them) */
.mid-panel {
  padding: 0 20px 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
  transition:
    opacity 0.3s ease,
    visibility 0.3s;
  visibility: visible;
  /* Force its own compositor layer: works around a WebKit/iOS ghosting bug
     where a stale painted frame of this panel could linger after rapid
     show/hide toggles between rebuses. */
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  transform: translateZ(0);
}

.bottom-panel.hidden,
.mid-panel.hidden {
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

.hints-row {
  display: flex;
  flex-direction: row;
  gap: 16px;
  justify-content: center;
  width: 100%;
}

.hint-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.hint-btn {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  border: 1.5px solid var(--rj-border);
  border-bottom: 5px solid var(--rj-border);
  background: #ffffff;
  color: var(--rj-text);
  font-family: "Onest", sans-serif;
  font-size: 1.15rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition:
    transform 0.1s ease,
    border-bottom-width 0.1s ease,
    background 0.12s ease;
}

@media (hover: hover) {
  .hint-btn:hover {
    background: var(--rj-hero-bg);
  }
}

.hint-btn:active {
  transform: translateY(4px);
  border-bottom-width: 1px;
}

.hint-btn svg {
  width: 22px;
  height: 22px;
}

/* Disabled look once a hint has already been purchased for this rebus */
.hint-item.used .hint-btn {
  background: #f2ece3;
  color: var(--rj-dot);
  cursor: default;
  pointer-events: none;
}

.hint-item.used .hint-btn:active {
  transform: none;
  border-bottom-width: 5px;
}

.hint-item.used .hint-price {
  opacity: 0.45;
}

.hint-price {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--rj-text-muted);
}

.hint-price-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--rj-accent);
  display: block;
  flex-shrink: 0;
}

.slots-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  flex-shrink: 0;
  margin-top: -16px;
  transition:
    max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.slots-container.visible {
  max-height: 110px;
  opacity: 1;
}

.slots-grid {
  display: flex;
  gap: clamp(4px, calc(8px - (var(--letter-count, 6) - 6) * 0.5px), 8px);
  justify-content: center;
  padding-top: 16px;
}

/* Letter template slots: bordered "3D press" tiles */
.slot {
  width: clamp(30px, calc(44px - (var(--letter-count, 6) - 6) * 2px), 44px);
  height: clamp(40px, calc(56px - (var(--letter-count, 6) - 6) * 2px), 56px);
  border-radius: 12px;
  background: #ffffff;
  border: 1.5px solid var(--rj-border);
  border-bottom: 5px solid var(--rj-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Onest", sans-serif;
  font-size: clamp(
    1rem,
    calc(1.5rem - (var(--letter-count, 6) - 6) * 0.05rem),
    1.5rem
  );
  font-weight: 800;
  color: var(--rj-text);
  flex-shrink: 0;
  box-sizing: border-box;
}

/* Revealed slot styled monochrome */
.slot.revealed {
  font-weight: 800;
}

/* Staggered wave animation on victory */
.slot.animate-wave {
  animation: slot-wave 0.55s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

@keyframes slot-wave {
  0% {
    opacity: 0;
    transform: translateY(12px) scale(0.85);
  }

  50% {
    transform: translateY(-6px) scale(1.05);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Bottom Panel (Controls & Keyboard) */
.bottom-panel {
  background: var(--rj-bg);
  border-top: none;
  padding: 14px 5px 24px 5px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex-shrink: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  visibility: visible;
}

.bottom-panel:has(.keyboard.hidden) {
  gap: 0;
  padding-bottom: 24px;
}

.input-bar {
  display: flex;
  gap: 10px;
  width: 100%;
  padding: 0 9px;
  box-sizing: border-box;
  transition:
    opacity 0.3s ease,
    visibility 0.3s;
}

.input-bar.hidden {
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

.input-wrapper {
  flex-grow: 1;
  background: #ffffff;
  border: 1.5px solid var(--rj-border);
  border-radius: 16px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  box-sizing: border-box;
}

#answer-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--rj-text);
  font-family: "Onest", sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0;
  padding: 0;
  display: flex;
  align-items: center;
  height: 54px;
  user-select: none;
  cursor: pointer;
}

#answer-input.placeholder {
  color: var(--rj-text-muted);
  font-weight: 600;
}

.enter-btn {
  width: 62px;
  height: 54px;
  flex-shrink: 0;
  border-radius: 16px;
  border: none;
  border-bottom: 5px solid var(--rj-accent-dark);
  background: var(--rj-accent);
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    transform 0.1s ease,
    border-bottom-width 0.1s ease;
}

.enter-btn:active {
  transform: translateY(4px);
  border-bottom-width: 1px;
}

.enter-btn svg {
  width: 24px;
  height: 24px;
}

/* Keyboard styling */
.keyboard {
  --key-width: calc((100cqi - 18px - (11 * var(--key-gap))) / 12);
  --key-gap: 4px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  opacity: 1;
  max-height: 220px;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: bottom;
  transform: translateY(0);
  visibility: visible;
}

/* Slide out state for Keyboard */
.keyboard.hidden {
  max-height: 0;
  opacity: 0;
  margin-top: -7px;
  pointer-events: none;
  transform: translateY(100%);
  visibility: hidden;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: var(--key-gap);
  width: 100%;
}

.key {
  /* Standard dimensions for normal keys */
  width: var(--key-width);
  height: calc(var(--key-width) * 1.5);
  max-height: 44px;
  background: #ffffff;
  border: 1px solid var(--rj-border);
  border-bottom: 3px solid var(--rj-border);
  border-radius: 9px;
  color: var(--rj-text);
  font-family: "Onest", sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    transform 0.08s,
    border-bottom-width 0.08s,
    background 0.1s;
  user-select: none;
  -webkit-user-select: none;
  padding: 0;
  box-sizing: border-box;
}

@media (hover: hover) {
  .key:hover,
  .key.special-key:hover {
    background: var(--rj-hero-bg);
  }
}

.key:active {
  background: #ffffff;
  border-bottom-width: 1px;
  transform: translateY(2px);
}

.key.special-key {
  width: calc(1.5 * var(--key-width) + 0.5 * var(--key-gap));
  background: #f2ece3;
}

.key.special-key:active {
  border-bottom-width: 1px;
  transform: translateY(2px);
}

.key.special-key svg {
  width: 19px;
  height: 19px;
}

.hide-key {
  color: var(--rj-text);
}

.delete-key {
  color: var(--rj-text);
}

/* Responsive Scaling for Desktop Frame */
@media (max-width: 480px) {
  :root {
    --header-h: 74px;
  }

  .game-container {
    max-width: 100%;
  }

  .game-header {
    padding: 18px 16px 14px;
  }

  .mid-panel {
    padding: 0 16px 16px 16px;
    gap: 12px;
  }

  .hint-btn {
    width: 50px;
    height: 50px;
  }

  .bottom-panel {
    padding: 12px 4px 20px 4px;
    gap: 10px;
  }

  .bottom-panel:has(.keyboard.hidden) {
    gap: 0;
    padding-bottom: 20px;
  }

  .input-bar {
    padding: 0 8px;
  }
}

/* Screen height tweaks for very small devices */
@media (max-height: 667px) {
  .rebus-display {
    height: 60px;
    /* Reduced height for short devices */
  }

  .rebus-area.keyboard-open .rebus-display {
    height: 52px;
  }
}

/* Screen shake animation for incorrect answers */
@keyframes shake {
  10%,
  90% {
    transform: translate3d(-4px, 0, 0);
  }

  20%,
  80% {
    transform: translate3d(4px, 0, 0);
  }

  30%,
  50%,
  70% {
    transform: translate3d(-6px, 0, 0);
  }

  40%,
  60% {
    transform: translate3d(6px, 0, 0);
  }
}

.shake {
  animation: shake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
  backface-visibility: hidden;
  perspective: 1000px;
}

/* Coins balance floating change indicator (+N / -N) */
.coins-delta {
  position: absolute;
  color: var(--rj-accent);
  font-weight: 800;
  font-size: 1.3rem;
  font-family: "Onest", sans-serif;
  pointer-events: none;
  animation: coin-value-pop-fade 1.8s cubic-bezier(0.25, 1, 0.5, 1) forwards;
  z-index: 100;
}

/* Shared pop-in / drift-and-fade motion for both +N and -N balance indicators:
   a quick oversized pop at the start makes the change register immediately,
   then it drifts further down and slightly inward (toward the badge's center)
   than before, so it reads clearly instead of fading a few pixels in place. */
@keyframes coin-value-pop-fade {
  0% {
    opacity: 0;
    transform: translate3d(4px, -4px, 0) scale(0.7);
  }

  14% {
    opacity: 1;
    transform: translate3d(0, 2px, 0) scale(1.22);
  }

  28% {
    transform: translate3d(-2px, 8px, 0) scale(1.04);
  }

  75% {
    opacity: 1;
    transform: translate3d(-8px, 30px, 0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate3d(-10px, 42px, 0) scale(1.1);
  }
}

/* Coins display scale pulse feedback */
@keyframes coins-pulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.2);
  }

  100% {
    transform: scale(1);
  }
}

.coins-pulse {
  animation: coins-pulse 0.3s ease-out;
}

/* Disable transitions temporarily during level loads to prevent artifacts */
.no-transition,
.no-transition * {
  transition: none !important;
}

/* Next Level Panel styling */
.next-level-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 16px 20px 32px 20px;
  background: var(--rj-bg);
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  opacity: 0;
  visibility: hidden;
  transform: translateY(100%);
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 90;
}

.next-level-panel.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.next-level-btn {
  width: 100%;
  max-width: 320px;
  height: 60px;
  background: var(--rj-accent);
  color: #ffffff;
  border: none;
  border-bottom: 5px solid var(--rj-accent-dark);
  border-radius: 16px;
  font-family: "Onest", sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    transform 0.1s ease,
    border-bottom-width 0.1s ease;
  position: relative;
}

.next-level-btn:active {
  transform: translateY(4px);
  border-bottom-width: 1px;
}

/* Screens Layouts & transitions
   Directional "push" navigation (like a native back/forward stack): the
   outgoing and incoming screens always move in lockstep along X, so their
   combined footprint covers 100% of the container at every single frame.
   Unlike the previous crossfade (opacity + scale on both screens at once),
   there's never a moment where two translucent screens overlap and the
   container's own background shows through underneath — transform is also
   the cheapest property to animate on low-end phones (GPU-composited,
   no repaint/reflow). */
.screen {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 0;
  left: 0;
  /* No delay here: the whole header choreography below (text fade, then
     header/wave settling on the incoming screen's height, then this
     push) is staged by JS via plain setTimeout, not CSS transition-delay
     — see switchScreen() in app.js and the comment above .collapsing
     below. By the time JS adds .hidden/.parked-* to trigger this
     transform, the header has already finished settling. */
  transition:
    transform 0.32s cubic-bezier(0.4, 0, 0.2, 1),
    visibility 0.32s;
  visibility: visible;
  transform: translateX(0);
  box-sizing: border-box;
}

.screen.hidden {
  visibility: hidden;
  pointer-events: none;
}

/* Promote animated waves only on the visible screen and pause infinite
   animations on the hidden screen to save GPU/battery on mobile. */
.screen:not(.hidden) .home-hero-wave-wrap,
.screen:not(.hidden) .game-hero-wave-wrap {
  will-change: transform;
}

.screen.hidden .home-hero-wave-wrap,
.screen.hidden .game-hero-wave-wrap,
.screen.hidden .card-arrow {
  animation-play-state: paused;
}

/* Parked resting position of a hidden screen: set right before it's asked
   to enter (so it animates in from that side), and left in place after it
   exits (so it's ready to re-enter from the correct side next time). */
.screen.hidden.parked-left {
  transform: translateX(-100%);
}

.screen.hidden.parked-right {
  transform: translateX(100%);
}

/* Header collapse choreography — driven by switchScreen() in app.js, not
   a single class toggle, because it's four staged moments rather than
   one crossfade:
     1. (t=0) the EXITING header's own content (logo/subtitle, or the
        level badge/buttons/coins) fades and lifts away — adds
        .header-content-hidden to the exiting *screen*.
     2. (t=contentFadeOut) the exiting header/wave — not just its
        content — shrinks or grows to land on the INCOMING screen's own
        header height, by adding .collapsing directly to the exiting
        .home-hero/.game-header and its wave-wrap. Landing on the
        incoming header's actual size (rather than collapsing to 0) is
        what makes the handoff read as one continuous motion instead of
        "old header vanishes, unrelated new one appears" — see PR
        discussion. This is a real layout reflow (max-height/padding/
        height), so it must fully finish BEFORE the next step: letting
        it overlap the .screen transform below is what caused a real
        Chromium mis-paint bug earlier (a stale rectangle of the header
        for a couple of frames) — hence staging this via JS timeouts
        that only fire once each prior phase's CSS transition duration
        has elapsed, rather than relying on transition-delay overlap.
     3. (t=contentFadeOut+waveSettle) the push: JS adds
        .hidden/.parked-* — same mechanism as before.
     4. (partway into the push) the INCOMING header's content — kept
        invisible since step 1 via .header-content-hidden on the
        incoming screen too — fades in, revealing the level badge /
        buttons / coins or the logo / subtitle.
   Once the push fully ends, switchScreen() resets the header that just
   exited back to its own natural size with no transition (it's fully
   offscreen by then) so it's ready to exit correctly again next time. */
.home-hero-wave-wrap,
.game-hero-wave-wrap {
  transition: height 0.16s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Lands on .game-hero-wave-wrap's real height */
.home-hero-wave-wrap.collapsing {
  height: var(--game-wave-h);
}

/* Lands on .home-hero-wave-wrap's real height */
.game-hero-wave-wrap.collapsing {
  height: var(--hero-wave-h);
}

.home-logo,
.home-subtitle,
.header-left,
.level-container,
.game-header .coins-badge {
  /* Duration matches HEADER_PHASE.contentFadeOut in app.js: the exit
     fade should be fully finished right as JS starts phase 2 (the
     header/wave shrinking), not still visibly fading while the box
     around it is also collapsing. */
  transition:
    opacity 0.11s ease,
    transform 0.11s ease;
}

.header-content-hidden .home-logo,
.header-content-hidden .home-subtitle,
.header-content-hidden .header-left,
.header-content-hidden .game-header .coins-badge {
  opacity: 0;
  transform: translateY(-10px);
}

.header-content-hidden .level-container {
  opacity: 0;
  transform: translateX(-50%) translateY(-10px);
}

/* Home Screen Widgets */
#home-screen {
  display: flex;
  flex-direction: column;
  background: var(--rj-bg);
  font-family: "Onest", sans-serif;
  box-sizing: border-box;
}

/* Hero header: logo + tagline on a warm accent background */
.home-hero {
  flex-shrink: 0;
  background: var(--rj-hero-bg);
  padding: 56px 26px 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  overflow: hidden;
  height: var(--hero-h);
  transition: height 0.16s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Lands on .game-header's real height when this hero is exiting (home -> game) */
.home-hero.collapsing {
  height: var(--header-h);
}

.home-logo {
  display: flex;
  align-items: baseline;
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--rj-text);
  line-height: 1;
}

.home-logo-dot {
  color: var(--rj-accent);
}

.home-subtitle span {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--rj-text);
  white-space: nowrap;
  background: linear-gradient(
    transparent 52%,
    #ffffff 52%,
    #ffffff 94%,
    transparent 94%
  );
  padding: 0 3px;
}

/* Wrap holds a randomly-shuffled sequence of HERO_WAVE_TILE_COUNT tiles,
   then the same sequence again (for a seamless loop) — width and duration
   scale with that count; see HERO_WAVE_TILE_COUNT in app.js. */
.home-hero-wave-wrap {
  flex-shrink: 0;
  display: flex;
  width: 1200%;
  height: var(--hero-wave-h);
  margin-top: -1px;
  animation: home-wave-scroll 54s linear infinite;
}

.home-hero-wave {
  display: block;
  flex: 1 0 0%;
  min-width: 0;
  height: 100%;
}

.home-hero-wave path {
  fill: var(--rj-hero-bg);
}

@keyframes home-wave-scroll {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(-50%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .home-hero-wave-wrap,
  .game-hero-wave-wrap {
    animation: none;
  }

  .screen {
    transition-duration: 0.01ms;
    transition-delay: 0s;
  }

  .home-hero,
  .game-header,
  .home-hero-wave-wrap,
  .game-hero-wave-wrap,
  .home-logo,
  .home-subtitle,
  .header-left,
  .level-container,
  .game-header .coins-badge {
    transition-duration: 0.01ms;
  }
}

/* Stats block: three equal-height cards — level/balance, overall progress, status */
.home-stats {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 24px;
  min-height: 0;
}

.home-stat-card {
  background: transparent;
  border: none;
  border-radius: 16px;
  padding: 12px 16px;
  box-sizing: border-box;
  min-height: 58px;
  display: flex;
  align-items: center;
}

.home-stat-level {
  justify-content: space-between;
  gap: 12px;
}

.home-level {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--rj-text);
}

.home-balance {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.home-balance-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--rj-text-muted);
}

.home-balance-value {
  display: flex;
  align-items: center;
  gap: 7px;
  border: none;
  padding: 0;
  background: transparent;
}

.home-coin-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--rj-accent);
  display: block;
  flex-shrink: 0;
}

#home-screen .coins-value {
  font-family: inherit;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--rj-text);
}

.home-stat-progress {
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 10px;
}

.home-stat-progress-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.home-stat-progress-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--rj-text);
}

.home-stat-progress-value {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--rj-text-muted);
  white-space: nowrap;
}

.home-progress-track {
  width: 100%;
  height: 10px;
  border-radius: 5px;
  background: var(--rj-dot);
  overflow: hidden;
}

.home-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 5px;
  background: var(--rj-accent);
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.home-buttons-list {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  align-self: center;
  width: 100%;
  max-width: 320px;
  gap: 14px;
  padding: 0 26px 32px;
  box-sizing: border-box;
}

#home-screen .home-btn,
.rules-modal .home-btn {
  width: 100%;
  height: 56px;
  background: #ffffff;
  color: var(--rj-text);
  border: 1.5px solid var(--rj-border);
  border-bottom: 5px solid var(--rj-border);
  border-radius: 16px;
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  transition:
    transform 0.1s ease,
    border-bottom-width 0.1s ease,
    background 0.12s ease;
  position: relative;
}

@media (hover: hover) {
  #home-screen .home-btn:hover,
  .rules-modal .home-btn:hover {
    background: var(--rj-hero-bg);
  }
}

#home-screen .home-btn:active,
.rules-modal .home-btn:active {
  transform: translateY(4px);
  border-bottom-width: 1px;
  box-shadow: none;
}

#home-screen .home-btn-primary,
.rules-modal .home-btn-primary {
  height: 60px;
  border: none;
  border-bottom: 5px solid var(--rj-accent-dark);
  background: var(--rj-accent);
  color: #ffffff;
  font-size: 1.15rem;
}

@media (hover: hover) {
  #home-screen .home-btn-primary:hover,
  .rules-modal .home-btn-primary:hover {
    background: var(--rj-accent);
  }
}

.rules-modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(31, 27, 23, 0.28);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 26px;
  box-sizing: border-box;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.rules-modal.visible {
  opacity: 1;
  visibility: visible;
}

.rules-content {
  width: 100%;
  max-width: 360px;
  background: #ffffff;
  border: none;
  border-radius: 20px;
  padding: 22px 20px 20px;
  box-shadow: 0 12px 32px rgba(31, 27, 23, 0.16);
  position: relative;
  box-sizing: border-box;
  font-family: "Onest", sans-serif;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: calc(100% - 8px);
  overflow: hidden;
  transform: scale(0.92) translateY(12px);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.rules-modal.visible .rules-content {
  transform: scale(1) translateY(0);
}

.rules-content h2 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--rj-text);
  margin: 0;
  text-align: center;
  line-height: 1.3;
}

/* Header row used by modals with a title + close button (e.g. "Как играть?") */
.modal-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-header-row h2 {
  text-align: left;
}

.modal-close-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 999px;
  background: #f2ece3;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--rj-text);
  transition:
    transform 0.12s ease,
    background 0.12s ease;
}

@media (hover: hover) {
  .modal-close-btn:hover {
    background: var(--rj-hero-bg);
  }
}

.modal-close-btn:active {
  transform: scale(0.92);
}

.modal-close-btn svg {
  width: 16px;
  height: 16px;
}

/* Confirmation-style modals (reset / hint purchase / game over) */
.confirmation-content {
  text-align: center;
}

.confirmation-buttons-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.confirmation-buttons-row .home-btn {
  flex: 1;
  height: 54px;
  font-size: 1.05rem;
}

/* Hint purchase confirmation text ("Узнать количество букв" + price line) */
.hint-confirm-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.hint-confirm-price-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--rj-text);
}

/* "Как играть?" modal content */
.rules-example {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.rules-example-rebus {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.rules-example-emoji {
  height: 34px;
  width: auto;
  display: block;
}

.rules-example-text {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--rj-text);
  line-height: 1;
}

.rules-example-note {
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--rj-text-muted);
  text-align: center;
  margin: 0;
}

.rules-guesses {
  width: 100%;
  display: flex;
  flex-direction: row;
  gap: 6px;
}

.rules-guess {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 10px;
  padding: 7px 4px;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rules-guess svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.rules-guess-wrong {
  background: var(--rj-bg);
  color: var(--rj-text-muted);
}

.rules-guess-wrong svg {
  color: #e0554a;
}

.rules-guess-correct {
  background: #eef5ef;
  color: #4c9a5b;
  font-weight: 800;
}

.rules-guess-correct svg {
  color: #4c9a5b;
}

.rules-divider {
  height: 1px;
  background: var(--rj-border);
  display: block;
}

.rules-coins-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.rules-coins-desc {
  flex: 1;
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.4;
  color: var(--rj-text-muted);
  text-align: left;
}

.rules-coins-chips {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex-shrink: 0;
}

.rules-coins-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--rj-hero-bg);
  border-radius: 999px;
  padding: 5px 10px 5px 7px;
  white-space: nowrap;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--rj-text);
}

.rules-coins-chip .coin-dot {
  width: 13px;
  height: 13px;
}

.rules-coins-chip-label {
  font-weight: 600;
  color: var(--rj-text-muted);
}

.rules-hints-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.rules-hint-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--rj-bg);
  border-radius: 14px;
  padding: 8px 10px;
}

.rules-hint-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 999px;
  background: #ffffff;
  border: 1.5px solid var(--rj-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--rj-text);
}

.rules-hint-icon svg {
  width: 14px;
  height: 14px;
}

.rules-hint-text {
  flex: 1;
  min-width: 0;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--rj-text);
  text-align: left;
}

.rules-hint-row .hint-price {
  flex-shrink: 0;
}

.game-over-content {
  text-align: center;
  padding: 4px 0 0;
}

h2.game-over-title {
  font-family: "Onest", sans-serif;
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0;
  color: #e0554a;
}

/* Card navigation arrows: normal flex children of .rebus-row, muted color */
.card-arrow {
  width: 32px;
  height: 50px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--rj-dot);
  background: transparent;
  border: none;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
  cursor: pointer;
  z-index: 5;
  padding: 0;
  outline: none;
}

@media (hover: hover) {
  .card-arrow:hover {
    color: var(--rj-text-muted);
  }
}

.card-arrow:active {
  color: var(--rj-text-muted);
}

.card-arrow svg {
  width: 22px;
  height: 22px;
}

.card-arrow-left {
  animation: bounce-left 2s infinite ease-in-out;
}

.card-arrow-right {
  animation: bounce-right 2s infinite ease-in-out;
}

/* Hidden at the first/last rebus in a group: stays invisible and unclickable
   but keeps its layout space, so the rebus card doesn't drift off-center. */
.card-arrow.invisible {
  visibility: hidden;
  pointer-events: none;
  animation: none;
}

@keyframes bounce-left {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }

  50% {
    transform: translate3d(-4px, 0, 0);
  }
}

@keyframes bounce-right {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }

  50% {
    transform: translate3d(4px, 0, 0);
  }
}

/* ============================================
   Loading Screen
   Shown until fonts and images finish loading,
   then removed from the DOM by platform.js.
   ============================================ */
#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  background: var(--rj-bg);
  opacity: 1;
  transition: opacity 0.4s ease;
}

#loading-screen.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-logo {
  font-family: "Onest", sans-serif;
  font-size: 42px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--rj-text);
}

.loading-logo-dot {
  color: var(--rj-accent);
}

.loading-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--rj-border);
  border-top-color: var(--rj-accent);
  border-radius: 50%;
  animation: loading-spin 0.8s linear infinite;
}

@keyframes loading-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Respect the user's reduced-motion preference (already honoured elsewhere) */
@media (prefers-reduced-motion: reduce) {
  .loading-spinner {
    animation-duration: 2.4s;
  }
}

/* ============================================
   Native Gesture & Selection Guards
   Requirements 1.6.1.8 / 1.6.2.7 (no context menu
   or selection) and 1.10.2 (no browser scroll or
   swipe-to-refresh).
   ============================================ */

/* Long-press on iOS opens a system callout even when text
   selection is disabled. This switches it off everywhere. */
* {
  -webkit-touch-callout: none;
}

/* Blocks pull-to-refresh and the rubber-band bounce effect. */
html,
body {
  overscroll-behavior: none;
}

/* Emoji are decorative. Making them transparent to pointer events
   kills the iOS long-press menu at the source, and touches pass
   straight through to the card — which also makes swiping smoother. */
.rebus-emoji,
.rules-example-emoji {
  pointer-events: none;
  -webkit-user-drag: none;
}

/* The rules modal can outgrow a short screen. Let it scroll inside
   itself instead of clipping content (requirement 1.10.1), and keep
   that scroll from leaking out to the page. */
.rules-content {
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* ============================================
   Desktop Layout (>= 900px)
   Single-column stage. The screen itself fills the
   viewport (requirement 1.6.2.1) so the aspect ratio
   matches the window rather than a narrow phone strip
   (requirement 1.6.2.2), while the content stays in a
   comfortable centred column.
   ============================================ */
@media (min-width: 900px) {
  :root {
    --hero-h: 206px;
  }

  /* Drop the phone-width cap so the game fills the viewport. */
  .game-container {
    max-width: none;
  }

  /* ---------- Home screen ---------- */
  .home-hero {
    padding: 72px 26px 34px;
  }

  .home-logo {
    font-size: 4rem;
  }

  .home-subtitle span {
    font-size: 1.15rem;
  }

  /* Keep the readable content column narrow and centred, while the
     warm background still reaches both edges of the screen. */
  .home-stats {
    width: 100%;
    max-width: 560px;
    align-self: center;
  }

  .home-buttons-list {
    max-width: 360px;
    padding-bottom: 48px;
  }

  /* ---------- Game screen ---------- */
  .game-header {
    padding: 22px 32px 18px;
  }

  .rebus-area {
    gap: 36px;
  }

  /* Without a cap the arrows would be flung to the far edges of a wide
     screen, leaving the rebus stranded in the middle. */
  .rebus-row {
    width: 100%;
    max-width: 720px;
    align-self: center;
    gap: 20px;
  }

  .card-arrow {
    width: 52px;
    height: 52px;
  }

  /* Room for a much larger rebus. The value is a cap: the existing
     container-query rule still shrinks long rebuses to fit. */
  .rebus-display {
    font-size: min(5rem, calc(100cqi / (var(--rebus-length, 3) * 0.72)));
    height: 130px;
  }

  .rebus-area.keyboard-open .rebus-display {
    font-size: min(4rem, calc(100cqi / (var(--rebus-length, 3) * 0.72)));
    height: 105px;
  }

  .mid-panel {
    padding: 0 20px 28px;
    gap: 24px;
  }

  .hints-row {
    gap: 28px;
  }

  .hint-btn {
    width: 62px;
    height: 62px;
  }

  .bottom-panel {
    align-items: center;
    padding-bottom: 32px;
  }

  .input-bar,
  .keyboard {
    width: 100%;
    max-width: 560px;
  }

  /* Key width normally derives from the container width (cqi). That
     container is now as wide as the viewport, so the keys would be
     enormous — pin them to the 560px the keyboard actually occupies. */
  .keyboard {
    --key-width: calc((560px - 18px - (11 * var(--key-gap))) / 12);
    max-height: 240px;
  }

  .next-level-panel {
    padding-bottom: 40px;
  }
}

/* ============================================
   Short-viewport adjustments
   Requirements 1.10.1 and 1.10.3: nothing may be
   clipped or overlap when the window is resized.
   Two steps down from the roomy desktop defaults.
   ============================================ */

/* --- Step 1: laptops and half-height windows (~760px and below) --- */
@media (min-width: 900px) and (max-height: 760px) {
  :root {
    --hero-h: 135px;
    --header-h: 68px;
    --hero-wave-h: 26px;
  }

  /* Home screen */
  .home-hero {
    padding: 34px 26px 20px;
  }

  .home-logo {
    font-size: 3rem;
  }

  .home-subtitle span {
    font-size: 1rem;
  }

  .home-stat-card {
    min-height: 48px;
    padding: 8px 16px;
  }

  .home-buttons-list {
    gap: 10px;
    padding-bottom: 28px;
  }

  #home-screen .home-btn {
    height: 50px;
  }

  /* Game screen */
  .game-header {
    padding: 14px 32px 12px;
  }

  .rebus-area {
    gap: 22px;
  }

  .rebus-display {
    font-size: min(3.6rem, calc(100cqi / (var(--rebus-length, 3) * 0.72)));
    height: 96px;
  }

  .rebus-area.keyboard-open .rebus-display {
    font-size: min(3rem, calc(100cqi / (var(--rebus-length, 3) * 0.72)));
    height: 78px;
  }

  .mid-panel {
    padding: 0 20px 16px;
    gap: 16px;
  }

  .hint-btn {
    width: 52px;
    height: 52px;
  }

  .bottom-panel {
    padding-bottom: 18px;
    gap: 10px;
  }

  .input-bar,
  .keyboard {
    max-width: 460px;
  }

  .keyboard {
    --key-width: calc((460px - 18px - (11 * var(--key-gap))) / 12);
    max-height: 190px;
  }

  .next-level-panel {
    padding-bottom: 22px;
  }
}

/* --- Step 2: genuinely short windows (~570px and below, any width) --- */
@media (max-height: 570px) {
  :root {
    --hero-h: 98px;
    --header-h: 60px;
    --hero-wave-h: 18px;
    --game-wave-h: 18px;
  }

  /* Home screen */
  .home-hero {
    padding: 18px 26px 12px;
  }

  .home-logo {
    font-size: 2.2rem;
  }

  .home-subtitle span {
    font-size: 0.9rem;
  }

  .home-stat-card {
    min-height: 38px;
    padding: 4px 16px;
  }

  .home-level {
    font-size: 1.2rem;
  }

  .home-buttons-list {
    gap: 8px;
    padding-bottom: 16px;
  }

  #home-screen .home-btn {
    height: 44px;
    font-size: 0.95rem;
  }

  /* Game screen */
  .game-header {
    padding: 10px 18px 8px;
  }

  .rebus-area {
    gap: 14px;
  }

  .rebus-display {
    font-size: min(2.6rem, calc(100cqi / (var(--rebus-length, 3) * 0.72)));
    height: 68px;
  }

  .rebus-area.keyboard-open .rebus-display {
    font-size: min(2.2rem, calc(100cqi / (var(--rebus-length, 3) * 0.72)));
    height: 56px;
  }

  .mid-panel {
    padding: 0 20px 10px;
    gap: 10px;
  }

  .hint-btn {
    width: 44px;
    height: 44px;
  }

  .bottom-panel {
    padding: 8px 5px 12px;
    gap: 8px;
  }

  #answer-input {
    height: 44px;
  }

  .enter-btn {
    height: 44px;
    width: 54px;
  }

  .input-bar,
  .keyboard {
    max-width: 400px;
    align-self: center;
  }

  .keyboard {
    --key-width: calc((min(100cqi, 400px) - 18px - (11 * var(--key-gap))) / 12);
    max-height: 150px;
  }

  .next-level-panel {
    padding-bottom: 14px;
  }

  .next-level-btn {
    height: 48px;
    font-size: 1rem;
  }
}

@media (min-width: 900px) and (max-height: 570px) {
  .game-header {
    padding: 10px 28px 8px;
  }
}

/* ============================================
   Rewarded-video offer inside the hint dialog

   Requirement 4.5.1 allows the reward to be stated
   in the text next to the button rather than on it,
   so the note carries the offer and the button stays
   to a single clear line.
   ============================================ */

/* The hidden attribute must beat the display:flex on .home-btn. */
[hidden] {
  display: none !important;
}

.hint-confirm-note {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--rj-text-muted);
}

/* Each line reads as one phrase, so the amount must not wrap away
   from the words that introduce it. */
.hint-confirm-note-line {
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  flex-wrap: wrap;
  gap: 7px;
}

.hint-confirm-note-reward {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  font-weight: 800;
  color: var(--rj-text);
}

.hint-confirm-note-reward .coin-dot {
  width: 14px;
  height: 14px;
}

/* "Посмотреть рекламу" needs more room than "Нет", so the ad button
   takes a larger share of the row and drops a size to fit one line. */
.rules-modal .home-btn-ad {
  flex: 1.7;
  font-size: 0.95rem;
  white-space: nowrap;
}

.home-btn-ad .coin-dot {
  width: 13px;
  height: 13px;
  background: #ffffff;
}

/* ============================================
   Sound toggle in the game header
   Recommendation 6.2 — the player can mute.
   ============================================ */
.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Both icons live in one button; the body class picks which shows. */
.icon-sound-off,
body.sound-muted .icon-sound-on {
  display: none;
}

body.sound-muted .icon-sound-off {
  display: block;
}

body.sound-muted #sound-btn {
  color: var(--rj-text-muted);
}

/* ============================================
   Attribution required by CC BY-SA 4.0.
   Deliberately no links: requirement 8.4.2 forbids
   sending the player to external sites.
   ============================================ */
.rules-credits {
  font-size: 0.78rem;
  line-height: 1.45;
  text-align: center;
  color: var(--rj-text-muted);
  margin: 0;
}
