:root {
  color-scheme: dark;
  font-family: "Instrument Sans", system-ui, -apple-system, "Apple SD Gothic Neo", sans-serif;
  color: #edf6f3;
  background: #101716;
  --panel: #151f1d;
  --line: #2c3c36;
  --muted: #a1b3ab;
  --accent: #9fedc1;
  --ink: #10251c;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, textarea, select { font: inherit; }
button, summary, select { cursor: pointer; }
button:disabled, input:disabled { cursor: default; opacity: .44; }
button:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.masthead {
  min-height: 64px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  border-bottom: 1px solid var(--line); padding: 0 max(24px, calc((100vw - 1344px) / 2));
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: .9rem; letter-spacing: .14em; white-space: nowrap; }
.brand-divider { color: #779589; margin: 0 4px; }
.brand-mark { display: grid; grid-template-columns: repeat(2, 7px); gap: 3px; transform: rotate(-12deg); }
.brand-mark i { height: 7px; border-radius: 2px; background: var(--accent); }
.brand-mark i:nth-child(2) { opacity: .42; }
.brand-mark i:nth-child(3) { opacity: .65; }
.masthead-note { color: var(--muted); font-size: .86rem; text-align: right; }
main {
  max-width: 1392px; margin: 0 auto; padding: 28px 24px;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 370px); gap: 20px; align-items: start;
}
.stage, .input-panel, .players-panel { border: 1px solid var(--line); border-radius: 15px; background: var(--panel); }
.stage { overflow: hidden; }
.stage-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding: 23px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.42rem, 3vw, 2rem); letter-spacing: -.05em; }
h2 { font-size: 1.15rem; letter-spacing: -.03em; }
#match-info { margin-top: 8px; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.frame-number { color: var(--accent); white-space: nowrap; padding: 6px 0 0; font: .96rem ui-monospace, monospace; }
.map {
  min-height: 290px; height: clamp(290px, 62vh, 665px); position: relative;
  display: grid; place-items: center; border-block: 1px solid var(--line);
  background-color: #101a17;
  background-image: linear-gradient(#22332b66 1px, transparent 1px), linear-gradient(90deg,#22332b66 1px,transparent 1px);
  background-size: 28px 28px;
}
canvas { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; }
.empty { display: grid; text-align: center; justify-items: center; gap: 9px; padding: 24px; color: var(--muted); }
.empty strong { color: #e6f4ed; font-size: 1.13rem; }
.empty-art { position: relative; display: block; width: 107px; height: 70px; margin: 0 0 12px; }
.empty-art i { position: absolute; width: 35px; height: 35px; border-radius: 6px; border: 1px solid #558879; background: #254d3e; transform: rotate(-14deg); }
.empty-art i:nth-child(1) { left: 2px; top: 27px; }
.empty-art i:nth-child(2) { left: 33px; top: 3px; background: #2b5e53; }
.empty-art i:nth-child(3) { left: 40px; top: 40px; background: #396950; }
.empty-art i:nth-child(4) { left: 72px; top: 17px; background: #548b6b; }
.empty-art i:nth-child(5) { left: 78px; top: 54px; width: 13px; height: 13px; background: var(--accent); }
.transport { padding: 15px 23px 18px; }
#frame-slider { width: 100%; margin: 2px 0 14px; accent-color: var(--accent); }
.transport-row, .transport-buttons { display: flex; align-items: center; gap: 7px; }
.transport-row { justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.icon-button, .play-button, .rate select {
  min-height: 38px; border: 1px solid var(--line); border-radius: 8px; background: #1e2d27; color: #e6f3ed;
}
.icon-button { min-width: 38px; font-size: .85rem; }
.play-button { min-width: 65px; background: var(--accent); color: var(--ink); font-weight: 750; }
.rate { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .88rem; }
.rate select { padding: 0 6px; color: #edf6f3; }
.command-info { margin-top: 12px; color: var(--muted); font-size: .9rem; }
.sidebar { display: grid; gap: 16px; }
.input-panel, .players-panel { padding: 20px; }
.input-panel { display: grid; gap: 15px; }
.switch { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; gap: 4px; background: #0e1814; border: 1px solid var(--line); border-radius: 9px; }
.source { padding: 7px; border: 0; color: var(--muted); background: transparent; border-radius: 6px; font-weight: 650; }
.source[aria-pressed="true"] { background: #294337; color: var(--accent); }
.file-drop {
  min-height: 109px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 7px;
  padding: 14px; border: 1px dashed #5b7d6e; border-radius: 10px; background: #192b22; cursor: pointer;
  text-align: center; overflow-wrap: anywhere;
}
.file-drop:hover, .file-drop.is-dragging { border-color: var(--accent); background: #203e2d; }
.file-drop:has(+ input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }
.file-drop span { font-weight: 700; }
.file-drop small, .option, .status { font-size: .88rem; color: var(--muted); }
.option summary { font-weight: 600; }
.option-body, .auth { display: grid; gap: 8px; }
.option-body { margin-top: 10px; }
.auth { border-top: 1px solid var(--line); padding-top: 14px; }
.auth-help p { margin-top: 9px; line-height: 1.5; }
.auth-help code { display: block; margin-top: 7px; color: var(--accent); font-size: .82rem; overflow-wrap: anywhere; user-select: all; }
textarea, input[type=password] {
  display: block; width: 100%; min-width: 0; background: #101a17; color: #edf6f3;
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px;
}
textarea { resize: vertical; font-family: ui-monospace, monospace; }
#base64-panel label { display: block; margin-bottom: 7px; }
.input-panel label:not(.file-drop) { font-size: .9rem; }
.input-panel input[type=file] { max-width: 100%; }
.submit { min-height: 44px; border: 0; border-radius: 8px; background: var(--accent); color: var(--ink); font-weight: 800; }
.submit:hover:not(:disabled), .play-button:hover:not(:disabled) { background: #bbf6d6; }
.status { line-height: 1.55; overflow-wrap: anywhere; }
.status[data-kind="error"] { color: #ffaeaa; }
.status[data-kind="warn"] { color: #f6d58d; }
.players-panel ul { padding: 0; margin: 12px 0 0; list-style: none; }
.players-panel li { display: flex; align-items: center; gap: 9px; padding: 8px 0; font-size: .9rem; }
.players-panel li + li { border-top: 1px solid var(--line); }
.player-mark { font-size: .75rem; }
.player-name { flex: 1; }
.player-name.is-current { font-weight: 750; color: var(--accent); }
.player-points { color: var(--muted); font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; clip: rect(0, 0, 0, 0); overflow: hidden; white-space: nowrap; border: 0; }
@media (max-width: 850px) {
  main { grid-template-columns: 1fr; padding: 16px; }
  .sidebar { grid-row: 1; }
  .map { height: clamp(280px, 68vw, 560px); }
  .masthead { padding: 0 16px; }
}
@media (max-width: 410px) {
  .masthead-note { font-size: .73rem; }
  .stage-head, .input-panel, .players-panel, .transport { padding-inline: 14px; }
}
