:root {
  --ink: #f4ecdc; --muted: #b9ad98; --dim: #8a7f6d;
  --glass: rgba(24, 20, 16, .86); --line: rgba(244, 236, 220, .14);
  --accent: #e9b65a; --good: #7ed38c; --bad: #ef7d6d;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1c1915; color: var(--ink); font: 16px/1.45 var(--sans); }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; border: 1px solid var(--line); background: rgba(255,255,255,.06); border-radius: 10px; padding: 9px 14px; }
button:hover:not(:disabled) { background: rgba(255,255,255,.12); }
button:disabled { cursor: default; opacity: .75; }
button:focus-visible, textarea:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.primary { background: var(--accent); color: #23180c; border-color: transparent; font-weight: 650; }
.primary:hover:not(:disabled) { background: #f3c674; }
.ghost { background: transparent; }
kbd { font: 600 11px var(--sans); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; margin-left: 4px; color: var(--muted); }

#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#fade { position: fixed; inset: 0; background: #0d0b09; opacity: 0; pointer-events: none; transition: opacity .5s; }
#fade.on { opacity: .85; }

/* HUD */
#hud { position: fixed; top: 12px; left: 12px; display: flex; align-items: center; gap: 12px; padding: 8px 14px 8px 8px; background: var(--glass); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(8px); }
#hud strong { display: block; font-family: var(--serif); font-size: 17px; }
#hud small { display: block; color: var(--muted); font-size: 12px; }
#hudScore { font: 700 18px var(--sans); color: var(--accent); margin-left: 6px; font-variant-numeric: tabular-nums; }
#menuBtn { padding: 6px 10px; }

#notes { position: fixed; top: 12px; right: 12px; width: 230px; padding: 12px 14px; background: rgba(247, 241, 228, .94); color: #2a2218; border-radius: 6px 6px 14px 14px; box-shadow: 0 10px 30px rgba(0,0,0,.35); font-size: 13px; }
#notes h3 { margin: 0 0 6px; font: 600 15px var(--serif); border-bottom: 1px solid #d8ccb5; padding-bottom: 4px; }
#notes h4 { margin: 10px 0 4px; font: 700 11px var(--sans); text-transform: uppercase; letter-spacing: .06em; color: #7a6a52; }
#notes .row { display: flex; justify-content: space-between; padding: 2px 0; }
#notes .tag { margin-top: 8px; background: #2b3b63; color: #f3e6c4; padding: 3px 8px; border-radius: 6px; font-size: 12px; }
#notes .tag.vote { background: #e8dcc3; color: #2a2218; font-weight: 600; margin-top: 0; }
#notes .motion { padding: 3px 0 3px 10px; border-left: 3px solid #c9b58f; margin: 3px 0; }
#notes .motion.passed { border-color: #3b9a52; }
#notes .motion.failed, #notes .motion.dropped { border-color: #c2584a; text-decoration: line-through; color: #8a7a64; }

#gavelBtn { position: fixed; right: 16px; bottom: calc(var(--panel-h, 210px) + 16px); display: flex; align-items: center; gap: 8px; background: var(--glass); backdrop-filter: blur(8px); border-radius: 999px; padding: 8px 14px 8px 10px; color: var(--accent); }
#gavelBtn span { color: var(--ink); font-size: 14px; }

/* Speech bubbles */
#bubbles { position: fixed; inset: 0; pointer-events: none; }
.bubble { position: absolute; left: 0; top: 0; max-width: min(320px, 70vw); background: #fbf8ef; color: #1d2433; padding: 8px 12px; border-radius: 14px; font-size: 14px; line-height: 1.35; box-shadow: 0 6px 20px rgba(0,0,0,.35); margin-top: -10px; }
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -7px; margin-left: -7px; border: 7px solid transparent; border-top-color: #fbf8ef; border-bottom: 0; }
.bubble.shout { background: var(--accent); font-weight: 700; }
.bubble.shout::after { border-top-color: var(--accent); }
.bubble.faint { opacity: .8; font-style: italic; font-size: 12px; }

/* Bottom panel */
#panel { position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); width: min(760px, calc(100vw - 24px)); max-height: 52vh; overflow: auto; padding: 16px 18px; background: var(--glass); border: 1px solid var(--line); border-radius: 18px; backdrop-filter: blur(10px); box-shadow: 0 18px 40px rgba(0,0,0,.4); }
#prompt { margin: 0 0 12px; font: 600 19px/1.3 var(--serif); }
#body > * + * { margin-top: 10px; }
.minor { color: var(--muted); font-size: 13px; margin: 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.minor .count { margin-left: auto; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; }
.card { text-align: left; padding: 12px 14px; border-radius: 12px; background: rgba(255,255,255,.07); line-height: 1.3; }
.card.right { border-color: var(--good); background: rgba(126, 211, 140, .18); }
.card.wrong { border-color: var(--bad); background: rgba(239, 125, 109, .18); }
.cards.lines { grid-template-columns: 1fr; }
.card.line { font-family: var(--serif); font-size: 15px; }

.checklist { display: flex; flex-wrap: wrap; gap: 6px; }
.item { font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 1px dashed var(--line); color: var(--dim); letter-spacing: .02em; }
.item.hit { border-style: solid; border-color: var(--good); color: var(--good); }
.item.miss { border-style: solid; border-color: var(--bad); color: var(--bad); }
.sayrow { display: flex; gap: 8px; align-items: stretch; }
textarea { flex: 1; resize: none; font: 16px/1.4 var(--serif); color: var(--ink); background: rgba(0,0,0,.35); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
textarea:disabled { opacity: .8; }
.mic { width: 48px; display: grid; place-items: center; padding: 0; }
.mic.on { background: var(--bad); color: #fff; border-color: transparent; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(239,125,109,.3); } }
.model { margin: 0; color: var(--muted); font-size: 14px; }
.model q { color: var(--ink); font-family: var(--serif); font-size: 15px; }

#feedback { margin-top: 10px; font-size: 14px; }
#feedback:empty { display: none; }
#feedback.ok { color: var(--good); }
#feedback.bad { color: #ffb3a7; }
#feedback em { color: var(--muted); font-style: normal; }

.strikes { display: flex; gap: 8px; }
.strikes i { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--accent); }
.strikes i.on { background: var(--accent); }

.votephase { font-size: 18px; }
.votephase strong { font-family: var(--serif); }
.votephase span { color: var(--muted); }
.tally { display: flex; gap: 18px; font-size: 15px; color: var(--muted); }
.tally b { color: var(--ink); font-size: 22px; }

.numbers { display: flex; gap: 14px; flex-wrap: wrap; }
.numbers label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.numbers input { width: 120px; font: 600 20px var(--sans); color: var(--ink); background: rgba(0,0,0,.35); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.numbers input.right { border-color: var(--good); }
.numbers input.wrong { border-color: var(--bad); }

.orderwrap { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sequence { margin: 0; padding: 8px 8px 8px 30px; border: 1px dashed var(--line); border-radius: 12px; min-height: 60px; font-size: 14px; }
.sequence li { padding: 4px 0; }

.event { margin: 0; font-family: var(--serif); font-size: 16px; color: var(--ink); }
.event.crisis { border-left: 3px solid var(--bad); padding-left: 12px; }
.timer { font: 700 28px var(--sans); color: var(--bad); font-variant-numeric: tabular-nums; }
.sheet { display: grid; grid-template-columns: auto 1fr; gap: 0; border: 1px solid #c8d3c0; background: #f7faf4; color: #1f2a1a; border-radius: 6px; overflow: hidden; font-size: 13px; }
.sheet > * { padding: 6px 10px; border-bottom: 1px solid #dbe4d4; }
.sheet b { color: #b3261e; }
.sheet span:last-child { grid-column: 1 / -1; }

/* Overlays */
.overlay { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: radial-gradient(ellipse at center, rgba(20,16,12,.55), rgba(10,8,6,.88)); overflow: auto; }
.sheet-card { width: min(720px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: rgba(250, 245, 234, .97); color: #231c13; border-radius: 18px; padding: 28px 30px; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.sheet-card h1 { font: 700 54px/1 var(--serif); margin: 0 0 8px; letter-spacing: -.01em; }
.sheet-card .lede { margin: 0 0 18px; color: #5a4c3a; font-size: 17px; }
.sheet-card h4 { margin: 18px 0 8px; font: 700 12px var(--sans); text-transform: uppercase; letter-spacing: .08em; color: #8a7458; }
.sheet-card button { border-color: #d9ccb4; background: #fff; color: #231c13; }
.sheet-card button:hover:not(:disabled) { background: #f3ead8; }
.sheet-card .primary { background: #2b3b63; color: #f8efdb; border-color: transparent; }
.sheet-card .primary:hover:not(:disabled) { background: #364a7b; }
.sheet-card .ghost { background: transparent; }
.sheet-card .minor { color: #7a6a52; margin-top: 6px; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.opts h4 { margin-top: 0; }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; text-align: left; }
.seg small { display: block; font-size: 12px; color: #8a7458; }
.seg button.on, .chip.on { background: #2b3b63 !important; color: #f8efdb !important; border-color: transparent; }
.seg button.on small { color: #c9d3ee; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border-radius: 999px; padding: 7px 14px; }
#levels { display: grid; gap: 6px; }
.level { display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 12px; text-align: left; padding: 10px 14px; border-radius: 12px; }
.level .num { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: #2b3b63; color: #f8efdb; font: 700 15px var(--serif); }
.level strong { display: block; font: 600 17px var(--serif); }
.level small { display: block; color: #7a6a52; font-size: 13px; }
.level .best { font-weight: 700; color: #3b7a4a; }
.foot { margin: 18px 0 0; font-size: 12px; color: #8a7458; }
.foot a { color: inherit; }

.score { display: flex; align-items: baseline; gap: 14px; }
.score span { font: 700 64px/1 var(--serif); }
.score small { font: 600 20px var(--serif); color: #2b3b63; }
#endMistakes { padding: 0; margin: 0; list-style: none; display: grid; gap: 8px; }
#endMistakes li { padding: 10px 12px; background: #fff; border: 1px solid #e6dbc6; border-radius: 10px; font-size: 14px; }
#endMistakes li strong { display: block; font-family: var(--serif); }
#endMistakes li span { color: #5a4c3a; }
#endMistakes li.clean { color: #3b7a4a; font-weight: 600; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }

@media (max-width: 900px) {
  #notes { top: auto; bottom: calc(var(--panel-h, 210px) + 70px); right: 12px; width: 190px; font-size: 12px; opacity: .92; }
}
@media (max-width: 640px) {
  #notes { display: none; }
  .opts, .orderwrap { grid-template-columns: 1fr; }
  .sheet-card { padding: 22px 18px; }
  .sheet-card h1 { font-size: 42px; }
  #prompt { font-size: 17px; }
  #gavelBtn span { display: none; }
}

#rotate { display: none; }
@media (orientation: portrait) and (max-width: 640px) {
  #rotate { display: block; position: fixed; top: 74px; left: 50%; transform: translateX(-50%); background: var(--glass); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 13px; color: var(--muted); white-space: nowrap; pointer-events: none; }
  #menu:not([hidden]) ~ #rotate, body:has(#menu:not([hidden])) #rotate { display: none; }
}
