/* POV-first play layout ----------------------------------------------------
   The video is the evidence surface. The floor plan behaves like GeoGuessr's
   guessing map: quiet at rest, large while in use, and primary after reveal. */

.mobile-dock-toggle,
.mobile-map-collapse {
  display: none;
}

#playStage {
  --audio-hud-height: 72px;
  --map-confirm-height: 52px;
  --result-audio-bottom: 9px;
  --result-bar-offset: 108px;
  --result-target-scale: .4;
  --result-target-hover-scale: .85;
  --map-resting-width: clamp(250px, 20vw, 320px);
  --map-resting-height: clamp(196px, 16vw, 232px);
  --map-size-1-width: min(620px, calc(100vw - 36px), calc((100dvh - 118px - var(--map-confirm-height)) * 16 / 9));
  --map-size-2-width: min(760px, calc(100vw - 36px), calc((100dvh - 118px - var(--map-confirm-height)) * 16 / 9));
  --map-size-3-width: min(960px, calc(100vw - 36px), calc((100dvh - 72px - var(--map-confirm-height)) * 16 / 9));
  --map-size-4-width: min(calc(100vw - 36px), max(980px, calc(100vw - 652px)), calc((100dvh - 36px - var(--map-confirm-height)) * 16 / 9));
  --map-expanded-width: var(--map-size-2-width);
  --map-expanded-height: calc(var(--map-expanded-width) * 9 / 16 + var(--map-confirm-height));
  --map-floor-selector-scale: .8;
}

#playStage[data-map-size="1"] {
  --map-expanded-width: var(--map-size-1-width);
  --map-floor-selector-scale: .7;
}

#playStage[data-map-size="3"] {
  --map-expanded-width: var(--map-size-3-width);
  --map-floor-selector-scale: .9;
}

#playStage[data-map-size="4"] {
  --map-expanded-width: var(--map-size-4-width);
  --map-floor-selector-scale: 1;
}

/* Full-viewport POV ------------------------------------------------------- */

#playStage[data-primary-view="pov"] .evidence-dock {
  position: fixed;
  inset: auto auto 18px 18px;
  z-index: auto;
  width: min(602px, calc(100vw - var(--map-resting-width) - 54px));
  min-width: 420px;
  transform: none;
}

#playStage[data-primary-view="pov"] .evidence-dock .pov-card {
  position: fixed;
  inset: 0;
  z-index: 1;
  width: 100vw;
  height: 100dvh;
  max-height: none;
  margin: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #07090d;
  box-shadow: none;
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

#playStage[data-primary-view="pov"] .pov-card .audio-stage,
#playStage[data-primary-view="pov"] .pov-card #video,
#playStage[data-primary-view="pov"] .pov-card #audioPoster {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
}

#playStage[data-primary-view="pov"] .pov-card #audioPoster {
  display: none;
}

#playStage[data-primary-view="pov"] .pov-card #video {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  object-fit: cover;
  opacity: 1;
}

#playStage[data-primary-view="pov"] .pov-card .poster-shade {
  z-index: 2;
  background: linear-gradient(180deg, #05070b35 0%, transparent 34%, #05070b4f 100%);
}

/* Operator identity remains supporting information. */

#playStage[data-primary-view="pov"] .evidence-dock .target-panel {
  position: fixed;
  inset: auto auto calc(18px + var(--audio-hud-height) + 10px) 18px;
  z-index: 27;
  width: min(320px, calc(100vw - 36px));
  height: 120px;
  overflow: hidden;
  border: 1px solid var(--white-line-strong);
  border-radius: 3px;
  background: #0b0f16f5;
  box-shadow: 0 12px 30px #0000008f;
  backdrop-filter: blur(10px);
  opacity: 1;
  outline: 0;
  transform: none;
  transition: opacity .18s ease;
}

.evidence-dock .target-panel-label {
  position: absolute;
  top: 10px;
  left: 12px;
  right: 12px;
  z-index: 1;
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  align-items: baseline;
  column-gap: 13px;
  color: #fff;
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .045em;
}

.evidence-dock .target-panel-label > span:first-child {
  justify-self: center;
  text-align: center;
  white-space: nowrap;
}

.evidence-dock .target-panel-round {
  justify-self: end;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: .08em;
}

.evidence-dock .target-panel .target-panel-top,
.evidence-dock .target-panel .guess-history,
.evidence-dock .target-panel #guessHistoryRows {
  width: 100%;
  height: 100%;
  max-height: none;
  overflow: hidden;
  opacity: 1;
  transform: none;
}

#playStage[data-primary-view="pov"] .evidence-dock .target-panel #guessHistoryRows .guess-row {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
}

.evidence-dock .target-panel .guess-operator {
  width: 100%;
  height: 100%;
  grid-template-columns: 82px minmax(0, 1fr);
  column-gap: 13px;
  padding: 28px 12px 8px;
}

.evidence-dock .target-panel .guess-operator-icon {
  width: 82px;
  height: 82px;
  transform: translate(-2px, 1px) scale(1.24);
  transform-origin: center;
}

.evidence-dock .target-panel .guess-operator-copy b {
  color: var(--text);
  font-size: 1.82rem;
  letter-spacing: -.045em;
}

.evidence-dock .target-panel .guess-operator-stat > span {
  font-size: .64rem;
}

.evidence-dock .target-panel .guess-operator-dots i {
  width: 9px;
  height: 9px;
}

/* Audio HUD --------------------------------------------------------------- */

.evidence-dock > .audio-controls {
  position: relative;
  z-index: 28;
  width: 100%;
  height: var(--audio-hud-height);
  min-height: var(--audio-hud-height);
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  padding: 8px 10px 8px 14px;
  overflow: visible;
  border: 1px solid #ffffff20;
  border-radius: 3px;
  background: #0b0f16ed;
  box-shadow: 0 12px 34px #00000082;
  backdrop-filter: blur(11px);
  container-type: inline-size;
}

.evidence-dock > .audio-controls .audio-primary-cluster,
.evidence-dock > .audio-controls .audio-total,
.evidence-dock > .audio-controls .audio-secondary-controls {
  flex: 0 0 auto;
}

.evidence-dock > .audio-controls .audio-waveform-main {
  flex: 1 1 150px;
  height: 54px;
}

.evidence-dock > .audio-controls .audio-primary {
  min-height: 42px;
  gap: 8px;
  font-size: 1.08rem;
}

.evidence-dock > .audio-controls .audio-secondary-controls {
  gap: 4px;
}

.evidence-dock > .audio-controls .iconbtn {
  width: 36px;
  height: 36px;
}

.evidence-dock > .audio-controls .volume-control {
  z-index: 40;
}

/* Guessing map ------------------------------------------------------------ */

#playStage[data-primary-view="pov"] .map-card {
  position: fixed;
  inset: auto 18px 18px auto;
  z-index: 25;
  width: var(--map-resting-width);
  height: var(--map-resting-height);
  min-width: 0;
  min-height: 0;
  display: block;
  overflow: visible;
  border: 1px solid #ffffff48;
  border-radius: 0;
  background: #080b10;
  box-shadow: 0 14px 36px #0000008f;
  opacity: 1;
  cursor: crosshair;
  transform: none;
  transform-origin: bottom right;
  transition:
    width .3s cubic-bezier(.2, .75, .25, 1),
    height .3s cubic-bezier(.2, .75, .25, 1),
    border-color .2s ease,
    box-shadow .2s ease,
    bottom .26s ease;
}

.map-size-controls {
  position: absolute;
  right: auto;
  bottom: 100%;
  left: -1px;
  z-index: 15;
  display: flex;
  gap: 3px;
  padding: 4px;
  border: 1px solid #ffffff24;
  border-bottom: 0;
  border-radius: 4px 4px 0 0;
  background: #090c10c9;
  box-shadow: 0 4px 15px #0000008c;
  backdrop-filter: blur(7px);
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity .15s ease, transform .15s ease;
}

.map-zoom-controls {
  position: absolute;
  top: 12px;
  right: auto;
  left: 12px;
  z-index: 15;
  display: flex;
  gap: 3px;
  padding: 4px;
  border: 1px solid #ffffff24;
  border-radius: 4px;
  background: #090c10c9;
  box-shadow: 0 4px 15px #0000008c;
  backdrop-filter: blur(7px);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity .15s ease, transform .15s ease;
}

.map-result-tools {
  display: contents;
}

.map-size-control,
.map-zoom-control {
  position: relative;
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #fff;
  box-shadow: none;
  cursor: pointer;
  transition: color .14s ease, transform .14s ease;
}

.map-size-control + .map-size-control::before,
.map-zoom-control + .map-zoom-control::before {
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: -2px;
  width: 1px;
  background: #ffffff4a;
  pointer-events: none;
  content: "";
}

.map-size-control svg,
.map-zoom-control svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.map-pin-control svg {
  transform: rotate(90deg);
  transform-origin: center;
  transition: transform .22s cubic-bezier(.2, .75, .25, 1);
}

.map-size-control:hover:not(:disabled),
.map-zoom-control:hover:not(:disabled) {
  background: transparent;
  color: #fff;
  transform: scale(1.08);
}

.map-size-control:focus-visible,
.map-zoom-control:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.map-size-control:disabled,
.map-zoom-control:disabled {
  background: transparent;
  color: #9198a1;
  box-shadow: none;
  cursor: default;
}

#playStage.map-pinned .map-pin-control {
  box-shadow: 0 0 0 2px var(--orange), 0 1px 3px #0000008c;
}

#playStage.map-pinned .map-size-controls .map-pin-control {
  box-shadow: none;
}

#playStage.map-pinned .map-pin-control svg {
  transform: rotate(0deg);
}

#playStage[data-primary-view="pov"] .map-card .mapbody,
#playStage[data-primary-view="pov"] .map-card .mapviewport {
  position: absolute;
  inset: 0;
  width: 100%;
  height: auto;
  min-height: 0;
  padding: 0;
  border-radius: 0;
}

#playStage[data-primary-view="pov"] .map-card .mapviewport {
  display: block;
  overflow: hidden;
  opacity: 1;
  filter: none;
}

#playStage[data-primary-view="pov"] .map-card .mapshell {
  width: 100%;
  height: calc(100% - var(--map-confirm-height));
  max-width: none;
  min-height: 0;
  aspect-ratio: auto;
  background: #080b10;
}

#playStage[data-primary-view="pov"] .map-card .maptitle {
  display: none;
}

#playStage[data-primary-view="pov"] .mapactions {
  position: absolute;
  inset: auto 0 0;
  z-index: 9;
  width: 100%;
  height: var(--map-confirm-height);
  padding: 6px;
  border-top: 1px solid #ffffff1f;
  background: #0b0f16f5;
  opacity: 1;
  filter: none;
  pointer-events: auto;
  transform: none;
  transition: opacity .2s ease, filter .2s ease;
}

#playStage[data-primary-view="pov"] .mapactions .btn.primary {
  width: 100%;
  height: 40px;
  min-height: 40px;
  padding: 7px 14px;
  box-shadow: none;
  font-size: .92rem;
  transition: background .18s ease, opacity .18s ease, filter .18s ease;
}

#playStage[data-primary-view="pov"] .mapactions .btn.primary:disabled {
  background: #6f7379;
  color: #15181d;
  opacity: .62;
}

#playStage[data-primary-view="pov"] .map-cardhead {
  display: block;
  pointer-events: none;
}

#playStage[data-primary-view="pov"] .map-cardhead .floor-tabs {
  position: absolute;
  inset: auto auto 9px 10px;
  flex-direction: column-reverse;
  align-items: flex-start;
  gap: 6px;
  padding: 10px 14px 10px 30px;
  opacity: 0;
  pointer-events: none;
  transform: none;
}

#playStage[data-primary-view="pov"] .map-cardhead .floor-tabs::before {
  display: none;
}

#playStage[data-primary-view="pov"] .map-cardhead .floor-tab {
  width: auto;
  min-width: 108px;
  height: auto;
  min-height: 0;
  justify-content: flex-start;
  padding: 0 4px;
  font-size: 3.7rem;
  line-height: .9;
  transform: none;
}

#playStage[data-primary-view="pov"] .map-cardhead .floor-tab-group {
  min-height: 0;
}

#playStage[data-primary-view="pov"] .map-cardhead .floor-tab > span:first-child {
  position: relative;
  isolation: isolate;
}

#playStage[data-primary-view="pov"] .map-cardhead .floor-tab > span:first-child::before {
  position: absolute;
  z-index: -1;
  top: -2px;
  bottom: -2px;
  left: -26px;
  width: 84px;
  background: #07090da3;
  backdrop-filter: blur(2px);
  content: "";
}

#playStage[data-primary-view="pov"] .map-cardhead .floor-tab:hover:not(.active) {
  color: #e1e5e9;
  text-shadow: 0 0 10px #dfe4e84d;
}

#playStage[data-primary-view="pov"] .map-cardhead .floor-tab:not(.active) {
  display: none;
}

#playStage[data-primary-view="pov"] .map-cardhead .floor-tab.active {
  color: #f04f5f;
  font-size: 4.15rem;
  transform: none;
}

#playStage[data-primary-view="pov"] .map-cardhead .floor-tab.active:hover {
  color: #f04f5f;
  text-shadow: none;
}

#playStage[data-primary-view="pov"] .map-cardhead .floor-tab.active::before {
  z-index: 2;
  top: -4px;
  right: auto;
  bottom: -4px;
  left: -22px;
  width: 8px;
  height: auto;
}

#playStage[data-primary-view="pov"] .map-cardhead .floor-tab-group .badges {
  --badge-slot-width: 96px;
  --badge-slot-height: 26px;
  top: 50%;
  right: auto;
  bottom: auto;
  left: 70px;
  grid-template-columns: max-content;
  grid-template-rows: repeat(2, var(--badge-slot-height));
  gap: 3px;
  justify-content: flex-start;
  transform: translateY(-50%);
  display: none;
}

#playStage[data-primary-view="pov"] .map-cardhead .floor-tab-group .badge {
  min-width: 0;
  padding: 3.3px 8.8px;
  overflow: hidden;
  font-size: .88rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#playStage[data-primary-view="pov"] .map-cardhead .badge.start {
  color: var(--green-bright);
}

#playStage[data-primary-view="pov"] .map-cardhead .badge.target {
  color: var(--red);
}

#playStage[data-primary-view="pov"] .map-cardhead .badge.selected {
  color: var(--yellow);
}

/* .map-open is shared by mouse, keyboard, and touch so delayed mouse collapse
   keeps the complete interactive region stable until its timer finishes. */
#playStage[data-primary-view="pov"][data-phase="investigate"]:not(.map-open) .map-card {
  width: var(--map-resting-width);
  height: var(--map-resting-height);
  opacity: 1;
  transform: none;
}

#playStage[data-phase="investigate"].map-open .map-card {
  width: var(--map-expanded-width);
  height: var(--map-expanded-height);
  border-color: #ffffff78;
  box-shadow: 0 20px 54px #000000aa;
  transform: translate(-2px, -2px);
}

#playStage[data-phase="investigate"].map-open .map-size-controls {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

#playStage[data-phase="investigate"].map-open .map-card .map-zoom-controls {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

#playStage[data-phase="investigate"].map-open .map-card .mapviewport {
  opacity: 1;
  filter: none;
}

#playStage[data-phase="investigate"].map-open .map-card .mapactions {
  opacity: 1;
  filter: none;
}

#playStage[data-phase="investigate"].map-open .map-card .floor-tab {
  display: flex;
}

#playStage[data-phase="investigate"].map-open .map-card .map-cardhead .floor-tabs {
  top: auto;
  bottom: 18px;
  left: 18px;
  gap: 6px;
  padding: 10px 14px 10px 30px;
  opacity: 1;
  pointer-events: auto;
  transform: scale(var(--map-floor-selector-scale));
  transform-origin: bottom left;
}

#playStage[data-phase="investigate"].map-open .map-card .map-cardhead .floor-tab-group .badges {
  display: grid;
  left: 70px;
  justify-content: flex-start;
}

#playStage[data-phase="investigate"] .mapactions {
  display: block;
}

/* Result phase ------------------------------------------------------------ */

#playStage[data-primary-view="pov"][data-phase="result"] .evidence-dock {
  z-index: 33;
}

#playStage[data-primary-view="pov"][data-phase="result"] .map-card {
  inset: 0;
  z-index: 1;
  width: 100vw;
  height: 100dvh;
  margin: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  cursor: default;
  transform: none;
  transition: none;
}

#playStage[data-phase="result"] .map-size-controls,
#playStage[data-phase="result"] .mapactions {
  display: none;
}

#playStage[data-phase="result"] .map-card .mapbody,
#playStage[data-phase="result"] .map-card .mapviewport {
  inset: 0;
}

#playStage[data-phase="result"] .map-card .mapshell {
  height: 100%;
}

#playStage[data-phase="result"] .map-card .mapviewport {
  opacity: 1;
  filter: none;
}

#playStage[data-primary-view="pov"][data-phase="result"] .map-card .floor-tab {
  display: flex;
}

#playStage[data-phase="result"] .map-card .floor-tab-group .badges {
  display: grid;
}

#playStage[data-phase="result"] .map-result-tools {
  position: absolute;
  right: auto;
  bottom: calc(var(--result-audio-bottom) + var(--audio-hud-height) + 14px);
  left: 18px;
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  pointer-events: none;
}

#playStage[data-phase="result"] .map-result-tools > * {
  pointer-events: auto;
}

#playStage[data-phase="result"] .map-cardhead .floor-tabs {
  position: relative;
  inset: auto;
  gap: 8px;
  padding: 10px 14px 10px 24px;
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

#playStage[data-phase="result"] .map-zoom-controls {
  position: relative;
  inset: auto;
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

#playStage[data-primary-view="pov"][data-phase="result"] .evidence-dock .pov-card {
  inset: auto 18px var(--result-bar-offset) auto;
  z-index: 26;
  width: var(--map-resting-width);
  height: auto;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid #ffffff48;
  border-radius: 3px;
  background: #080b10;
  box-shadow: 0 14px 36px #0000008f;
  opacity: 1;
  filter: none;
  transform-origin: bottom right;
  transition:
    width .3s cubic-bezier(.2, .75, .25, 1),
    opacity .2s ease,
    filter .2s ease,
    box-shadow .2s ease;
}

#playStage[data-primary-view="pov"][data-phase="result"] .evidence-dock .pov-card:hover,
body.keyboard-navigation #playStage[data-primary-view="pov"][data-phase="result"] .evidence-dock .pov-card:focus-within {
  width: min(680px, calc(100vw - var(--map-resting-width) - 72px));
  opacity: 1;
  filter: none;
  box-shadow: 0 20px 54px #000000aa;
}

#playStage[data-phase="result"] .evidence-dock > .audio-controls {
  position: fixed;
  inset: auto auto var(--result-audio-bottom) 18px;
  z-index: 33;
  width: min(602px, calc(100vw - var(--map-resting-width) - 72px));
  opacity: 1;
  pointer-events: auto;
}

#playStage[data-primary-view="pov"][data-phase="result"] .evidence-dock .target-panel {
  position: absolute;
  inset: auto auto 10px 10px;
  z-index: 27;
  width: 320px;
  height: 120px;
  opacity: 1;
  pointer-events: auto;
  transform: scale(var(--result-target-scale));
  transform-origin: bottom left;
  transition:
    transform .3s cubic-bezier(.2, .75, .25, 1),
    opacity .18s ease,
    box-shadow .2s ease;
}

#playStage[data-primary-view="pov"][data-phase="result"] .evidence-dock .pov-card:hover .target-panel,
body.keyboard-navigation #playStage[data-primary-view="pov"][data-phase="result"] .evidence-dock .pov-card:focus-within .target-panel {
  transform: scale(var(--result-target-hover-scale));
}

/* Responsive behavior ---------------------------------------------------- */

@media (max-width: 1100px) {
  #playStage[data-primary-view="pov"] .evidence-dock {
    right: 10px;
    bottom: 10px;
    left: 10px;
    width: auto;
    min-width: 0;
  }

  #playStage {
    --map-resting-width: clamp(190px, 28vw, 260px);
    --map-resting-height: clamp(160px, 22vw, 205px);
    --map-size-1-width: min(620px, 62vw, calc((42dvh - var(--map-confirm-height)) * 16 / 9));
    --map-size-2-width: min(760px, 74vw, calc((52dvh - var(--map-confirm-height)) * 16 / 9));
    --map-size-3-width: min(960px, 86vw, calc((64dvh - var(--map-confirm-height)) * 16 / 9));
    --map-size-4-width: min(calc(100vw - 20px), calc((100dvh - 118px - var(--map-confirm-height)) * 16 / 9));
  }

  #playStage[data-primary-view="pov"] .map-card {
    right: 10px;
    bottom: calc(var(--audio-hud-height) + 20px);
  }

  #playStage[data-primary-view="pov"] .evidence-dock .target-panel {
    top: auto;
    bottom: calc(10px + var(--audio-hud-height) + 10px);
    left: 10px;
  }
}

@media (max-width: 700px) {
  #playStage {
    --audio-hud-height: 76px;
    --map-confirm-height: 48px;
    --result-audio-bottom: 16px;
    --result-bar-offset: 122px;
    --result-target-scale: .28;
    --result-target-hover-scale: .7;
    --map-resting-width: 180px;
    --map-resting-height: 150px;
    --map-size-1-width: 70vw;
    --map-size-2-width: 80vw;
    --map-size-3-width: 90vw;
    --map-size-4-width: calc(100vw - 20px);
  }

  .evidence-dock > .audio-controls {
    gap: 4px;
    padding-inline: 7px;
  }

  .evidence-dock > .audio-controls .audio-primary {
    font-size: .94rem;
  }

  .evidence-dock > .audio-controls .audio-waveform-main {
    min-width: 70px;
  }

  #playStage[data-primary-view="pov"] .mapactions {
    height: var(--map-confirm-height);
    padding: 5px;
  }

  #playStage[data-primary-view="pov"] .mapactions .btn.primary {
    height: 38px;
    min-height: 38px;
    font-size: .84rem;
  }

  #playStage[data-phase="result"] .map-card {
    inset: 0;
    width: 100vw;
    height: 100dvh;
  }

  #playStage[data-primary-view="pov"][data-phase="result"] .evidence-dock .pov-card {
    right: 10px;
    bottom: var(--result-bar-offset);
    left: auto;
    width: 180px;
  }

  #playStage[data-phase="result"] .map-result-tools {
    bottom: calc(var(--result-audio-bottom) + var(--audio-hud-height) + 12px);
    left: 10px;
    transform: scale(.72);
    transform-origin: bottom left;
  }

  #playStage[data-phase="result"] .evidence-dock > .audio-controls {
    right: 200px;
    bottom: var(--result-audio-bottom);
    left: 10px;
    width: auto;
  }

  #playStage[data-primary-view="pov"][data-phase="result"] .evidence-dock .target-panel {
    inset: auto auto 8px 8px;
  }
}

@media (max-width: 560px) {
  #playStage {
    --audio-hud-height: 100px;
    --result-audio-bottom: 4px;
  }

  .evidence-dock > .audio-controls {
    display: grid;
    grid-template-columns: auto minmax(72px, 1fr) auto;
    grid-template-rows: 48px 34px;
    row-gap: 2px;
  }

  .evidence-dock > .audio-controls .audio-primary-cluster {
    grid-column: 1;
    grid-row: 1;
  }

  .evidence-dock > .audio-controls .audio-waveform-main {
    grid-column: 2;
    grid-row: 1;
  }

  .evidence-dock > .audio-controls .audio-total {
    grid-column: 3;
    grid-row: 1;
  }

  .evidence-dock > .audio-controls .audio-secondary-controls {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: end;
  }

  #playStage[data-primary-view="pov"] .evidence-dock .target-panel {
    width: min(320px, calc(100vw - 20px));
    height: 120px;
  }

  #playStage[data-phase="result"] .evidence-dock > .audio-controls {
    right: 10px;
    bottom: var(--result-audio-bottom);
    left: 10px;
    width: auto;
  }

  #playStage[data-primary-view="pov"][data-phase="result"] .evidence-dock .pov-card {
    bottom: calc(var(--result-bar-offset) + var(--audio-hud-height) + 10px);
    width: 154px;
  }

  #playStage[data-primary-view="pov"][data-phase="result"] .evidence-dock .pov-card:hover,
  body.keyboard-navigation #playStage[data-primary-view="pov"][data-phase="result"] .evidence-dock .pov-card:focus-within {
    width: 154px;
  }

  #playStage[data-primary-view="pov"][data-phase="result"] .evidence-dock .target-panel {
    inset: auto auto 6px 6px;
    --result-target-scale: .24;
    --result-target-hover-scale: .24;
  }

  #playStage[data-phase="result"] .map-result-tools {
    bottom: calc(var(--result-audio-bottom) + var(--audio-hud-height) + 108px);
    left: 10px;
  }

  #playStage[data-phase="result"] .map-card {
    bottom: 0;
    height: 100dvh;
  }
}

@media (hover: none) {
  #playStage[data-phase="investigate"].map-open .map-size-controls {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  #playStage[data-primary-view="pov"] .map-card,
  #playStage[data-primary-view="pov"] .map-card .mapviewport,
  .evidence-dock .target-panel,
  .map-size-controls,
  .map-size-control,
  .map-zoom-controls,
  .map-zoom-control {
    transition: none;
  }
}

/* Touch-first phone layout ------------------------------------------------ */
@media (max-width: 700px), (max-width: 900px) and (max-height: 520px) {
  #playStage {
    --map-resting-width: clamp(160px, 48vw, 200px);
    --map-resting-height: calc(var(--map-resting-width) * 9 / 16);
    --map-confirm-height: 48px;
    --mobile-map-expanded-width: min(
      100vw,
      calc((100dvh - var(--mobile-header-height) - var(--mobile-bottom-height) - var(--map-confirm-height) - 12px) * 16 / 9)
    );
    --map-expanded-width: var(--mobile-map-expanded-width);
    --map-expanded-height: calc(var(--map-expanded-width) * 9 / 16 + var(--map-confirm-height));
  }

  #playStage[data-primary-view="pov"] .evidence-dock {
    position: relative;
    inset: auto;
    z-index: auto;
    width: 100%;
    height: var(--mobile-bottom-height);
    min-width: 0;
  }

  #playStage[data-primary-view="pov"][data-phase="result"] .evidence-dock {
    z-index: auto;
  }

  .evidence-dock > .audio-controls,
  #playStage[data-phase="result"] .evidence-dock > .audio-controls {
    position: fixed;
    inset: auto 0 0;
    z-index: 40;
    width: 100%;
    height: var(--mobile-bottom-height);
    min-height: var(--mobile-bottom-height);
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 4px;
    padding: 6px max(6px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    border: 0;
    border-top: 1px solid #ffffff24;
    border-radius: 0;
    background: #090d13f4;
    box-shadow: 0 -12px 32px #00000070;
    backdrop-filter: blur(12px);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    transition: opacity .18s ease, transform .2s ease, visibility .2s;
  }

  .evidence-dock > .audio-controls .audio-primary-cluster {
    min-width: 0;
    gap: 3px;
  }

  .evidence-dock > .audio-controls .audio-primary {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    justify-content: center;
    padding: 0;
  }

  .evidence-dock > .audio-controls .audio-primary span {
    display: none;
  }

  .evidence-dock > .audio-controls .audio-primary img {
    width: 20px;
    height: 20px;
  }

  .evidence-dock > .audio-controls .audio-elapsed,
  .evidence-dock > .audio-controls .audio-total {
    width: auto;
    min-width: 27px;
    font-size: .7rem;
  }

  .evidence-dock > .audio-controls .audio-waveform-main {
    min-width: 34px;
    height: 48px;
    flex: 1 1 72px;
  }

  .evidence-dock > .audio-controls .audio-secondary-controls {
    display: flex;
    grid-column: auto;
    grid-row: auto;
    justify-self: auto;
    gap: 0;
  }

  .evidence-dock > .audio-controls .iconbtn {
    width: 44px;
    height: 44px;
  }

  #playStage[data-primary-view="pov"] .evidence-dock .target-panel {
    position: fixed;
    inset: auto auto calc(var(--mobile-bottom-height) + 6px) 4px;
    z-index: 27;
    width: calc(100vw - var(--map-resting-width) - 12px);
    height: var(--map-resting-height);
    min-width: 0;
    overflow: hidden;
    border-radius: 2px;
  }

  #playStage.map-open .evidence-dock .target-panel {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }

  .evidence-dock .target-panel-label {
    top: 7px;
    right: 7px;
    left: 7px;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 5px;
    font-size: clamp(.52rem, 2.2vw, .65rem);
  }

  .evidence-dock .target-panel-label > span:first-child {
    justify-self: start;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .evidence-dock .target-panel .guess-operator {
    grid-template-columns: clamp(44px, 13vw, 56px) minmax(0, 1fr);
    grid-template-rows: minmax(24px, auto) 1fr;
    column-gap: 5px;
    padding: 24px 7px 5px;
  }

  .evidence-dock .target-panel .guess-operator-icon {
    width: clamp(44px, 13vw, 56px);
    height: clamp(44px, 13vw, 56px);
    grid-row: 1 / 3;
    transform: scale(1.08);
  }

  .evidence-dock .target-panel .guess-operator-copy {
    min-width: 0;
    align-self: end;
  }

  .evidence-dock .target-panel .guess-operator-copy b {
    display: block;
    overflow: hidden;
    font-size: clamp(1rem, 5vw, 1.38rem);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .evidence-dock .target-panel .guess-operator-stats {
    min-width: 0;
    align-self: start;
    gap: 4px;
  }

  .evidence-dock .target-panel .guess-operator-stat > span {
    font-size: .48rem;
  }

  .evidence-dock .target-panel .guess-operator-dots i {
    width: 6px;
    height: 6px;
  }

  #playStage[data-primary-view="pov"] .map-card,
  #playStage[data-primary-view="pov"][data-phase="investigate"]:not(.map-open) .map-card {
    position: fixed;
    inset: auto 4px calc(var(--mobile-bottom-height) + 6px) auto;
    z-index: 25;
    width: var(--map-resting-width);
    height: var(--map-resting-height);
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: 2px;
    transform: none;
  }

  #playStage[data-primary-view="pov"] .map-card:hover,
  #playStage[data-primary-view="pov"] .map-card:focus-within {
    width: var(--map-resting-width);
    height: var(--map-resting-height);
    transform: none;
  }

  #playStage[data-primary-view="pov"] .map-card .mapbody,
  #playStage[data-primary-view="pov"] .map-card .mapviewport,
  #playStage[data-primary-view="pov"] .map-card .mapshell {
    inset: 0;
    width: 100%;
    height: 100%;
  }

  #playStage[data-primary-view="pov"] .map-card .mapactions {
    display: none;
  }

  #playStage[data-phase="investigate"].map-open .map-card,
  #playStage[data-primary-view="pov"][data-phase="investigate"].map-open .map-card {
    right: 50%;
    bottom: var(--mobile-bottom-height);
    z-index: 35;
    width: var(--map-expanded-width);
    height: var(--map-expanded-height);
    max-width: 100vw;
    aspect-ratio: auto;
    overflow: visible;
    transform: translateX(50%);
  }

  #playStage[data-phase="investigate"].map-open .map-card:hover,
  #playStage[data-phase="investigate"].map-open .map-card:focus-within {
    width: var(--map-expanded-width);
    height: var(--map-expanded-height);
    transform: translateX(50%);
  }

  #playStage[data-phase="investigate"].map-open .map-card .mapshell {
    height: calc(100% - var(--map-confirm-height));
    aspect-ratio: 16 / 9;
  }

  #playStage[data-phase="investigate"].map-open .map-card .mapactions {
    display: block;
    bottom: 0;
    height: var(--map-confirm-height);
    padding: 4px;
  }

  #playStage[data-phase="investigate"].map-open .map-card .mapactions .btn.primary {
    height: 40px;
    min-height: 40px;
  }

  .map-size-controls {
    top: 7px;
    right: 7px;
    bottom: auto;
    left: auto;
    z-index: 18;
    padding: 0;
    border: 0;
    background: #090c10d9;
  }

  .map-size-controls > :not(.mobile-map-collapse) {
    display: none;
  }

  .mobile-map-collapse {
    display: grid;
    width: 44px;
    height: 44px;
  }

  .mobile-map-collapse svg {
    width: 20px;
    height: 20px;
  }

  #playStage[data-phase="result"] .map-size-controls,
  #playStage:not(.map-open) .map-size-controls {
    display: none;
  }

  .map-zoom-controls,
  #playStage[data-phase="result"] .map-zoom-controls {
    position: absolute;
    top: 7px;
    right: auto;
    bottom: auto;
    left: 7px;
    z-index: 17;
    gap: 0;
    padding: 0;
    transform: none;
  }

  .map-size-control,
  .map-zoom-control {
    width: 44px;
    height: 44px;
  }

  .map-size-control svg,
  .map-zoom-control svg {
    width: 20px;
    height: 20px;
  }

  #playStage[data-phase="investigate"].map-open .map-card .map-cardhead .floor-tabs,
  #playStage[data-phase="result"] .map-card .map-cardhead .floor-tabs {
    position: absolute;
    top: auto;
    right: auto;
    bottom: 7px;
    left: 7px;
    gap: 2px;
    padding: 0;
    opacity: 1;
    pointer-events: auto;
    transform: none;
  }

  #playStage[data-phase="investigate"].map-open .map-card .map-cardhead .floor-tabs::before,
  #playStage[data-phase="result"] .map-card .map-cardhead .floor-tabs::before {
    display: none;
  }

  #playStage[data-primary-view="pov"] .map-cardhead .floor-tab,
  #playStage[data-primary-view="pov"] .map-cardhead .floor-tab.active,
  #playStage[data-phase="result"] .map-cardhead .floor-tab {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    justify-content: center;
    padding: 0;
    background: transparent;
    font-size: 1.35rem;
    line-height: 1;
    transform: none;
  }

  #playStage[data-primary-view="pov"] .map-cardhead .floor-tab > span:first-child {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    background: #07090dcc;
  }

  #playStage[data-primary-view="pov"] .map-cardhead .floor-tab.active > span:first-child {
    background: #15171dd9;
  }

  #playStage[data-primary-view="pov"] .map-cardhead .floor-tab > span:first-child::before {
    display: none;
  }

  #playStage[data-primary-view="pov"] .map-cardhead .floor-tab.active::before {
    top: 4px;
    right: auto;
    bottom: 4px;
    left: 4px;
    width: 3px;
  }

  #playStage[data-primary-view="pov"] .map-cardhead .floor-tab-group .badges {
    --badge-slot-width: 52px;
    --badge-slot-height: 18px;
    left: calc(100% + 1px);
    gap: 1px;
  }

  #playStage[data-primary-view="pov"] .map-cardhead .floor-tab-group .badge {
    max-width: var(--badge-slot-width);
    min-height: var(--badge-slot-height);
    padding: 1px 3px;
    overflow: hidden;
    font-size: .5rem;
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #playStage[data-phase="result"] .map-result-tools {
    position: static;
    display: contents;
    transform: none;
  }

  #playStage[data-primary-view="pov"][data-phase="result"] .map-card,
  #playStage[data-phase="result"] .map-card {
    position: fixed;
    inset: auto 50% var(--mobile-bottom-height) auto;
    z-index: 35;
    width: var(--mobile-map-expanded-width);
    height: calc(var(--mobile-map-expanded-width) * 9 / 16);
    max-width: 100vw;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border: 1px solid #ffffff62;
    transform: translateX(50%);
  }

  #playStage[data-phase="result"] .map-card .mapbody,
  #playStage[data-phase="result"] .map-card .mapviewport,
  #playStage[data-phase="result"] .map-card .mapshell {
    inset: 0;
    width: 100%;
    height: 100%;
    aspect-ratio: 16 / 9;
  }

  #playStage[data-primary-view="pov"][data-phase="result"] .evidence-dock .pov-card {
    position: fixed;
    inset: 0;
    z-index: 1;
    width: 100vw;
    height: 100dvh;
    display: block;
    aspect-ratio: auto;
    border: 0;
    border-radius: 0;
    opacity: 1;
    transform: none;
  }

  #playStage[data-primary-view="pov"][data-phase="result"] .evidence-dock .pov-card:hover,
  body.keyboard-navigation #playStage[data-primary-view="pov"][data-phase="result"] .evidence-dock .pov-card:focus-within {
    width: 100vw;
  }

  #playStage[data-primary-view="pov"][data-phase="result"] .pov-card .audio-stage,
  #playStage[data-primary-view="pov"][data-phase="result"] .pov-card #video {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
  }

  #playStage[data-primary-view="pov"][data-phase="result"] .evidence-dock .target-panel {
    position: fixed;
    inset: auto auto calc(var(--mobile-bottom-height) + 6px) 4px;
    transform: none;
  }
}
