:root {
  color-scheme: dark;
  --bg0: #100b08;
  --bg1: #1c140e;
  --ink: #f6ead4;
  --muted: #c9b59a;
  --gold: #e6c36a;
  --gold-deep: #b88932;
  --panel: rgba(22, 14, 10, 0.78);
  --line: rgba(230, 195, 110, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(230, 140, 60, 0.18), transparent 55%),
    radial-gradient(circle at top, #2a1b12, var(--bg0) 58%);
  color: var(--ink);
  font-family: "IBM Plex Sans KR", system-ui, sans-serif;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

#app {
  width: min(100vw, 1180px);
  padding: 18px 18px 22px;
}

.topbar,
.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 6px 4px 12px;
}

h1 {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--gold);
}

.sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.cam-switch,
.lang-switch {
  display: flex;
  gap: 6px;
}

.cam-switch button {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.82rem;
}

.cam-switch button.is-active {
  background: var(--gold);
  color: #2a1808;
  border-color: var(--gold);
}

.lang-switch button {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font-family: inherit;
}

.lang-switch button.is-active {
  background: var(--gold);
  color: #2a1808;
  border-color: var(--gold);
}

.join {
  display: flex;
  gap: 8px;
  margin: 0 0 12px;
}

.join.is-hidden {
  display: none;
}

.join input {
  flex: 1;
  min-width: 0;
  background: rgba(255, 236, 200, 0.06);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 12px;
  padding: 11px 13px;
  font-size: 1rem;
  font-family: inherit;
}

.join input:focus {
  outline: 2px solid rgba(230, 195, 110, 0.45);
}

.join button {
  background: linear-gradient(#f0d48a, var(--gold-deep));
  color: #2a1808;
  border: 0;
  font-weight: 700;
  font-family: inherit;
  padding: 11px 18px;
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(184, 137, 50, 0.28);
}

.join-msg {
  margin: 0 0 10px;
  color: #ffb4a0;
  font-size: 0.85rem;
}

.play-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 228px;
  gap: 14px;
  align-items: stretch;
}

.viewport {
  padding: 8px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(230, 195, 110, 0.28), rgba(80, 48, 20, 0.35)),
    #1a120c;
  box-shadow:
    0 0 0 1px rgba(230, 195, 110, 0.2),
    0 24px 70px rgba(0, 0, 0, 0.5);
}

.viewport-stack {
  position: relative;
}

#view {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 960 / 540;
  background: #140e0a;
  border-radius: 10px;
}

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

#score-readout {
  position: absolute;
  top: 14px;
  left: 14px;
  min-width: 64px;
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(16, 10, 6, 0.62);
  border: 1px solid rgba(230, 190, 110, 0.5);
  color: #ffe7b0;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.6rem;
  font-weight: 800;
}

#combo-readout {
  position: absolute;
  top: 14px;
  left: 110px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(180, 70, 20, 0.72);
  color: #ffe7b0;
  font-weight: 700;
}

#combo-readout.is-fever {
  background: rgba(255, 170, 30, 0.9);
  color: #3a1a00;
  box-shadow: 0 0 18px rgba(255, 180, 40, 0.55);
}

#fever-readout {
  position: absolute;
  top: 14px;
  right: 14px;
  padding: 8px 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff7a18, #ffd24a);
  color: #3a1600;
  font-weight: 800;
  letter-spacing: 0.12em;
  animation: feverPulse 0.55s ease-in-out infinite alternate;
}

#dash-meter {
  position: absolute;
  left: 14px;
  bottom: 14px;
  width: 88px;
  height: 7px;
  border-radius: 999px;
  background: rgba(16, 10, 6, 0.55);
  border: 1px solid rgba(230, 190, 110, 0.4);
  overflow: hidden;
}

#dash-meter > i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #7ad7ff, #ffe08a);
}

#combo-readout[hidden],
#fever-readout[hidden],
#dash-meter[hidden],
#toast[hidden] {
  display: none;
}

@keyframes feverPulse {
  from { filter: brightness(1); transform: scale(1); }
  to { filter: brightness(1.18); transform: scale(1.04); }
}

.daily-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.82rem;
}

.daily-btn.is-active {
  background: var(--gold);
  color: #2a1808;
  border-color: var(--gold);
}

.occupancy-chip {
  min-width: 7.5rem;
  text-align: center;
  background: rgba(16, 10, 6, 0.72);
  color: #ffe7b0;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.occupancy-chip.is-full {
  border-color: #ff8a6a;
  color: #ffd0c0;
}

#ghost-readout {
  position: absolute;
  left: 14px;
  bottom: 36px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #f4f0e8;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

#ghost-readout[hidden] {
  display: none;
}

.online-list {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  font-size: 0.86rem;
}

.online-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 5px 0;
  color: var(--ink);
}

.online-list li.is-me {
  color: #ffe08a;
}

.online-list li.is-down {
  color: var(--muted);
}

.online-list .score {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.missions-title {
  margin-top: 16px;
}

.missions {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.82rem;
}

.missions li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 6px 0;
  color: var(--muted);
}

.missions li.is-done {
  color: #c8e8a4;
}

#medal-readout {
  display: block;
  margin: 6px 0 2px;
  font-family: Fraunces, Georgia, serif;
  letter-spacing: 0.14em;
  color: #ffe08a;
}

#medal-readout:empty {
  display: none;
}

body.is-fever {
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(255, 140, 40, 0.32), transparent 55%),
    radial-gradient(circle at top, #4a2410, var(--bg0) 58%);
}

#toast {
  position: absolute;
  top: 22%;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(16, 10, 6, 0.78);
  border: 1px solid rgba(230, 190, 110, 0.6);
  color: #ffe9b8;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.skins {
  display: flex;
  gap: 8px;
  padding: 8px 4px 0;
}

.skin-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  padding: 0;
}

.skin-dot.is-locked {
  opacity: 0.28;
  cursor: not-allowed;
}

.skin-dot.is-active {
  border-color: #ffe7b0;
  box-shadow: 0 0 0 2px rgba(230, 190, 110, 0.45);
}

#crash-banner {
  position: absolute;
  left: 0;
  right: 0;
  top: 38%;
  padding: 18px 12px;
  background: rgba(8, 6, 4, 0.62);
  color: #ffe7b0;
  text-align: center;
}

#crash-banner[hidden] {
  display: none;
}

#crash-banner strong {
  display: block;
  font-family: Fraunces, Georgia, serif;
  font-size: 2rem;
}

#crash-banner span {
  display: block;
  margin-top: 6px;
  color: #f4ead4;
  font-size: 0.95rem;
}

.board {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  min-height: 160px;
  box-shadow: inset 0 1px 0 rgba(255, 220, 150, 0.08);
}

.board h2 {
  margin: 0 0 10px;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.05rem;
  color: var(--gold);
}

.board ol {
  margin: 0;
  padding-left: 1.15rem;
  font-size: 0.9rem;
}

.board li {
  margin: 6px 0;
}

.board .empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.board .empty.is-hidden {
  display: none;
}

.meta {
  color: var(--muted);
  font-size: 0.86rem;
}

#player-nick,
#stage-name {
  display: block;
}

#stage-name {
  color: #f0d9a4;
}

.help {
  margin: 12px 4px 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

@media (max-width: 820px) {
  .play-row {
    grid-template-columns: 1fr;
  }
}
