:root {
  color-scheme: light;
  --paper: #f5f2ea;
  --panel: #fffcf6;
  --ink: #231f1a;
  --muted: #655d52;
  --line: #d9d1c3;
  --orange: #f78437;
  --orange-ink: #a43b10;
  --green: #16674b;
  --red: #a13936;
  --mono: ui-monospace, "SF Mono", Consolas, monospace;
  font-family: Arial, "Noto Sans Hebrew", sans-serif;
  font-synthesis: none;
}

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

.masthead { border-bottom: 1px solid var(--line); }
.masthead-inner, .shell { max-width: 1320px; margin-inline: auto; padding-inline: 36px; }
.masthead-inner { min-height: 67px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font: 900 22px/1 Arial, sans-serif; letter-spacing: -.07em; }
.brand-icon { width: 36px; height: 36px; color: var(--orange); }
.brand-accent { color: var(--orange-ink); }
.sound-button { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 0 11px; background: transparent; border: 1px solid var(--line); border-radius: 8px; font-size: .84rem; font-weight: 600; }
.sound-button:hover { background: var(--panel); }
.speaker { width: 18px; height: 18px; }
.sound-on, .sound-button[aria-pressed="true"] .sound-off { display: none; }
.sound-button[aria-pressed="true"] .sound-on { display: initial; }

.intro { margin: 35px 0 25px; }
.intro h1 { margin: 0; font-family: "Arial Black", Arial, sans-serif; font-size: clamp(2.7rem, 6vw, 5rem); font-weight: 900; line-height: .98; letter-spacing: -.065em; }
.title-tail { color: #51473d; }
.title-period { color: var(--orange-ink); }
.intro p { display: inline-block; margin: 13px 0 0; color: var(--muted); font-size: 1.02rem; line-height: 1.45; }

.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 303px); gap: 18px; align-items: start; }
.play-area { min-width: 0; }
.broadcast { position: relative; aspect-ratio: 1024 / 682; overflow: hidden; border: 1px solid #2f2b27; isolation: isolate; background: #383a3c url("assets/office.png") center / cover no-repeat; border-radius: 12px; touch-action: manipulation; user-select: none; }
#stage { width: 100%; height: 100%; display: block; }
.camera-frame { position: absolute; inset: 12px; pointer-events: none; opacity: .63; --corner: #efe9dd; --length: 13px; --top: linear-gradient(var(--corner), var(--corner)); background: var(--top) top left / var(--length) 1px, var(--top) top left / 1px var(--length), var(--top) top right / var(--length) 1px, var(--top) top right / 1px var(--length), var(--top) bottom left / var(--length) 1px, var(--top) bottom left / 1px var(--length), var(--top) bottom right / var(--length) 1px, var(--top) bottom right / 1px var(--length); background-repeat: no-repeat; }
.broadcast-status { position: absolute; top: 22px; left: 24px; display: flex; align-items: center; gap: 8px; direction: ltr; }
.status-badge, .clock { display: inline-flex; align-items: center; height: 26px; padding: 0 8px; color: #fff6eb; background: #24221eeb; border-radius: 4px; font: 700 .68rem/1 var(--mono); letter-spacing: .05em; }
.status-badge { gap: 6px; }
.status-badge i { display: block; width: 7px; height: 7px; background: #f4bd6e; border-radius: 50%; }
.broadcast[data-phase="flying"] .status-badge, .broadcast[data-phase="missed"] .status-badge { background: #9e2a21; }
.broadcast[data-phase="flying"] .status-badge i, .broadcast[data-phase="missed"] .status-badge i { background: #ffdad6; }
.location { position: absolute; top: 24px; right: 25px; padding: 5px 8px; border-radius: 4px; background: #24221ee8; color: #fff6eb; font-size: .77rem; }
.stage-message { position: absolute; left: 50%; bottom: 7%; translate: -50% 0; width: max-content; max-width: 85%; text-align: center; color: #fff0e3; background: #3d221eea; border: 1px solid #f1a791; border-radius: 8px; padding: 8px 12px; font-size: clamp(.75rem, 1.6vw, .96rem); font-weight: 700; }
.stage-message:empty, .float-change:empty { display: none; }
.swing-cue { position: absolute; top: 64%; left: 47.5%; translate: -50% 0; border-radius: 4px; padding: 4px 7px; background: #9aefbd; color: #123c2a; font-size: clamp(.7rem, 1.4vw, .86rem); font-weight: 800; }
.float-change { position: absolute; top: 38%; left: 47%; translate: -50% 0; padding: 5px 8px; border-radius: 5px; background: #1c3128eb; color: #c3f5cf; font: bold clamp(.75rem, 1.5vw, 1.05rem) var(--mono); pointer-events: none; }
.float-change[data-direction="down"] { background: #402322ec; color: #ffb5af; }

.controls { display: flex; align-items: center; gap: 20px; margin-top: 11px; padding: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 11px; }
.action-button { display: inline-flex; justify-content: center; align-items: center; gap: 10px; min-height: 47px; min-width: 152px; padding: 0 15px; border: 1px solid #ab480e; border-radius: 7px; background: var(--orange); font-weight: 800; box-shadow: 0 2px #a94717; }
.action-button:hover { background: #ffa05a; }
.action-button:active { translate: 0 2px; box-shadow: none; }
.action-button svg { width: 18px; height: 18px; }
.timing-panel { min-width: 0; flex: 1; padding-inline-end: 7px; }
.timing-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 23px; margin-bottom: 4px; color: var(--muted); font-size: .81rem; font-weight: 700; }
#timing-label[data-open="true"] { color: var(--green); }
kbd { display: inline-block; padding: 3px 7px; border: 1px solid #d4cabc; border-bottom-width: 2px; border-radius: 4px; background: #f5f0e5; color: #524b40; font: 700 .66rem/1 var(--mono); }
.timing-track { direction: ltr; position: relative; height: 8px; border-radius: 4px; background: #e5ded2; }
.timing-zone { position: absolute; top: 0; bottom: 0; inset-inline: 70.48% 4.41%; border-radius: 2px; background: #8dbda0; }
.timing-marker { position: absolute; top: -3px; width: 5px; height: 14px; border-radius: 2px; translate: -50% 0; background: #2b251e; }
.instruction { margin: 10px 2px 0; color: var(--muted); font-size: .87rem; line-height: 1.55; }

.dashboard { display: grid; gap: 11px; }
.panel { min-width: 0; padding: 15px 17px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 6px; color: var(--muted); }
.panel-heading h2 { margin: 0; color: var(--ink); font-size: 1rem; }
.panel-heading svg { width: 20px; height: 20px; }
.ticker { color: var(--muted); font: 700 .68rem/1 var(--mono); letter-spacing: .025em; }
.quote { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 12px 0 9px; }
.quote strong { font: 800 clamp(1.9rem, 3.1vw, 2.55rem)/1 var(--mono); letter-spacing: -.09em; }
.change { white-space: nowrap; padding: 5px 6px; border-radius: 4px; background: #eeeadf; color: var(--muted); font: 700 .71rem/1 var(--mono); }
.change[data-direction="up"] { background: #e1f1e5; color: var(--green); }
.change[data-direction="down"] { background: #f9e3e0; color: var(--red); }
.chart-wrap { position: relative; height: 100px; margin: 4px 0 8px; }
#chart { width: 100%; height: 100%; display: block; direction: ltr; }
.chart-caption, .combo-details { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: .76rem; }
.chart-caption { border-top: 1px solid #e6dfd4; padding-top: 9px; }
.chart-caption b, .combo-details b { color: var(--ink); font-family: var(--mono); white-space: nowrap; }
.audience strong { display: block; margin-top: 7px; text-align: right; font: 800 1.95rem/1 var(--mono); letter-spacing: -.06em; }
.streak-count { margin-top: 7px; text-align: right; font: 800 2.2rem/1 var(--mono); letter-spacing: -.06em; }
.streak-count span { margin-left: 3px; color: var(--orange-ink); font-size: 1.25rem; }
.combo-track { overflow: hidden; height: 5px; margin: 12px 0 9px; border-radius: 3px; background: #e9e0d2; }
.combo-track span { display: block; width: 0; height: 100%; background: #d85c20; transition: width .2s ease-out; }
.footer { color: var(--muted); border-top: 1px solid var(--line); margin: 24px 0 0; padding: 11px 0 20px; font-size: .76rem; }

@media (min-width: 851px) and (max-height: 950px) {
  .shell { max-width: min(1320px, max(850px, calc((100svh - 295px) * 1.5 + 393px))); }
  .intro { margin: 23px 0 18px; }
  .intro h1 { font-size: clamp(2.7rem, 6vw, 4.45rem); }
}

@media (max-width: 850px) {
  .masthead-inner, .shell { padding-inline: 22px; }
  .game-layout { grid-template-columns: minmax(0, 1fr) 225px; gap: 11px; }
  .panel { padding-inline: 12px; }
  .controls { gap: 13px; }
  .action-button { min-width: 124px; }
}

@media (max-width: 650px) {
  .masthead-inner, .shell { padding-inline: 14px; }
  .masthead-inner { min-height: 55px; }
  .brand { font-size: 20px; }
  .brand-icon { width: 30px; height: 30px; }
  .intro { margin: 24px 0 16px; }
  .intro h1 { font-size: clamp(2.15rem, 9.5vw, 3.95rem); }
  .intro p { font-size: .88rem; margin-top: 7px; }
  .game-layout { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .broadcast { border-radius: 9px; }
  .camera-frame { inset: 7px; --length: 8px; }
  .broadcast-status { top: 12px; left: 13px; gap: 4px; }
  .status-badge, .clock { height: 20px; padding-inline: 5px; font-size: .57rem; }
  .status-badge i { width: 5px; height: 5px; }
  .location { top: 12px; right: 13px; font-size: .62rem; padding: 4px 5px; }
  .controls { margin-top: 8px; padding: 8px; }
  .action-button { min-width: 108px; min-height: 45px; font-size: .91rem; }
  .instruction { margin-top: 7px; font-size: .78rem; }
  .dashboard { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
  .market { grid-column: 1 / -1; }
  .combo-details { flex-wrap: wrap; }
  .chart-wrap { height: 72px; }
}

@media (prefers-reduced-motion: reduce) {
  .combo-track span { transition: none; }
}
