:root {
  color-scheme: light;
  --ink: #102a43;
  --muted: #60758a;
  --paper: #ffffff;
  --sky: #eaf4ff;
  --blue: #1473e6;
  --red: #d92d20;
  /* Turquoise */
  --turquoise: #2da095;
  /* Bordeaux */
  --bordeaux: #a44968;
  --line: rgba(16, 42, 67, .1);
  --shadow: 0 24px 70px rgba(31, 67, 103, .13);
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; background: var(--sky); }
body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 7% 14%, rgba(255,255,255,.92), transparent 34%),
    radial-gradient(ellipse at 94% 83%, rgba(172,214,255,.45), transparent 38%),
    var(--sky);
  overscroll-behavior: none;
}
body[data-phase="game-over"] { background: var(--bordeaux); }
body[data-phase="game-over"][data-outcome="winner"] { background: var(--turquoise); animation: result-flash 2.4s ease-in-out 1; }
body[data-phase="game-over"][data-outcome="spectator"] { background: #d39b00; animation: result-flash 2.4s ease-in-out 1; }
body[data-phase="game-over"] .brand { color: white; }
body[data-phase="game-over"] .top-chip { border-color: rgba(255,255,255,.25); color: white; background: rgba(255,255,255,.13); }
body[data-phase="game-over"] .connection-dot { background: white; }
body[data-phase="game-over"] .footer { color: rgba(255,255,255,.68); }
body[data-outcome="spectator"] .brand, body[data-outcome="spectator"] .top-chip { color: #493600; }
body[data-outcome="spectator"] .top-chip { border-color: rgba(73,54,0,.25); background: rgba(255,255,255,.45); }
button { font: inherit; }
button:focus-visible { outline: 3px solid #102a43; outline-offset: 4px; }
.app-shell {
  width: min(100%, 680px);
  min-height: 100vh;
  min-height: 100svh;
  margin-inline: auto;
  padding: max(14px, env(safe-area-inset-top)) 20px max(14px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}
.splash-screen { position: fixed; z-index: 1000; inset: 0; display: grid; place-items: center; background: #eaf4ff; }
.splash-icon { display: block; width: min(58.8vw, 266px); height: min(58.8vw, 266px); object-fit: contain; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 900; letter-spacing: .12em; }
.brand-mark { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 12px; color: white; background: var(--blue); font-size: 18px; box-shadow: 0 5px 14px color-mix(in srgb, var(--blue) 27%, transparent); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.top-chip, .quiet-button, .icon-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255,255,255,.72);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.top-chip { display: inline-flex; align-items: center; gap: 7px; padding: 0 13px; font-size: 12px; font-weight: 750; }
.quiet-button { padding: 0 14px; font-size: 12px; font-weight: 750; cursor: pointer; }
.icon-button { display: grid; width: 38px; padding: 0; place-items: center; font-size: 23px; cursor: pointer; }
.connection-dot { width: 8px; height: 8px; border-radius: 50%; background: #f1ad3f; }
.connection-dot.online { background: #25a779; box-shadow: 0 0 0 3px rgba(37,167,121,.14); }
.connection-dot.offline { background: #d92d20; }
.stage { flex: 1; display: grid; place-items: center; padding-block: 22px; }
.game-card {
  width: min(100%, 480px);
  padding: clamp(24px, 6vw, 42px);
  border: 1px solid rgba(255,255,255,.9);
  border-radius: 32px;
  background: rgba(255,255,255,.88);
  box-shadow: var(--shadow);
  text-align: center;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.join-card { padding-block: clamp(26px, 7vh, 52px); }
.eyebrow { margin: 0 0 8px; color: var(--blue); font-size: 11px; font-weight: 900; letter-spacing: .18em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
.hero-title { margin: 0; font-size: clamp(34px, 9vw, 54px); line-height: 1; font-weight: 950; letter-spacing: -.055em; }
.subhead { max-width: 340px; margin: 14px auto 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.nickname-block { margin-top: 25px; }
.field-caption { display: block; margin-bottom: 9px; color: var(--muted); font-size: 12px; font-weight: 700; }
.nickname-button {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 174px;
  min-height: 58px;
  padding: 8px 20px;
  border: 1px solid var(--line);
  border-radius: 19px;
  color: var(--ink);
  background: white;
  box-shadow: 0 6px 18px rgba(16,42,67,.06);
  font-size: 31px;
  cursor: pointer;
  touch-action: manipulation;
}
.nickname-button span:last-child { color: var(--muted); font-size: 12px; font-weight: 750; }
.join-options { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 13px; }
.records { display: flex; justify-content: center; gap: 9px; flex-wrap: wrap; margin: 25px 0 0; }
.record-pill { padding: 9px 12px; border-radius: 13px; color: #426078; background: #f0f6fc; font-size: 11px; font-weight: 750; }
.instructions { max-width: 360px; margin: 20px auto 0; color: var(--muted); font-size: 16px; font-weight: 800; line-height: 1.5; }
.primary-button, .answer-button, .secondary-button {
  border: 0;
  border-radius: 17px;
  color: white;
  font-weight: 850;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: transform .12s ease, filter .12s ease, opacity .12s ease;
}
.primary-button:active, .answer-button:active, .secondary-button:active { transform: scale(.975); filter: brightness(.96); }
.primary-button { min-height: 54px; padding: 0 28px; background: var(--blue); box-shadow: 0 9px 20px color-mix(in srgb, var(--blue) 24%, transparent); font-size: 15px; }
.join-button { width: min(100%, 260px); margin-top: 23px; }
.primary-button:disabled { opacity: .5; cursor: not-allowed; }
.loading-card { padding-block: 70px; }
.loader { width: 36px; height: 36px; margin: 0 auto 19px; border: 3px solid rgba(20,115,230,.16); border-top-color: var(--blue); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-title { margin: 0; font-size: 23px; font-weight: 850; }
.game-card.game-over-card { color: white; border-color: rgba(255,255,255,.25); background: var(--bordeaux); }
.game-card.game-over-winner { color: #103b24; border-color: rgba(255,255,255,.8); background: #d9fbe5; }
.game-card.game-over-spectator { color: #493600; border-color: rgba(255,255,255,.8); background: #fff3bd; }
.game-card.game-over-winner .game-message, .game-card.game-over-winner .winner-line,
.game-card.game-over-winner .keyboard-note, .game-card.game-over-winner .stats-row, .game-card.game-over-winner .latency,
.game-card.game-over-spectator .game-message, .game-card.game-over-spectator .winner-line,
.game-card.game-over-spectator .keyboard-note, .game-card.game-over-spectator .stats-row, .game-card.game-over-spectator .latency { color: inherit; }
.game-card.game-over-winner .player-chip, .game-card.game-over-spectator .player-chip { color: inherit; border-color: currentColor; background: rgba(255,255,255,.55); }
.game-card.game-over-winner .stats-row span, .game-card.game-over-spectator .stats-row span { background: rgba(16,42,67,.08); }
.result-popup { margin: 14px auto 4px; padding: 13px 18px; border: 2px solid var(--turquoise); border-radius: 18px; color: #103b24; background: white; box-shadow: 0 8px 28px rgba(16,42,67,.16); font-size: 17px; font-weight: 900; animation: popup-in .28s ease-out both; }
.spectator-message { border-color: #bd8800; color: #493600; font-size: 13px; }
@keyframes result-flash { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.35); } }
@keyframes popup-in { from { opacity: 0; transform: translateY(-8px) scale(.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
.game-card.game-over-card .eyebrow, .game-card.game-over-card .field-caption { color: rgba(255,255,255,.72); }
.game-card.game-over-winner .eyebrow, .game-card.game-over-winner .field-caption,
.game-card.game-over-spectator .eyebrow, .game-card.game-over-spectator .field-caption { color: inherit; }
.game-topline { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 26px; padding-top: 46px; }
.player-corner { position: absolute; top: 17px; inset-inline-end: 20px; display: flex; gap: 8px; }
.player-corner-item { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: #f5f9fd; font-size: 10px; font-weight: 800; white-space: nowrap; }
.player-corner-emoji { font-size: 17px; line-height: 1; }
.game-card { position: relative; }
.turn-label { margin: 0; font-size: 13px; font-weight: 900; }
.player-chip { display: inline-flex; align-items: center; gap: 7px; min-height: 35px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink); background: #f5f9fd; font-size: 11px; font-weight: 800; cursor: pointer; }
.game-over-card .player-chip { border-color: rgba(255,255,255,.3); color: white; background: rgba(255,255,255,.14); }
.number-orb { display: grid; width: clamp(128px, 35vw, 178px); aspect-ratio: 1; margin: 0 auto 19px; place-items: center; border: 1px solid rgba(16,42,67,.05); border-radius: 50%; color: var(--ink); background: white; box-shadow: 0 14px 40px rgba(16,42,67,.1); font-size: clamp(56px, 15vw, 78px); font-weight: 950; letter-spacing: -.06em; font-variant-numeric: tabular-nums; }
.turn-progress { width: min(100%, 300px); height: 10px; margin: 0 auto; overflow: hidden; border-radius: 999px; background: color-mix(in srgb, var(--blue) 16%, white); }
.turn-progress-fill { display: block; width: 100%; height: 100%; border-radius: inherit; background: var(--blue); transform: scaleX(1); transform-origin: left center; transition: transform 100ms linear; }
.game-message { min-height: 22px; margin: 14px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.game-over-card .game-message { color: white; }
.winner-line { margin: 8px 0 0; color: white; font-size: 14px; font-weight: 800; }
.answer-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 23px; }
.answer-button { min-height: clamp(60px, 15vw, 74px); font-size: 25px; }
.answer-button.boom { background: var(--bordeaux); }
.answer-button.number { background: var(--turquoise); font-size: 29px; font-variant-numeric: tabular-nums; }
.answer-button:disabled { opacity: .43; cursor: default; }
.keyboard-note { margin: 12px 0 0; color: var(--muted); font-size: 10px; }
.game-over-card .keyboard-note, .game-over-card .stats-row, .game-over-card .latency { color: rgba(255,255,255,.8); }
.stats-row { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 22px; color: var(--muted); font-size: 11px; font-weight: 750; }
.stats-row span { padding: 7px 9px; border-radius: 10px; background: rgba(16,42,67,.045); }
.game-over-card .stats-row span { background: rgba(255,255,255,.12); }
.latency { margin: 14px 0 0; color: #8193a4; font-size: 10px; }
.play-again { margin-top: 23px; }
.footer { padding: 2px 0; color: #8499ad; text-align: center; font-size: 10px; }
.music-credit { display: block; margin-top: 3px; font-size: 9px; line-height: 1.4; }
.music-credit a { color: inherit; text-underline-offset: 2px; }

.dialog {
  width: min(420px, calc(100vw - 30px));
  max-width: 420px;
  max-height: min(82svh, 650px);
  padding: 23px;
  overflow: auto;
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 26px;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 28px 90px rgba(16,42,67,.22);
}
.dialog::backdrop { background: rgba(16,42,67,.38); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.dialog-head h2, .offline-dialog h2 { margin: 0; font-size: 24px; letter-spacing: -.035em; }
.dialog-head .eyebrow { margin-bottom: 5px; }
.emoji-grid { display: grid; direction: ltr; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 7px; }
.dialog-error { color: var(--red); margin: 8px 0; }
.emoji-choice { display: grid; min-width: 0; min-height: 48px; place-items: center; border: 1px solid transparent; border-radius: 15px; background: #f3f7fb; font-size: 23px; cursor: pointer; touch-action: manipulation; }
.emoji-choice.selected { border-color: var(--blue); background: #e8f2ff; box-shadow: inset 0 0 0 1px var(--blue); }
.nickname-button, .emoji-choice, .roster-player, .winner-line { font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.theme-options { display: grid; gap: 9px; }
.theme-option { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 58px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 15px; color: var(--ink); background: white; text-align: start; cursor: pointer; }
.theme-option:disabled { opacity: .52; cursor: not-allowed; }
.theme-option.current { border-color: var(--blue); background: #f2f8ff; }
.theme-left { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.swatch { display: block; width: 22px; height: 22px; border-radius: 8px; background: var(--swatch); }
.theme-lock { color: var(--muted); font-size: 10px; }
.roster-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 9px; }
.roster-player { display: flex; min-height: 74px; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 2px solid transparent; border-radius: 18px; background: #f3f7fb; }
.roster-emoji { font-size: 29px; line-height: 1.1; }
.roster-location { max-width: 100%; overflow: hidden; color: var(--muted); font-size: 9px; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.roster-player.active { border-color: var(--blue); }
.dialog-note { margin: 15px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.offline-dialog { text-align: center; }
.offline-icon { display: grid; width: 58px; height: 58px; margin: 2px auto 17px; place-items: center; border-radius: 20px; color: var(--blue); background: #edf5ff; font-size: 31px; }
.offline-dialog .primary-button { width: 100%; margin-top: 23px; }

html[dir="rtl"] .game-topline, html[dir="rtl"] .topbar { direction: rtl; }
html[dir="rtl"] .answer-row { direction: rtl; }
html[dir="rtl"] .brand { letter-spacing: 0; }
html[dir="rtl"] .turn-progress-fill { transform-origin: right center; }
@media (max-height: 720px) {
  .stage { padding-block: 12px; }
  .game-card { padding: 21px; border-radius: 26px; }
  .join-card { padding-block: 24px; }
  .game-topline { margin-bottom: 16px; padding-top: 42px; }
  .number-orb { width: clamp(112px, 29vh, 150px); margin-bottom: 13px; }
  .answer-row { margin-top: 16px; }
  .answer-button { min-height: 57px; }
  .stats-row { margin-top: 15px; }
}
@media (max-width: 390px) {
  .app-shell { padding-inline: 13px; }
  .game-card { padding-inline: 20px; }
  .top-chip { padding-inline: 10px; }
  .records { gap: 6px; }
  .record-pill { padding-inline: 9px; font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
