:root {
  --replay-bg: var(--theme-bg, #eef3f5);
  --replay-surface: var(--theme-surface, #ffffff);
  --replay-surface-2: var(--theme-surface-muted, #e3eaed);
  --replay-line: var(--theme-line, #b7c5ca);
  --replay-text: var(--theme-text, #17242a);
  --replay-muted: var(--theme-muted, #586a72);
  --replay-accent: var(--theme-accent, #167d8d);
  --replay-accent-soft: var(--theme-accent-soft, #d7eef0);
  --replay-danger: var(--theme-danger, #c84b55);
}

[data-theme="dark"], body[data-theme="dark"] {
  --replay-bg: var(--theme-bg, #10181c);
  --replay-surface: var(--theme-surface, #182329);
  --replay-surface-2: var(--theme-surface-muted, #202e34);
  --replay-line: var(--theme-line, #3b4d54);
  --replay-text: var(--theme-text, #eef5f6);
  --replay-muted: var(--theme-muted, #a9b8bd);
  --replay-accent: var(--theme-accent, #55c1c8);
  --replay-accent-soft: var(--theme-accent-soft, #17363c);
  --replay-danger: var(--theme-danger, #f1777e);
}

.replay-workbench {
  display: grid;
  width: 100%;
  min-width: 0;
  min-height: 520px;
  align-content: start;
  gap: 0;
  overflow: hidden;
  background: var(--replay-bg);
  color: var(--replay-text);
  letter-spacing: 0;
}

.replay-workbench button,
.replay-workbench input,
.replay-workbench select { font: inherit; letter-spacing: 0; }
.replay-workbench button { cursor: pointer; }
.replay-workbench button:focus-visible,
.replay-workbench input:focus-visible,
.replay-workbench select:focus-visible { outline: 2px solid var(--replay-accent); outline-offset: 2px; }

.replay-workbench__header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--replay-line);
  background: var(--replay-surface);
}
.replay-workbench__header > div { display: grid; gap: 3px; }
.replay-workbench__header span { color: var(--replay-accent); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.replay-workbench__header h2 { margin: 0; color: var(--replay-text); font-size: 22px; line-height: 1.2; }
.replay-workbench__header p { max-width: 440px; margin: 0; color: var(--replay-muted); font-size: 11px; line-height: 1.5; text-align: right; }

.replay-selector-layout { display: grid; grid-template-columns: minmax(180px, 260px) minmax(0, 1fr); min-height: 430px; }
.replay-selector-layout > aside { padding: 22px 18px; border-right: 1px solid var(--replay-line); background: var(--replay-surface-2); }
.replay-selector-layout > aside span { display: block; margin-bottom: 8px; color: var(--replay-text); font-size: 15px; font-weight: 800; }
.replay-selector-layout > aside p { margin: 0; color: var(--replay-muted); font-size: 12px; line-height: 1.7; }
.replay-archive-list { display: grid; align-content: start; gap: 1px; min-width: 0; padding: 18px; }
.replay-archive-row { display: grid; grid-template-columns: minmax(150px, 1.3fr) minmax(160px, 1fr) auto auto; align-items: center; gap: 14px; width: 100%; min-width: 0; min-height: 68px; padding: 12px 14px; border: 1px solid var(--replay-line); border-radius: 6px; background: var(--replay-surface); color: var(--replay-text); text-align: left; }
.replay-archive-row:hover { border-color: var(--replay-accent); background: var(--replay-accent-soft); }
.replay-archive-row > span { display: grid; min-width: 0; gap: 3px; }
.replay-archive-row__times { align-content: center; }
.replay-archive-row strong { overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.replay-archive-row em, .replay-archive-row small { color: var(--replay-muted); font-size: 11px; font-style: normal; }
.replay-archive-row b { font-size: 12px; }
.replay-archive-row i { color: var(--replay-accent); font-size: 12px; font-style: normal; font-weight: 800; }

.replay-workbench__loading,
.replay-workbench__empty { display: grid; place-items: center; align-content: center; gap: 10px; min-height: 340px; margin: 0; padding: 30px; color: var(--replay-muted); text-align: center; }
.replay-workbench__empty strong { color: var(--replay-text); font-size: 18px; }
.replay-workbench__empty p { max-width: 520px; margin: 0; line-height: 1.7; }
.replay-workbench__empty button { min-height: 38px; padding: 0 14px; border: 1px solid var(--replay-accent); border-radius: 5px; background: var(--replay-accent); color: #fff; font-weight: 800; }

.replay-match-toolbar,
.replay-stage-toolbar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 16px; padding: 14px 18px; border-bottom: 1px solid var(--replay-line); background: var(--replay-surface-2); }
.replay-match-toolbar > button,
.replay-stage-toolbar > button { min-height: 38px; padding: 0 12px; border: 1px solid var(--replay-line); border-radius: 5px; background: var(--replay-surface); color: var(--replay-text); font-weight: 800; }
.replay-match-toolbar > div,
.replay-stage-toolbar > div { display: grid; min-width: 0; gap: 2px; }
.replay-match-toolbar span,
.replay-stage-toolbar span { color: var(--replay-accent); font-size: 11px; font-weight: 800; }
.replay-match-toolbar strong,
.replay-stage-toolbar strong { overflow: hidden; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
.replay-match-toolbar p,
.replay-stage-toolbar small,
.replay-stage-toolbar time { margin: 0; color: var(--replay-muted); font-size: 11px; }

.replay-match-list { display: grid; max-height: 520px; gap: 1px; padding: 14px 18px; overflow-y: auto; overscroll-behavior: contain; }
.replay-match-row { display: grid; grid-template-columns: 145px minmax(160px, 1.2fr) minmax(150px, 1fr) auto; align-items: center; gap: 14px; min-height: 58px; padding: 9px 12px; border: 1px solid var(--replay-line); border-radius: 5px; background: var(--replay-surface); color: var(--replay-text); text-align: left; }
.replay-match-row:hover { border-color: var(--replay-accent); background: var(--replay-accent-soft); }
.replay-match-row time { color: var(--replay-muted); font-size: 11px; }
.replay-match-row > span { display: grid; min-width: 0; gap: 2px; }
.replay-match-row strong, .replay-match-row b { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.replay-match-row em, .replay-match-row small { color: var(--replay-muted); font-size: 10px; font-style: normal; }
.replay-match-row i { color: var(--replay-accent); font-size: 11px; font-style: normal; font-weight: 800; }

.replay-pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px 18px; color: var(--replay-muted); font-size: 11px; }
.replay-pagination > div { display: flex; gap: 4px; }
.replay-pagination button { min-width: 34px; min-height: 34px; padding: 0 9px; border: 1px solid var(--replay-line); border-radius: 4px; background: var(--replay-surface); color: var(--replay-text); }
.replay-pagination button[aria-current="page"] { border-color: var(--replay-accent); background: var(--replay-accent); color: #fff; }
.replay-pagination form { display: flex; align-items: center; gap: 6px; }
.replay-pagination input { width: 58px; min-height: 34px; border: 1px solid var(--replay-line); border-radius: 4px; background: var(--replay-surface); color: var(--replay-text); text-align: center; }

.replay-stage { position: relative; width: 100%; min-height: 420px; aspect-ratio: 16 / 8.5; overflow: hidden; background: #071014; }
.replay-stage #replay-map,
.replay-stage #replay-overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
.replay-stage #replay-map { z-index: 1; }
.replay-stage #replay-overlay { z-index: 2; overflow: visible; pointer-events: none; }
.replay-stage .leaflet-container { width: 100%; height: 100%; background: #071014; }
.replay-stage .leaflet-control-container { display: none; }
.replay-map-tools { position: absolute; z-index: 3; top: 10px; right: 10px; display: flex; gap: 4px; padding: 4px; border: 1px solid rgba(255,255,255,.24); border-radius: 5px; background: rgba(7,16,20,.86); }
.replay-map-tools button { width: 34px; height: 32px; border: 1px solid rgba(255,255,255,.24); border-radius: 4px; background: #15242a; color: #fff; font-weight: 900; }
.replay-player { stroke: #fff; stroke-width: 3; vector-effect: non-scaling-stroke; }
.replay-player--knocked { stroke: #f2c14e; stroke-dasharray: 4 2; }
.replay-player--player { stroke-width: 4; }
.replay-player-label { paint-order: stroke; stroke: #071014; stroke-width: 3; stroke-linejoin: round; font-size: 11px; font-weight: 800; }
.replay-zone { fill-opacity: .08; stroke-width: 2; vector-effect: non-scaling-stroke; }
.replay-zone--safe { fill: #55c58a; stroke: #55c58a; }
.replay-zone--warning { fill: #5fa8d3; stroke: #5fa8d3; stroke-dasharray: 7 5; }
.replay-zone--red { fill: #df6b6b; stroke: #df6b6b; stroke-dasharray: 4 4; }
.replay-event { fill: #f2c14e; stroke: #071014; stroke-width: 2; }

.replay-controls { display: grid; grid-template-columns: 108px minmax(180px, 1fr) 132px 100px; align-items: center; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--replay-line); background: var(--replay-surface); }
.replay-controls button,
.replay-controls select { min-height: 38px; border: 1px solid var(--replay-line); border-radius: 5px; background: var(--replay-surface-2); color: var(--replay-text); font-weight: 800; }
.replay-controls input { width: 100%; accent-color: var(--replay-accent); }
.replay-controls output { color: var(--replay-text); font-size: 12px; font-variant-numeric: tabular-nums; text-align: center; }
.replay-controls label { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 6px; color: var(--replay-muted); font-size: 11px; }
.replay-visibility { display: flex; flex-wrap: wrap; gap: 16px; margin: 0; padding: 10px 18px; border: 0; border-top: 1px solid var(--replay-line); background: var(--replay-surface-2); color: var(--replay-muted); font-size: 12px; }
.replay-visibility label { display: inline-flex; align-items: center; gap: 6px; }
.replay-visibility input { accent-color: var(--replay-accent); }
.replay-current-event { min-height: 44px; margin: 0; padding: 12px 18px; border-left: 4px solid var(--replay-accent); background: var(--replay-accent-soft); color: var(--replay-text); font-size: 12px; line-height: 1.6; }

@media (max-width: 700px) {
  .replay-workbench { min-height: 500px; }
  .replay-workbench__header { align-items: start; flex-direction: column; gap: 8px; padding: 14px; }
  .replay-workbench__header h2 { font-size: 18px; }
  .replay-workbench__header p { text-align: left; }
  .replay-selector-layout { grid-template-columns: 1fr; min-height: 0; }
  .replay-selector-layout > aside { padding: 14px; border-right: 0; border-bottom: 1px solid var(--replay-line); }
  .replay-archive-list { padding: 10px; }
  .replay-archive-row { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .replay-archive-row__times { grid-column: 1 / -1; }
  .replay-archive-row i { display: none; }
  .replay-match-toolbar,
  .replay-stage-toolbar { grid-template-columns: 1fr; align-items: start; padding: 10px; }
  .replay-stage-toolbar > time { display: none; }
  .replay-match-list { max-height: 440px; padding: 8px; }
  .replay-match-row { grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
  .replay-match-row time { grid-column: 1 / -1; }
  .replay-match-row > span:nth-of-type(2) { grid-column: 1 / 2; }
  .replay-match-row i { display: none; }
  .replay-pagination { align-items: stretch; flex-direction: column; padding: 10px; }
  .replay-pagination > div { overflow-x: auto; }
  .replay-pagination form { justify-content: space-between; }
  .replay-stage { min-height: 300px; aspect-ratio: 4 / 5; }
  .replay-player-label { display: none; }
  .replay-controls { grid-template-columns: 92px minmax(0, 1fr); gap: 8px; padding: 10px; }
  .replay-controls output,
  .replay-controls label { min-height: 34px; }
  .replay-visibility { gap: 10px; padding: 10px; }
  .replay-current-event { padding: 10px 12px; }
}
