:root {
  --bg-top: #0b2a4a;
  --bg-bottom: #03101f;
  --card: rgba(255, 255, 255, 0.06);
  --card-border: rgba(255, 255, 255, 0.12);
  --text: #e8f1fa;
  --muted: #8fa8c0;
  --accent: #35d0ba;
  --accent-dark: #1fa592;
  --gold: #ffc857;
  --wrong: #ff6b6b;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom)) fixed;
}

#app { max-width: 640px; margin: 0 auto; padding: 24px 16px 64px; }

.brand { text-align: center; margin-bottom: 24px; }
.brand h1 { margin: 0; line-height: 0; }
.logo { width: 100%; max-width: 420px; height: auto; }
.tag { margin: 4px 0 0; color: var(--muted); }

h2 { margin: 0 0 12px; font-size: 1.15rem; }
.question { font-size: 1.5rem; line-height: 1.3; margin-bottom: 20px; }

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.screen[hidden], [hidden] { display: none !important; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }

input, button { font: inherit; color: inherit; }

input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: rgba(0, 0, 0, 0.25);
  outline: none;
}
input:focus { border-color: var(--accent); }
input:disabled { opacity: 0.5; }

button {
  padding: 12px 18px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  white-space: nowrap;
}
button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.14); }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #032; font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--accent-dark); }
button.link { background: none; border: none; color: var(--muted); text-decoration: underline; padding: 8px; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 4px; }
.field.inline { display: flex; align-items: center; gap: 10px; margin: 0; }
.field.inline > span { margin: 0; }
.field.inline input { width: 80px; }

#screen-home .primary { width: 100%; }
.row { display: flex; gap: 8px; }
#join-code { text-transform: uppercase; letter-spacing: 0.3em; font-weight: 600; }

.divider { display: flex; align-items: center; gap: 10px; margin: 18px 0; color: var(--muted); font-size: 0.85rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--card-border); }

.code-box { text-align: center; margin-bottom: 20px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.code {
  font-size: 2.6rem; font-weight: 700; letter-spacing: 0.3em; padding: 6px 12px 6px 22px;
  background: rgba(0, 0, 0, 0.25); border-color: var(--accent);
}

.players { list-style: none; padding: 0; margin: 0 0 20px; }
.players li { padding: 8px 12px; border-radius: 8px; background: rgba(0, 0, 0, 0.2); margin-bottom: 6px; }
.players li.away, .chips li.away { opacity: 0.5; }
.crown { color: var(--gold); margin-right: 6px; }

#owner-controls { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
#screen-lobby .link, .actions .link { display: block; margin: 8px auto 0; }

.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 8px; }
.pill { padding: 6px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--card-border); font-size: 0.9rem; }

.timer { position: relative; width: 64px; height: 64px; }
.timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer circle { fill: none; stroke-width: 3; }
.timer .track { stroke: rgba(255, 255, 255, 0.12); }
.timer .bar { stroke: var(--accent); stroke-linecap: round; transition: stroke 0.3s; }
.timer.low .bar { stroke: var(--wrong); }
#timer-text { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: 1.3rem; }
.timer.low #timer-text { color: var(--wrong); }

.feedback { min-height: 3em; margin-top: 14px; }
.feedback.wrong { color: var(--wrong); }
.feedback.correct { color: var(--accent); font-size: 1.3rem; }
.points { color: var(--gold); font-weight: 700; }

.wrong-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.wrong-list li { font-size: 0.8rem; color: var(--muted); text-decoration: line-through; padding: 2px 8px; border-radius: 6px; background: rgba(255, 107, 107, 0.08); }

.chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chips li { padding: 6px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--card-border); font-size: 0.9rem; }
.chips li.done { border-color: var(--accent); color: var(--accent); }

.shake { animation: shake 0.35s; }
@keyframes shake {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.board { width: 100%; border-collapse: collapse; }
.board th { text-align: left; color: var(--muted); font-weight: 500; font-size: 0.85rem; padding: 6px 8px; border-bottom: 1px solid var(--card-border); }
.board td { padding: 10px 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.board .num { text-align: right; }
.board tr.you td { background: rgba(53, 208, 186, 0.08); }

.reveal { text-align: center; }

.winner { text-align: center; border-color: var(--gold); }
.winner h2 { font-size: 1.6rem; }
.standings { text-align: left; margin: 12px 0 8px; }
.standings tr.you td { color: var(--accent); }
.standings tr.away td { opacity: 0.6; }
.players .pts { float: right; font-weight: 600; color: var(--gold); }

.actions { text-align: center; }
#final-owner { display: flex; justify-content: center; align-items: center; gap: 12px; }
#btn-next { margin: 0 auto; }

.conn, .toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  padding: 10px 16px; border-radius: 10px; background: #12324f; border: 1px solid var(--card-border);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4); max-width: 90vw; text-align: center;
}
.toast { bottom: 24px; }
.conn { top: 12px; color: var(--gold); }

@media (max-width: 480px) {
  .question { font-size: 1.25rem; }
  .code { font-size: 2rem; }
  .board th:first-child, .board td:first-child { display: none; }
}

.exit { display: block; margin: 8px auto 0; }
#owner-away { top: 56px; }
#closed-board { margin-bottom: 16px; }
#screen-closed .primary { width: 100%; }
