.zr-app {
  position: relative;
  height: 100dvh;
  background: #05070c;
  color: #f4f1ea;
  overflow: hidden;
}

.zr-app canvas,
.zr-lobby,
.zr-overlay,
.zr-hud {
  position: absolute;
  top: 72px;
  left: 0;
  right: 0;
  bottom: 0;
}

.zr-app canvas {
  display: block;
  width: 100%;
  height: calc(100dvh - 72px);
  background: #05070c;
}

.zr-lobby,
.zr-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(12, 18, 28, 0.28);
  z-index: 5;
}

.zr-lobby[hidden],
.zr-overlay[hidden],
.zr-hud[hidden] {
  display: none !important;
}

.zr-countdown {
  position: fixed;
  inset: 0;
  z-index: 520;
  display: none;
  place-items: center;
  pointer-events: none;
  color: #fff;
  background: radial-gradient(circle at center, rgba(0, 0, 0, 0.28), rgba(0, 0, 0, 0.03) 48%, transparent 72%);
}

.zr-countdown.is-active { display: grid; }

.zr-countdown strong {
  min-width: 1.2em;
  text-align: center;
  font-size: clamp(92px, 18vw, 220px);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 10px 40px rgba(0, 0, 0, 0.72);
}

.zr-lobby-card,
.zr-overlay-card {
  width: min(560px, 100%);
  background: rgba(16, 22, 34, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
  max-height: calc(100dvh - 120px);
  overflow: auto;
}

.zr-kicker {
  margin: 0 0 8px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 11px;
  color: #f5c542;
}

.zr-lobby-card h1,
.zr-overlay-card h2 {
  margin: 0 0 10px;
  font-size: 34px;
}

.zr-lead,
.zr-overlay-card p {
  margin: 0 0 18px;
  line-height: 1.5;
  color: rgba(244, 241, 234, 0.88);
}

.zr-field {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
  font-weight: 700;
}

.zr-seg {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.zr-seg label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-weight: 600;
  cursor: pointer;
}

.zr-seg input { accent-color: #f5c542; }

.zr-comfort input[type="range"] {
  width: 100%;
  accent-color: #f5c542;
}

.zr-comfort > span {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.zr-comfort em {
  font-style: normal;
  font-variant-numeric: tabular-nums;
  color: #f5c542;
}

.zr-leaderboard {
  margin: 18px 0 12px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.zr-leaderboard h2,
.zr-overlay-card h3 {
  margin: 0 0 10px;
  font-size: 17px;
}

.zr-leaderboard-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 28px;
  margin: 0;
  padding-left: 28px;
  font-size: 12px;
}

.zr-leaderboard-list li { padding-left: 2px; }
.zr-leaderboard-list li span { margin-right: 8px; }
.zr-leaderboard-list li strong { float: right; color: #f5c542; }

.zr-score-form {
  display: flex;
  align-items: end;
  gap: 10px;
  margin: 16px 0 20px;
}

.zr-score-form label { flex: 1; font-weight: 700; }
.zr-score-form input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.36);
  color: #fff;
}
.zr-score-error { color: #ff8b7f; }

.zr-pace-readout {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.zr-pace-readout div {
  padding: 10px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  text-align: center;
}

.zr-pace-readout strong {
  display: block;
  font-size: 20px;
  font-weight: 800;
}

.zr-pace-readout span {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(244, 241, 234, 0.68);
}

.zr-safety {
  margin: 8px 0 16px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #f59e0b;
  background: #3b2504;
  color: #fff3cd;
  line-height: 1.45;
  font-size: 14px;
}

.zr-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* Match the controls already used by the shared workout start gate. The gate
   markup and behavior remain owned by ftms_web_bluetooth.js. */
#web-start-gate .panel-action-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

#web-start-gate .panel-action-btn {
  border: 0;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  background: #f00;
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  text-align: center;
}

#web-start-gate .panel-action-btn:hover { background: #d60000; }

@media (max-width: 699px) {
  #web-start-gate {
    padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)) !important;
    align-items: center !important;
  }

  #web-start-gate .web-start-gate-card {
    max-height: calc(100dvh - max(20px, env(safe-area-inset-top)) - max(20px, env(safe-area-inset-bottom)));
    overflow: auto;
    box-sizing: border-box;
    padding: 18px !important;
  }
}

.zr-btn {
  appearance: none;
  border: 0;
  border-radius: 10px;
  padding: 12px 16px;
  font-weight: 800;
  cursor: pointer;
}

.zr-btn-primary { background: #f5c542; color: #1c1404; }
.zr-btn-secondary { background: rgba(255, 255, 255, 0.12); color: #fff; }

.zr-status {
  margin: 14px 0 0;
  font-size: 13px;
  line-height: 1.4;
  color: rgba(244, 241, 234, 0.75);
}

.zr-hud {
  pointer-events: none;
  z-index: 3;
}

.zr-tools,
.zr-drop,
.zr-overlay-card button {
  pointer-events: auto;
}

.zr-tools {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 6px;
}

.zr-icon-btn {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  background: rgba(10, 14, 22, 0.55);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}

.zr-icon-danger { background: rgba(140, 24, 24, 0.72); }

.zr-objective {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, calc(100% - 120px));
  text-align: center;
  pointer-events: none;
}

.zr-objective-label {
  margin: 0 0 8px;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 800;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.7);
}

.zr-paces {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
}

.zr-pace {
  background: rgba(10, 14, 22, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  padding: 8px 10px 10px;
}

.zr-pace span,
.zr-pace em {
  display: block;
  font-size: 11px;
  color: rgba(244, 241, 234, 0.7);
}

.zr-pace strong {
  font-size: 34px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.zr-pace-pacer { border-color: #f5c542; box-shadow: 0 0 16px rgba(245, 197, 66, 0.25); }
.zr-pace-pacer strong { color: #f5c542; }

.zr-pace-delta {
  min-width: 108px;
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  background: rgba(10, 14, 22, 0.7);
}

.zr-app.zr-slow .zr-pace-you { border-color: #f59e0b; }
.zr-app.zr-slow .zr-pace-delta { background: #f59e0b; color: #1c1404; }
.zr-app.zr-fast .zr-pace-you { border-color: #60a5fa; }
.zr-app.zr-fast .zr-pace-delta { background: #60a5fa; color: #0b1b33; }
.zr-app.zr-locked .zr-pace-you { border-color: #4ade80; }
.zr-app.zr-locked .zr-pace-delta { background: #4ade80; color: #052e16; }
.zr-app.zr-danger .zr-threat { background: rgba(180, 28, 28, 0.82); }

.zr-lock {
  margin-top: 8px;
  height: 28px;
  border-radius: 999px;
  background: rgba(10, 14, 22, 0.55);
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.zr-lock-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #f5c542, #4ade80);
}

.zr-lock-text {
  position: absolute;
  inset: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.zr-strip {
  position: absolute;
  left: 50%;
  bottom: 124px;
  transform: translateX(-50%);
  width: min(640px, calc(100% - 32px));
  pointer-events: none;
}

.zr-strip-track {
  position: relative;
  height: 18px;
  border-radius: 999px;
  background: rgba(10, 14, 22, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.zr-strip-zombie,
.zr-strip-you,
.zr-strip-pacer {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 999px;
  background: #111;
}

.zr-strip-zombie { background: #3f7a2a; }
.zr-strip-zombie.is-hunter { background: #b42318; }
.zr-strip-zombie.is-latched { background: #ef4444; }
.zr-strip-you { background: #2aa4d4; }
.zr-strip-pacer { background: #f5c542; color: #1c1404; }

.zr-inventory {
  position: absolute;
  left: 50%;
  bottom: 52px;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  pointer-events: auto;
  z-index: 4;
}

body[data-cinematic-ui] button.zr-inv-slot,
.zr-inv-slot {
  min-width: 110px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(10, 14, 22, 0.78);
  color: #f4f1ea;
  text-align: left;
  cursor: pointer;
}

.zr-inv-slot strong,
.zr-inv-slot span,
.zr-inv-slot em {
  display: block;
}

.zr-inv-slot span {
  font-size: 11px;
  color: rgba(244, 241, 234, 0.7);
}

.zr-inv-slot em {
  font-size: 20px;
  font-style: normal;
  font-weight: 800;
}

.zr-inv-slot.is-selected { outline: 2px solid #f5c542; }
.zr-inv-slot.is-empty { opacity: 0.45; }
.zr-inv-slot[data-zr-item="food"] strong { color: #f5c542; }
.zr-inv-slot[data-zr-item="bait"] strong { color: #fb923c; }
.zr-inv-slot[data-zr-item="med"] strong { color: #4ade80; }
.zr-inv-slot[data-zr-item="flare"] strong { color: #60a5fa; }

.zr-health {
  position: absolute;
  left: 12px;
  top: 12px;
  min-width: 150px;
  padding: 8px 10px;
  background: rgba(10, 14, 22, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  pointer-events: none;
}

.zr-health span,
.zr-health em {
  display: block;
  font-size: 11px;
  font-weight: 700;
}

.zr-health-track {
  height: 10px;
  margin: 6px 0 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.zr-health-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ef4444, #4ade80);
}

.zr-threat,
.zr-vitals {
  position: absolute;
  background: rgba(10, 14, 22, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  pointer-events: none;
}

.zr-threat {
  left: 12px;
  bottom: 18px;
  padding: 10px 12px;
  min-width: 120px;
}

.zr-threat-kicker,
.zr-threat em,
.zr-threat-speed {
  display: block;
  font-size: 11px;
  color: rgba(244, 241, 234, 0.7);
}

.zr-threat-speed { margin-top: 2px; }

.zr-threat strong { font-size: 26px; }

.zr-vitals {
  right: 12px;
  bottom: 18px;
  display: flex;
  gap: 12px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
}

body[data-cinematic-ui] button.zr-btn-primary,
button.zr-btn-primary {
  background: #f5c542;
  color: #1c1404;
}

body[data-cinematic-ui] button.zr-drop,
.zr-drop {
  position: absolute;
  left: 50%;
  bottom: 56px;
  transform: translateX(-50%);
  width: min(360px, 70vw);
  min-height: 72px;
  border: 0;
  border-radius: 16px;
  background: #f5c542;
  color: #1c1404;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 0.08em;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  animation: zr-drop-pulse 1s ease infinite;
}

.zr-drop[hidden] { display: none; }

@keyframes zr-drop-pulse {
  50% { transform: translateX(-50%) scale(1.03); }
}

.zr-flash { animation: zr-bite 400ms ease; }

@keyframes zr-bite {
  from { box-shadow: inset 0 0 0 90px rgba(180, 20, 20, 0.4); }
  to { box-shadow: inset 0 0 0 0 rgba(180, 20, 20, 0); }
}

@media (max-width: 800px) {
  .zr-objective { width: calc(100% - 24px); top: 56px; }
  .zr-pace strong { font-size: 26px; }
  .zr-tools { top: 8px; }
  .zr-strip { bottom: 22px; }
  .zr-leaderboard-list { grid-template-columns: 1fr; }
}

body.mobile-mode .zr-app canvas,
body.mobile-mode .zr-hud,
body.mobile-mode .zr-lobby,
body.mobile-mode .zr-overlay {
  top: 56px;
  bottom: 64px;
}

body.mobile-mode .zr-app canvas {
  height: calc(100dvh - 120px);
}

/* Phone game mode: keep the playfield immersive and reserve the center for the
   runner. These rules intentionally apply by viewport size as well as the
   server's mobile-mode flag because iOS can request a desktop user agent. */
@media (max-width: 600px) {
  .yt-site-header,
  .mobile-app-header,
  .mobile-bottom-nav {
    display: none !important;
  }

  .zr-app canvas,
  .zr-hud,
  .zr-lobby,
  .zr-overlay,
  body.mobile-mode .zr-app canvas,
  body.mobile-mode .zr-hud,
  body.mobile-mode .zr-lobby,
  body.mobile-mode .zr-overlay {
    top: 0;
    bottom: 0;
  }

  .zr-app canvas,
  body.mobile-mode .zr-app canvas {
    height: 100dvh;
  }

  .zr-lobby,
  .zr-overlay {
    padding: calc(10px + env(safe-area-inset-top)) 10px calc(10px + env(safe-area-inset-bottom));
  }

  .zr-lobby-card,
  .zr-overlay-card {
    padding: 16px;
    border-radius: 14px;
    max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 20px);
  }

  .zr-kicker { display: none; }
  .zr-lobby-card h1,
  .zr-overlay-card h2 { font-size: 26px; }
  .zr-lead { font-size: 13px; line-height: 1.35; }
  .zr-leaderboard-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px 18px; }

  .zr-tools {
    top: calc(8px + env(safe-area-inset-top));
    right: calc(8px + env(safe-area-inset-right));
    gap: 5px;
  }

  body.mobile-mode button.zr-icon-btn,
  .zr-icon-btn {
    width: 42px;
    height: 42px;
    min-height: 42px;
    padding: 0;
    font-size: 16px;
  }

  .zr-health {
    top: calc(8px + env(safe-area-inset-top));
    left: calc(8px + env(safe-area-inset-left));
    min-width: 0;
    width: 126px;
    padding: 7px 9px;
  }

  .zr-health-track { height: 7px; margin: 4px 0 2px; }

  .zr-objective {
    top: calc(62px + env(safe-area-inset-top));
    width: calc(100% - 16px - env(safe-area-inset-left) - env(safe-area-inset-right));
  }

  .zr-objective-label { margin-bottom: 4px; font-size: 11px; }
  .zr-paces { gap: 6px; }
  .zr-pace { padding: 5px 7px 7px; border-radius: 11px; }
  .zr-pace strong { font-size: 25px; }
  .zr-pace-delta { min-width: 84px; padding: 7px 8px; font-size: 12px; }
  .zr-lock { height: 24px; margin-top: 5px; }
  .zr-lock-text { padding: 0 8px; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .zr-inventory {
    left: calc(8px + env(safe-area-inset-left));
    right: calc(8px + env(safe-area-inset-right));
    bottom: calc(8px + env(safe-area-inset-bottom));
    transform: none;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
  }

  body.mobile-mode button.zr-inv-slot,
  body[data-cinematic-ui] button.zr-inv-slot,
  .zr-inv-slot {
    min-width: 0;
    min-height: 54px;
    padding: 6px 7px;
    border-radius: 10px;
    text-align: center;
  }

  .zr-inv-slot strong { font-size: 11px; white-space: nowrap; }
  .zr-inv-slot span { display: none; }
  .zr-inv-slot em { font-size: 18px; line-height: 1.1; }

  .zr-strip {
    bottom: calc(70px + env(safe-area-inset-bottom));
    width: calc(100% - 20px - env(safe-area-inset-left) - env(safe-area-inset-right));
  }

  .zr-threat {
    left: calc(8px + env(safe-area-inset-left));
    bottom: calc(94px + env(safe-area-inset-bottom));
    min-width: 0;
    padding: 6px 8px;
  }

  .zr-threat strong { font-size: 18px; }
  .zr-threat-kicker,
  .zr-threat em,
  .zr-threat-speed { font-size: 9px; }

  .zr-vitals {
    right: calc(8px + env(safe-area-inset-right));
    bottom: calc(94px + env(safe-area-inset-bottom));
    padding: 6px 9px;
    gap: 8px;
    font-size: 11px;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .yt-site-header,
  .mobile-app-header,
  .mobile-bottom-nav {
    display: none !important;
  }

  .zr-app canvas,
  .zr-hud,
  .zr-lobby,
  .zr-overlay,
  body.mobile-mode .zr-app canvas,
  body.mobile-mode .zr-hud,
  body.mobile-mode .zr-lobby,
  body.mobile-mode .zr-overlay {
    top: 0;
    bottom: 0;
  }

  .zr-app canvas,
  body.mobile-mode .zr-app canvas { height: 100dvh; }

  .zr-health {
    top: calc(8px + env(safe-area-inset-top));
    left: calc(8px + env(safe-area-inset-left));
    width: 112px;
    min-width: 0;
    padding: 6px 8px;
  }

  .zr-health-track { height: 6px; margin: 3px 0 2px; }

  .zr-tools {
    top: calc(8px + env(safe-area-inset-top));
    right: calc(8px + env(safe-area-inset-right));
    flex-direction: column;
    gap: 5px;
  }

  body.mobile-mode button.zr-icon-btn,
  .zr-icon-btn {
    width: 40px;
    height: 40px;
    min-height: 40px;
    padding: 0;
  }

  .zr-objective {
    top: calc(7px + env(safe-area-inset-top));
    width: min(46vw, 350px);
  }

  .zr-objective-label { margin-bottom: 3px; font-size: 10px; }
  .zr-paces { gap: 5px; }
  .zr-pace { padding: 4px 6px 5px; border-radius: 9px; }
  .zr-pace span,
  .zr-pace em { font-size: 9px; }
  .zr-pace strong { font-size: 21px; }
  .zr-pace-delta { min-width: 70px; padding: 6px; font-size: 10px; }
  .zr-lock { height: 20px; margin-top: 4px; }
  .zr-lock-text { padding: 0 6px; font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .zr-inventory {
    top: calc(68px + env(safe-area-inset-top));
    bottom: auto;
    left: calc(8px + env(safe-area-inset-left));
    right: auto;
    transform: none;
    display: grid;
    grid-template-columns: 104px;
    gap: 5px;
  }

  body.mobile-mode button.zr-inv-slot,
  body[data-cinematic-ui] button.zr-inv-slot,
  .zr-inv-slot {
    min-width: 0;
    min-height: 42px;
    padding: 5px 7px;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    text-align: left;
  }

  .zr-inv-slot strong { font-size: 10px; white-space: nowrap; }
  .zr-inv-slot span { display: none; }
  .zr-inv-slot em { font-size: 17px; }

  .zr-threat {
    left: auto;
    right: calc(8px + env(safe-area-inset-right));
    bottom: calc(50px + env(safe-area-inset-bottom));
    min-width: 0;
    padding: 5px 7px;
    text-align: right;
  }

  .zr-threat strong { font-size: 17px; }
  .zr-threat-kicker,
  .zr-threat em,
  .zr-threat-speed { font-size: 8px; }

  .zr-vitals {
    right: calc(8px + env(safe-area-inset-right));
    bottom: calc(8px + env(safe-area-inset-bottom));
    padding: 5px 7px;
    font-size: 10px;
  }

  .zr-strip {
    bottom: calc(8px + env(safe-area-inset-bottom));
    width: min(44vw, 330px);
  }

  .zr-lobby,
  .zr-overlay { padding: calc(8px + env(safe-area-inset-top)) calc(8px + env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left)); }
  .zr-lobby-card,
  .zr-overlay-card { max-height: calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); padding: 14px; }
  .zr-lobby-card { width: min(700px, calc(100% - 32px)); }
  .zr-kicker,
  .zr-status { display: none; }
  .zr-lobby-card h1 { margin-bottom: 5px; font-size: 24px; }
  .zr-lead { margin-bottom: 7px; font-size: 10px; line-height: 1.25; }
  .zr-field { gap: 3px; margin-bottom: 6px; font-size: 12px; }
  .zr-pace-readout { gap: 6px; }
  .zr-pace-readout div { padding: 4px 6px; }
  .zr-pace-readout strong { font-size: 16px; }
  .zr-pace-readout span { font-size: 8px; }
  .zr-safety { margin: 4px 0 7px; padding: 6px 8px; font-size: 10px; line-height: 1.25; }
  .zr-actions { gap: 7px; }
  .zr-btn { min-height: 38px; padding: 8px 12px; }
  .zr-leaderboard { display: none; }
}
