/* Tastegolf — calm Nordic palette, system font, monospace for key sequences. */

:root {
  color-scheme: light dark;
  --primary: #16365c;
  --green: #2e9e7a;
  --bg-info: #eef1f6;
  --active: #fff5d6;
  --text: #1c2530;
  --grid: #c9d3df;
  --error: #c62828;
  --bg: #ffffff;
  --surface: #ffffff;
  --muted: #55626f;
  --selection: rgba(22, 54, 92, 0.13);
  --header-bg: #eef1f6;
  --header-hl: #d9e1ec;
  --kbd-bg: #f6f8fb;
  --kbd-border: #b9c5d3;
  --on-primary: #ffffff;
  --focus: #16365c;
  --shadow: 0 8px 24px rgba(28, 37, 48, 0.18);
  --cond-bg: #fde7e7;
  --cond-text: #9c1c1c;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #8fb4e3;
    --green: #5cc9a0;
    --bg-info: #1f2a37;
    --active: #4a4320;
    --text: #e6ebf1;
    --grid: #3a4756;
    --error: #f08a8a;
    --bg: #121a24;
    --surface: #182230;
    --muted: #a6b2bf;
    --selection: rgba(143, 180, 227, 0.22);
    --header-bg: #1f2a37;
    --header-hl: #2b3a4d;
    --kbd-bg: #1f2a37;
    --kbd-border: #4a5868;
    --on-primary: #0d1620;
    --focus: #8fb4e3;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    --cond-bg: #4a2222;
    --cond-text: #f3a6a6;
  }
}

:root[data-theme="dark"] {
    --primary: #8fb4e3;
    --green: #5cc9a0;
    --bg-info: #1f2a37;
    --active: #4a4320;
    --text: #e6ebf1;
    --grid: #3a4756;
    --error: #f08a8a;
    --bg: #121a24;
    --surface: #182230;
    --muted: #a6b2bf;
    --selection: rgba(143, 180, 227, 0.22);
    --header-bg: #1f2a37;
    --header-hl: #2b3a4d;
    --kbd-bg: #1f2a37;
    --kbd-border: #4a5868;
    --on-primary: #0d1620;
    --focus: #8fb4e3;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    --cond-bg: #4a2222;
    --cond-text: #f3a6a6;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5rem; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.25rem; color: var(--green); }
h3 { font-size: 1rem; }
p { margin: 0 0 0.75rem; }
a { color: var(--primary); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* Header and footer */
.app-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--grid); background: var(--surface);
}
.app-header .brand { display: flex; align-items: baseline; gap: 10px; }
.app-header .brand h1 { margin: 0; color: var(--primary); }
.app-header .brand .tagline { color: var(--muted); font-size: 0.9rem; }
.app-header .tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.app-footer {
  margin-top: auto; padding: 14px 16px; border-top: 1px solid var(--grid);
  color: var(--muted); font-size: 0.85rem;
}

main { width: 100%; max-width: 1140px; margin: 0 auto; padding: 16px; }

/* Banner */
.banner {
  display: flex; gap: 12px; align-items: flex-start; justify-content: space-between;
  background: var(--bg-info); border-left: 4px solid var(--primary);
  padding: 10px 14px; margin: 0 16px 12px; border-radius: 4px; font-size: 0.95rem;
}

/* Buttons */
.btn {
  font: inherit; font-size: 0.95rem; cursor: pointer;
  padding: 8px 14px; border-radius: 6px;
  border: 1px solid var(--primary); background: var(--primary); color: var(--on-primary);
}
.btn:hover { filter: brightness(1.1); }
.btn.secondary { background: transparent; color: var(--primary); }
.btn.small { padding: 5px 10px; font-size: 0.85rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; filter: none; }

.badge {
  display: inline-block; font-size: 0.75rem; padding: 2px 8px; border-radius: 999px;
  background: var(--bg-info); border: 1px solid var(--grid); color: var(--muted);
}
.badge.ok { color: var(--green); border-color: var(--green); }

/* Start screen */
.start-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin: 16px 0; }
.card {
  border: 1px solid var(--grid); border-radius: 8px; padding: 14px 16px; background: var(--surface);
}
.card h3 { margin-bottom: 4px; }
.card p { color: var(--muted); font-size: 0.95rem; }
.browser-note {
  background: var(--bg-info); border-left: 4px solid var(--primary); border-radius: 6px;
  padding: 10px 14px; margin: 0 0 16px;
}
.browser-note h3 { font-size: 1rem; margin: 0 0 4px; }
.browser-note p { margin: 0; font-size: 0.92rem; }
.stats-row { display: flex; gap: 24px; flex-wrap: wrap; margin: 8px 0 16px; }
.stat { min-width: 120px; }
.stat .label { color: var(--muted); font-size: 0.85rem; }
.stat .value { font-size: 1.6rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--primary); }

.task-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.task-list li {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 10px; border: 1px solid var(--grid); border-radius: 6px; background: var(--surface);
}
.task-list .task-title { flex: 1 1 240px; }
.task-list .task-meta { color: var(--muted); font-size: 0.85rem; }

/* Task screen */
.task-layout { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 16px; align-items: start; }
.task-layout > * { min-width: 0; }
@media (max-width: 900px) { .task-layout { grid-template-columns: 1fr; } }

.prompt {
  display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap;
  background: var(--bg-info); border-left: 4px solid var(--green);
  padding: 12px 14px; border-radius: 4px; margin-bottom: 12px;
}
.prompt .text { font-size: 1.15rem; font-weight: 600; flex: 1 1 300px; margin: 0; }
.prompt .meta { color: var(--muted); font-size: 0.85rem; display: flex; gap: 8px; align-items: center; }

.workspace { border: 1px solid var(--grid); border-radius: 8px; background: var(--surface); }

.ribbon { border-bottom: 1px solid var(--grid); background: var(--surface); border-radius: 8px 8px 0 0; }
.ribbon-tabs { display: flex; gap: 2px; padding: 6px 8px 0; background: var(--bg-info); border-bottom: 1px solid var(--grid); border-radius: 8px 8px 0 0; flex-wrap: wrap; }
.ribbon-tab {
  position: relative; padding: 5px 12px; font: inherit; font-size: 0.9rem; color: var(--muted); cursor: pointer;
  background: none; border: 1px solid transparent; border-bottom: 0; border-radius: 6px 6px 0 0;
}
.ribbon-tab.active { color: var(--text); background: var(--surface); border-color: var(--grid); margin-bottom: -1px; }
.ribbon-body { display: flex; flex-wrap: wrap; align-items: stretch; min-height: 72px; padding: 4px 6px 2px; row-gap: 6px; }
.ribbon-group { display: flex; flex-direction: column; justify-content: space-between; padding: 0 8px; border-right: 1px solid var(--grid); }
.ribbon-group:last-child { border-right: 0; }
.ribbon-buttons { display: flex; gap: 2px; align-items: flex-start; }
.ribbon-button-wrap { position: relative; }
.ribbon-button {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 58px; padding: 5px 6px 4px; border: 1px solid transparent; border-radius: 6px;
  background: none; color: var(--text); font: inherit; font-size: 0.72rem; line-height: 1.2; cursor: pointer;
}
.ribbon-button:hover, .ribbon-button.active { background: var(--bg-info); border-color: var(--grid); }
.ribbon-label { white-space: nowrap; }
.ribbon-group-label { font-size: 0.68rem; color: var(--muted); text-align: center; padding-top: 3px; }
.icon {
  display: inline-block; width: 22px; height: 22px; background-color: currentColor;
  -webkit-mask-size: contain; -webkit-mask-position: center; -webkit-mask-repeat: no-repeat;
  mask-size: contain; mask-position: center; mask-repeat: no-repeat;
}
.caret { color: var(--muted); font-size: 0.7rem; }
.keytip {
  position: absolute; left: 50%; bottom: -9px; transform: translateX(-50%); z-index: 4;
  background: var(--primary); color: var(--on-primary); font: 600 0.72rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 1px 5px; border-radius: 3px; box-shadow: var(--shadow); pointer-events: none;
}
.ribbon-tab .keytip { bottom: -10px; }
.ribbon-menu {
  position: absolute; top: 100%; left: 0; z-index: 6; min-width: 230px; padding: 4px; display: grid;
  background: var(--surface); border: 1px solid var(--grid); border-radius: 6px; box-shadow: var(--shadow);
}
.ribbon-menu-item {
  position: relative; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 6px 34px 6px 10px; background: none; border: 0; border-radius: 4px; color: var(--text);
  font: inherit; font-size: 0.85rem; text-align: left; cursor: pointer; white-space: nowrap;
}
.ribbon-menu-item:hover { background: var(--bg-info); }
.ribbon-menu-item .keytip { left: auto; right: 6px; bottom: auto; top: 50%; transform: translateY(-50%); }

.formula-bar { display: flex; align-items: stretch; border-bottom: 1px solid var(--grid); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9rem; }
.formula-bar .name-box { width: 72px; padding: 5px 8px; border-right: 1px solid var(--grid); }
.formula-bar .fx { padding: 5px 8px; color: var(--muted); border-right: 1px solid var(--grid); font-style: italic; }
.formula-bar .formula-text { flex: 1; padding: 5px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 1.8em; }

.sheet-region { position: relative; overflow: auto; outline-offset: -3px; }
.sheet-region:focus-visible, .sheet-region:focus { outline: 3px solid var(--focus); outline-offset: -3px; }

table.sheet { border-collapse: collapse; table-layout: fixed; font-size: 0.85rem; user-select: none; }
table.sheet th, table.sheet td {
  border: 1px solid var(--grid); height: 24px; padding: 0 5px;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
table.sheet th { background: var(--header-bg); color: var(--muted); font-weight: normal; text-align: center; cursor: pointer; }
table.sheet th.hl { background: var(--header-hl); color: var(--text); font-weight: 600; }
table.sheet th.corner { width: 40px; cursor: default; }
table.sheet th.row-head { width: 40px; }
table.sheet th.col-head { width: 92px; }
table.sheet td { width: 92px; text-align: left; cursor: cell; }
table.sheet td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.sheet td.bold { font-weight: 700; }
table.sheet td.italic { font-style: italic; }
table.sheet td.underline { text-decoration: underline; }
table.sheet td.bordered { border: 1.5px solid var(--text); }
table.sheet td.bordered-outside { border: 1.5px solid var(--text); }
table.sheet td.wrap { white-space: pre-line; height: auto; line-height: 1.3; padding-top: 2px; padding-bottom: 2px; vertical-align: top; }
table.sheet td.editing { background: var(--surface); outline: 2px solid var(--primary); outline-offset: -2px; white-space: pre-wrap; overflow: visible; }
table.sheet td.table-header { background: var(--primary); color: var(--on-primary); font-weight: 600; }
table.sheet td.table-band { background: var(--bg-info); }
table.sheet td.table-header.selected, table.sheet td.table-band.selected { background: var(--selection); }
table.sheet tr.freeze-edge td, table.sheet tr.freeze-edge th { border-bottom: 2px solid var(--primary); }
table.sheet td.freeze-col-edge, table.sheet th.freeze-col-edge { border-right: 2px solid var(--primary); }
.filter-arrow {
  float: right; margin-left: 4px; padding: 0 3px; font-size: 0.7rem; line-height: 1.3;
  color: var(--muted); background: var(--surface); border: 1px solid var(--grid); border-radius: 2px;
}
.caret-mark { display: inline-block; width: 1px; height: 1.1em; margin: 0 -0.5px; background: var(--text); vertical-align: text-bottom; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.formula-text.editing { white-space: pre; }
table.sheet td.selected { background: var(--selection); }
table.sheet td.active { background: var(--active); outline: 2px solid var(--primary); outline-offset: -2px; }
table.sheet .after-hidden { border-top: 3px solid var(--muted); }
table.sheet th.after-hidden { border-left: 3px solid var(--muted); border-top: 1px solid var(--grid); }

.sheet-tabs { display: flex; gap: 2px; padding: 4px 8px 0; background: var(--bg-info); border-top: 1px solid var(--grid); border-radius: 0 0 8px 8px; }
.sheet-tab { padding: 4px 14px; font: inherit; font-size: 0.85rem; color: var(--muted); background: none; border: 1px solid transparent; border-top: 0; border-radius: 0 0 6px 6px; cursor: pointer; }
.sheet-tab.active { background: var(--surface); color: var(--text); border: 1px solid var(--grid); border-top: 2px solid var(--green); margin-top: -1px; }

/* Side panel */
.panel { display: grid; gap: 12px; min-width: 0; }
.panel .card { padding: 12px 14px; min-width: 0; overflow-wrap: anywhere; }
.counters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.counters .stat { min-width: 0; }
.counters .stat .value { font-size: 1.4rem; }
.panel .hint-text { margin-top: 8px; color: var(--text); background: var(--bg-info); padding: 8px 10px; border-radius: 4px; font-size: 0.95rem; }
.panel .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.panel .help { color: var(--muted); font-size: 0.85rem; margin: 0; }
.panel .help kbd { font-size: 0.75rem; }

/* Keyboard capsules */
kbd {
  display: inline-block; padding: 1px 7px; border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.8rem;
  background: var(--kbd-bg); border: 1px solid var(--kbd-border); border-bottom-width: 2px; color: var(--text);
  line-height: 1.5;
}
.kbd-chord { white-space: nowrap; }
.kbd-plus { margin: 0 2px; color: var(--muted); }
.kbd-sequence { line-height: 2; }
.kbd-sep { color: var(--muted); }
.sequence-line { margin: 4px 0 10px; }

/* Result */
.result { border: 2px solid var(--green); animation: pop 280ms ease-out; }
.result h2 { margin-bottom: 8px; }
.result .verdict { font-size: 1.1rem; font-weight: 600; color: var(--green); }
.result .label { color: var(--muted); font-size: 0.85rem; margin-bottom: 2px; }
.result .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.result dl { display: grid; grid-template-columns: auto auto; gap: 2px 14px; margin: 0 0 10px; }
.result dt { color: var(--muted); }
.result dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; }

@keyframes pop {
  0% { transform: scale(0.96); opacity: 0.4; }
  60% { transform: scale(1.01); opacity: 1; }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .result { animation: none; }
  .caret-mark { animation: none; }
  * { transition: none !important; }
}

/* Score */
.result .term { font-size: 1.5rem; font-weight: 700; color: var(--green); margin: 0 0 2px; }
.result .score-total { font-size: 2rem; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; line-height: 1.1; }
.result .score-label { color: var(--muted); font-size: 0.85rem; }
.score-breakdown { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; font-size: 0.9rem; margin: 8px 0 10px; font-variant-numeric: tabular-nums; }
.score-breakdown .neg { color: var(--error); }
.score-breakdown .pos { color: var(--green); }
.score-breakdown .sum { border-top: 1px solid var(--grid); padding-top: 3px; font-weight: 600; }
.kbd-text { font-family: inherit; font-style: italic; }
.kbd-chord.done kbd { border-color: var(--green); color: var(--green); }
.kbd-chord.current kbd { background: var(--active); border-color: var(--primary); }
.replay-status { border: 2px solid var(--primary); }
.replay-status .label { color: var(--muted); font-size: 0.85rem; margin-bottom: 2px; }
.replay-status .progress { color: var(--muted); font-size: 0.85rem; margin-top: 6px; }
.note { color: var(--muted); font-size: 0.85rem; flex-basis: 100%; margin: 0; }

/* Dialog extras */
.dialog .tabs { display: flex; gap: 2px; flex-wrap: wrap; border-bottom: 1px solid var(--grid); margin-bottom: 8px; }
.dialog .tab { padding: 4px 8px; font-size: 0.85rem; color: var(--muted); border: 1px solid transparent; border-bottom: 0; border-radius: 4px 4px 0 0; }
.dialog .tab.active { color: var(--text); border-color: var(--grid); background: var(--surface); margin-bottom: -1px; }
.dialog .field { margin: 6px 0; }
.dialog .field .label { color: var(--muted); font-size: 0.85rem; margin-bottom: 3px; }
.dialog .range-box { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; border: 1px solid var(--grid); padding: 4px 8px; border-radius: 4px; background: var(--bg-info); }
.dialog .checkbox { display: flex; align-items: center; gap: 8px; }
.dialog .checkbox .box { width: 14px; height: 14px; border: 2px solid var(--muted); border-radius: 3px; flex-shrink: 0; }
.dialog .checkbox.checked .box { background: var(--primary); border-color: var(--primary); }

/* Dialog inside the sheet */
.dialog-backdrop {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(28, 37, 48, 0.3);
}
.dialog {
  background: var(--surface); color: var(--text); border: 1px solid var(--grid); border-radius: 8px;
  padding: 14px 16px; min-width: 280px; box-shadow: var(--shadow);
}
.dialog-title { font-weight: 600; margin-bottom: 8px; }
.dialog-options { display: grid; gap: 4px; margin-bottom: 10px; }
.dialog-option { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 4px; cursor: pointer; }
.dialog-option .radio { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--muted); flex-shrink: 0; }
.dialog-option.checked .radio { border-color: var(--primary); background: radial-gradient(var(--primary) 45%, transparent 50%); }
.dialog-option.checked { background: var(--bg-info); }
.dialog-option .accel { color: var(--muted); font-size: 0.8rem; }
.dialog-buttons { display: flex; gap: 8px; justify-content: flex-end; }
.dialog-help { color: var(--muted); font-size: 0.8rem; margin: 8px 0 0; }

.error-box { border-left: 4px solid var(--error); background: var(--bg-info); padding: 10px 14px; border-radius: 4px; }

/* Phase 3: navigation, statistics, settings, daily round */
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav .btn.active { background: var(--bg-info); color: var(--primary); border-color: var(--grid); font-weight: 600; }
.mode-card .status { color: var(--text); font-size: 0.9rem; }
.badge.due { color: var(--primary); border-color: var(--primary); }

.bars { display: grid; gap: 6px; margin-top: 10px; }
.bar-row { display: grid; grid-template-columns: 60px minmax(0, 1fr) 32px auto; align-items: center; gap: 10px; font-size: 0.9rem; }
.bar-label { color: var(--text); }
.bar-track { height: 14px; background: var(--bg-info); border-radius: 4px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--primary); border-radius: 0 4px 4px 0; min-width: 0; }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.bar-note { color: var(--muted); font-size: 0.8rem; }
@media (max-width: 600px) { .bar-row { grid-template-columns: 54px minmax(0, 1fr) 28px; } .bar-note { display: none; } }

.stats-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.stats-table th, .stats-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--grid); vertical-align: top; }
.stats-table th { color: var(--muted); font-weight: 600; font-size: 0.82rem; }
.stats-table td.num, .stats-table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stats-table td.emoji { font-size: 1.1rem; width: 1.6em; }
.daily-table td:nth-child(4), .daily-table td:nth-child(5), .daily-table th:nth-child(4), .daily-table th:nth-child(5) { text-align: right; }

.settings-form { display: grid; gap: 16px; margin: 12px 0 16px; }
.settings-form fieldset { border: 1px solid var(--grid); border-radius: 8px; padding: 12px 16px 14px; margin: 0; background: var(--surface); }
.settings-form legend { font-weight: 600; padding: 0 6px; }
.radio-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.radio-row input { width: 18px; height: 18px; accent-color: var(--primary); }
.settings-form .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.btn.danger { color: var(--error); border-color: var(--error); }
label.btn { display: inline-block; }
.form-message { margin: 8px 0 0; font-size: 0.9rem; color: var(--muted); }
.form-message.ok { color: var(--green); }
.form-message.error { color: var(--error); }
.form-message:empty { display: none; }

.share-card .share-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.95rem;
  background: var(--bg-info); border: 1px solid var(--grid); border-radius: 6px; padding: 10px 12px;
  white-space: pre-wrap; user-select: all; margin: 0 0 10px;
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
section + section, section + .actions { margin-top: 16px; }

/* Phase 4: conditional formats, dialogs with text fields, arcade, dark-mode polish */
table.sheet td.cond-hit { background: var(--cond-bg); color: var(--cond-text); }
table.sheet td.cond-hit.selected { background: color-mix(in srgb, var(--cond-bg) 70%, var(--selection)); }
.dialog .input-box { background: var(--surface); min-height: 1.9em; }
.dialog .input-box.active { outline: 2px solid var(--primary); outline-offset: -1px; }
.dialog .cond-sample { background: var(--cond-bg); color: var(--cond-text); }
.dialog .stats-table { margin-bottom: 10px; }

.arcade-status { border: 2px solid var(--primary); }
.arcade-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.arcade-score { font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }
.time-track { height: 10px; background: var(--bg-info); border-radius: 5px; overflow: hidden; }
.time-fill { display: block; height: 100%; background: var(--green); transition: width 120ms linear; }
.time-fill.low { background: var(--error); }
.arcade-time { margin-top: 6px; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.9rem; }
.arcade-status.flash-solved { border-color: var(--green); }
.arcade-status.flash-solved .arcade-time { color: var(--green); font-weight: 600; }
.arcade-status.flash-timeout { border-color: var(--error); }
.arcade-status.flash-timeout .arcade-time { color: var(--error); font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .time-fill { transition: none; } }

/* Dark-mode polish: scrollbars, selection, focus and header icons follow the theme */
:root[data-theme="dark"], :root:not([data-theme="light"]) { scrollbar-color: var(--grid) var(--bg); }
::selection { background: var(--selection); }
table.sheet th.hl { box-shadow: inset 0 -2px 0 var(--primary); }
table.sheet th.row-head.hl { box-shadow: inset -2px 0 0 var(--primary); }
.ribbon-button:focus-visible, .ribbon-tab:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
