/* =========================================================================
   KLETA — 3 Ride Challenge
   A polished arcade-style endless runner.

   System:
   - Game logic lives in a 1280x720 LOGICAL world. .stage-world is scaled.
   - HUD / overlays / controls live OUTSIDE the world (viewport pixels) so they
     stay readable + tappable at any size.
   - Desktop  → arcade-cabinet framing (marquee + plinth + HUD chrome)
   - Mobile   → "Kleta Handheld" device chrome (LCD + D-pad + A/B + speaker)
   ========================================================================= */

:root {
  /* Brand palette */
  --kleta-yellow:       #ffd33d;
  --kleta-yellow-deep:  #f4b400;
  --kleta-yellow-soft:  #ffe87a;
  --kleta-yellow-glow:  #fff099;
  --kleta-coral:        #ff6b5c;
  --kleta-coral-deep:   #e6432d;
  --kleta-sky:          #6ec8ff;
  --kleta-sea:          #1b6fb0;
  --kleta-cream:        #fff5d6;
  --kleta-cream-deep:   #f1d98a;

  /* Neutrals — slight blue tilt, never pure black */
  --ink:           #11161c;
  --ink-soft:      #1c232b;
  --ink-mid:       #2a323c;
  --ink-line:      #3a4250;
  --paper:         #ffffff;
  --paper-soft:    #fff8e5;

  /* Handheld plastics */
  --plastic-cream:      #efe8d0;
  --plastic-cream-mid:  #ddd2a8;
  --plastic-cream-deep: #b9ad7d;
  --plastic-cream-shadow: #877c52;
  --plastic-purple:     #5a4f7c;
  --plastic-purple-deep:#352c54;

  /* Glass tokens (form screens) */
  --glass-bg:    rgba(255, 255, 255, 0.04);
  --glass-bg-2:  rgba(255, 255, 255, 0.08);
  --glass-line:  rgba(255, 255, 255, 0.12);
  --glass-line-2:rgba(255, 255, 255, 0.18);

  /* Shadows */
  --shadow-lift-sm:  0 6px 14px rgba(0, 0, 0, 0.22);
  --shadow-lift-md:  0 14px 28px rgba(0, 0, 0, 0.28);
  --shadow-lift-lg:  0 26px 60px rgba(0, 0, 0, 0.42);
  --shadow-yellow:   0 14px 28px rgba(244, 180, 0, 0.34);
  --shadow-yellow-lg:0 22px 44px rgba(244, 180, 0, 0.46);

  /* Safe-area */
  --safe-top:    max(env(safe-area-inset-top), 0px);
  --safe-bottom: max(env(safe-area-inset-bottom), 0px);
  --safe-left:   max(env(safe-area-inset-left), 0px);
  --safe-right:  max(env(safe-area-inset-right), 0px);

  /* Stage system */
  --logical-width:  1280px;
  --logical-height:  720px;
  --stage-scale: 1;

  /* Easings */
  --ease-pop:  cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-soft: cubic-bezier(0.22, 1, 0.36, 1);

  /* Type */
  --font-display: "Fredoka", "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  --font-body:    "Fredoka", "Avenir Next", "Trebuchet MS", system-ui, sans-serif;
  --font-mono:    "DM Mono", "JetBrains Mono", ui-monospace, "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  overscroll-behavior-y: contain;
  position: fixed;
  inset: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

input, textarea, .leaderboard-list {
  user-select: auto;
  -webkit-user-select: auto;
  touch-action: auto;
}

body {
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(255, 211, 61, 0.18), transparent 60%),
    radial-gradient(ellipse 60% 60% at 50% 110%, rgba(255, 107, 92, 0.10), transparent 60%),
    linear-gradient(180deg, #161d26 0%, #0d1118 65%, #080b10 100%);
}

button, input, select { font: inherit; }

button {
  cursor: pointer;
  border: 0;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

button * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  pointer-events: none;
}

img { display: block; max-width: 100%; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* =========================================================================
   APP SHELL
   ========================================================================= */

.app { position: fixed; inset: 0; overflow: hidden; }

.screen {
  position: absolute;
  inset: 0;
  display: none;
  padding:
    calc(var(--safe-top) + 12px)
    calc(var(--safe-right) + 12px)
    calc(var(--safe-bottom) + 12px)
    calc(var(--safe-left) + 12px);
  overflow: hidden;
}

.screen.active { display: block; }

/* =========================================================================
   COVER (start)
   ========================================================================= */

.screen-cover { align-items: stretch; justify-content: stretch; }
.screen-cover.active { display: grid; place-items: center; }

.cover-backdrop {
  position: absolute; inset: 0;
  background: url("background.png") center / cover no-repeat;
  transform: scale(1.06);
  animation: drift 18s ease-in-out infinite alternate;
}

.cover-overlay {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 60% 60% at 50% 32%, rgba(255, 211, 61, 0.28), transparent 65%),
    linear-gradient(180deg, rgba(10, 14, 18, 0.45) 0%, rgba(10, 14, 18, 0.15) 35%, rgba(10, 14, 18, 0.86) 100%);
}

.cover-content {
  position: relative;
  display: grid;
  place-items: center;
  gap: 26px;
  width: min(640px, 100%);
  padding: 32px 24px;
  text-align: center;
}

.cover-logo {
  width: min(360px, 58vw);
  filter: drop-shadow(0 26px 36px rgba(0, 0, 0, 0.55));
  animation: floatLogo 4s ease-in-out infinite alternate;
}

.cover-tagline {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 2.5vw, 1.4rem);
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--paper-soft);
  text-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

.cover-actions {
  display: grid;
  gap: 12px;
  width: min(340px, 88vw);
}

.cover-footnote {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.66);
  letter-spacing: 0.02em;
}

.cover-lang {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.lang-pill {
  min-width: 44px;
  padding: 6px 12px;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  transition: background 140ms ease, color 140ms ease;
}
.lang-pill:hover { color: var(--paper); }
.lang-pill[aria-pressed="true"] {
  background: linear-gradient(180deg, var(--kleta-yellow-soft), var(--kleta-yellow-deep));
  color: var(--ink);
}

/* =========================================================================
   BUTTONS
   ========================================================================= */

.primary-button,
.ghost-button {
  position: relative;
  min-height: 56px;
  padding: 0 28px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: 0.01em;
  transition:
    transform 140ms var(--ease-pop),
    box-shadow 180ms var(--ease-soft),
    background 180ms var(--ease-soft),
    color 180ms var(--ease-soft);
  touch-action: manipulation;
}

.primary-button {
  color: var(--ink);
  background: linear-gradient(180deg, var(--kleta-yellow-soft) 0%, var(--kleta-yellow-deep) 100%);
  box-shadow:
    var(--shadow-yellow),
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -3px 0 rgba(150, 100, 0, 0.28);
}
.primary-button:hover,
.primary-button:focus-visible {
  transform: translateY(-2px);
  box-shadow:
    var(--shadow-yellow-lg),
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -3px 0 rgba(150, 100, 0, 0.28);
}
.primary-button:active { transform: translateY(1px); }
.primary-button[disabled] { opacity: 0.5; cursor: default; transform: none; }

.ghost-button {
  color: var(--paper);
  background: var(--glass-bg-2);
  border: 1px solid var(--glass-line-2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.ghost-button:hover,
.ghost-button:focus-visible {
  background: rgba(255, 255, 255, 0.16);
  transform: translateY(-2px);
}
.ghost-button:active { transform: translateY(0); }

.back-pill {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  color: var(--paper);
  background: var(--glass-bg-2);
  border: 1px solid var(--glass-line-2);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
}
.back-pill:hover { background: rgba(255, 255, 255, 0.16); }

/* =========================================================================
   FORM SCREENS (email, character, initials, leaderboard)
   ========================================================================= */

.screen-form { display: none; place-items: center; }
.screen-form::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 70% 40% at 50% -10%, rgba(255, 211, 61, 0.18), transparent 70%),
    radial-gradient(ellipse 60% 40% at 50% 110%, rgba(255, 107, 92, 0.10), transparent 70%);
}
.screen-form.active { display: grid; overflow: hidden; }

.form-card {
  position: relative;
  width: min(460px, 100%);
  margin: auto;
  padding: 30px 24px 22px;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--glass-line);
  box-shadow:
    var(--shadow-lift-lg),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  color: var(--paper);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  /* JS sets --form-fit-scale via updateFormFit() so the card shrinks to fit
     viewports that would otherwise force scrolling. Origin is top-center so
     the shrunk card stays anchored to the top of its container — when a
     grid item overflows its track, align-items:center degenerates to start,
     so the layout top is what we need to preserve. */
  transform: scale(var(--form-fit-scale, 1));
  transform-origin: 50% 0;
  transition: transform 120ms ease;
}

.form-card-narrow { width: min(380px, 100%); }
.form-card-wide   { width: min(720px, 100%); }

.form-header {
  display: grid;
  gap: 10px;
  margin-bottom: 22px;
  text-align: center;
}
.form-header-tight { margin-bottom: 14px; }

.form-chip {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--glass-bg-2);
  border: 1px solid var(--glass-line-2);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.78);
}
.form-chip-gold {
  background: linear-gradient(180deg, var(--kleta-yellow-soft), var(--kleta-yellow-deep));
  color: var(--ink);
  border-color: rgba(255, 199, 38, 0.6);
}

.form-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.7rem, 4.4vw, 2.3rem);
  line-height: 1.04;
  letter-spacing: -0.01em;
}

.form-header p {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.74);
  line-height: 1.45;
  text-wrap: pretty;
}

.form-body { display: grid; gap: 18px; }

.field { display: grid; gap: 6px; }

.field-label {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
}

.field-input {
  width: 100%;
  min-height: 54px;
  padding: 0 18px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1.5px solid var(--glass-line-2);
  color: var(--paper);
  font-size: 1.02rem;
  font-weight: 500;
  outline: none;
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}
.field-input::placeholder { color: rgba(255, 255, 255, 0.36); }
.field-input:focus {
  border-color: var(--kleta-yellow);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 0 4px rgba(255, 211, 61, 0.18);
}
.field-input[aria-invalid="true"] { border-color: var(--kleta-coral); }

.field-error { min-height: 18px; font-size: 0.84rem; font-weight: 600; color: #ff9b9b; }

.consent {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.94rem;
  color: rgba(255, 255, 255, 0.82);
  cursor: pointer;
}
.consent input { width: 22px; height: 22px; accent-color: var(--kleta-yellow); }

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-top: 10px;
}
.form-actions > * { flex: 1 1 0; }
.form-actions .primary-button { flex: 2 1 0; }

/* =========================================================================
   CHARACTER SELECT
   ========================================================================= */

.character-rail {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}

.rail-arrow {
  width: 46px;
  height: 46px;
  border-radius: 999px;
  background: var(--glass-bg-2);
  border: 1px solid var(--glass-line-2);
  color: var(--paper);
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
  transition: opacity 140ms ease, transform 160ms var(--ease-pop), background 140ms ease;
}
.rail-arrow:hover { background: rgba(255, 255, 255, 0.18); transform: scale(1.06); }
.rail-arrow:disabled { opacity: 0.3; cursor: default; transform: none; }

.character-grid {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 6px 4px 10px;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
}
.character-grid::-webkit-scrollbar { display: none; }

.character-card {
  position: relative;
  flex: 0 0 min(190px, 64vw);
  display: grid;
  gap: 8px;
  padding: 12px 12px 14px;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
  border: 2px solid var(--glass-line);
  color: var(--paper);
  text-align: left;
  scroll-snap-align: center;
  transition: border-color 200ms ease, box-shadow 200ms ease, transform 200ms var(--ease-pop);
}
.character-card:hover { transform: translateY(-2px); border-color: var(--glass-line-2); }

.character-card.selected {
  border-color: var(--kleta-yellow);
  box-shadow:
    0 18px 30px rgba(255, 199, 38, 0.22),
    0 0 0 6px rgba(255, 211, 61, 0.14);
  transform: translateY(-4px);
}

.character-badge {
  justify-self: start;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.46);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.character-card.selected .character-badge {
  background: linear-gradient(180deg, var(--kleta-yellow-soft), var(--kleta-yellow-deep));
  color: var(--ink);
}

.character-art {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(110, 200, 255, 0.34), rgba(255, 245, 211, 0.06)),
    repeating-linear-gradient(
      -45deg,
      rgba(255, 255, 255, 0.02),
      rgba(255, 255, 255, 0.02) 14px,
      rgba(255, 255, 255, 0.06) 14px,
      rgba(255, 255, 255, 0.06) 28px
    );
  overflow: hidden;
}
.character-art img {
  width: 88%;
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.32));
  transition: transform 240ms var(--ease-pop);
}
.character-card:hover .character-art img { transform: scale(1.04); }
.character-card.selected .character-art img { transform: scale(1.06); }

.character-meta { display: grid; gap: 2px; }

.character-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.12rem;
}

.character-detail {
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.66);
  font-weight: 500;
}

/* =========================================================================
   LEVEL SELECTION (Barcelona / València)
   ========================================================================= */

.level-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
  padding: 4px;
}

.level-card {
  position: relative;
  display: grid;
  gap: 10px;
  padding: 14px 14px 16px;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
  border: 2px solid var(--glass-line);
  color: var(--paper);
  text-align: left;
  transition: border-color 200ms ease, box-shadow 200ms ease, transform 200ms var(--ease-pop);
  cursor: pointer;
}
.level-card:hover { transform: translateY(-2px); border-color: var(--glass-line-2); }

.level-card[aria-checked="true"] {
  border-color: var(--kleta-yellow);
  box-shadow:
    0 18px 30px rgba(255, 199, 38, 0.22),
    0 0 0 6px rgba(255, 211, 61, 0.14);
  transform: translateY(-3px);
}

.level-badge {
  justify-self: start;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.46);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--paper);
}
.level-badge-hard { background: linear-gradient(180deg, #ff8a64, #d24a2a); color: #fff; }

.level-art {
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  background-color: rgba(0, 0, 0, 0.2);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}
.level-art-barcelona { background-image: url("background.png"); }
.level-art-valencia  { background-image: url("backgroundvalencia.png"); }

.level-meta { display: grid; gap: 2px; }
.level-name { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; }
.level-detail { font-size: 0.86rem; color: rgba(255, 255, 255, 0.66); font-weight: 500; }

/* When the player picks València, swap the in-game backdrop. */
body.level-valencia .stage-backdrop { background-image: url("backgroundvalencia.png"); }
@media (orientation: portrait) and (max-width: 720px) {
  body.level-valencia .stage-backdrop { background-image: url("backgroundmobilevalencia.png"); }
}

/* Desktop / landscape: show all riders at once in a 3-column grid.
   The portrait-phone breakpoint below keeps the horizontal slider. */
@media (min-width: 721px) {
  #character-screen .form-card-wide { width: min(960px, 96vw); }

  .character-rail { grid-template-columns: 1fr; gap: 0; }
  .rail-arrow { display: none; }

  .character-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    overflow: visible;
    scroll-snap-type: none;
    padding: 6px 4px 10px;
  }

  .character-card { flex: initial; width: auto; padding: 16px 14px 18px; }
  .character-name { font-size: 1.22rem; }
  .character-detail { font-size: 0.88rem; }
}

/* =========================================================================
   GAME SCREEN — desktop arcade frame + stage
   ========================================================================= */

.screen-game {
  display: none;
  padding: 0;
  background:
    radial-gradient(ellipse 70% 40% at 50% -10%, rgba(255, 211, 61, 0.18), transparent 70%),
    radial-gradient(ellipse 60% 40% at 50% 110%, rgba(255, 107, 92, 0.08), transparent 70%),
    linear-gradient(180deg, #11161d 0%, #0a0d12 60%, #06090d 100%);
}
.screen-game.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
}

/* DESKTOP / landscape — arcade frame: marquee + stage + plinth */

.arcade-marquee {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 22px;
  margin-bottom: 14px;
  border-radius: 18px 18px 6px 6px;
  background:
    linear-gradient(180deg, #1d2330 0%, #14191f 100%);
  border: 1px solid rgba(255, 211, 61, 0.32);
  border-bottom-color: rgba(255, 211, 61, 0.16);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.6) inset,
    0 12px 24px rgba(0, 0, 0, 0.4),
    0 0 22px rgba(255, 211, 61, 0.16);
  width: var(--fit-width, auto);
  max-width: 100%;
  position: relative;
  z-index: 4;
  overflow: hidden;
}
/* Sheen sweep across the marquee */
.arcade-marquee::before {
  content: "";
  position: absolute;
  top: 0; left: -40%;
  width: 30%;
  height: 100%;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(255, 211, 61, 0.08) 50%,
    transparent 100%);
  animation: marqueeSheen 6s ease-in-out infinite;
  pointer-events: none;
}
@keyframes marqueeSheen {
  0%, 50% { transform: translateX(0); }
  90%, 100% { transform: translateX(550%); }
}
.arcade-marquee-logo {
  width: 64px;
  height: auto;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.5));
}
.arcade-marquee-meta {
  display: grid;
  gap: 2px;
  flex: 1 1 auto;
}
.arcade-marquee-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: 0.02em;
  color: var(--kleta-yellow-soft);
  text-shadow: 0 0 14px rgba(255, 211, 61, 0.55), 0 2px 0 rgba(0, 0, 0, 0.4);
}
.arcade-marquee-sub {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
}
.arcade-marquee-lights {
  display: flex;
  gap: 7px;
  padding-right: 4px;
}
.arcade-marquee-lights span {
  width: 9px; height: 9px;
  border-radius: 999px;
  background: rgba(255, 211, 61, 0.25);
  box-shadow: 0 0 6px rgba(255, 211, 61, 0.2);
  animation: chase 1.6s linear infinite;
}
.arcade-marquee-lights span:nth-child(1) { animation-delay: 0s; }
.arcade-marquee-lights span:nth-child(2) { animation-delay: 0.2s; }
.arcade-marquee-lights span:nth-child(3) { animation-delay: 0.4s; }
.arcade-marquee-lights span:nth-child(4) { animation-delay: 0.6s; }
.arcade-marquee-lights span:nth-child(5) { animation-delay: 0.8s; }
.arcade-marquee-lights span:nth-child(6) { animation-delay: 1.0s; }
.arcade-marquee-lights span:nth-child(7) { animation-delay: 1.2s; }
.arcade-marquee-lights span:nth-child(8) { animation-delay: 1.4s; }

@keyframes chase {
  0%, 30%, 100% {
    background: rgba(255, 211, 61, 0.25);
    box-shadow: 0 0 6px rgba(255, 211, 61, 0.2);
  }
  10% {
    background: var(--kleta-yellow);
    box-shadow: 0 0 14px var(--kleta-yellow), 0 0 22px rgba(255, 211, 61, 0.5);
  }
}

.arcade-plinth {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 18px;
  padding: 8px 20px;
  margin-top: 12px;
  border-radius: 4px 4px 18px 18px;
  background: linear-gradient(180deg, #14191f 0%, #1d2330 100%);
  border: 1px solid rgba(255, 211, 61, 0.18);
  border-top-color: rgba(255, 211, 61, 0.05);
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.4);
  width: var(--fit-width, auto);
  max-width: 100%;
  z-index: 4;
}
.arcade-key {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.66);
}
.arcade-key kbd {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 26px;
  padding: 0 8px;
  border-radius: 6px;
  background: linear-gradient(180deg, #2a323c, #181d23);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--kleta-yellow-soft);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 2px 0 rgba(0, 0, 0, 0.5);
}

/* Portrait phones: anchor stage near the top so the empty space sits between
   stage and controls. Marquee + plinth are hidden via the handheld override. */
@media (orientation: portrait) and (max-width: 720px) {
  .screen-game.active {
    justify-content: flex-start;
    padding-top: calc(var(--safe-top) + 12px);
  }
  .arcade-marquee, .arcade-plinth { display: none; }
}

/* =========================================================================
   STAGE (16:9 viewport into the 1280x720 logical world)
   ========================================================================= */

.stage-fit {
  position: relative;
  width: var(--fit-width, 100%);
  height: var(--fit-height, 100%);
  overflow: hidden;
  background: linear-gradient(180deg, #8ad3ff 0%, #a6dcff 14%, #ffefbc 70%, #f0b05f 100%);
  /* arcade-style bezel + glow on desktop */
  box-shadow:
    0 0 0 3px rgba(255, 211, 61, 0.3),
    0 0 0 6px rgba(0, 0, 0, 0.65),
    0 30px 80px rgba(0, 0, 0, 0.55),
    0 0 60px rgba(255, 211, 61, 0.18);
  border-radius: 8px;
}

.stage-world {
  position: absolute;
  top: 0; left: 0;
  width: var(--logical-width);
  height: var(--logical-height);
  transform-origin: top left;
  transform: scale(var(--stage-scale));
}

.stage-backdrop {
  position: absolute; inset: 0;
  background: url("background.png") center bottom / cover no-repeat;
  animation: drift 18s ease-in-out infinite alternate;
}

.stage-overlay {
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.10), transparent 22%),
    linear-gradient(180deg, transparent 58%, rgba(248, 182, 84, 0.14) 100%);
}

.stage-road-glow {
  position: absolute; left: 0; right: 0; bottom: 84px;
  height: 100px;
  background: radial-gradient(circle at center, rgba(255, 211, 61, 0.28), transparent 70%);
}

.stage-road {
  position: absolute; left: -8%; right: -8%; bottom: -18px;
  height: 208px;
  border-radius: 54px 54px 0 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.24), transparent 28%),
    linear-gradient(180deg, #56606d, #2f3640);
}
.stage-road::before, .stage-road::after {
  content: ""; position: absolute; left: 0; right: 0;
}
.stage-road::before { top: 18px; border-top: 7px solid rgba(255, 255, 255, 0.28); }
.stage-road::after {
  top: -5px; height: 15px;
  background: linear-gradient(90deg, rgba(255, 225, 127, 0.85), rgba(255, 245, 199, 1), rgba(255, 225, 127, 0.85));
}

/* =========================================================================
   HUD (overlaid on stage, viewport pixels)
   ========================================================================= */

.stage-hud {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 9;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  pointer-events: none;
}

.stage-brand {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 14px;
  background: rgba(15, 20, 24, 0.82);
  border: 1px solid rgba(255, 211, 61, 0.25);
  backdrop-filter: blur(6px);
}
.stage-brand img { width: clamp(48px, 7vw, 84px); }

.stage-pills {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  justify-content: flex-end;
  min-width: 0;
  margin-left: auto;
}

.stage-pill {
  position: relative;
  padding: 6px 12px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(20, 26, 34, 0.92), rgba(12, 16, 22, 0.92));
  border: 1px solid rgba(255, 211, 61, 0.22);
  color: var(--paper);
  backdrop-filter: blur(6px);
  text-align: right;
  min-width: 64px;
  white-space: nowrap;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.stage-pill.hidden { display: none; }

.stage-pill-multiplier {
  background: linear-gradient(180deg, var(--kleta-yellow-soft) 0%, var(--kleta-yellow-deep) 100%);
  color: var(--ink);
  border-color: rgba(244, 180, 0, 0.7);
  animation: streakPulse 600ms var(--ease-pop) infinite alternate;
  box-shadow:
    0 0 14px rgba(255, 211, 61, 0.5),
    var(--shadow-yellow),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
}
.stage-pill-multiplier .stage-pill-label { color: rgba(50, 35, 5, 0.7); }
.stage-pill-multiplier strong { color: var(--ink); }

@keyframes streakPulse {
  from { transform: scale(1); }
  to   { transform: scale(1.07); }
}

.stage-pill-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.58);
  margin-bottom: 2px;
}

.stage-pill strong {
  font-family: var(--font-mono);
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--kleta-yellow-soft);
}
.stage-pill-multiplier strong {
  font-family: var(--font-display);
  font-size: 1.1rem;
}

@media (min-width: 720px) {
  .stage-hud { top: 18px; left: 18px; right: 18px; gap: 14px; }
  .stage-brand { padding: 8px 12px; border-radius: 18px; }
  .stage-brand img { width: 96px; }
  .stage-pills { gap: 10px; }
  .stage-pill { padding: 10px 16px; border-radius: 16px; min-width: 96px; }
  .stage-pill-label { font-size: 0.62rem; margin-bottom: 4px; }
  .stage-pill strong { font-size: 1.36rem; }
  .stage-pill-multiplier strong { font-size: 1.55rem; }
}

/* Even bigger HUD numerals at fair-display sizes */
@media (min-width: 1280px) {
  .stage-pill { padding: 12px 18px; min-width: 108px; }
  .stage-pill strong { font-size: 1.65rem; }
  .stage-pill-multiplier strong { font-size: 1.85rem; }

  .arcade-marquee { gap: 22px; padding: 16px 28px; }
  .arcade-marquee-logo { width: 84px; }
  .arcade-marquee-title { font-size: 1.85rem; }
  .arcade-marquee-sub { font-size: 0.82rem; }
  .arcade-marquee-lights span { width: 11px; height: 11px; }

  .arcade-plinth { padding: 12px 24px; gap: 26px; }
  .arcade-key { font-size: 0.84rem; }
  .arcade-key kbd { height: 30px; min-width: 36px; font-size: 0.82rem; }
}

@media (min-width: 1600px) {
  .stage-pill strong { font-size: 1.85rem; }
  .stage-pill-multiplier strong { font-size: 2.1rem; }
  .arcade-marquee-logo { width: 100px; }
  .arcade-marquee-title { font-size: 2.1rem; }
}

/* =========================================================================
   PLAYER + ENTITIES
   ========================================================================= */

.player {
  position: absolute;
  left: 82px; bottom: 110px;
  width: 268px;
  z-index: 6;
  transform-origin: center bottom;
  pointer-events: none;
  will-change: transform;
}
.player img { width: 100%; filter: drop-shadow(0 18px 26px rgba(10, 17, 24, 0.18)); }
.player.running img { animation: riderFloat 420ms ease-in-out infinite alternate; }
.player.powered img {
  filter:
    drop-shadow(0 0 14px rgba(255, 211, 61, 0.85))
    drop-shadow(0 18px 26px rgba(10, 17, 24, 0.16));
  animation: poweredGlow 700ms ease-in-out infinite alternate;
}
.player.crouching { width: 284px; }
.player.crouching img, .player.jumping img { animation: none; }

.player-shadow {
  position: absolute;
  left: 44px; right: 40px; bottom: 8px;
  height: 24px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(17, 19, 21, 0.32), transparent 70%);
  transform: scale(1);
  transition: transform 120ms linear, opacity 120ms linear;
  pointer-events: none;
}

.entity-layer { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.entity { position: absolute; display: block; will-change: transform; }
.entity img {
  width: 100%; height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 16px 18px rgba(10, 17, 24, 0.2));
}
.entity.powerup img {
  filter:
    drop-shadow(0 0 10px rgba(255, 197, 54, 0.85))
    drop-shadow(0 16px 18px rgba(10, 17, 24, 0.14));
}
.entity.ekleta img {
  filter:
    drop-shadow(0 0 16px rgba(255, 211, 61, 0.85))
    drop-shadow(0 16px 18px rgba(10, 17, 24, 0.14));
  animation: ekletaPulse 1.2s ease-in-out infinite;
}

/* =========================================================================
   COUNTDOWN / BANNERS
   ========================================================================= */

.countdown {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(3.5rem, 14vw, 8rem);
  color: var(--kleta-yellow-soft);
  text-shadow:
    0 0 18px rgba(255, 211, 61, 0.7),
    0 0 36px rgba(255, 211, 61, 0.4),
    0 12px 30px rgba(10, 17, 24, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease, transform 220ms var(--ease-pop);
  transform: scale(0.7);
  letter-spacing: 0.02em;
}
.countdown.visible { opacity: 1; transform: scale(1); }

.message-banner {
  position: absolute;
  top: 64px;
  left: 50%;
  z-index: 11;
  padding: 9px 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--kleta-yellow-soft), var(--kleta-yellow-deep));
  color: #4a2a00;
  font-family: var(--font-display);
  font-size: 0.94rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
  box-shadow:
    0 0 22px rgba(255, 211, 61, 0.5),
    0 12px 22px rgba(255, 174, 0, 0.36),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transform: translate(-50%, -18px);
  opacity: 0;
  transition: transform 220ms var(--ease-pop), opacity 180ms ease;
  pointer-events: none;
}
.message-banner.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 720px) {
  .message-banner { top: 96px; padding: 12px 22px; font-size: 1.1rem; }
}

/* =========================================================================
   PAUSE BUTTON
   ========================================================================= */

.pause-button {
  position: absolute;
  top: 52px; right: 12px;
  z-index: 10;
  width: 40px; height: 40px;
  border-radius: 999px;
  background: rgba(15, 20, 24, 0.85);
  border: 1px solid rgba(255, 211, 61, 0.32);
  color: var(--paper);
  font-size: 1.1rem;
  line-height: 1;
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  transition: transform 140ms var(--ease-pop), background 140ms ease;
}
.pause-button:hover { background: rgba(15, 20, 24, 0.95); transform: scale(1.06); }

@media (min-width: 720px) {
  .pause-button { top: 80px; right: 18px; width: 48px; height: 48px; font-size: 1.4rem; }
}

body.gameplay-active .pause-button { display: flex; }

/* =========================================================================
   MODALS (game over, pause) — sit outside .stage-fit so portrait phones don't clip
   ========================================================================= */

.modal-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: calc(var(--safe-top) + 12px) 14px calc(var(--safe-bottom) + 12px);
  background: rgba(8, 12, 18, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.modal-overlay.hidden { display: none; }

/* The skip-email modal lives at the document root (not inside a screen) so
   it can be invoked from any flow. Anchor it to the viewport. */
#skip-email-modal { position: fixed; z-index: 100; }
.skip-email-card h2 { margin: 0 0 8px; font-family: var(--font-display); font-size: 1.35rem; }
.skip-email-card p  { margin: 0 0 16px; font-size: 0.95rem; line-height: 1.4; color: rgba(17, 19, 21, 0.78); }
.skip-email-card .form-actions { display: flex; gap: 10px; justify-content: stretch; }
.skip-email-card .form-actions > * { flex: 1; min-height: 48px; }

.modal-card {
  width: min(420px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 22px 22px 18px;
  text-align: center;
  color: var(--ink);
  border-radius: 24px;
  background:
    linear-gradient(180deg, var(--paper-soft) 0%, #ffe9af 100%);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow:
    var(--shadow-lift-lg),
    0 0 0 4px rgba(255, 211, 61, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

/* Game-over content */
.game-over-logo { width: 68px; margin: 0 auto 6px; }

.game-over-run {
  margin: 0 0 4px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(17, 19, 21, 0.58);
}

.game-over-card-inner h2 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.55rem;
  letter-spacing: -0.01em;
  line-height: 1.05;
}

.game-over-score, .game-over-session {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 5px 0;
  padding: 9px 14px;
  border-radius: 14px;
  background: rgba(17, 19, 21, 0.06);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(17, 19, 21, 0.7);
}

.game-over-score strong, .game-over-session strong {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.02em;
}

.game-over-session {
  background: linear-gradient(180deg, rgba(255, 231, 126, 0.5), rgba(255, 197, 38, 0.22));
  border: 1px solid rgba(244, 180, 0, 0.32);
}

.game-over-status {
  margin: 10px 0 14px;
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 600;
  color: rgba(17, 19, 21, 0.7);
}

.game-over-actions { display: flex; gap: 8px; }
.game-over-actions > .hidden { display: none; }
.game-over-actions > * {
  flex: 1 1 0;
  min-height: 46px;
  padding: 0 8px;
  font-size: 0.88rem;
  border-radius: 999px;
}

.game-over-actions .ghost-button {
  color: var(--ink);
  background: rgba(17, 19, 21, 0.08);
  border-color: rgba(17, 19, 21, 0.14);
}
.game-over-actions .ghost-button:hover { background: rgba(17, 19, 21, 0.14); }

.pause-card {
  display: grid;
  gap: 10px;
  padding: 26px 22px;
}
.pause-card h2 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.7rem;
}
.pause-card .ghost-button {
  color: var(--ink);
  background: rgba(17, 19, 21, 0.08);
  border-color: rgba(17, 19, 21, 0.14);
}

@media (min-width: 720px) {
  .modal-card { width: min(480px, 100%); padding: 28px 26px 24px; border-radius: 28px; }
  .game-over-logo { width: 92px; margin-bottom: 10px; }
  .game-over-run { font-size: 0.74rem; }
  .game-over-card-inner h2 { font-size: 2.05rem; margin-bottom: 18px; }
  .game-over-score, .game-over-session { margin: 6px 0; padding: 12px 18px; font-size: 0.86rem; border-radius: 16px; }
  .game-over-score strong, .game-over-session strong { font-size: 1.35rem; }
  .game-over-status { font-size: 1rem; margin: 12px 0 20px; }
  .game-over-actions > * { min-height: 52px; font-size: 0.98rem; padding: 0 14px; }
  .pause-card { padding: 32px 28px; gap: 14px; }
  .pause-card h2 { font-size: 2.1rem; }
}

/* =========================================================================
   TOUCH CONTROLS (desktop landscape baseline; mobile overrides further down)
   ========================================================================= */

.game-controls {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(var(--safe-bottom) + 14px);
  z-index: 14;
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 calc(var(--safe-left) + 18px) 0 calc(var(--safe-right) + 18px);
  pointer-events: none;
}

.game-controls-cluster { display: flex; gap: 12px; pointer-events: auto; }

.control-pad {
  width: 70px; height: 70px;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.04)),
    rgba(15, 20, 24, 0.66);
  border: 1px solid rgba(255, 211, 61, 0.24);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 12px 24px rgba(0, 0, 0, 0.42);
  color: var(--paper);
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  display: grid;
  place-items: center;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  touch-action: none;
  transition: transform 80ms ease, background 80ms ease;
}

.control-pad-jump {
  background:
    linear-gradient(180deg, var(--kleta-yellow-soft), var(--kleta-yellow-deep)),
    rgba(255, 220, 100, 0.2);
  color: var(--ink);
  border-color: rgba(255, 229, 124, 0.7);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    0 14px 28px rgba(255, 174, 0, 0.34);
}

.control-pad:active, .control-pad.pressed {
  transform: scale(0.93);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.08)),
    rgba(15, 20, 24, 0.72);
}
.control-pad-jump:active, .control-pad-jump.pressed {
  background:
    linear-gradient(180deg, var(--kleta-yellow) 0%, #d49600 100%);
}

body.touch-device.gameplay-active .game-controls { display: flex; }

@media (min-width: 720px) {
  .control-pad { width: 84px; height: 84px; border-radius: 26px; font-size: 1.7rem; }
  .game-controls { padding: 0 32px; bottom: calc(var(--safe-bottom) + 22px); }
}

@media (max-height: 420px) and (orientation: landscape) {
  .control-pad { width: 56px; height: 56px; border-radius: 18px; font-size: 1.2rem; }
  .game-controls { padding: 0 14px; bottom: calc(var(--safe-bottom) + 10px); }
  .game-controls-cluster { gap: 8px; }
}

/* =========================================================================
   INITIALS ENTRY
   ========================================================================= */

.initials-stage {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 18px 0 22px;
}

.initials-slot {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 6px;
  width: 78px;
  text-align: center;
}

.initials-arrow {
  width: 100%;
  height: 38px;
  border-radius: 12px;
  background: var(--glass-bg-2);
  border: 1px solid var(--glass-line-2);
  color: var(--paper);
  font-size: 0.86rem;
  display: grid;
  place-items: center;
  transition: background 100ms ease, transform 100ms ease;
}
.initials-arrow:active {
  background: rgba(255, 211, 61, 0.3);
  transform: scale(0.94);
}

.initials-letter {
  display: grid;
  place-items: center;
  height: 90px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 211, 61, 0.22), rgba(255, 199, 38, 0.08)),
    radial-gradient(circle at 50% 30%, rgba(255, 211, 61, 0.12), transparent 70%);
  border: 2px solid rgba(255, 211, 61, 0.5);
  color: var(--kleta-yellow);
  font-family: var(--font-display);
  font-size: 2.7rem;
  font-weight: 700;
  text-shadow:
    0 0 18px rgba(255, 211, 61, 0.5),
    0 0 36px rgba(255, 211, 61, 0.3);
  user-select: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* =========================================================================
   LEADERBOARD
   ========================================================================= */

.leaderboard-list {
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
  display: grid;
  gap: 8px;
  max-height: 56vh;
  overflow-y: auto;
}

.leaderboard-list li {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-line);
  font-weight: 600;
  transition: transform 140ms var(--ease-pop), background 140ms ease;
}
.leaderboard-list li:hover { transform: translateX(2px); background: rgba(255, 255, 255, 0.06); }

.leaderboard-list li.rank-1 {
  background: linear-gradient(135deg, rgba(255, 211, 61, 0.32), rgba(255, 199, 38, 0.1));
  border-color: rgba(255, 211, 61, 0.5);
  box-shadow: 0 0 24px rgba(255, 211, 61, 0.18);
}
.leaderboard-list li.rank-2 { background: rgba(192, 200, 210, 0.18); border-color: rgba(192, 200, 210, 0.32); }
.leaderboard-list li.rank-3 { background: rgba(205, 127, 50, 0.18); border-color: rgba(205, 127, 50, 0.32); }

.leaderboard-rank {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--kleta-yellow);
}
.leaderboard-list li.rank-1 .leaderboard-rank { color: var(--kleta-yellow-soft); }

.leaderboard-initials {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--paper);
}

.leaderboard-score {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--kleta-yellow-soft);
  white-space: nowrap;
}

.leaderboard-empty {
  display: block !important;
  text-align: center;
  padding: 36px 14px !important;
  color: rgba(255, 255, 255, 0.5);
  background: transparent !important;
  border: 1px dashed rgba(255, 255, 255, 0.14) !important;
}

/* =========================================================================
   TOASTS
   ========================================================================= */

.toast-stack {
  position: fixed;
  top: calc(var(--safe-top) + 12px);
  left: 50%;
  z-index: 50;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, #1d2330, #11161c);
  color: var(--paper);
  border: 1px solid rgba(255, 211, 61, 0.32);
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.4), 0 0 18px rgba(255, 211, 61, 0.18);
  animation: toast-in 200ms var(--ease-pop), toast-out 280ms ease 2.4s forwards;
}

/* =========================================================================
   ANIMATIONS
   ========================================================================= */

@keyframes drift {
  from { transform: scale(1.04) translateX(-1.2%); }
  to   { transform: scale(1.09) translateX(1.2%); }
}
@keyframes riderFloat {
  from { transform: translateY(0); }
  to   { transform: translateY(-4px); }
}
@keyframes poweredGlow {
  from { filter: drop-shadow(0 0 14px rgba(255, 211, 61, 0.7)) drop-shadow(0 18px 26px rgba(10, 17, 24, 0.16)); }
  to   { filter: drop-shadow(0 0 22px rgba(255, 211, 61, 1)) drop-shadow(0 18px 26px rgba(10, 17, 24, 0.16)); }
}
@keyframes floatLogo {
  from { transform: translateY(-4px) rotate(-0.6deg); }
  to   { transform: translateY(4px)  rotate(0.6deg); }
}
@keyframes toast-in  { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { from { opacity: 1; transform: translateY(0); }    to { opacity: 0; transform: translateY(-8px); } }
@keyframes ekletaPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}

/* =========================================================================
   TUTORIAL OVERLAY
   ========================================================================= */
.tutorial-overlay {
  position: absolute;
  inset: 0;
  z-index: 14;
  display: grid;
  place-items: center;
  padding: 8px;
  background: rgba(8, 12, 18, 0.72);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  pointer-events: none;
}
.tutorial-overlay.hidden { display: none; }

.tutorial-card {
  width: min(420px, 100%);
  padding: 16px 18px;
  border-radius: 18px;
  background: linear-gradient(180deg, var(--paper-soft), #ffe9af);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow-lift-lg), 0 0 0 4px rgba(255, 211, 61, 0.18);
  text-align: left;
}

.tutorial-card h3 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  text-align: center;
}

.tutorial-controls {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  display: grid;
  gap: 6px;
  font-size: 0.86rem;
  font-weight: 500;
}

.tutorial-controls li { display: flex; align-items: center; gap: 8px; }

.tutorial-key {
  display: inline-grid;
  place-items: center;
  min-width: 32px;
  height: 28px;
  padding: 0 8px;
  border-radius: 8px;
  background: #2a2e35;
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}
.tutorial-key-jump  { background: linear-gradient(180deg, var(--kleta-yellow-soft), var(--kleta-yellow-deep)); color: var(--ink); }
.tutorial-key-duck  { background: linear-gradient(180deg, #6e7480, #2a2e35); }
.tutorial-key-pickup{ background: linear-gradient(180deg, var(--kleta-yellow-soft), var(--kleta-yellow-deep)); color: var(--ink); }

.tutorial-tip {
  margin: 6px 0 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: rgba(17, 19, 21, 0.66);
  text-align: center;
}

/* =========================================================================
   TUTORIAL SCREEN — full-page guide accessible from the start menu
   ========================================================================= */

.tutorial-items {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: grid;
  gap: 12px;
}

.tutorial-item {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.tutorial-item-bonus {
  background: linear-gradient(180deg, rgba(255, 211, 61, 0.16), rgba(255, 211, 61, 0.06));
  border-color: rgba(255, 211, 61, 0.35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 0 18px rgba(255, 211, 61, 0.08);
}

.tutorial-item-art {
  width: 92px;
  height: 92px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.22);
  overflow: hidden;
}

.tutorial-item-art img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.35));
}

.tutorial-item-text h3 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--paper);
}

.tutorial-item-text p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.78);
}

.tutorial-item-text strong {
  color: var(--kleta-yellow-soft);
  font-weight: 700;
}

.tutorial-controls-summary {
  margin: 0 0 18px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--glass-line);
}

.tutorial-controls-summary h3 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--kleta-yellow-soft);
}

.tutorial-controls-summary ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.86);
}

.tutorial-controls-summary li {
  display: flex;
  align-items: center;
  gap: 10px;
}

@media (max-width: 560px) {
  .tutorial-item {
    grid-template-columns: 72px 1fr;
    gap: 12px;
    padding: 10px 12px;
  }
  .tutorial-item-art { width: 72px; height: 72px; }
  .tutorial-item-text h3 { font-size: 0.98rem; }
  .tutorial-item-text p { font-size: 0.84rem; }
  .tutorial-controls-summary ul { grid-template-columns: 1fr; }
}

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

@media (max-width: 720px) {
  .form-card { padding: 22px 16px 16px; }
}

@media (max-height: 480px) and (orientation: landscape) {
  .form-card { padding: 16px 18px 14px; }
  .form-header { margin-bottom: 10px; }
  .form-header h2 { font-size: 1.45rem; }
  .form-header p { font-size: 0.84rem; }
  .form-card-wide { width: min(580px, 92vw); }
  .character-card { flex-basis: min(160px, 32vw); }
  .character-art img { width: 80%; }
  .form-actions > * { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .stage-backdrop, .cover-backdrop, .arcade-marquee-lights span,
  .player.running img, .player.powered img, .cover-logo { animation: none; }
  * { transition-duration: 0.001ms !important; }
}

/* Hide HUD logo on any phone-sized viewport (handheld provides its own brand) */
@media (max-width: 720px), (max-height: 540px) {
  .screen-game .stage-brand { display: none; }
}

/* =========================================================================
   KLETA HANDHELD — portrait phones only.
   An original retro-handheld design with Kleta branding.
   ========================================================================= */
@media (orientation: portrait) and (max-width: 720px) {

  /* Device body — warm cream plastic with brand accent stripe at top */
  .screen-game {
    background:
      /* corner screw heads */
      radial-gradient(circle, var(--plastic-cream-shadow) 0 3.5px, transparent 4.5px) 14px 14px / 18px 18px no-repeat,
      radial-gradient(circle, var(--plastic-cream-shadow) 0 3.5px, transparent 4.5px) calc(100% - 14px) 14px / 18px 18px no-repeat,
      radial-gradient(circle, var(--plastic-cream-shadow) 0 3.5px, transparent 4.5px) 14px calc(100% - 14px) / 18px 18px no-repeat,
      radial-gradient(circle, var(--plastic-cream-shadow) 0 3.5px, transparent 4.5px) calc(100% - 14px) calc(100% - 14px) / 18px 18px no-repeat,
      /* warm cream body with subtle vertical shading */
      linear-gradient(180deg, var(--plastic-cream) 0%, var(--plastic-cream-mid) 70%, var(--plastic-cream-deep) 100%);
  }

  .screen-game.active {
    justify-content: flex-start;
    padding: calc(var(--safe-top) + 28px) 14px calc(var(--safe-bottom) + 14px);
    align-items: stretch;
    gap: 14px;
  }

  /* Subtle highlight + shadow rim (gives the body a molded plastic feel) */
  .screen-game.active::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.45) 0%, transparent 8%, transparent 92%, rgba(0, 0, 0, 0.22) 100%),
      linear-gradient(90deg, rgba(0, 0, 0, 0.06) 0%, transparent 6%, transparent 94%, rgba(0, 0, 0, 0.06) 100%);
    pointer-events: none;
    z-index: 1;
  }

  /* Power LED — sits at top-left of the device */
  .screen-game.active::after {
    content: "";
    position: absolute;
    top: calc(var(--safe-top) + 32px);
    left: 26px;
    width: 11px;
    height: 11px;
    border-radius: 999px;
    background: radial-gradient(circle at 30% 30%, #ff8d76, var(--kleta-coral-deep));
    box-shadow:
      0 0 12px rgba(230, 67, 45, 0.7),
      0 0 24px rgba(230, 67, 45, 0.35),
      inset 0 1px 0 rgba(255, 255, 255, 0.65);
    z-index: 6;
    pointer-events: none;
    animation: ledBlink 3s ease-in-out infinite;
  }

  @keyframes ledBlink {
    0%, 95%, 100% { opacity: 1; }
    97% { opacity: 0.45; }
  }

  /* LCD — bigger, properly proportioned, with dark bezel */
  .screen-game .stage-fit {
    margin: 14px auto 22px;
    height: clamp(280px, 50dvh, 480px);
    border-radius: 8px;
    background: url("backgroundmobile.png") center bottom / cover no-repeat;
    box-shadow:
      0 0 0 12px #1a1d22,
      0 0 0 13px rgba(0, 0, 0, 0.55),
      0 0 0 14px rgba(255, 255, 255, 0.4),
      inset 0 0 18px rgba(0, 0, 0, 0.45),
      0 12px 22px rgba(0, 0, 0, 0.32);
    overflow: hidden;
    position: relative;
    z-index: 2;
  }

  /* Decorative LCD labels: "KLETA" wordmark above + "DOT MATRIX" tag below */
  .screen-game .stage-fit::before {
    content: "● POWER";
    position: absolute;
    top: -28px;
    left: 24px;
    font-family: var(--font-mono);
    font-size: 0.56rem;
    font-weight: 700;
    letter-spacing: 0.22em;
    color: rgba(60, 50, 20, 0.72);
    z-index: 6;
    pointer-events: none;
  }

  .screen-game .stage-fit::after {
    content: "KLETA  ·  CICLISTA URBÀ";
    position: absolute;
    top: -28px;
    right: 18px;
    font-family: var(--font-mono);
    font-size: 0.56rem;
    font-weight: 700;
    letter-spacing: 0.22em;
    color: rgba(60, 50, 20, 0.72);
    z-index: 6;
    pointer-events: none;
  }

  /* Game world inside LCD */
  .screen-game .stage-backdrop {
    background: url("backgroundmobile.png") center bottom / cover no-repeat;
  }
  .screen-game .stage-world {
    top: auto; bottom: 0; left: 0;
    transform-origin: bottom left;
    transform: scale(var(--stage-scale));
    border-radius: 4px;
    overflow: hidden;
  }
  /* The LCD already shows the city + road; hide the duplicate world chrome */
  .screen-game .stage-backdrop,
  .screen-game .stage-road,
  .screen-game .stage-road-glow { display: none; }

  /* HUD inside the LCD — compact, monospaced, brand-yellow numerals */
  .screen-game .stage-hud {
    top: 10px; left: 10px; right: 10px;
    bottom: auto;
    padding: 0;
    gap: 6px;
    justify-content: flex-end;
    flex-wrap: nowrap;
  }
  .screen-game .stage-hud .stage-brand {
    padding: 3px 6px;
    border-radius: 8px;
    margin-right: auto;
  }
  .screen-game .stage-hud .stage-brand img { width: 48px; }
  .screen-game .stage-pill {
    background: rgba(15, 20, 24, 0.85);
    padding: 6px 10px;
    border-radius: 10px;
    min-width: 0;
    flex: 0 1 auto;
    border-color: rgba(255, 211, 61, 0.28);
  }
  .screen-game .stage-pill-label { font-size: 0.58rem; margin-bottom: 1px; letter-spacing: 0.14em; }
  .screen-game .stage-pill strong { font-size: 1rem; font-family: var(--font-mono); letter-spacing: 0.02em; }

  .screen-game .pause-button { display: none !important; }

  /* ====== CONTROL DECK ====== */
  .screen-game .game-controls {
    position: relative;
    left: auto; right: auto; bottom: auto;
    transform: none;
    width: 100%;
    margin-top: auto;
    margin-bottom: calc(var(--safe-bottom) + 28px);
    padding: 0 6px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 22px 8px;
    align-items: center;
    z-index: 5;
    pointer-events: none;
  }

  /* Kleta wordmark sits between the D-pad and A/B */
  .screen-game.active .game-controls::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 12px;
    transform: translateX(-50%) rotate(-6deg);
    width: 110px;
    height: 38px;
    background: url("logo3.png") center / contain no-repeat;
    pointer-events: none;
    z-index: 0;
    filter: drop-shadow(0 2px 0 rgba(120, 80, 0, 0.18));
  }

  /* Recessed deck plate behind the controls */
  .screen-game.active .game-controls::after {
    content: "";
    position: absolute;
    left: -2px; right: -2px;
    top: -8px; bottom: -34px;
    background:
      linear-gradient(180deg, rgba(0, 0, 0, 0.06), transparent 14%),
      radial-gradient(ellipse 60% 80% at 50% 60%, rgba(0, 0, 0, 0.03), transparent 70%);
    box-shadow:
      inset 0 1px 0 rgba(0, 0, 0, 0.14),
      inset 0 2px 0 rgba(255, 255, 255, 0.4);
    pointer-events: none;
    z-index: -1;
  }

  body.is-game .game-controls { display: grid !important; }
  body.is-game:not(.gameplay-active) .game-controls { opacity: 0.55; pointer-events: none; }

  /* ====== D-PAD (left cluster) ====== */
  .screen-game .game-controls-left {
    grid-column: 1; grid-row: 1;
    position: relative;
    width: 178px; height: 178px;
    justify-self: center;
    display: block;
    pointer-events: auto;
  }
  /* Vertical arm */
  .screen-game .game-controls-left::before {
    content: "";
    position: absolute;
    top: 0; bottom: 0;
    left: 50%;
    width: 60px;
    transform: translateX(-50%);
    background:
      linear-gradient(180deg, #3a3e44 0%, #1a1d22 50%, #2c2f35 100%);
    border-radius: 12px;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.14),
      inset 0 -3px 5px rgba(0, 0, 0, 0.45),
      0 2px 5px rgba(0, 0, 0, 0.55);
    z-index: 0;
  }
  /* Horizontal arm */
  .screen-game .game-controls-left::after {
    content: "";
    position: absolute;
    left: 0; right: 0;
    top: 50%;
    height: 60px;
    transform: translateY(-50%);
    background:
      linear-gradient(90deg, #3a3e44 0%, #1a1d22 50%, #2c2f35 100%);
    border-radius: 12px;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.14),
      inset 0 -3px 5px rgba(0, 0, 0, 0.45),
      0 2px 5px rgba(0, 0, 0, 0.55);
    z-index: 0;
  }
  /* Center pivot */
  .screen-game .game-controls-left .dpad-center {
    position: absolute;
    left: 50%; top: 50%;
    width: 42px; height: 42px;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle at 35% 30%, #4d5158, #1a1d22 70%);
    border-radius: 999px;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.18),
      0 1px 3px rgba(0, 0, 0, 0.55);
    z-index: 1;
    pointer-events: none;
  }
  /* Arrow buttons on each arm */
  .screen-game .game-controls-left .dpad-button {
    position: absolute;
    width: 60px; height: 60px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    color: rgba(255, 255, 255, 0.82);
    font-size: 1.05rem;
    line-height: 1;
    display: grid; place-items: center;
    z-index: 2;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .screen-game .game-controls-left .dpad-up    { top: 0;    left: 50%; transform: translateX(-50%); }
  .screen-game .game-controls-left .dpad-down  { bottom: 0; left: 50%; transform: translateX(-50%); }
  .screen-game .game-controls-left .dpad-left  { left: 0;   top: 50%;  transform: translateY(-50%); }
  .screen-game .game-controls-left .dpad-right { right: 0;  top: 50%;  transform: translateY(-50%); }

  .screen-game .game-controls-left .dpad-button:active,
  .screen-game .game-controls-left .dpad-button.pressed {
    background: rgba(255, 211, 61, 0.12);
    box-shadow: inset 0 0 0 1px rgba(255, 211, 61, 0.5);
  }

  /* ====== A / B BUTTONS (right cluster) ====== */
  .screen-game .game-controls-right {
    grid-column: 2; grid-row: 1;
    width: 178px; height: 178px;
    justify-self: center;
    display: block;
    position: relative;
    pointer-events: auto;
  }

  .screen-game .game-controls-right .control-pad {
    position: absolute;
    width: 82px; height: 82px;
    border-radius: 999px;
    padding: 0;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    font-size: 0;
  }
  .screen-game .game-controls-right .ab-icon { display: none; }
  .screen-game .game-controls-right .ab-label {
    font-size: 1.85rem;
    font-weight: 700;
    font-family: var(--font-display);
  }

  /* B button — coral (Kleta accent) duck */
  .screen-game .game-controls-right .control-pad-duck {
    left: 0; bottom: 14px;
    background:
      radial-gradient(circle at 32% 28%, #ff9d8e 0%, var(--kleta-coral) 40%, var(--kleta-coral-deep) 100%);
    border: 1px solid rgba(120, 30, 10, 0.6);
    color: rgba(255, 255, 255, 0.96);
    box-shadow:
      inset 0 2px 0 rgba(255, 255, 255, 0.32),
      inset 0 -4px 8px rgba(120, 30, 10, 0.45),
      0 6px 12px rgba(180, 60, 40, 0.5),
      0 0 0 3px rgba(255, 255, 255, 0.05);
  }

  /* A button — Kleta yellow jump */
  .screen-game .game-controls-right .control-pad-jump {
    right: 0; top: 14px;
    background:
      radial-gradient(circle at 32% 28%, var(--kleta-yellow-glow) 0%, var(--kleta-yellow-deep) 50%, #a87a00 100%);
    border: 1px solid rgba(120, 80, 0, 0.55);
    color: rgba(50, 30, 0, 0.92);
    box-shadow:
      inset 0 2px 0 rgba(255, 255, 255, 0.55),
      inset 0 -4px 8px rgba(110, 70, 0, 0.42),
      0 6px 12px rgba(180, 130, 0, 0.45),
      0 0 0 3px rgba(255, 255, 255, 0.05);
  }

  .screen-game .game-controls-right .control-pad:active,
  .screen-game .game-controls-right .control-pad.pressed {
    transform: translateY(2px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  }

  /* Engraved A/B labels under the buttons */
  .screen-game .game-controls-right .control-pad-duck::after,
  .screen-game .game-controls-right .control-pad-jump::after {
    position: absolute;
    bottom: -20px;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    font-weight: 700;
    color: rgba(50, 35, 5, 0.72);
    letter-spacing: 0.06em;
  }
  .screen-game .game-controls-right .control-pad-duck::after { content: "B"; left: 50%; transform: translateX(-50%); }
  .screen-game .game-controls-right .control-pad-jump::after { content: "A"; left: 50%; transform: translateX(-50%); }

  /* ====== START / SELECT pills ====== */
  .screen-game .game-controls-middle {
    grid-column: 1 / span 2;
    grid-row: 2;
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-top: 12px;
    margin-bottom: 8px;
    transform: rotate(-12deg);
    pointer-events: auto;
  }
  .screen-game .pill-button {
    width: 82px;
    height: 26px;
    padding: 0;
    border-radius: 999px;
    background: linear-gradient(180deg, #757b87 0%, #3e424a 100%);
    border: 1px solid rgba(0, 0, 0, 0.45);
    color: rgba(255, 255, 255, 0.95);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.22),
      inset 0 -1px 0 rgba(0, 0, 0, 0.45),
      0 3px 6px rgba(0, 0, 0, 0.32);
    position: relative;
  }
  .screen-game .pill-button .pill-label {
    font-family: var(--font-mono);
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.22em;
    line-height: 1;
  }
  .screen-game #select-button::after,
  .screen-game #start-button::after {
    position: absolute;
    top: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-mono);
    font-size: 0.46rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: rgba(50, 35, 5, 0.72);
  }
  .screen-game #select-button::after { content: "SELECT"; }
  .screen-game #start-button::after  { content: "START"; }
  .screen-game .pill-button:active,
  .screen-game .pill-button.pressed { transform: translateY(1px); }

  /* ====== Speaker grille ====== */
  .screen-game .gameboy-speaker {
    position: absolute;
    right: 18px;
    bottom: calc(var(--safe-bottom) + 16px);
    width: 60px;
    height: 56px;
    pointer-events: none;
    background-image: repeating-linear-gradient(
      62deg,
      rgba(50, 35, 5, 0.34) 0,
      rgba(50, 35, 5, 0.34) 3px,
      transparent 3px,
      transparent 9px
    );
    -webkit-mask-image: linear-gradient(180deg, transparent 0%, black 30%, black 100%);
            mask-image: linear-gradient(180deg, transparent 0%, black 30%, black 100%);
    border-radius: 4px;
    z-index: 3;
    opacity: 0.85;
  }
}

/* =========================================================================
   Non-mobile: hide Game Boy-only buttons (up/down arrows, Start/Select).
   ========================================================================= */
@media (min-width: 721px), (orientation: landscape) {
  .game-controls .dpad-up,
  .game-controls .dpad-down,
  .game-controls .game-controls-middle,
  .game-controls .gameboy-speaker,
  .game-controls .dpad-center {
    display: none !important;
  }
  .game-controls .ab-label { display: none; }
}
