:root {
  --bg: #15100c;
  --bg-2: #1f1813;
  --card: #2a2018;
  --card-2: #332619;
  --amber: #f5a623;
  --amber-2: #ffc857;
  --foam: #fff6e0;
  --text: #f3e9da;
  --muted: #a8957f;
  --green: #5fcf80;
  --red: #ff6b6b;
  --line: #3d2f22;
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(1200px 600px at 50% -10%, #3a2a16 0%, transparent 60%),
    var(--bg);
  min-height: 100vh;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 18px 16px calc(28px + env(safe-area-inset-bottom));
  min-height: 100vh;
}

/* ---- screens ---- */
.screen { display: none; animation: fade .25s ease; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- hero ---- */
.hero { text-align: center; padding: 28px 0 12px; }
.logo { font-size: 64px; line-height: 1; filter: drop-shadow(0 6px 14px rgba(245,166,35,.35)); }
h1 {
  font-size: 40px; margin: 10px 0 4px; letter-spacing: -1px;
  background: linear-gradient(180deg, var(--amber-2), var(--amber));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tagline { color: var(--muted); margin: 0; font-size: 15px; }

h2 { font-size: 18px; margin: 0 0 10px; }

/* ---- cards ---- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin: 14px 0;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.host-card { background: linear-gradient(180deg, var(--card-2), var(--card)); border-color: #4a3820; }

.stack { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }

/* ---- inputs ---- */
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; font-weight: 600; }
label:first-child { margin-top: 0; }
input, select {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 14px 14px;
  font-size: 17px;
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus { border-color: var(--amber); }
.code-input { text-transform: uppercase; letter-spacing: 8px; font-size: 28px; text-align: center; font-weight: 800; }
.weigh-row { display: flex; gap: 8px; }
.weigh-row input { flex: 1; }
.weigh-row .btn { width: auto; white-space: nowrap; padding-left: 20px; padding-right: 20px; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%;
  border: none; border-radius: 12px;
  padding: 14px 18px;
  font-size: 16px; font-weight: 700;
  cursor: pointer;
  transition: transform .08s, filter .15s, background .15s;
  font-family: inherit;
}
.btn:active { transform: scale(.97); }
.btn.big { padding: 18px; font-size: 18px; }
.btn-primary { background: linear-gradient(180deg, var(--amber-2), var(--amber)); color: #3a2400; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:disabled { background: #5a4a36; color: #8a7a64; cursor: not-allowed; }
.btn-ghost { background: var(--bg-2); color: var(--text); border: 1px solid var(--line); }
.btn-text { background: none; color: var(--muted); font-weight: 600; margin-top: 6px; }
.btn-text:hover { color: var(--text); }
form .btn { margin-top: 14px; }

/* ---- room bar ---- */
.room-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; margin: 4px 0 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.room-label { font-size: 12px; letter-spacing: 1.5px; color: var(--muted); font-weight: 700; }
.room-code { font-size: 30px; font-weight: 900; letter-spacing: 6px; color: var(--amber-2); }
.room-count { font-size: 15px; color: var(--muted); font-weight: 700; }

/* ---- player list ---- */
.player-list { list-style: none; margin: 0; padding: 0; }
.player-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 4px; border-bottom: 1px solid var(--line);
}
.player-list li:last-child { border-bottom: none; }
.p-name { flex: 1; font-weight: 600; }
.p-name .you-tag { color: var(--amber); font-size: 12px; margin-left: 6px; }
.crown { font-size: 14px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); flex: none; }
.dot.off { background: #6b5a47; }
.p-status { font-size: 13px; color: var(--muted); font-weight: 600; }
.p-status.ok { color: var(--green); }
.p-status.pending { color: var(--amber); }

/* ---- big stat (drink amount) ---- */
.target-card { text-align: center; background: linear-gradient(180deg, #3a2a14, var(--card)); border-color: #5a431f; }
.big-stat-label { font-size: 14px; letter-spacing: 3px; color: var(--amber); font-weight: 800; }
.big-stat-value { font-size: 72px; font-weight: 900; line-height: 1; color: var(--foam); }
.big-stat-value .unit { font-size: 32px; color: var(--muted); margin-left: 4px; }
.target-detail { margin-top: 12px; color: var(--muted); font-size: 15px; }
.target-detail strong { color: var(--text); }

/* ---- score table ---- */
.score-table { width: 100%; border-collapse: collapse; }
.score-table th, .score-table td { padding: 10px 6px; text-align: right; font-size: 14px; }
.score-table th { color: var(--muted); font-size: 11px; letter-spacing: .5px; text-transform: uppercase; border-bottom: 1px solid var(--line); }
.score-table td.name, .score-table th.name { text-align: left; }
.score-table tr { border-bottom: 1px solid var(--line); }
.score-table tr:last-child { border-bottom: none; }
.score-table tr.me { background: rgba(245,166,35,.10); }
.score-table .rank { color: var(--muted); width: 28px; text-align: center; font-weight: 800; }
.score-table .total { font-weight: 900; color: var(--amber-2); }
.score-table .pts-pos { color: var(--muted); }
.score-table .pts-exact { color: var(--green); font-weight: 800; }
.medal { font-size: 16px; }

/* ---- yours card (results) ---- */
.yours-card { text-align: center; }
.yours-big { font-size: 40px; font-weight: 900; color: var(--foam); margin: 4px 0; }
.yours-big.exact { color: var(--green); }
.yours-sub { color: var(--muted); font-size: 14px; }
.pts-pill {
  display: inline-block; margin-top: 10px; padding: 6px 16px; border-radius: 999px;
  font-weight: 800; font-size: 18px;
  background: var(--bg-2); border: 1px solid var(--line);
}
.pts-pill.good { background: rgba(95,207,128,.15); border-color: var(--green); color: var(--green); }

/* ---- punishment ---- */
.punishment-card { text-align: center; border-color: var(--red); background: linear-gradient(180deg, #2e1818, var(--card)); }
.punishment-card em { color: var(--amber-2); font-style: normal; font-weight: 700; }

/* ---- misc ---- */
.hint { color: var(--muted); font-size: 13px; margin: 0 0 12px; line-height: 1.4; }
.footnote { text-align: center; color: var(--muted); font-size: 12px; margin: 18px 0 6px; line-height: 1.4; }
.weigh-status { margin-top: 10px; font-weight: 700; font-size: 14px; }
.weigh-status.ok { color: var(--green); }
.hidden { display: none !important; }

/* ---- toast ---- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom));
  background: #3a2418; color: var(--foam);
  border: 1px solid var(--amber); border-radius: 12px;
  padding: 12px 18px; font-size: 14px; font-weight: 600;
  z-index: 50; max-width: 90%; text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
  animation: fade .2s ease;
}
.toast.err { border-color: var(--red); }
