:root {
  --bg: #fff6ea;
  --bg-accent: #ffe8cc;
  --surface: #ffffff;
  --text: #2b1d14;
  --muted: #8a7461;
  --line: #f0dfc8;
  --tomato: #e4572e;
  --tomato-dark: #c2401b;
  --mustard: #f2a541;
  --lettuce: #2e9e5b;
  --berry: #8e44ad;
  --shadow: 0 8px 24px rgba(120, 70, 20, 0.12);
  --radius: 18px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(circle at 10% 0%, var(--bg-accent) 0, transparent 40%), radial-gradient(circle at 90% 100%, #ffe1d6 0, transparent 40%), var(--bg);
  color: var(--text);
  font-family: 'Segoe UI Variable', 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  font-size: 16px; line-height: 1.45; -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.15; }
button, input { font: inherit; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }

.app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px;
  position: sticky; top: 0; z-index: 10; background: rgba(255, 246, 234, 0.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: -0.01em; }
.brand .logo { font-size: 1.5rem; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.chip { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-weight: 700; font-size: 0.9rem; }
.chip.code { letter-spacing: 0.15em; color: var(--tomato-dark); }
.icon-btn { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; width: 38px; height: 38px; cursor: pointer; font-size: 1.1rem; }

main { flex: 1; width: 100%; max-width: 640px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }

.btn {
  border: 0; border-radius: 14px; padding: 13px 18px; font-weight: 800; cursor: pointer; background: var(--tomato); color: #fff;
  box-shadow: 0 4px 0 var(--tomato-dark); transition: transform 0.08s, box-shadow 0.08s; min-height: 48px;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--tomato-dark); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.alt { background: var(--mustard); color: var(--text); box-shadow: 0 4px 0 #c98320; }
.btn.ghost { background: var(--surface); color: var(--text); border: 1px solid var(--line); box-shadow: none; }
.btn.big { width: 100%; font-size: 1.1rem; padding: 16px; }
.btn.green { background: var(--lettuce); box-shadow: 0 4px 0 #1f7a43; }
input[type='text'] { width: 100%; border: 2px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fffdf9; color: var(--text); min-height: 48px; }
input[type='text']:focus { outline: none; border-color: var(--mustard); }
label.field { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: 0.9rem; }

.hero { text-align: center; padding: 24px 8px 8px; }
.hero h1 { font-size: clamp(2rem, 8vw, 2.8rem); letter-spacing: -0.02em; }
.hero h1 em { color: var(--tomato); font-style: normal; }
.hero .mask { font-size: 3rem; }

.error { color: var(--tomato-dark); font-weight: 700; min-height: 1.3em; }
.notice { background: #fff0cf; border: 1px solid var(--mustard); border-radius: 12px; padding: 10px 14px; font-size: 0.92rem; }
.notice.bad { background: #ffe3da; border-color: var(--tomato); }

.codebox { font-size: 2.6rem; font-weight: 900; letter-spacing: 0.25em; color: var(--tomato-dark); text-align: center; padding-left: 0.25em; }
.player { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--bg); border: 1px solid var(--line); }
.player .avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--mustard); display: grid; place-items: center; font-weight: 900; }
.player.you .avatar { background: var(--tomato); color: #fff; }
.player .name { font-weight: 800; flex: 1; overflow-wrap: anywhere; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--lettuce); }
.dot.off { background: #c8b8a6; }

.scene { background: linear-gradient(135deg, #fff0cf, #ffe1d6); }
.scene .theme { font-size: 1.35rem; font-weight: 900; }
.tag { display: inline-block; font-size: 0.75rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.roles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.role { border-radius: 14px; padding: 12px; background: var(--surface); border: 2px solid var(--line); }
.role.mine { border-color: var(--tomato); }
.role .who { font-weight: 800; font-size: 1.02rem; }
.dots { display: flex; gap: 6px; justify-content: center; }
.dots i { width: 28px; height: 8px; border-radius: 4px; background: var(--line); }
.dots i.done { background: var(--lettuce); } .dots i.now { background: var(--tomato); }

.timer { display: flex; flex-direction: column; gap: 4px; }
.timer-track { height: 12px; border-radius: 8px; background: var(--line); overflow: hidden; }
.timer-fill { height: 100%; background: var(--lettuce); transform-origin: left; transition: transform 0.25s linear, background 0.3s; }
.timer.urgent .timer-fill { background: var(--tomato); }
.timer-label { font-weight: 700; font-size: 0.9rem; text-align: right; }

.rec-btn { width: 100%; padding: 22px; font-size: 1.2rem; }
.rec-btn.recording { background: var(--tomato-dark); animation: pulse 1s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(228, 87, 46, 0.25), 0 4px 0 var(--tomato-dark); } }
audio { width: 100%; }
.voice { display: flex; flex-direction: column; gap: 6px; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 5px solid var(--line); border-top-color: var(--tomato); animation: spin 0.9s linear infinite; margin: 8px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.banner { text-align: center; font-size: 1.4rem; font-weight: 900; }
.banner.win { color: var(--lettuce); } .banner.tie { color: var(--mustard); }
.scores { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.score { text-align: center; }
.score.winner { outline: 3px solid var(--lettuce); }
.score .big { font-size: 2.6rem; font-weight: 900; color: var(--tomato-dark); line-height: 1; }
.score .sub { display: flex; justify-content: space-between; font-size: 0.9rem; border-top: 1px dashed var(--line); padding-top: 4px; margin-top: 4px; }
.comment { font-size: 0.88rem; color: var(--muted); text-align: left; }
.badge { display: inline-block; font-size: 0.72rem; font-weight: 800; background: var(--bg-accent); border-radius: 8px; padding: 2px 8px; }
details { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; background: #fffdf9; }
details summary { cursor: pointer; font-weight: 700; }
.tr { font-size: 0.9rem; margin-top: 6px; overflow-wrap: anywhere; }
table.rounds { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.rounds td, table.rounds th { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: center; }
table.rounds td:first-child, table.rounds th:first-child { text-align: left; }

.chat-fab { position: fixed; right: 14px; bottom: 14px; z-index: 20; }
.chat-fab .icon-btn { width: 52px; height: 52px; box-shadow: var(--shadow); position: relative; }
.chat-fab .badge-n { position: absolute; top: -4px; right: -4px; background: var(--tomato); color: #fff; border-radius: 999px; font-size: 0.72rem; padding: 1px 6px; font-weight: 800; }
.chat-panel { position: fixed; right: 14px; bottom: 76px; z-index: 20; width: min(340px, calc(100vw - 28px)); max-height: 60vh; display: flex; flex-direction: column; gap: 8px; }
.chat-list { overflow-y: auto; display: flex; flex-direction: column; gap: 6px; max-height: 34vh; min-height: 60px; }
.msg { background: var(--bg); border-radius: 12px; padding: 6px 10px; font-size: 0.92rem; overflow-wrap: anywhere; }
.msg.mine { background: #ffe1d6; align-self: flex-end; }
.msg b { font-size: 0.78rem; display: block; color: var(--muted); }
.quick { display: flex; gap: 6px; }
.quick button { flex: 1; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; font-size: 1.2rem; padding: 4px; cursor: pointer; }
[hidden] { display: none !important; }
