/* Layout: lobby = single column of room cards; room = player + queue on the left, people + chat on the right, stacked on phones. */
:root {
  --bg: #f6f3ec; --panel: #ffffff; --ink: #1d2420; --sub: #5f6b64; --line: #e3ddd0; --soft: #efe9dc;
  --brand: #14322a; --accent: #f06a3c; --accent-ink: #ffffff; --ok: #2f8f5b; --bad: #c4453a;
  --f-display: "Bricolage Grotesque", "Avenir Next", system-ui, sans-serif;
  --f-body: "DM Sans", "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) { :root {
  --bg: #0f1613; --panel: #17211d; --ink: #e8ede9; --sub: #9aa8a0; --line: #26332d; --soft: #1e2a25;
  --brand: #bfe3cf; --accent: #ff8459; --accent-ink: #1a0d07; --ok: #5cc28a; --bad: #ff7a6e; color-scheme: dark } }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--f-body); }
#app { max-width: 1180px; margin: 0 auto; padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 40px max(16px, env(safe-area-inset-left)); }
h1, h2, h3 { font-family: var(--f-display); margin: 0; line-height: 1.15; text-wrap: balance; }
h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 19px; font-weight: 600; }
.boot { color: var(--sub); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand small { color: var(--sub); }
.me { display: flex; align-items: center; gap: 8px; color: var(--sub); font-size: 14px; }
.av { width: 28px; height: 28px; border-radius: 50%; background: var(--soft); display: inline-grid; place-items: center; font-weight: 700; font-size: 12px; color: var(--brand); overflow: hidden; flex: none; }
.av img { width: 100%; height: 100%; object-fit: cover; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
input[type="text"], input[type="email"], input[type="search"], input[type="password"] { font: inherit; border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 10px; padding: 9px 12px; min-width: 0; flex: 1 1 200px; }
button { font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 8px 14px; font-weight: 600; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; font-weight: 600; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--accent); overflow-wrap: anywhere; }
a.btn.primary { background: var(--accent); color: var(--accent-ink); }
button.ghost { background: transparent; }
button.small { padding: 4px 9px; font-size: 13px; border-radius: 8px; }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.login { max-width: 420px; margin: 12vh auto 0; text-align: left; }
.login p { color: var(--sub); }
.err { color: var(--bad); font-size: 14px; }
.rooms { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.room-card { text-align: left; display: grid; gap: 4px; padding: 14px 16px; border-radius: 14px; }
.room-card b { font-family: var(--f-display); font-size: 18px; }
.room-card span { color: var(--sub); font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layout { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
.player-wrap { position: relative; aspect-ratio: 16 / 9; width: 100%; max-width: 100%; border-radius: 14px; overflow: hidden; background: #000; }
.player-wrap > div, .player-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; }
.join-cover { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(10, 20, 16, .72); color: #fff; text-align: center; padding: 16px; }
.join-cover p { margin: 8px 0 0; opacity: .8; font-size: 14px; }
.idle { position: absolute; inset: 0; display: grid; place-items: center; color: #cfd9d3; text-align: center; padding: 20px; }
.now { display: grid; gap: 2px; margin-top: 10px; }
.now .title { font-family: var(--f-display); font-size: 20px; font-weight: 600; }
.now .by { color: var(--sub); font-size: 13px; }
.controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.reacts { display: flex; gap: 4px; flex-wrap: wrap; }
.reacts button { font-size: 18px; padding: 4px 8px; border-radius: 99px; }
.floaters { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.floater { position: absolute; bottom: 10px; font-size: 30px; animation: rise 2.4s ease-out forwards; }
.floater small { display: block; font-size: 11px; color: #fff; text-shadow: 0 1px 2px #000; text-align: center; }
@keyframes rise { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-220px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .floater { animation: none; opacity: 0; } }
.add { margin-top: 16px; }
.results, .queue { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.track { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 6px; border-radius: 10px; }
.track:hover { background: var(--soft); }
.track img { width: 64px; height: 36px; object-fit: cover; border-radius: 6px; background: var(--soft); }
.track .t { overflow: hidden; }
.track .t b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track .t span { color: var(--sub); font-size: 12.5px; }
.track .acts { display: flex; gap: 4px; }
.muted { color: var(--sub); font-size: 14px; }
.people { display: flex; flex-wrap: wrap; gap: 6px; }
.person { display: inline-flex; gap: 6px; align-items: center; background: var(--soft); border-radius: 99px; padding: 3px 10px 3px 3px; font-size: 13px; font-weight: 500; }
.person .av { width: 22px; height: 22px; font-size: 10px; }
.chat { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: min(70vh, 640px); }
.msgs { overflow-y: auto; display: grid; align-content: start; gap: 8px; padding: 8px 2px; }
.msg { display: grid; gap: 1px; }
.msg .who { font-size: 12.5px; font-weight: 700; color: var(--brand); }
.msg .who time { font-weight: 400; color: var(--sub); margin-left: 6px; }
.msg .body { overflow-wrap: anywhere; white-space: pre-wrap; }
.msg.system { color: var(--sub); font-size: 13px; font-style: italic; }
.send { display: flex; gap: 6px; }
.badge { background: var(--soft); color: var(--sub); border-radius: 99px; padding: 1px 8px; font-size: 12px; font-weight: 600; }
#toast { position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--brand); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; max-width: calc(100% - 32px); z-index: 20; }
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .chat { height: 60vh; }
  h1 { font-size: 26px; }
}
.tabs { display: flex; gap: 4px; }
.tab { text-decoration: none; color: var(--sub); font-weight: 600; padding: 6px 12px; border-radius: 99px; }
.tab.on { background: var(--brand); color: var(--bg); }
.alert-row { grid-template-columns: 40px minmax(0, 1fr) auto; }
.alert-row .emoji { font-size: 24px; text-align: center; }
.days { gap: 6px; }
.day { display: inline-flex; gap: 4px; align-items: center; background: var(--soft); border-radius: 99px; padding: 4px 10px; font-size: 13px; font-weight: 600; }
select, input[type="time"] { font: inherit; border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 10px; padding: 8px 10px; }
.alert-banner { position: fixed; top: max(12px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: min(520px, calc(100% - 32px)); z-index: 30; background: var(--brand); color: var(--bg); border-radius: 16px; padding: 14px 16px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
.alert-banner .row { grid-column: 1 / -1; }
.alert-banner button.ghost { color: var(--bg); border-color: transparent; }
.chip { border-radius: 99px; padding: 6px 14px; font-size: 13px; min-height: 40px; }
.chip.on { background: var(--brand); color: var(--bg); border-color: var(--brand); }
.controls button.on { background: var(--brand); color: var(--bg); border-color: var(--brand); }
.vote { display: grid; gap: 4px; text-align: left; padding: 12px; border-radius: 14px; border-width: 2px; }
.vote.mine { border-color: var(--accent); }
.vote .n { font-weight: 800; font-variant-numeric: tabular-nums; }
.vote .bar { display: block; height: 6px; border-radius: 99px; background: var(--soft); overflow: hidden; }
.vote .bar i { display: block; height: 100%; background: var(--brand); }
.vote.mine .bar i { background: var(--accent); }
.winner { background: var(--soft); border-radius: 14px; padding: 14px; }
input[type="number"], input[type="url"] { font: inherit; border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 10px; padding: 9px 12px; min-width: 0; }
.bill-row { text-decoration: none; color: inherit; grid-template-columns: 40px minmax(0, 1fr) auto; }
.track.item { width: 100%; text-align: left; border: 1px solid var(--line); grid-template-columns: 28px minmax(0, 1fr) auto; background: var(--panel); }
.track.item.mine { border-color: var(--accent); }
.track.item .check { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--line); display: grid; place-items: center; font-weight: 800; color: var(--accent-ink); }
.track.item.mine .check { background: var(--accent); border-color: var(--accent); }
.owe-card { background: var(--brand); color: var(--bg); border-color: var(--brand); }
.owe-card .big { font-family: var(--f-display); font-size: 26px; font-variant-numeric: tabular-nums; }
.owe-card button { background: var(--bg); color: var(--brand); border-color: var(--bg); }
.owe { color: var(--bad); } .owed { color: var(--ok); }
.warn { color: var(--bad); font-weight: 600; margin: 0; } .ok-text { color: var(--ok); font-weight: 600; margin: 0; }
.badge.ok { color: var(--ok); }

.status-group h3 { font-size: 15px; font-weight: 600; color: var(--sub); }
.table-wrap { overflow-x: auto; }
table.week { border-collapse: collapse; width: 100%; min-width: 520px; font-size: 14px; }
table.week th, table.week td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
table.week th[scope="row"], table.week thead th:first-child { text-align: left; }
table.week thead th { color: var(--sub); font-weight: 600; font-size: 13px; }
table.week td { font-size: 18px; }
table.week td.usual { opacity: .45; }
table.week tr.me-row { background: var(--soft); }
table.week select { font-size: 13px; padding: 4px 6px; }
.brand { min-width: 0; flex-wrap: wrap; }
.tabs { overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.tab { white-space: nowrap; }
@media (max-width: 560px) { .brand { width: 100%; } .tabs { width: 100%; } }
table.week select { width: 5.6em; }
