:root {
  color-scheme: dark;
  --ink: #fff3e6;
  --muted: #d4c9be;
  --orange: #ff944b;
  --mono: ui-monospace, "SF Mono", Consolas, monospace;
  font-family: Arial, sans-serif;
  background: #171717;
  color: var(--ink);
}

* { box-sizing: border-box; }
body { margin: 0; }
button, a { color: inherit; }
button { font: inherit; cursor: pointer; }
kbd { font-family: var(--mono); }
button:focus-visible, a:focus-visible { outline: 2px solid #ffb47a; outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.masthead { min-height: 60px; padding: 8px clamp(12px, 2.3vw, 36px); display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: center; background: #1b1a19; border-bottom: 1px solid #51413a; }
.brand { display: inline-flex; align-items: center; gap: 8px; font: 900 1.19rem/1 Arial, sans-serif; letter-spacing: -.055em; width: max-content; }
.brand svg { display: block; width: 32px; height: 32px; }
.accent { color: var(--orange); }
h1 { margin: 0; text-align: center; font-size: clamp(1.08rem, 2.15vw, 1.72rem); letter-spacing: -.045em; line-height: 1.05; }
.masthead-actions { display: flex; align-items: center; justify-content: end; gap: 8px; }
.sound-button, .version-link { display: inline-grid; place-items: center; width: 38px; height: 35px; border: 1px solid #62564b; border-radius: 6px; background: #282421; }
.version-link { font: 700 .79rem var(--mono); color: #ffc292; text-decoration: none; }
.sound-button:hover, .version-link:hover { background: #493227; }
.sound-button svg { width: 19px; height: 19px; }
.sound-on, .sound-button[aria-pressed="true"] .sound-off { display: none; }
.sound-button[aria-pressed="true"] .sound-on { display: initial; }

.broadcast { position: relative; isolation: isolate; width: 100%; height: clamp(500px, calc(100svh - 98px), 940px); overflow: hidden; touch-action: manipulation; user-select: none; background: #373739 url("assets/office.png") center / cover no-repeat; border-bottom: 1px solid #51413a; cursor: pointer; }
#stage { display: block; width: 100%; height: 100%; }
.broadcast::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, #1815148c, transparent 25%, transparent 69%, #171415ac); pointer-events: none; z-index: 1; }
.camera-frame { position: absolute; inset: 12px; pointer-events: none; z-index: 2; opacity: .6; --side: 16px; --line: linear-gradient(#ffe4cd, #ffe4cd); background: var(--line) left top / var(--side) 1px, var(--line) left top / 1px var(--side), var(--line) right top / var(--side) 1px, var(--line) right top / 1px var(--side), var(--line) left bottom / var(--side) 1px, var(--line) left bottom / 1px var(--side), var(--line) right bottom / var(--side) 1px, var(--line) right bottom / 1px var(--side); background-repeat: no-repeat; }

.hud-left, .hud-right { position: absolute; top: 23px; display: grid; gap: 7px; z-index: 3; pointer-events: none; direction: ltr; font-family: var(--mono); }
.hud-left { left: 23px; }
.hud-right { right: 23px; }
.stream-line { min-height: 39px; display: flex; align-items: start; gap: 5px; }
.status-badge, .clock { display: inline-flex; align-items: center; padding: 6px 9px; min-height: 25px; color: #fff1e2; border: 1px solid #ffffff28; border-radius: 5px; background: #211c18e8; font: 800 .7rem/1 var(--mono); letter-spacing: .04em; }
.status-badge { gap: 6px; }
.status-badge i { flex: none; width: 7px; height: 7px; background: #f5bd70; border-radius: 50%; }
.broadcast:not([data-phase="ready"]) .status-badge { background: #a62f29; border-color: #fb897a; }
.broadcast:not([data-phase="ready"]) .status-badge i { background: #ffe3db; box-shadow: 0 0 7px #ffd3d1a0; }
.hud-stats { margin: 0; border: 1px solid #ffffff26; border-radius: 7px; display: flex; color: var(--ink); background: #211c18e8; box-shadow: 0 3px 8px #0003; }
.hud-stats > div { min-width: 76px; padding: 8px 10px; }
.hud-stats > div + div { border-left: 1px solid #ffffff23; }
.hud-stats dt, .quote-label { color: #ded1c5; white-space: nowrap; font-size: .66rem; font-weight: 800; letter-spacing: .05em; }
.hud-stats dd { margin: 2px 0 0; min-width: 2ch; font-size: clamp(1.15rem, 2.35vw, 1.8rem); line-height: 1; font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: -.06em; }
.hud-right .hud-stats dd { color: #ffc697; }
.quote { border: 1px solid #ffffff26; border-radius: 7px; padding: 6px 9px 7px; background: #211c18e8; }
.quote-data { display: flex; align-items: center; flex-wrap: wrap; gap: 3px 7px; }
.quote-data strong { font-size: clamp(1.05rem, 2vw, 1.52rem); line-height: 1.15; letter-spacing: -.06em; }
#change { padding: 3px 4px; border-radius: 3px; color: var(--muted); background: #ffffff19; font-size: .68rem; font-weight: 800; }
#change[data-direction="up"] { color: #b9ffc9; background: #246444; }
#change[data-direction="down"] { color: #ffccbf; background: #773431; }

.controls { position: absolute; z-index: 5; bottom: max(18px, env(safe-area-inset-bottom)); left: 50%; translate: -50% 0; width: min(565px, calc(100% - 34px)); text-align: center; }
.timing-button { position: relative; display: block; width: 100%; min-height: 68px; padding: 0 7% 6px; border: 1px solid #fff1d215; border-radius: 12px; background: #201a18ed; box-shadow: 0 4px 18px #0807069a; touch-action: manipulation; }
.timing-button:hover { border-color: #fd9d57a8; }
.timing-button::before { content: ""; position: absolute; top: 4px; height: 38px; inset-inline: 1%; background: url("assets/timing-track.png") center / 100% 100% no-repeat; pointer-events: none; }
.timing-groove { display: block; position: relative; direction: ltr; height: 14px; margin: 15px 0 8px; background: #171716; border: 1px solid #776558; border-radius: 3px; box-shadow: inset 0 0 8px #000; }
.timing-groove::before { content: ""; position: absolute; inset: 0; opacity: .27; background: repeating-linear-gradient(90deg, #ffffff40 0 1px, transparent 1px 10%); }
.timing-target { position: absolute; top: 0; bottom: 0; background: linear-gradient(#a4ea92, #45af63); border: 1px solid #b2f5a4; border-radius: 2px; box-shadow: 0 0 7px #8bf58a57; }
.timing-gold { position: absolute; top: -1px; bottom: -1px; background: linear-gradient(#fff097, #ffbf4a); border: 1px solid #fff0a5; border-radius: 1px; box-shadow: 0 0 6px #ffe28edf; }
.timing-marker { position: absolute; top: -5px; bottom: -5px; width: 5px; translate: -50% 0; background: #fff4e8; border: 1px solid #222; border-radius: 2px; box-shadow: 0 0 7px #fff4e3a8; }
.timing-marker[data-quality="gold"] { background: #fff28d; }
.action-caption { min-height: 21px; display: flex; align-items: center; justify-content: center; gap: 8px; color: #fff2e4; font-size: .88rem; font-weight: 800; }
#action[data-quality="green"] .action-caption { color: #a9f7a8; }
#action[data-quality="gold"] .action-caption { color: #ffe48c; }
.action-caption kbd { padding: 2px 5px; border: 1px solid #817061; border-bottom-width: 2px; border-radius: 3px; font-size: .68rem; color: #eee0d1; }
.instruction { margin: 6px 0 0; font-size: .76rem; color: #fff2e5; text-shadow: 0 2px 4px #000; }
.game-status { display: table; margin: 0 auto 8px; max-width: 100%; padding: 5px 8px; background: #49251fee; color: #ffdbca; border: 1px solid #f39b79; border-radius: 5px; font-size: .83rem; font-weight: 700; }

.heart-layer { position: absolute; z-index: 4; left: clamp(8px, 4vw, 66px); bottom: 15%; width: clamp(54px, 11vw, 150px); height: 65%; pointer-events: none; }
.heart { position: absolute; left: 0; bottom: 0; width: var(--size); height: var(--size); filter: drop-shadow(0 2px 4px #401d358c); will-change: transform, opacity; }
.heart svg { display: block; width: 100%; height: 100%; fill: var(--fill); stroke: #ffffff6b; stroke-width: .8; }
.float-change { z-index: 3; position: absolute; left: 50%; top: 25%; translate: -50% 0; color: #caffd2; background: #193729ed; padding: 5px 9px; border: 1px solid #88dca5; border-radius: 5px; font: 900 clamp(.82rem, 2.25vw, 1.15rem) var(--mono); pointer-events: none; white-space: nowrap; }
.float-change[data-direction="down"] { color: #ffd4c6; background: #4b2322; border-color: #ff9d90; }
.float-change[data-direction="gold"] { color: #fff0a4; background: #453519; border-color: #ffdc83; }

footer { display: flex; justify-content: space-between; gap: 10px; align-items: center; min-height: 37px; padding: 5px clamp(12px, 2.3vw, 36px); color: #c8baad; font-size: .73rem; }
@media (max-width: 650px) {
  .masthead { min-height: 52px; gap: 7px; }
  .brand { font-size: .83rem; gap: 5px; }
  .brand svg { width: 26px; height: 26px; }
  .masthead-actions { gap: 5px; }
  .sound-button, .version-link { width: 31px; height: 30px; }
  .broadcast { height: clamp(420px, calc(100svh - 89px), 665px); }
  .camera-frame { inset: 7px; --side: 11px; }
  .hud-left, .hud-right { top: 15px; gap: 5px; }
  .hud-left { left: 12px; }
  .hud-right { right: 12px; }
  .hud-stats > div { min-width: 59px; padding: 5px 6px; }
  .hud-stats dt, .quote-label { font-size: .56rem; letter-spacing: .015em; }
  .status-badge, .clock { padding: 4px 5px; font-size: .61rem; }
  .quote { padding: 4px 6px; }
  #change { font-size: .59rem; }
  .controls { bottom: max(13px, env(safe-area-inset-bottom)); }
  .heart-layer { bottom: 17%; }
}
@media (max-width: 350px) {
  .masthead h1 { font-size: .98rem; }
  .quote-data { gap: 2px 4px; }
}
@media (pointer: coarse) {
  .action-caption kbd { display: none; }
}
