:root {
  --ink: #fff6e6;
  --muted: #b3a9bf;
  --night: #16131f;
  --panel: #231e31;
  --line: #41385a;
  --hot: #ff5a36;
  --sun: #ffc23d;
  --font: "Avenir Next", "Segoe UI", Roboto, system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--night);
  color: var(--ink);
  font-family: var(--font);
  overscroll-behavior: none;
}

.screen {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  display: flex;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background:
    repeating-linear-gradient(115deg, transparent 0 60px, rgba(255, 194, 61, .05) 60px 62px),
    linear-gradient(160deg, #2b1d3f, var(--night) 65%);
}

.panel {
  margin: auto;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.panel.wide { max-width: 520px; }

.logo {
  margin: 0;
  font-size: clamp(52px, 16vw, 76px);
  line-height: .88;
  font-weight: 900;
  font-style: italic;
  letter-spacing: -.03em;
}
.logo span { display: block; color: var(--hot); margin-left: .55em; }
.tagline { margin: 0 0 6px; color: var(--muted); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .label, h2 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
h2 { margin: 6px 0 0; }

input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 8px;
  outline: none;
}
input:focus { border-color: var(--sun); }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  border: 3px solid transparent;
  outline: 2px solid transparent;
  cursor: pointer;
}
.swatch.on { border-color: var(--night); outline-color: var(--ink); }

.btn {
  min-height: 48px;
  padding: 0 18px;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--hot); border-color: var(--hot); color: #1d0f0a; font-size: 18px; font-weight: 800; }
.btn.small { min-height: 40px; padding: 0 14px; }
.btn:disabled { opacity: .5; cursor: default; }

.join-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.join-row input { text-transform: uppercase; letter-spacing: .25em; font-weight: 700; }

.error { margin: 0; min-height: 1.3em; color: #ff9b85; font-size: 14px; }

.lobby-head { display: flex; justify-content: space-between; align-items: center; }
.room-code { font-size: 44px; font-weight: 900; letter-spacing: .12em; line-height: 1; color: var(--sun); }
.share { margin: 0; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.share b { color: var(--ink); user-select: all; }

.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice {
  flex: 1 1 0;
  min-width: 84px;
  min-height: 44px;
  padding: 6px 10px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.choice.on { border-color: var(--sun); color: var(--sun); }
.choice:disabled { cursor: default; }

.back { color: var(--muted); font-size: 14px; font-weight: 700; text-decoration: none; align-self: flex-start; padding: 6px 0; }

.account { display: flex; justify-content: flex-end; align-items: center; gap: 10px; min-height: 40px; font-weight: 700; overflow-wrap: anywhere; }
.link-btn { display: inline-flex; align-items: center; text-decoration: none; }
.auth-logo { font-size: clamp(38px, 12vw, 54px); color: var(--sun); }
.panel-form { display: flex; flex-direction: column; gap: 12px; }
.hint { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.4; }
input[readonly] { color: var(--muted); }

.music-toggle {
  position: fixed;
  z-index: 20;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink);
  background: var(--panel);
  border: 2px solid var(--sun);
  border-radius: 999px;
  cursor: pointer;
}
.music-toggle.off { border-color: var(--line); color: var(--muted); }

.music-menu {
  position: fixed;
  z-index: 21;
  right: max(12px, env(safe-area-inset-right));
  bottom: calc(max(12px, env(safe-area-inset-bottom)) + 46px);
  width: min(240px, calc(100vw - 24px));
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 12px;
}
.music-menu button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  min-height: 44px;
  justify-content: center;
  padding: 6px 10px;
  font: inherit;
  text-align: left;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.music-menu button:hover { background: rgba(255, 255, 255, .06); }
.music-menu button.on { background: rgba(255, 194, 61, .16); color: var(--sun); }
.music-menu b { font-size: 15px; font-weight: 800; }
.music-menu small { color: var(--muted); font-size: 12px; }

.chat-toast {
  position: fixed;
  z-index: 1000;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(360px, calc(100vw - 24px));
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  color: var(--ink);
  background: var(--panel);
  border: 2px solid var(--sun);
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .45);
  font-family: var(--font);
  font-size: 14px;
  text-decoration: none;
}
div.chat-toast { pointer-events: none; }
.chat-toast b, .chat-toast span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chat-toast span { color: var(--muted); }

.rainbow-name {
  color: transparent;
  background: linear-gradient(90deg, #ff6b6b, #ffb020, #ffe14d, #3ddc84, #27c4ff, #b18cff, #ff5fd2, #ff6b6b) 0 0 / 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  animation: rainbow-slide 3s linear infinite;
}
@keyframes rainbow-slide { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .rainbow-name { animation: none; } }
