:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --paper: #f2f1eb;
  --surface: #fffefa;
  --ink: #20302e;
  --muted: #66716d;
  --line: #d8ded7;
  --teal: #0d7168;
  --teal-hover: #095b54;
  --yellow: #f7d84b;
  --orange: #ff9b49;
  --green: #6cc678;
  --magenta: #d75ab9;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body.operator-page { background: var(--paper); color: var(--ink); }
button, select, input { font: inherit; }
button { cursor: pointer; }
button:disabled, input:disabled { cursor: not-allowed; }
button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 3px solid #3daba1;
  outline-offset: 3px;
}
::selection { background: #b5dfd5; color: #12312c; }

.topbar {
  min-height: 82px;
  padding: 14px clamp(22px, 3vw, 48px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark { display: grid; grid-template-columns: repeat(2, 11px); gap: 2px; transform: rotate(-5deg); }
.brand-mark i { width: 11px; height: 11px; border-radius: 2px; }
.brand-mark i:nth-child(1) { background: var(--yellow); }
.brand-mark i:nth-child(2) { background: var(--orange); }
.brand-mark i:nth-child(3) { background: var(--green); }
.brand-mark i:nth-child(4) { background: var(--magenta); }
.brand strong { display: block; font-size: 14px; letter-spacing: .09em; font-weight: 850; }
.brand span:not(.brand-mark) { color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 20px; }
.connection-pill { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.theme-switch { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.theme-switch-label { display: inline-flex; align-items: center; gap: 6px; padding: 0 7px 0 6px; color: var(--muted); font-size: 11px; font-weight: 700; }
.theme-switch-label kbd { padding: 3px 5px; font-size: 10px; }
.theme-switch button { display: inline-flex; align-items: center; gap: 7px; min-height: 34px; padding: 6px 11px; border: 0; border-radius: 7px; background: transparent; color: #36584f; font-size: 12px; font-weight: 700; cursor: pointer; transition: background-color .18s ease, color .18s ease; }
.theme-switch button:hover:not([aria-pressed="true"]) { background: #e7f0ea; }
.theme-switch button[aria-pressed="true"] { background: #213a36; color: #fff; }
.theme-dot { width: 11px; height: 11px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(20, 30, 24, .3); }
.theme-dot[data-theme="dark"] { background: #000; }
.theme-dot[data-theme="light"] { background: #f3f2ec; }
.theme-switch button[aria-pressed="true"] .theme-dot { box-shadow: 0 0 0 1px rgba(255, 255, 255, .55); }
.backdrop-pick { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 4px 9px 4px 6px; border-radius: 7px; color: #36584f; font-size: 12px; font-weight: 700; cursor: pointer; }
.backdrop-pick[data-active="true"] { background: #213a36; color: #fff; }
.backdrop-pick input { width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; }
.backdrop-pick input::-webkit-color-swatch-wrapper { padding: 0; }
.backdrop-pick input::-webkit-color-swatch { border: 1px solid rgba(20, 30, 24, .3); border-radius: 50%; }
.backdrop-pick input:disabled { cursor: not-allowed; opacity: .43; }
#backdrop-reset { min-height: 34px; padding: 6px 9px; }
#backdrop-reset[hidden] { display: none; }
.sound-toggle { min-height: 40px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: #36584f; font-size: 12px; font-weight: 700; cursor: pointer; }
.sound-toggle[aria-pressed="false"] { color: var(--muted); text-decoration: line-through; }
.connection-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #c49d54; }
.connection-pill[data-tone="ready"]::before { background: #278b5a; }
.connection-pill[data-tone="error"]::before { background: #d95c50; }

.button {
  border: 1px solid transparent;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  transition: background-color .18s ease, border-color .18s ease, transform .18s ease;
}
.button:active:not(:disabled) { transform: translateY(1px); }
.button:disabled { opacity: .43; }
.button[hidden] { display: none; }
.button-dark { background: #213a36; color: white; }
.button-dark:hover:not(:disabled) { background: #142a27; }
.button[data-attention="true"] { box-shadow: 0 0 0 3px var(--paper), 0 0 0 6px var(--teal); }
.button-primary { background: var(--teal); color: white; }
.button-primary:hover:not(:disabled) { background: var(--teal-hover); }
.button-secondary { background: var(--surface); color: var(--ink); border-color: #b8c9c1; }
.button-secondary:hover:not(:disabled) { background: #e9f2ec; border-color: #91b4a7; }
.button-light { background: white; color: #1b3531; }
.button-light:hover:not(:disabled) { background: #eaf3ee; }
.button-text { background: transparent; color: #244d48; }
.button-text:hover:not(:disabled) { background: #e4eee8; }
kbd { font-family: inherit; font-size: 11px; font-weight: 700; line-height: 1; padding: 5px 6px; border: 1px solid currentColor; border-radius: 4px; opacity: .65; white-space: nowrap; }

.workspace { max-width: 1600px; margin: 0 auto; padding: clamp(24px, 3vw, 44px); }
.page-intro { display: flex; justify-content: space-between; align-items: end; gap: 28px; margin-bottom: 29px; }
.page-intro h1 { margin: 0 0 8px; font-size: clamp(28px, 3vw, 42px); line-height: 1.06; letter-spacing: -.035em; }
.page-intro p { margin: 0; max-width: 62ch; color: var(--muted); line-height: 1.5; }
.step-hint { display: flex; align-items: center; gap: 9px; padding-bottom: 4px; color: #59645e; font-size: 12px; white-space: nowrap; }
.step-hint b { color: #a7b1aa; font-weight: 400; }
.step-hint span[data-state="done"] { color: #8b968f; }
.step-hint span[data-state="done"]::before { content: "✓ "; }
.step-hint span[data-state="current"] { color: var(--teal); font-weight: 700; }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(320px, .9fr); gap: clamp(22px, 2.4vw, 38px); align-items: start; }
.camera-area { min-width: 0; }
.section-heading { min-height: 51px; margin-bottom: 15px; display: flex; justify-content: space-between; align-items: end; gap: 12px; }
.section-heading h2 { margin: 0 0 4px; font-size: 17px; line-height: 1.2; letter-spacing: -.015em; }
.section-heading p { margin: 0; font-size: 12px; line-height: 1.4; color: var(--muted); }
.section-heading p[data-tone="next"] { color: var(--teal); font-weight: 650; }
.meta-value { color: var(--muted); font-size: 12px; white-space: nowrap; }
.camera-stage { position: relative; background: #0b1312; aspect-ratio: 16 / 9; border-radius: 13px; overflow: hidden; box-shadow: 0 18px 35px -24px rgba(7, 25, 20, .6); }
.camera-stage video, .camera-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.camera-stage video { object-fit: contain; }
.camera-stage canvas { pointer-events: none; }
.camera-placeholder { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 11px; padding: 24px; color: #edf6f1; text-align: center; }
.camera-placeholder[hidden], .live-tag[hidden], .projector-toast[hidden] { display: none; }
.camera-placeholder strong { font-size: 18px; font-weight: 650; }
.camera-placeholder span { color: #bdccc5; font-size: 13px; line-height: 1.45; max-width: 36ch; }
.camera-placeholder .button { margin-top: 10px; }
.camera-glyph { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 14px; background: #1e302b; margin-bottom: 4px; }
.camera-glyph svg { width: 29px; fill: none; stroke: #bbd7c8; stroke-linecap: round; stroke-linejoin: round; stroke-width: 3; }
.live-tag { position: absolute; top: 16px; left: 17px; display: flex; align-items: center; gap: 7px; color: #f3fff6; background: rgba(6, 19, 15, .7); border: 1px solid rgba(225, 255, 232, .14); border-radius: 6px; padding: 6px 8px; font-size: 10px; font-weight: 800; letter-spacing: .1em; }
.live-tag span { width: 6px; height: 6px; background: #63de8e; border-radius: 50%; }
.camera-toolbar { display: flex; align-items: center; gap: 11px; min-height: 66px; border-bottom: 1px solid var(--line); }
.camera-toolbar label { color: #43574e; font-size: 12px; font-weight: 700; }
.camera-toolbar select { background: var(--surface); border: 1px solid #c6d1c9; border-radius: 7px; color: var(--ink); min-width: 240px; max-width: 45%; height: 35px; padding: 0 29px 0 10px; font-size: 12px; }
.toolbar-note { margin-left: auto; text-align: right; color: var(--muted); font-size: 11px; }
.camera-toolbar { flex-wrap: wrap; row-gap: 8px; padding-block: 10px; }
.camera-lock { flex: 1 1 220px; min-width: 0; margin-left: auto; overflow: hidden; color: var(--muted); font-size: 11px; line-height: 1.35; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.camera-lock[data-tone="ok"] { color: #1f6a4a; font-weight: 650; }
.align-status { margin: 0 0 12px; font-size: 13px; line-height: 1.4; color: var(--muted, #5b6663); }
.align-status:empty { display: none; }
.align-status[data-tone="ok"] { color: #1f6a4a; font-weight: 650; }
.align-status[data-tone="warn"] { color: #94571a; font-weight: 650; }
.align-status[data-tone="error"] { color: #944439; font-weight: 650; }
.camera-lock[data-tone="busy"] { color: #155d55; font-weight: 650; }
.camera-lock[data-tone="warn"] { color: #94571a; font-weight: 650; }
.camera-lock[data-tone="error"] { color: #944439; font-weight: 650; }
.button-compact { flex: 0 0 auto; min-height: 34px; padding: 7px 11px; font-size: 12px; }
.palette { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 17px; }
.palette-role { --role-color: #c9d0cb; display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto auto; align-items: center; gap: 8px; min-height: 46px; padding: 6px 7px 6px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); transition: border-color .18s ease, box-shadow .18s ease; }
.palette-role[data-picking="true"] { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(13, 113, 104, .16); }
.role-light { width: 10px; height: 10px; border-radius: 50%; background: #d3d9d5; box-shadow: inset 0 0 0 1px rgba(20, 30, 24, .1); transition: background-color .2s ease, box-shadow .2s ease; }
.role-light[data-state="on"] { background: var(--role-color); box-shadow: 0 0 0 3px color-mix(in srgb, var(--role-color) 30%, transparent), 0 0 12px 2px var(--role-color); }
.role-light[data-state="warn"] { background: #e8a33a; box-shadow: 0 0 0 3px rgba(232, 163, 58, .28); }
.role-swatch { width: 26px; height: 26px; padding: 0; border: 1px solid rgba(20, 30, 24, .2); border-radius: 6px; background: none; cursor: pointer; }
.role-swatch:disabled { cursor: default; opacity: .55; }
.role-swatch::-webkit-color-swatch-wrapper { padding: 2px; }
.role-swatch::-webkit-color-swatch { border: 0; border-radius: 4px; }
.role-name { overflow: hidden; color: var(--ink); font-size: 12px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.role-count { color: #6a766f; font-size: 12px; font-variant-numeric: tabular-nums; }
.role-count[data-state="on"] { color: #1f6a4a; }
.role-count[data-state="warn"] { color: #a2620f; }
.role-pick { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid transparent; border-radius: 7px; background: transparent; color: #36584f; cursor: pointer; }
.role-pick:hover:not(:disabled) { background: #e7f0ea; }
.role-pick:disabled { opacity: .4; cursor: default; }
.role-pick[aria-pressed="true"] { background: var(--teal); color: #fff; }
.role-pick svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.palette-footer { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; margin-top: 9px; }
.palette-footer p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.palette-footer p[data-tone="warn"] { color: #94571a; font-weight: 650; }
.link-button { flex: 0 0 auto; border: 0; background: none; padding: 4px 0; color: #244d48; font-size: 11px; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.link-button:disabled { opacity: .45; cursor: default; }
.camera-stage[data-picking] { cursor: crosshair; }
.pick-banner { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); max-width: calc(100% - 32px); padding: 8px 12px; border-radius: 8px; background: rgba(6, 19, 15, .84); color: #f3fff6; font-size: 12px; font-weight: 650; text-align: center; pointer-events: none; }
.pick-banner[hidden] { display: none; }

.control-area { background: var(--surface); border: 1px solid #e3e6df; border-radius: 13px; overflow: hidden; box-shadow: 0 16px 32px -30px rgba(20, 35, 28, .35); }
.setup-section, .play-section { padding: 23px 24px; }
.setup-section { border-bottom: 1px solid var(--line); }
.section-heading.compact { min-height: auto; margin-bottom: 17px; align-items: start; }
.setup-actions, .play-actions { display: flex; flex-direction: column; gap: 9px; }
.setup-actions .button, .play-actions .button { width: 100%; }
.detected-notes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 15px; margin-top: 20px; }
.detected-notes > div { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #59665f; }
.detected-notes strong { color: #31433b; margin-left: auto; font-variant-numeric: tabular-nums; }
.note-dot { width: 9px; height: 9px; border-radius: 2px; flex: 0 0 auto; }
.note-dot[data-role="start"] { background: var(--yellow); }
.note-dot[data-role="goal"] { background: var(--orange); }
.note-dot[data-role="bumper"] { background: var(--green); }
.note-dot[data-role="marker"] { background: var(--magenta); }
.game-pill { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; color: #596a5f; font-size: 11px; white-space: nowrap; }
.game-pill[data-tone="running"] { color: #0b7169; border-color: #9dcac2; background: #e9f5f0; }
.game-pill[data-tone="paused"] { color: #91601f; border-color: #dec496; background: #fff7e8; }
.game-pill[data-tone="won"] { color: #257440; border-color: #aed9b3; background: #eff9ed; }
.game-pill[data-tone="lost"] { color: #ad4539; border-color: #edb7ae; background: #fff2ed; }
.drop-note { color: #4b5a51; font-size: 12px; margin: 22px 0 21px; }
.game-stats { display: flex; justify-content: space-between; gap: 10px; border-top: 1px solid var(--line); margin-top: 20px; padding-top: 16px; }
.game-stats span { display: flex; flex-direction: column; gap: 5px; color: #647169; font-size: 11px; }
.game-stats strong { color: var(--ink); font-size: 16px; font-variant-numeric: tabular-nums; font-weight: 700; }
.status-panel { display: flex; gap: 10px; align-items: start; margin: 0 24px 12px; padding: 12px 13px; border-radius: 8px; background: #eef4ed; color: #3a5a49; }
.status-panel[data-tone="error"] { background: #fff0eb; color: #944439; }
.status-panel[data-tone="busy"] { background: #eaf4f2; color: #155d55; }
.status-mark { width: 7px; height: 7px; flex: 0 0 auto; margin-top: 5px; border-radius: 50%; background: currentColor; }
.status-panel p { margin: 0; font-size: 12px; line-height: 1.45; }
.footnote { margin: 0 24px 24px; color: #68746c; font-size: 11px; line-height: 1.5; }

body.projector-page { background: #000; color: #fff; overflow: hidden; }
#projector-canvas { display: block; width: 100vw; height: 100vh; cursor: default; }
body.projector-page[data-mode="live"] #projector-canvas, body.projector-page[data-mode="black"] #projector-canvas { cursor: none; }
body.projector-page[data-capture="true"] .projector-topline,
body.projector-page[data-capture="true"] .projector-toast,
body.projector-page[data-mode="align"] .projector-topline,
body.projector-page[data-mode="neutral"] .projector-topline,
body.projector-page[data-mode="black"] .projector-topline,
body.projector-page[data-mode="black"] .projector-toast,
body.projector-page:fullscreen[data-mode="live"] .projector-topline,
body.projector-page:fullscreen[data-mode="live"] .projector-toast,
html:fullscreen body.projector-page[data-mode="live"] .projector-topline,
html:fullscreen body.projector-page[data-mode="live"] .projector-toast { display: none; }
.projector-topline { position: fixed; inset: 17px 18px auto; display: flex; align-items: center; justify-content: space-between; gap: 16px; pointer-events: none; }
.projector-topline span { color: #f3f7f7; font-size: 14px; font-weight: 650; text-shadow: 0 1px 5px #000; }
.projector-control { pointer-events: auto; min-height: 39px; padding: 8px 12px; border: 1px solid #66827b; border-radius: 7px; background: #1b302c; color: #f9fffb; font-size: 12px; font-weight: 700; }
.projector-control:hover { background: #2d4841; }
.projector-control.primary { background: #eaf7ed; border-color: #eaf7ed; color: #173329; }
.projector-control.primary:hover { background: #c8e6d6; }
.projector-toast { position: fixed; top: 76px; right: 18px; max-width: 40ch; padding: 10px 12px; border-radius: 8px; background: #fff0eb; color: #8e3c31; font-size: 12px; }
/* Light projector theme: ink on a lit wall. A scan still turns it black. */
body.projector-page[data-theme="light"] { background: #f3f2ec; color: #17211f; }
body.projector-page[data-blackout="true"] { background: #000; }
body.projector-page[data-theme="light"] .projector-topline span { color: #17211f; text-shadow: none; }
body.projector-page[data-theme="light"] .projector-control { background: #fff; border-color: #b8c9c1; color: #17211f; }
body.projector-page[data-theme="light"] .projector-control:hover { background: #e9f2ec; }
body.projector-page[data-theme="light"] .projector-control.primary { background: #213a36; border-color: #213a36; color: #fff; }
body.projector-page[data-theme="light"] .projector-control.primary:hover { background: #142a27; }

@media (max-width: 1050px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .control-area { display: grid; grid-template-columns: 1fr 1fr; }
  .setup-section { border-bottom: 0; border-right: 1px solid var(--line); }
  .status-panel, .footnote { grid-column: 1 / -1; }
  .palette { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .topbar { min-height: 70px; }
  .brand span:not(.brand-mark), .connection-pill, .step-hint, .toolbar-note { display: none; }
  .workspace { padding: 22px 16px; }
  .page-intro h1 { font-size: 29px; }
  .camera-toolbar { gap: 8px; }
  .camera-toolbar select { min-width: 0; max-width: none; flex: 1; }
  .control-area { display: block; }
  .setup-section { border-right: 0; border-bottom: 1px solid var(--line); }
  .topbar-actions .button { font-size: 11px; padding: 9px 11px; }
  .topbar-actions { gap: 10px; }
  .theme-switch-label { display: none; }
  .theme-switch button { padding: 6px 8px; }
  .palette-footer { flex-direction: column; gap: 4px; }
  .camera-lock { flex-basis: 100%; margin-left: 0; text-align: left; white-space: normal; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
