:root {
  --blue: #2b8be3;
  --teal: #3bd9d6;
  --yellow: #ffd933;
  --ink: #1d1d1f;
  --sky: #2b8be3;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  /* Extra air after the notch / status bar — iOS uses 14–18pt. */
  --chrome-pad: 18px;
  --chrome-top: calc(var(--safe-top) + var(--chrome-pad));
  --chrome-right: calc(var(--safe-right) + var(--chrome-pad));
  --chrome-bottom: calc(var(--safe-bottom) + var(--chrome-pad));
  --chrome-left: calc(var(--safe-left) + var(--chrome-pad));
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: #0e3d6b;
  color: #fff;
  font-family: "Avenir Next", Avenir, Nunito, system-ui, -apple-system, sans-serif;
  font-weight: 700;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#frame {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background:
    linear-gradient(180deg, var(--blue) 0%, var(--teal) 100%);
}

#frame.menu-open #stage {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
}

#orientation-note {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 30;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  background: linear-gradient(160deg, #0e3d6b, #176f88);
  color: #fff;
  text-align: center;
}
#orientation-note > span { font-size: 3rem; line-height: 1; }
#orientation-note strong { font-size: 1.5rem; font-weight: 900; }
#orientation-note small { font-size: 1rem; opacity: 0.86; }

/* Size against the frame (visual viewport), not 100vh. Mobile Safari's
   100vh is taller than the visible tab, and a flex-centered stage then
   clips the top chrome. */
#stage {
  position: relative;
  width: min(100%, calc(100vh * 750 / 1334));
  height: min(100%, calc(100vw * 1334 / 750));
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
  background: #2b8be3;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.12), 0 18px 50px rgba(0,0,0,0.28);
}

@supports (height: 100dvh) {
  #stage {
    width: min(100%, calc(100dvh * 750 / 1334));
    height: min(100%, calc(100dvw * 1334 / 750));
  }
}

/* Tall phones: fill the screen (aspect-fill, matching iOS .aspectFill). */
@media (orientation: portrait) and (max-aspect-ratio: 750/1334) {
  #stage {
    width: 100%;
    height: 100%;
  }
  #stage canvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.layer.overlay {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding:
    calc(var(--chrome-top) + 52px)
    max(24px, var(--chrome-right))
    calc(var(--chrome-bottom) + 24px)
    max(24px, var(--chrome-left));
  background: rgba(16, 74, 128, 0.28);
}

#overlay-home,
#overlay-pause,
#overlay-over,
#overlay-party,
#overlay-lobby,
#overlay-countdown,
#overlay-party-over,
#overlay-missions,
#overlay-board {
  background: rgba(12, 52, 96, 0.55);
  backdrop-filter: blur(6px);
}

.hidden { display: none !important; }

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(29, 29, 31, 0.72);
}

#hud {
  pointer-events: none;
}
#hud .icon-btn { pointer-events: auto; }

#btn-pause, #btn-mute {
  position: absolute;
  top: var(--chrome-top);
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: rgba(0,0,0,0.22);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}
#btn-pause { left: var(--chrome-left); }
#btn-mute { left: calc(var(--chrome-left) + 52px); }

#best-label {
  position: absolute;
  top: calc(var(--chrome-top) + 8px);
  left: 0;
  right: 0;
  text-align: center;
  font-size: 18px;
  font-weight: 800;
  text-shadow: 0 2px 8px rgba(0,0,0,0.35);
}

#coin-wrap {
  position: absolute;
  top: calc(var(--chrome-top) + 4px);
  right: var(--chrome-right);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 20px;
  font-weight: 800;
  text-shadow: 0 2px 8px rgba(0,0,0,0.35);
}
#coin-wrap img { width: 22px; height: 20px; object-fit: contain; }

#score-label {
  position: absolute;
  top: calc(var(--chrome-top) + 70px);
  left: 0;
  right: 0;
  text-align: center;
  font-size: 92px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  text-shadow: 0 6px 18px rgba(0,0,0,0.28);
}

#daily-badge {
  position: absolute;
  top: calc(var(--chrome-top) + 168px);
  left: 0;
  right: 0;
  text-align: center;
  font-size: 18px;
  font-weight: 800;
  color: #ffd933;
  text-shadow: 0 2px 8px rgba(0,0,0,0.35);
}

#bonus-label {
  position: absolute;
  top: calc(var(--chrome-top) + 54px);
  right: var(--chrome-right);
  font-size: 24px;
  font-weight: 800;
}

#combo-label {
  position: absolute;
  top: calc(var(--safe-top) + 200px);
  left: 0;
  right: 0;
  text-align: center;
  font-size: 32px;
  font-weight: 900;
  color: #ffd933;
  text-shadow: 0 3px 10px rgba(0,0,0,0.35);
  transform-origin: center;
}

#bag-flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease-out;
}
#bag-flash.on { opacity: 0.45; transition: none; }

.tutorial-cue {
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  pointer-events: none;
}
.tutorial-card {
  width: min(310px, 84vw);
  margin-top: 170px;
  padding: 16px 18px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 12px;
  align-items: center;
  border: 2px solid rgba(255,255,255,0.72);
  border-radius: 18px;
  background: rgba(8, 32, 64, 0.84);
  box-shadow: 0 14px 34px rgba(0,0,0,0.3);
  text-align: left;
  backdrop-filter: blur(8px);
}
.tutorial-tap {
  grid-row: 1 / 3;
  font-size: 2rem;
  animation: tutorial-tap 0.8s ease-in-out infinite alternate;
}
.tutorial-card strong { font-size: 1rem; font-weight: 900; }
.tutorial-card > span:last-child { font-size: 0.82rem; line-height: 1.25; opacity: 0.88; }
@keyframes tutorial-tap {
  from { transform: translateY(2px) scale(0.96); }
  to { transform: translateY(-3px) scale(1.04); }
}

#shield-pop {
  position: absolute;
  top: 46%;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 72px;
  pointer-events: none;
  animation: shield-pop 0.7s ease-out;
}
@keyframes shield-pop {
  0% { transform: scale(0.4); opacity: 1; }
  70% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1.4); opacity: 0; }
}

.coin-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  pointer-events: auto;
}
.coin-pill img { width: 40px; height: 36px; object-fit: contain; }
.coin-pill-text {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.05;
}
.coin-pill-text span:first-child {
  font-size: 20px;
  font-weight: 900;
}
.coin-caption {
  font-size: 12px;
  font-weight: 600;
  opacity: 0.95;
}

.over-coin-pill { margin-top: 14px; }

.overlay-chrome {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: var(--chrome-top) var(--chrome-right) 10px var(--chrome-left);
  pointer-events: none;
}
.overlay-chrome > * { pointer-events: auto; }

.home-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
}
.home-links .ghost { margin-top: 0; }

.boost-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
  pointer-events: auto;
}
.boost-chip {
  min-width: 104px;
  min-height: 40px;
  padding: 8px 10px;
  border: 0;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
}
.home-section-label {
  margin-top: 14px;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.82;
}
.boost-chip.armed {
  background: rgba(255, 217, 51, 0.55);
  color: #1d1d1f;
}

.sheet {
  justify-content: flex-start;
  padding-top: 0;
  background: rgba(12, 52, 96, 0.72);
  backdrop-filter: blur(8px);
}
.sheet .overlay-chrome {
  position: relative;
  flex-shrink: 0;
  width: 100%;
  margin-bottom: 8px;
}
.sheet-back {
  border: 0;
  background: transparent;
  color: #fff;
  font: inherit;
  font-weight: 800;
  min-height: 44px;
  cursor: pointer;
}
.sheet-kicker {
  margin-bottom: 8px;
  opacity: 0.9;
}

.store-carousel {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  justify-content: center;
  margin: 8px 0 4px;
}
.store-viewport {
  position: relative;
  width: min(220px, 56vw);
  height: 220px;
  overflow: hidden;
  flex: 0 0 min(220px, 56vw);
  touch-action: pan-y;
}
.store-track {
  display: flex;
  height: 100%;
  will-change: transform;
  transition: transform 0.3s cubic-bezier(0.22, 0.85, 0.32, 1);
}
.store-track.no-anim { transition: none; }
.store-slide {
  flex: 0 0 min(220px, 56vw);
  width: min(220px, 56vw);
  height: 220px;
}
.store-slide img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  -webkit-user-drag: none;
}
.carousel-nav {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 22px;
  background: rgba(255,255,255,0.16);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  z-index: 1;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}
.carousel-nav:focus-visible { box-shadow: 0 0 0 2px rgba(255,255,255,0.55); }
.carousel-nav:disabled { opacity: 0.35; }

.store-meta { min-height: 4.4rem; }
.store-meta.anim-next { animation: store-meta-in 0.28s ease-out; }
.store-meta.anim-prev { animation: store-meta-in-rev 0.28s ease-out; }
@keyframes store-meta-in {
  from { opacity: 0; transform: translateX(18px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes store-meta-in-rev {
  from { opacity: 0; transform: translateX(-18px); }
  to { opacity: 1; transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce) {
  .store-track { transition: none; }
  .store-meta.anim-next,
  .store-meta.anim-prev { animation: none; }
}

#store-mult { margin-top: 4px; opacity: 0.92; }
#btn-store-use.in-use { opacity: 0.7; }

.dots {
  display: flex;
  gap: 6px;
  margin-top: 16px;
}
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
}
.dot.on { background: #fff; transform: scale(1.35); }

.themes-list {
  width: min(420px, 92%);
  max-height: 68vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  pointer-events: auto;
}
.theme-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 12px 12px 12px 10px;
  border: 0;
  border-radius: 16px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  text-align: left;
  font: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  box-shadow: inset 3px 0 0 0 transparent;
}
.theme-row:hover { background: rgba(255,255,255,0.18); }
.theme-row:focus-visible {
  box-shadow: inset 4px 0 0 0 #fff, 0 0 0 2px rgba(255,255,255,0.4);
}
.theme-row.in-use {
  background: linear-gradient(90deg, rgba(255, 217, 51, 0.28), rgba(255,255,255,0.14) 42%);
  box-shadow: inset 4px 0 0 0 #ffd933;
}
.theme-row.in-use:hover {
  background: linear-gradient(90deg, rgba(255, 217, 51, 0.34), rgba(255,255,255,0.18) 42%);
}
.theme-row.in-use:focus-visible {
  box-shadow: inset 4px 0 0 0 #ffd933, 0 0 0 2px rgba(255, 217, 51, 0.55);
}
.theme-copy { display: flex; flex-direction: column; }
.theme-copy em { font-style: normal; font-size: 0.85rem; opacity: 0.85; font-weight: 600; }
.theme-action {
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
  padding: 6px 12px;
  border-radius: 999px;
  line-height: 1.2;
}
.theme-action.is-using {
  background: #fff;
  color: #1a8f94;
}
.theme-action.is-owned {
  background: rgba(255,255,255,0.22);
  color: #fff;
}
.theme-action.is-buy {
  background: #ffd933;
  color: #1d1d1f;
}
.theme-swatch {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #2b8be3;
}
.theme-row.in-use .theme-swatch::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: inherit;
  background: rgba(0, 0, 0, 0.28);
  font-size: 16px;
  font-weight: 900;
  color: #fff;
}
.theme-day { background: linear-gradient(180deg, #2b8be3, #3bd9d6); }
.theme-night { background: linear-gradient(180deg, #171a52, #3a3f80); }
.theme-city { background: linear-gradient(180deg, #401f59, #8a5ea3); }
.theme-beach { background: linear-gradient(180deg, #ffd98c, #f4c36a); }
.theme-mountains { background: linear-gradient(180deg, #a6c7f2, #6f8fb8); }
.theme-sunset { background: linear-gradient(180deg, #ff8c59, #ffb56b); }
.theme-sakura { background: linear-gradient(180deg, #ffc2d6, #ffdce8); }
.theme-aurora { background: linear-gradient(180deg, #0a2447, #3cbc8c); }
.theme-synthwave { background: linear-gradient(180deg, #380d61, #e68cf2); }

.revive-overlay {
  background: rgba(0, 0, 0, 0.25);
  justify-content: center;
  padding-bottom: calc(80px + var(--safe-bottom));
}
.revive-card {
  position: relative;
  width: min(270px, 86vw);
  background: #fff;
  color: #111;
  border-radius: 20px;
  padding: 44px 20px 20px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  animation: revive-up 0.5s ease-out;
}
.revive-card p {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.35;
  white-space: pre-line;
}
.revive-x {
  position: absolute;
  top: 7px;
  left: 7px;
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  color: #222;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.revive-yes {
  margin-top: 20px;
  width: 180px;
  height: 50px;
  border: 0;
  border-radius: 25px;
  background: #2b99e3;
  color: #fff;
  font: inherit;
  font-weight: 900;
  font-size: 18px;
  cursor: pointer;
}
@keyframes revive-up {
  from { transform: translateY(110%); }
  to { transform: translateY(0); }
}

h1, h2 { font-weight: 900; letter-spacing: -0.02em; }
h1 { font-size: clamp(2.2rem, 8vw, 3.4rem); margin-top: 12px; }
h2 { font-size: clamp(1.8rem, 6vw, 2.6rem); }

.home-icon {
  width: 112px;
  height: 112px;
  border-radius: 26px;
  box-shadow: 0 14px 32px rgba(0,0,0,0.28);
}

.tagline { margin-top: 8px; font-size: 1.2rem; opacity: 0.95; }
.hint { margin-top: 22px; font-size: 1.05rem; }
.best-line { margin-top: 10px; opacity: 0.9; }
.over-score {
  font-size: 5rem;
  font-weight: 900;
  line-height: 1;
  margin: 12px 0 4px;
}

.primary, .ghost {
  pointer-events: auto;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 900;
}

@media (max-height: 720px) {
  :root { --chrome-pad: 14px; }
  .home-icon { width: 84px; height: 84px; }
  h1 { font-size: 2rem; }
  .primary { margin-top: 16px; padding: 12px 28px; }
  .hint { margin-top: 12px; }
  .layer.overlay {
    padding-top: calc(var(--chrome-top) + 44px);
    padding-bottom: calc(var(--chrome-bottom) + 16px);
  }
  #overlay-home,
  #overlay-over {
    justify-content: flex-start;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
    scrollbar-width: thin;
  }
  #overlay-home .home-links,
  #overlay-over .home-links { margin-top: 10px; }
  #overlay-home .ghost,
  #overlay-over .ghost { margin-top: 8px; }
  #overlay-home .home-section-label,
  #overlay-over .home-section-label { margin-top: 10px; }
  #overlay-home .boost-bar,
  #overlay-over .boost-bar { margin-top: 4px; }
}

.primary {
  margin-top: 28px;
  min-width: 220px;
  padding: 16px 36px;
  border-radius: 18px;
  background: var(--yellow);
  color: var(--ink);
  font-size: 1.35rem;
  box-shadow: 0 10px 24px rgba(0,0,0,0.22);
}
.primary:active { transform: translateY(1px); }

.ghost {
  margin-top: 12px;
  padding: 10px 18px;
  border-radius: 14px;
  background: rgba(255,255,255,0.16);
  color: #fff;
  font-size: 1rem;
}
#btn-share,
#btn-over-board { min-width: 140px; }

.site-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: #fff;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 800;
  opacity: 0.92;
}
.site-link:hover { text-decoration: underline; }

.skip-hint {
  position: absolute;
  bottom: calc(var(--safe-bottom) + 28px);
  left: 0;
  right: 0;
  font-size: 0.95rem;
  opacity: 0.85;
}

#btn-party,
#btn-home-board { min-width: 140px; }
.missions-launch { min-width: 220px; }
.missions-launch.claimable {
  background: rgba(255, 217, 51, 0.35);
}

.daily-row {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 8px;
  width: min(340px, 90vw);
  margin-top: 12px;
  pointer-events: auto;
}
.daily-btn {
  flex: 1;
  margin-top: 0;
  min-width: 0;
  font-size: 0.95rem;
  line-height: 1.15;
  white-space: normal;
}
.ghost-toggle {
  margin-top: 0;
  min-width: 104px;
  padding: 8px 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 0.78rem;
}
.ghost-icon { font-size: 1rem; }
.ghost-toggle.armed {
  background: rgba(255, 217, 51, 0.55);
  color: #1d1d1f;
}
#over-streak { color: #ffd933; }
.primary:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

#overlay-party .sheet-back,
#overlay-lobby .sheet-back {
  position: absolute;
  top: var(--chrome-top);
  left: max(4px, calc(var(--chrome-left) - 8px));
}

.party-stack {
  width: min(280px, 86vw);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  margin-top: 8px;
}
.party-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 18px;
  width: 100%;
  text-align: center;
  font-size: 0.95rem;
}
.party-field input,
#party-code {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border: 0;
  border-radius: 14px;
  font: inherit;
  font-weight: 800;
  text-align: center;
  letter-spacing: 0.04em;
  color: #1d1d1f;
  background: #fff;
  user-select: text;
  -webkit-user-select: text;
  pointer-events: auto;
}
#btn-party-create {
  width: 100%;
  min-width: 0;
  margin-top: 16px;
}
#party-code {
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
.party-join {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 12px;
  align-items: stretch;
  pointer-events: auto;
}
#btn-party-join {
  margin-top: 0;
  height: 50px;
  padding: 0 18px;
  display: grid;
  place-items: center;
}
.party-error {
  color: #ffd933;
  margin-top: 14px;
  width: 100%;
  text-align: center;
}
.party-seats {
  list-style: none;
  width: min(280px, 86vw);
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.party-seats li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
}
.party-seats .you { outline: 2px solid #ffd933; }
.party-seats .out { opacity: 0.55; }
.party-seats .seat-score { font-variant-numeric: tabular-nums; }

#race-board {
  position: absolute;
  top: calc(var(--chrome-top) + 44px);
  right: max(8px, var(--chrome-right));
  width: 128px;
  z-index: 6;
  pointer-events: none;
  text-align: left;
  padding: 8px 8px 10px;
  border-radius: 14px;
  background: rgba(8, 32, 64, 0.58);
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
}
#race-board .race-kicker {
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.82;
  margin-bottom: 8px;
}
#race-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#race-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 800;
}
#race-list .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 8px;
  margin-top: 5px;
}
#race-list .who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#race-list .out { opacity: 0.5; }
#race-list .just-out {
  opacity: 1;
  color: #ff8c40;
  animation: race-miss 0.7s ease;
}
#race-list .you .who { color: #ffd933; }
@keyframes race-miss {
  0% { transform: scale(1.08); }
  100% { transform: scale(1); }
}
.race-out {
  margin-top: 8px;
  font-size: 0.78rem;
  color: #ffd933;
}

#overlay-missions,
#overlay-board {
  background: rgba(12, 52, 96, 0.72);
  backdrop-filter: blur(8px);
}
#overlay-missions .overlay-chrome {
  align-items: center;
}
#missions-list {
  width: min(420px, 92%);
  max-height: 62vh;
  overflow-y: auto;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: auto;
  touch-action: pan-y;
  text-align: left;
}
.missions-section {
  margin: 8px 0 2px;
  font-size: 1.15rem;
  font-weight: 900;
}
.mission-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255,255,255,0.12);
}
.mission-row.claimed { opacity: 0.55; }
.mission-text { font-weight: 800; }
.mission-count { margin-top: 4px; font-size: 0.85rem; opacity: 0.85; }
.mission-bar {
  margin-top: 8px;
  height: 6px;
  border-radius: 99px;
  background: rgba(255,255,255,0.25);
  overflow: hidden;
}
.mission-fill {
  height: 100%;
  border-radius: 99px;
  background: #ffd933;
}
.mission-reward {
  color: #ffd933;
  font-weight: 800;
  white-space: nowrap;
}
.mission-claim {
  border: 0;
  border-radius: 17px;
  padding: 8px 14px;
  background: #ffd933;
  color: #332600;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}
#overlay-board .overlay-chrome {
  align-items: center;
}
.board-nick {
  margin-top: 0;
  padding: 8px 12px;
  font-size: 0.85rem;
  max-width: 58%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.board-tabs {
  width: min(420px, 96%);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}
.board-tab {
  min-width: 0;
  min-height: 40px;
  padding: 7px 5px;
  border: 1px solid rgba(255,255,255,0.38);
  border-radius: 12px;
  background: rgba(255,255,255,0.08);
  color: #fff;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
}
.board-tab.active {
  border-color: #ffd933;
  background: #ffd933;
  color: #1d1d1f;
}
.board-podium {
  width: min(420px, 92%);
  margin-top: 14px;
  font-size: 0.95rem;
  font-weight: 800;
  opacity: 0.95;
}
.board-list {
  list-style: none;
  width: min(420px, 92%);
  max-height: 54vh;
  overflow-y: auto;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
  touch-action: pan-y;
}
.board-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,0.12);
  text-align: left;
}
.board-row.you {
  background: linear-gradient(90deg, rgba(255, 217, 51, 0.28), rgba(255,255,255,0.14) 42%);
  box-shadow: inset 4px 0 0 0 #ffd933;
}
.board-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid #fff;
  object-fit: cover;
  background: rgba(0,0,0,0.2);
}
.board-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.board-score {
  font-variant-numeric: tabular-nums;
  font-weight: 900;
}
.board-row.skeleton .board-avatar { opacity: 0.3; }
.board-row.skeleton .board-bar {
  height: 14px;
  border-radius: 7px;
  background: rgba(255,255,255,0.35);
  animation: board-pulse 0.7s ease-in-out infinite alternate;
}
.board-row.skeleton .board-bar.name { width: 130px; }
.board-row.skeleton .board-bar.score { width: 44px; justify-self: end; }
@keyframes board-pulse {
  from { opacity: 1; }
  to { opacity: 0.4; }
}
@media (prefers-reduced-motion: reduce) {
  .board-row.skeleton .board-bar { animation: none; }
  .tutorial-tap { animation: none; }
}

@media (orientation: landscape) and (max-height: 540px) {
  #frame.game-active #stage { visibility: hidden; }
  #frame.game-active #orientation-note { display: flex; }
  #frame.menu-open #stage { visibility: visible; }
  #overlay-home,
  #overlay-over {
    padding-left: max(48px, var(--chrome-left));
    padding-right: max(48px, var(--chrome-right));
  }
}
.board-empty {
  margin-top: 24px;
  opacity: 0.85;
}
.nick-card h3 {
  font-size: 1.15rem;
  font-weight: 900;
  margin-bottom: 8px;
}
.nick-card p {
  font-size: 0.95rem;
  font-weight: 700;
}
#nick-input {
  display: block;
  width: 100%;
  height: 48px;
  margin-top: 16px;
  padding: 0 14px;
  border: 0;
  border-radius: 14px;
  font: inherit;
  font-weight: 800;
  text-align: center;
  color: #1d1d1f;
  background: #f3f5f7;
  user-select: text;
  -webkit-user-select: text;
  pointer-events: auto;
}

@media (min-width: 980px) {
  #frame.party-live {
    gap: 20px;
  }
  #frame.party-live #race-board {
    position: relative;
    top: auto;
    right: auto;
    width: 230px;
    padding: 18px;
    pointer-events: auto;
  }
  #frame.party-live #race-board .race-kicker { font-size: 0.85rem; }
  #frame.party-live #race-list li { font-size: 1.05rem; }
}

#stage.shake {
  animation: shake 0.4s ease-out;
}
@keyframes shake {
  0% { transform: translateX(-14px); }
  12% { transform: translateX(14px); }
  24% { transform: translateX(-10px); }
  36% { transform: translateX(10px); }
  48% { transform: translateX(-6px); }
  60% { transform: translateX(6px); }
  72% { transform: translateX(-2px); }
  84% { transform: translateX(2px); }
  100% { transform: translateX(0); }
}
