:root {
  color-scheme: dark;
  --panel: rgba(14, 18, 28, 0.74);
  --panel-strong: rgba(13, 22, 34, 0.88);
  --panel-border: rgba(255, 255, 255, 0.14);
  --text: #f4f7ff;
  --muted: rgba(244, 247, 255, 0.72);
  --accent: #ff5e66;
  --accent-2: #74d0ff;
  --accent-3: #ffd36f;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.36);
}

* { box-sizing: border-box; }
html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  background: radial-gradient(circle at top, #18315c 0%, #08111d 60%, #03060a 100%);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}
body { color: var(--text); }
button, a { font: inherit; }
a { text-decoration: none; }
.hidden { display: none !important; }
[hidden] { display: none !important; }

.scene {
  position: relative;
  width: 100%;
  height: 100%;
  isolation: isolate;
}

.scene__photo,
.scene__wash,
#game,
.hud {
  position: absolute;
  inset: 0;
}

.scene__photo {
  background-image: url("./kayusha-photo.jpg");
  background-size: cover;
  background-position: center;
  filter: blur(8px) saturate(1.08) brightness(0.62);
  transform: scale(1.08);
  opacity: 0.88;
}

.scene__wash {
  background:
    linear-gradient(180deg, rgba(4, 9, 18, 0.04), rgba(4, 9, 18, 0.36) 42%, rgba(3, 7, 15, 0.9)),
    radial-gradient(circle at 50% 16%, rgba(116, 208, 255, 0.14), transparent 34%),
    radial-gradient(circle at 68% 28%, rgba(255, 94, 102, 0.12), transparent 28%);
  pointer-events: none;
}

#game {
  width: 100%;
  height: 100%;
  display: block;
}

.hud {
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 8px;
  gap: 6px;
}

.hud__top {
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(0, 1fr) minmax(0, 0.82fr);
  gap: 6px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 5px 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.hud-card,
.screen-card,
.countdown-card,
.menu-chip,
.result-pill,
.primary-btn,
.secondary-btn {
  border: 1px solid var(--panel-border);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.hud-card {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0 4px;
  min-width: 0;
}

.hud-card--right { text-align: right; }
.hud-label {
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud-title {
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 2px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud-timer {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #08111d;
  background: linear-gradient(90deg, #ffd36f, #ff9a3d);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14) inset;
}
.hud-message {
  font-size: 11px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud-value {
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 0;
}
.hud-sub {
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud-card--center {
  text-align: center;
}

.overlay {
  pointer-events: auto;
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow-y: auto;
  padding: 18px;
}

.screen {
  display: none;
  width: min(1080px, calc(100vw - 24px));
}
.screen--active { display: block; }

.screen-card,
.countdown-card {
  border-radius: 24px;
  padding: 22px;
  text-align: center;
}

.screen-card--menu,
.screen-card--result {
  max-width: 860px;
  margin: 0 auto;
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.screen-card h1 {
  margin: 0;
  line-height: 1;
  font-size: clamp(34px, 4vw, 58px);
}

.screen-card p {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.menu-chip {
  border-radius: 24px;
  padding: 16px;
  text-align: left;
}

.menu-chip__title {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.menu-chip__text {
  color: var(--muted);
  line-height: 1.45;
  font-size: 15px;
  margin-top: 10px;
}

.menu-chip__options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.option-btn,
.primary-btn,
.secondary-btn {
  appearance: none;
  border-radius: 16px;
  padding: 12px 16px;
  color: var(--text);
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
  pointer-events: auto;
}

.option-btn {
  background: rgba(255, 255, 255, 0.05);
}

.option-btn.is-active {
  border-color: rgba(116, 208, 255, 0.52);
  background: rgba(116, 208, 255, 0.14);
  box-shadow: 0 0 0 1px rgba(116, 208, 255, 0.12) inset;
}

.primary-btn {
  background: linear-gradient(135deg, rgba(255, 94, 102, 0.28), rgba(116, 208, 255, 0.22));
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.05);
}

.option-btn:hover,
.primary-btn:hover,
.secondary-btn:hover,
.plane-link:hover {
  transform: translateY(-1px);
}

.menu-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.menu-note {
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.08em;
}

.plane-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.screen--countdown {
  display: grid;
  place-items: center;
}

.countdown-card {
  width: min(520px, calc(100vw - 24px));
  border: 1px solid rgba(255, 255, 255, 0.16);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 211, 111, 0.18), transparent 36%),
    rgba(10, 16, 31, 0.82);
}

.countdown-number {
  font-size: clamp(96px, 16vw, 180px);
  font-weight: 800;
  line-height: 0.9;
  margin: 8px 0;
  color: #fff4bf;
  text-shadow: 0 0 18px rgba(255, 211, 111, 0.42), 0 0 34px rgba(255, 94, 102, 0.24);
  animation: pop 700ms ease-out;
}

.countdown-text {
  font-size: 18px;
  color: var(--muted);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  animation: rise 700ms ease-out;
}

.results-banner {
  display: inline-flex;
  margin: 0 auto 10px;
  padding: 8px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255, 94, 102, 0.24), rgba(116, 208, 255, 0.24));
  color: #fff4bf;
  letter-spacing: 0.26em;
  font-weight: 800;
  text-transform: uppercase;
}

.results-subtitle {
  font-size: 20px !important;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text) !important;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.result-pill {
  border-radius: 18px;
  padding: 14px;
  display: flex;
  justify-content: space-between;
  font-size: 15px;
}

.results-footer {
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.voice-hud {
  pointer-events: none;
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 6;
}

#voice-hud { display: none !important; }

#menu-start:disabled { opacity: .45; cursor: not-allowed; filter: grayscale(.35); }
#online-status { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px; min-height: 54px; padding: 10px; border: 1px solid rgba(255,255,255,.25); border-radius: 14px; background: rgba(19,35,58,.55); }
#online-status.is-ready { border-color: rgba(125,255,150,.72); background: rgba(47,122,79,.34); }

.voice-hud__label {
  border-radius: 999px;
  padding: 6px 12px;
  background: rgba(10, 16, 31, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  box-shadow: var(--shadow);
}

.voice-hud__pairs {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
}

.voice-hud__pair {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.voice-hud__pair-label {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.voice-hud__arrows {
  display: flex;
  gap: 8px;
}

.voice-arrow {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 800;
  color: rgba(245, 247, 255, 0.64);
  background: rgba(10, 16, 31, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow);
  transition: transform 100ms ease, background 100ms ease, color 100ms ease, box-shadow 100ms ease;
}

.voice-arrow.is-active {
  color: #ffffff;
  background: linear-gradient(135deg, rgba(255, 94, 102, 0.3), rgba(116, 208, 255, 0.28));
  box-shadow: 0 0 0 1px rgba(116, 208, 255, 0.16) inset, 0 0 22px rgba(255, 211, 111, 0.24);
  transform: translateY(-4px) scale(1.06);
  animation: voiceBlink 540ms ease-out;
}

.voice-hud__hint {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-align: center;
}

@keyframes pop {
  0% { transform: scale(0.82); opacity: 0.45; }
  60% { transform: scale(1.04); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes rise {
  0% { transform: translateY(8px); opacity: 0.2; }
  60% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(0); opacity: 1; }
}

@keyframes voiceBlink {
  0% { opacity: 0.45; }
  40% { opacity: 1; }
  100% { opacity: 0.92; }
}

@media (max-width: 1100px) {
  .hud__top { grid-template-columns: minmax(0, 0.82fr) minmax(0, 1fr) minmax(0, 0.82fr); }
  .hud-card--right,
  .hud-card--stats { text-align: inherit; }
  .menu-grid,
  .results-grid { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .hud { padding: 6px; }
  .hud__top { padding: 4px 6px; gap: 4px; }
  .hud-card { padding: 0 2px; }
  .hud-sub,
  .hud-message { display: none; }
  .hud-title { font-size: 10px; margin: 0; }
  .hud-value { font-size: 16px; }
  .overlay { padding: 10px; }
  .screen-card,
  .countdown-card { padding: 16px; }
  .menu-chip { padding: 12px; }
  .hud-label,
  .hud-sub,
  .hud-message { font-size: 9px; }
  .hud-title { font-size: 11px; }
  .hud-value { font-size: 16px; }
  .voice-hud { bottom: 10px; gap: 6px; }
  .voice-arrow { width: 42px; height: 42px; border-radius: 14px; font-size: 22px; }
}

.game-bar {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: flex;
  gap: 10px;
  z-index: 7;
}

.game-bar__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 120px;
  padding: 10px 14px;
  border: 0;
  border-radius: 16px;
  color: #fff;
  text-decoration: none;
  font: 800 15px Trebuchet MS, sans-serif;
}

.game-bar__btn--primary {
  background: linear-gradient(135deg, rgba(255, 179, 0, 0.28), rgba(255, 94, 102, 0.22));
}

.game-bar__btn--secondary {
  background: rgba(10, 16, 31, 0.72);
}

body.child-view .hud {
  padding: 6px;
  gap: 4px;
}

body.child-view .hud__top {
  padding: 4px 6px;
  gap: 4px;
  border-radius: 18px;
}

body.child-view .hud-card {
  padding: 0 2px;
}

body.child-view .hud-label {
  font-size: 8px;
  margin-bottom: 1px;
}

body.child-view .hud-title {
  font-size: 10px;
  margin-bottom: 1px;
}

body.child-view .hud-message,
body.child-view .hud-sub {
  display: none;
}

body.child-view .hud-value {
  font-size: 14px;
}

body.child-view .game-bar,
body.child-view .menu-actions,
body.child-view [data-role-picker] {
  display: none !important;
}

body.child-view .overlay {
  padding: 8px;
}

body.child-view .screen-card,
body.child-view .countdown-card {
  padding: 14px 12px;
  border-radius: 20px;
}

body.child-view .screen-card h1 {
  font-size: clamp(28px, 5vw, 40px);
}

body.child-view .screen-card p {
  font-size: 14px;
}

body.child-view .menu-grid {
  gap: 8px;
}

body.child-view .menu-chip {
  padding: 10px;
}

body.child-view .menu-chip__title {
  font-size: 10px;
  margin-bottom: 6px;
}

body.child-view .menu-chip__text {
  font-size: 12px;
}

body.child-view .menu-actions {
  margin-top: 12px;
  gap: 8px;
}

body.child-view .voice-hud {
  bottom: 8px;
  gap: 6px;
}

body.child-view .voice-arrow {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 20px;
}

@media (max-width: 700px) {
  .game-bar {
    right: 10px;
    bottom: 62px;
    flex-direction: column;
  }

  .game-bar__btn {
    min-width: 104px;
    padding: 9px 12px;
    font-size: 14px;
  }
}
@media (max-width: 900px) and (orientation: landscape) {
  .hud { padding: 6px; gap: 5px; }
  .hud__top { padding: 4px 6px; gap: 4px; }
  .hud-sub, .hud-message { display: none; }
  .hud-label { font-size: 9px; margin-bottom: 2px; }
  .hud-title { font-size: 10px; margin-bottom: 2px; }
  .hud-value { font-size: 15px; }
  .overlay { padding: 8px; }
  .screen-card, .countdown-card { padding: 16px; }
  .menu-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
  .menu-chip { padding: 12px; }
  .menu-actions { margin-top: 14px; gap: 8px; }
  .game-bar { right: 8px; bottom: 8px; gap: 8px; }
  .game-bar__btn { min-width: 100px; padding: 10px 12px; }
  .voice-hud { bottom: 8px; }
  .voice-arrow { width: 38px; height: 38px; border-radius: 12px; font-size: 20px; }
}

