.replay-page {
  min-height: 100vh;
  overflow: hidden;
}

.replay-main {
  height: calc(100vh - 74px);
  min-height: 520px;
}

.replay-stage {
  position: relative;
  height: 100%;
  background: #070a0f;
  overflow: hidden;
}

.replay-stage.free-roam #replay-canvas {
  cursor: crosshair;
  touch-action: none;
}

.replay-free-roam-help {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: 98px;
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: calc(100% - 36px);
  padding: 8px 11px;
  border: 1px solid rgba(56, 189, 248, .34);
  border-radius: 7px;
  color: #a9c5dd;
  background: rgba(4, 12, 24, .84);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .34);
  font: 750 10px Inter, system-ui, sans-serif;
  transform: translateX(-50%);
  backdrop-filter: blur(10px);
  pointer-events: none;
}

.replay-free-roam-help[hidden] {
  display: none;
}

.replay-free-roam-help strong {
  color: #38bdf8;
  font-family: Orbitron, Inter, sans-serif;
  font-size: 10px;
  white-space: nowrap;
}

.replay-free-roam-help.locked {
  opacity: .72;
}

.replay-free-roam-touch {
  display: none;
}

.replay-free-roam-touch[hidden] {
  display: none !important;
}

@media (pointer: coarse), (max-width: 900px) {
  .replay-stage.free-roam .replay-free-roam-touch {
    position: absolute;
    z-index: 6;
    right: max(14px, env(safe-area-inset-right, 0px));
    bottom: max(16px, env(safe-area-inset-bottom, 0px));
    left: max(14px, env(safe-area-inset-left, 0px));
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    pointer-events: none;
    transition: bottom .2s ease;
  }

  .replay-touch-pad {
    display: grid;
    grid-template: repeat(3, 50px) / repeat(3, 50px);
    gap: 4px;
    pointer-events: auto;
  }

  .replay-touch-pad .forward { grid-area: 1 / 2; }
  .replay-touch-pad .left { grid-area: 2 / 1; }
  .replay-touch-pad .back { grid-area: 2 / 2; }
  .replay-touch-pad .right { grid-area: 2 / 3; }

  .replay-touch-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(58px, auto));
    gap: 7px;
    pointer-events: auto;
  }

  .replay-free-roam-touch button {
    min-width: 50px;
    min-height: 50px;
    padding: 0 9px;
    border: 1px solid rgba(56, 189, 248, .46);
    border-radius: 9px;
    color: #d9f2ff;
    background: rgba(4, 18, 34, .8);
    box-shadow: 0 8px 22px rgba(0, 0, 0, .34);
    font: 800 11px Orbitron, Inter, sans-serif;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    backdrop-filter: blur(8px);
  }

  .replay-free-roam-touch button.pressed {
    border-color: #38bdf8;
    color: #fff;
    background: rgba(14, 116, 180, .78);
    transform: scale(.95);
  }
}

.replay-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.replay-export-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border: 1px solid rgba(251, 191, 36, .55);
  border-radius: 6px;
  color: #fff8df;
  background: rgba(245, 158, 11, .18);
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}

.replay-compare-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border: 1px solid rgba(244, 114, 182, .55);
  border-radius: 6px;
  color: #fff1f8;
  background: rgba(219, 39, 119, .16);
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}

.replay-compare-button.active {
  border-color: #f472b6;
  background: rgba(219, 39, 119, .3);
}

.replay-compare-panel {
  position: absolute;
  z-index: 5;
  top: 166px;
  left: 18px;
  width: min(390px, calc(100% - 36px));
  padding: 16px;
  border: 1px solid rgba(244, 114, 182, .34);
  border-radius: 8px;
  color: #e2e8f0;
  background: rgba(7, 10, 15, .94);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .48);
  backdrop-filter: blur(18px);
}

.replay-compare-panel[hidden],
.replay-compare-legend[hidden] {
  display: none;
}

.replay-compare-heading,
.replay-compare-panel-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.replay-compare-heading span,
.replay-compare-panel label > span {
  display: block;
  color: #f9a8d4;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.replay-compare-heading strong {
  display: block;
  margin-top: 3px;
  color: #f8fafc;
  font-family: Orbitron, Inter, sans-serif;
  font-size: 18px;
}

.replay-compare-heading button {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(148, 163, 184, .24);
  border-radius: 6px;
  color: #cbd5e1;
  background: rgba(30, 41, 59, .72);
  font-size: 22px;
  cursor: pointer;
}

.replay-compare-panel p {
  margin: 12px 0;
  color: #9cacc0;
  font-size: 13px;
  line-height: 1.45;
}

.replay-compare-panel label {
  display: grid;
  gap: 6px;
}

.replay-compare-panel select {
  width: 100%;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid rgba(148, 163, 184, .28);
  border-radius: 6px;
  color: #f8fafc;
  background: #111827;
  font: inherit;
}

.replay-compare-panel-actions {
  justify-content: flex-start;
  margin-top: 12px;
}

.replay-compare-panel-actions button {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid rgba(244, 114, 182, .56);
  border-radius: 6px;
  color: #fff1f8;
  background: rgba(219, 39, 119, .22);
  font-weight: 850;
  cursor: pointer;
}

.replay-compare-panel-actions button.secondary {
  border-color: rgba(148, 163, 184, .28);
  color: #d5dde8;
  background: rgba(30, 41, 59, .82);
}

.replay-compare-panel-actions button:disabled {
  cursor: wait;
  opacity: .55;
}

#replay-compare-status {
  display: block;
  min-height: 16px;
  margin-top: 9px;
  color: #fda4af;
  font-weight: 700;
}

.replay-compare-legend {
  position: absolute;
  z-index: 2;
  left: 18px;
  bottom: 104px;
  display: grid;
  grid-template-columns: 10px auto;
  align-items: center;
  gap: 5px 8px;
  max-width: min(420px, calc(100% - 286px));
  padding: 10px 12px;
  border: 1px solid rgba(148, 163, 184, .2);
  border-radius: 8px;
  color: #dbe5f1;
  background: rgba(7, 10, 15, .78);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
  backdrop-filter: blur(14px);
  pointer-events: none;
}

.replay-compare-legend .primary-dot,
.replay-compare-legend .compare-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, .65);
}

.replay-compare-legend .compare-dot {
  background: #f472b6;
  box-shadow: 0 0 10px rgba(244, 114, 182, .7);
}

.replay-compare-legend strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.replay-compare-delta {
  grid-column: 1 / -1;
  margin-top: 3px;
  color: #fbcfe8;
  font-family: Orbitron, Inter, sans-serif;
  font-size: 11px;
  font-weight: 800;
}

.replay-export-button:disabled {
  cursor: wait;
  opacity: .65;
}

#replay-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.replay-topbar,
.replay-stats,
.replay-controls,
.replay-status {
  position: absolute;
  z-index: 2;
  border: 1px solid rgba(148, 163, 184, .18);
  background: rgba(7, 10, 15, .78);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
  backdrop-filter: blur(14px);
}

.replay-grenade-hud {
  position: absolute;
  left: 18px;
  top: 50%;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 6px;
  min-width: 96px;
  padding: 10px 10px 8px;
  border: 1px solid rgba(148, 163, 184, .18);
  border-radius: 8px;
  background: rgba(7, 10, 15, .72);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .24);
  backdrop-filter: blur(10px);
  opacity: 0;
  transform: translateY(-50%) translateX(-12px);
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: none;
}

.replay-grenade-hud.visible {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

.replay-grenade-hud img {
  display: block;
  width: 54px;
  height: 54px;
  object-fit: contain;
  image-rendering: auto;
}

.replay-grenade-hud span {
  color: #e2e8f0;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.replay-input-hud {
  position: absolute;
  right: 18px;
  bottom: 112px;
  z-index: 2;
  width: 232px;
  padding: 10px;
  border: 1px solid rgba(148, 163, 184, .22);
  border-radius: 8px;
  background: rgba(7, 10, 15, .78);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
  backdrop-filter: blur(14px);
  pointer-events: none;
}

.replay-speedometer {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 9px;
  padding: 8px 10px;
  border: 1px solid rgba(56, 189, 248, .24);
  border-radius: 6px;
  background: rgba(14, 165, 233, .12);
  font-variant-numeric: tabular-nums;
}

.replay-speedometer-metric {
  display: grid;
  min-width: 0;
  padding: 0 8px;
  text-align: center;
}

.replay-speedometer-metric + .replay-speedometer-metric {
  border-left: 1px solid rgba(56, 189, 248, .2);
}

.replay-speedometer-metric > div {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  min-width: 0;
}

.replay-speedometer span,
.replay-speedometer small {
  color: #8ea0b8;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .08em;
}

.replay-speedometer strong {
  color: #f8fafc;
  font-family: Orbitron, Inter, sans-serif;
  font-size: 20px;
  line-height: 1;
}

.replay-keyboard {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  grid-template-areas: ". w ." "a s d";
  justify-content: center;
  gap: 5px;
}

.replay-keyboard [data-input="forward"] { grid-area: w; }
.replay-keyboard [data-input="left"] { grid-area: a; }
.replay-keyboard [data-input="back"] { grid-area: s; }
.replay-keyboard [data-input="right"] { grid-area: d; }

.replay-input-actions {
  display: grid;
  grid-template-columns: 1fr 1.5fr .7fr .7fr;
  gap: 5px;
  margin-top: 5px;
}

.replay-timing-mini {
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid rgba(148, 163, 184, .16);
  font-variant-numeric: tabular-nums;
}

.replay-timing-mini-summary {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
  gap: 6px;
}

.replay-timing-mini-summary > div {
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid rgba(56, 189, 248, .24);
  border-radius: 5px;
  background: rgba(14, 165, 233, .1);
}

.replay-timing-mini-summary > div[hidden] {
  display: none !important;
}

.replay-timing-mini span,
.replay-timing-mini-heading,
.replay-timing-mini-summary small {
  color: #8ea0b8;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.replay-timing-mini-summary strong {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  color: #f8fafc;
  font-family: Orbitron, Inter, sans-serif;
  font-size: 15px;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.replay-timing-mini-summary small {
  display: block;
  margin-top: 4px;
  color: #dff7ff;
  font-family: Orbitron, Inter, sans-serif;
  font-size: 11px;
  text-align: right;
}

.replay-timing-mini-heading {
  display: flex;
  justify-content: space-between;
  margin: 9px 2px 4px;
}

.replay-timing-mini-heading small {
  color: #64748b;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: none;
}

.replay-mini-splits-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.replay-mini-splits-table th {
  padding: 3px 4px;
  color: #64748b;
  font-size: 8px;
  letter-spacing: .08em;
  text-align: right;
  text-transform: uppercase;
}

.replay-mini-splits-table th:first-child,
.replay-mini-splits-table td:first-child { text-align: left; }

.replay-mini-splits-table td {
  padding: 5px 4px;
  border-top: 1px solid rgba(148, 163, 184, .12);
  color: #dbe5f1;
  text-align: right;
  white-space: nowrap;
}

.replay-mini-splits-table tr.active td {
  color: #fff8df;
  background: rgba(245, 158, 11, .13);
}

.replay-mini-splits-table tr.active td:first-child { box-shadow: inset 2px 0 #fbbf24; }
.replay-mini-splits-table .delta-ahead { color: #6ee7b7; }
.replay-mini-splits-table .delta-behind { color: #fda4af; }
.replay-mini-splits-table .delta-neutral { color: #94a3b8; }

.replay-input-hud kbd {
  display: grid;
  min-height: 38px;
  place-items: center;
  border: 1px solid rgba(148, 163, 184, .28);
  border-radius: 5px;
  color: #aebdce;
  background: rgba(30, 41, 59, .86);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .28);
  font-family: Inter, sans-serif;
  font-size: 11px;
  font-weight: 900;
  transition: color .06s ease, background .06s ease, border-color .06s ease, transform .06s ease;
}

.replay-input-hud kbd.pressed {
  border-color: #7dd3fc;
  color: #06111f;
  background: linear-gradient(180deg, #67e8f9, #38bdf8);
  box-shadow: 0 0 16px rgba(56, 189, 248, .46);
  transform: translateY(2px);
}

.replay-topbar,
.replay-stats,
.replay-controls {
  transition: opacity .2s ease, transform .2s ease;
}

.replay-stage.overlays-hidden .replay-topbar,
.replay-stage.overlays-hidden .replay-controls {
  opacity: 0;
  pointer-events: none;
}

.replay-stage.overlays-hidden .replay-topbar {
  transform: translateY(-10px);
}

.replay-stage.overlays-hidden .replay-controls {
  transform: translateY(10px);
}

.replay-stage.overlays-hidden .replay-compare-legend {
  opacity: 0;
}

.replay-topbar {
  top: 18px;
  left: 18px;
  right: 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 18px;
  border-radius: 8px;
}

.replay-topbar h1 {
  margin: 2px 0 4px;
  color: #f8fafc;
  font-family: Orbitron, Inter, sans-serif;
  font-size: clamp(24px, 3vw, 44px);
  letter-spacing: 0;
  line-height: 1.05;
}

.replay-topbar p {
  margin: 0;
  color: #a7b5c8;
}

.replay-topbar > a,
.speedrun-replay-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(56, 189, 248, .35);
  border-radius: 6px;
  color: #dff7ff;
  background: rgba(14, 165, 233, .14);
  text-decoration: none;
  font-weight: 800;
  white-space: nowrap;
}

.replay-topbar > a {
  padding: 10px 12px;
}

.speedrun-replay-link {
  margin-left: 10px;
  padding: 5px 8px;
  font-size: 12px;
  line-height: 1;
}

.replay-stats {
  top: 166px;
  right: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(112px, 1fr));
  gap: 8px;
  width: min(420px, calc(100% - 36px));
  padding: 10px;
  border-radius: 8px;
}

.replay-stats div {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid rgba(148, 163, 184, .12);
  border-radius: 6px;
  background: rgba(15, 23, 42, .72);
}

.replay-run-clock-card {
  grid-column: 1 / -1;
  border-color: rgba(56, 189, 248, .32) !important;
  background: linear-gradient(110deg, rgba(14, 165, 233, .18), rgba(15, 23, 42, .76)) !important;
}

.replay-run-clock-card strong {
  color: #dff7ff;
  font-family: Orbitron, Inter, sans-serif;
  font-size: clamp(20px, 2.2vw, 30px);
  letter-spacing: .03em;
  font-variant-numeric: tabular-nums;
}

.replay-splits-panel {
  position: absolute;
  z-index: 2;
  top: 166px;
  left: 18px;
  width: min(520px, calc(100% - 36px));
  max-height: min(46vh, 440px);
  padding: 14px;
  overflow: auto;
  border: 1px solid rgba(56, 189, 248, .22);
  border-radius: 8px;
  background: rgba(7, 10, 15, .84);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
  backdrop-filter: blur(14px);
}

.replay-splits-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

.replay-splits-heading-tools {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.replay-splits-live-clock {
  min-width: 92px;
  padding: 5px 8px;
  border: 1px solid rgba(56, 189, 248, .35);
  border-radius: 4px;
  background: rgba(8, 47, 73, .45);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.replay-splits-live-clock span {
  display: block;
  color: #7dd3fc;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .08em;
}

.replay-splits-live-clock strong {
  display: block;
  margin-top: 2px;
  color: #f8fafc;
  font-family: Orbitron, Inter, sans-serif;
  font-size: 14px;
  line-height: 1;
}

.replay-splits-kicker,
.replay-splits-precision {
  color: #67e8f9;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.replay-splits-heading h2 {
  margin: 3px 0 0;
  color: #f8fafc;
  font-family: Orbitron, Inter, sans-serif;
  font-size: 18px;
}

.replay-splits-precision {
  color: #94a3b8;
  text-align: right;
}

.replay-splits-status {
  min-height: 17px;
  margin-bottom: 6px;
  color: #a7b5c8;
  font-size: 11px;
  line-height: 1.35;
}

.replay-splits-table-wrap {
  overflow-x: auto;
}

.replay-splits-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.replay-splits-table th {
  padding: 6px 7px;
  color: #8294aa;
  font-size: 9px;
  letter-spacing: .08em;
  text-align: right;
  text-transform: uppercase;
}

.replay-splits-table th:first-child,
.replay-splits-table td:first-child { text-align: left; }

.replay-splits-table td {
  padding: 7px;
  border-top: 1px solid rgba(148, 163, 184, .12);
  color: #dbe5f1;
  text-align: right;
  white-space: nowrap;
}

.replay-splits-table tr.active td {
  color: #fff8df;
  background: rgba(245, 158, 11, .13);
}

.replay-splits-table tr.active td:first-child { box-shadow: inset 2px 0 #fbbf24; }
.replay-splits-table .delta-ahead { color: #6ee7b7; }
.replay-splits-table .delta-behind { color: #fda4af; }
.replay-splits-table .delta-neutral { color: #94a3b8; }

.replay-theoretical-best {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid rgba(148, 163, 184, .15);
  color: #fcd34d;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.replay-scrubber-track {
  position: relative;
  display: block;
  min-width: 0;
}

.replay-scrubber-markers {
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  height: 12px;
  transform: translateY(-50%);
  pointer-events: none;
}

.replay-scrubber-marker {
  position: absolute;
  top: 50%;
  width: 8px;
  height: 8px;
  padding: 0;
  border: 1px solid #0f172a;
  border-radius: 50%;
  background: #facc15;
  box-shadow: 0 0 0 1px rgba(250, 204, 21, .55), 0 0 10px rgba(250, 204, 21, .5);
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
}

.replay-scrubber-marker.start { background: #34d399; box-shadow: 0 0 0 1px rgba(52, 211, 153, .55), 0 0 10px rgba(52, 211, 153, .5); }
.replay-scrubber-marker.finish { background: #fb7185; box-shadow: 0 0 0 1px rgba(251, 113, 133, .55), 0 0 10px rgba(251, 113, 133, .5); }

.replay-stats span {
  display: block;
  color: #8ea0b8;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.replay-stats strong {
  display: block;
  overflow: hidden;
  margin-top: 4px;
  color: #eff6ff;
  font-size: 12px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.replay-controls {
  left: 18px;
  right: 18px;
  bottom: 18px;
  display: grid;
  grid-template-columns: auto auto auto auto auto auto auto auto minmax(180px, 1fr);
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 8px;
}

.replay-button,
.replay-speed button {
  min-height: 38px;
  border: 1px solid rgba(148, 163, 184, .24);
  border-radius: 6px;
  color: #f8fafc;
  background: rgba(15, 23, 42, .92);
  font-weight: 850;
  cursor: pointer;
}

.replay-button {
  min-width: 88px;
  padding: 0 14px;
}

.replay-button.secondary {
  color: #d5dde8;
  background: rgba(30, 41, 59, .82);
}

.replay-button.active {
  border-color: rgba(251, 191, 36, .72);
  color: #fff8df;
  background: rgba(245, 158, 11, .18);
}

.replay-speed {
  display: grid;
  grid-template-columns: repeat(3, 58px);
  gap: 6px;
}

.replay-fov {
  display: grid;
  grid-template-columns: auto auto auto;
  align-items: center;
  gap: 6px;
}

.replay-fov-label {
  min-width: 72px;
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 850;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.replay-speed button.active,
.replay-button.active {
  border-color: rgba(251, 191, 36, .72);
  color: #fff8df;
  background: rgba(245, 158, 11, .18);
}

.replay-scrubber {
  display: grid;
  grid-template-columns: 74px minmax(90px, 1fr) 74px;
  align-items: center;
  gap: 10px;
  color: #cbd5e1;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.replay-scrubber input {
  width: 100%;
  accent-color: #38bdf8;
}

.replay-status {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 12px 16px;
  border-radius: 8px;
  color: #f8fafc;
  font-weight: 900;
}

.replay-status[hidden] {
  display: none;
}

@media (max-width: 760px) {
  .replay-page {
    min-height: 100dvh;
  }

  .replay-page .site-header {
    display: none;
  }

  .replay-main {
    height: 100dvh;
    min-height: 0;
  }

  .replay-topbar {
    top: calc(env(safe-area-inset-top, 0px) + 8px);
    left: 8px;
    right: 8px;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
  }

  .replay-topbar h1 {
    margin: 1px 0 2px;
    font-size: clamp(22px, 7vw, 34px);
    line-height: 1;
  }

  .replay-topbar p {
    font-size: 12px;
    line-height: 1.2;
  }

  .replay-topbar .speedrun-kicker {
    font-size: 10px;
  }

  .replay-topbar > a {
    padding: 8px 9px;
    font-size: 12px;
  }

  .replay-actions {
    gap: 5px;
  }

  .replay-compare-button,
  .replay-export-button {
    padding: 7px 8px;
    font-size: 11px;
  }

  .replay-compare-panel {
    top: calc(env(safe-area-inset-top, 0px) + 96px);
    left: 8px;
    width: min(390px, calc(100% - 16px));
  }

  .replay-compare-legend {
    left: 8px;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 210px);
    max-width: calc(100% - 16px);
  }

  .replay-stats {
    display: none;
  }

  .replay-splits-panel {
    top: calc(env(safe-area-inset-top, 0px) + 250px);
    left: 8px;
    width: auto;
    max-height: min(35vh, 300px);
    padding: 10px;
  }

  .replay-stats div {
    padding: 6px 8px;
  }

  .replay-stats span {
    font-size: 8px;
    letter-spacing: .06em;
  }

  .replay-stats strong {
    margin-top: 2px;
    font-size: 11px;
  }

  .replay-controls {
    left: 8px;
    right: 8px;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 8px;
  }

  .replay-free-roam-help {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 236px);
    width: max-content;
    font-size: 9px;
  }

  .replay-button,
  .replay-speed button {
    min-height: 34px;
    min-width: 0;
    font-size: 12px;
  }

  .replay-button {
    padding: 0 8px;
  }

  .replay-speed {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .replay-fov,
  .replay-speed,
  .replay-scrubber {
    grid-column: 1 / -1;
  }

  .replay-fov {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  }

  .replay-fov-label {
    min-width: 64px;
    font-size: 11px;
  }

  .replay-grenade-hud {
    left: 8px;
    min-width: 84px;
    padding: 8px 8px 7px;
  }

  .replay-grenade-hud img {
    width: 46px;
    height: 46px;
  }

  .replay-grenade-hud span {
    font-size: 10px;
  }

  .replay-input-hud {
    top: calc(env(safe-area-inset-top, 0px) + 8px);
    right: 8px;
    bottom: auto;
    width: min(260px, calc(100vw - 16px));
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - 92px);
    overflow-y: auto;
    padding: 5px;
  }

  .replay-speedometer {
    margin-bottom: 4px;
    padding: 4px 6px;
  }

  .replay-speedometer-metric { padding: 0 4px; }
  .replay-speedometer strong { font-size: 15px; }
  .replay-keyboard {
    grid-template-columns: repeat(3, 30px);
    gap: 3px;
    transform: translateX(24px);
  }
  .replay-input-actions { gap: 3px; margin-top: 3px; }
  .replay-input-hud kbd { min-height: 27px; font-size: 8px; }

  .replay-input-hud {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 7px;
  }
  .replay-speedometer {
    grid-column: 1 / -1;
    grid-row: 1;
  }
  .replay-timing-mini {
    grid-column: 1;
    grid-row: 2;
    display: block;
    margin-top: 2px;
    padding-top: 0;
    border-top: 0;
  }
  .replay-keyboard {
    grid-column: 2;
    grid-row: 2;
    align-self: center;
    transform: none;
  }
  .replay-input-actions {
    grid-column: 1 / -1;
    grid-row: 3;
  }
  .replay-timing-mini-heading,
  .replay-mini-splits-table { display: none; }
  .replay-timing-mini-summary {
    grid-template-columns: 1fr;
  }
  .replay-timing-mini-summary > div {
    display: flex;
    align-items: center;
    min-height: 25px;
    padding: 3px 5px;
  }
  .replay-timing-mini span,
  .replay-timing-mini-summary small { font-size: 7px; }
  .replay-timing-mini-summary strong {
    margin: 0 0 0 auto;
    font-size: 11px;
  }
  .replay-timing-mini-summary small {
    margin: 0 0 0 4px;
    text-align: right;
  }
  .replay-timing-mini-summary > div:last-child strong {
    overflow: visible;
    text-overflow: clip;
  }
  .replay-timing-mini-summary > div:last-child small { margin-top: 0; }

  .replay-scrubber {
    grid-template-columns: 62px minmax(0, 1fr) 62px;
    gap: 8px;
    font-size: 11px;
  }
}

@media (max-width: 430px) {
  .replay-topbar h1 {
    font-size: clamp(20px, 8vw, 30px);
  }

  .replay-topbar > a {
    display: none;
  }

  .replay-stats {
    top: calc(env(safe-area-inset-top, 0px) + 88px);
  }

  .replay-stats strong {
    font-size: 10px;
  }

  .replay-splits-panel {
    top: calc(env(safe-area-inset-top, 0px) + 236px);
    max-height: min(32vh, 250px);
  }
}
