:root {
  --tape: #ede6cc;
  --ink: #17140e;
  --label: #e8e2c8;
  --rec: #e8342a;
  --night: #7cff7a;
  --wall: #c9b45e;
  --glass: rgba(12, 10, 6, 0.42);
}
* {
  box-sizing: border-box;
  margin: 0;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  height: 100%;
  background: #000;
  color: #fff;
  overflow: hidden;
  touch-action: none;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}
canvas {
  display: block;
  position: fixed;
  inset: 0;
}
.vcr {
  font-family: 'VCR OSD Mono', 'Courier New', Courier, monospace;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-shadow:
    0 0 2px rgba(255, 255, 255, 0.6),
    2px 2px 0 rgba(0, 0, 0, 0.7);
}
.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
  padding: 24px;
  z-index: 10;
  background: #000;
}
.screen.on {
  display: flex;
}
#title {
  background: #000;
  justify-content: center;
  padding: 24px;
  cursor: pointer;
}
#title h1 {
  font:
    700 clamp(40px, 12vw, 120px) / 1 'Courier New',
    Courier,
    monospace;
  letter-spacing: 0.22em;
  margin-right: -0.22em;
  color: var(--tape);
  text-shadow:
    -2px 0 rgba(232, 52, 42, 0.55),
    2px 0 rgba(80, 200, 255, 0.45),
    0 0 18px rgba(237, 230, 204, 0.25);
  animation: dying-tube 5s infinite;
}
#title p {
  position: absolute;
  bottom: max(28px, env(safe-area-inset-bottom));
  font:
    700 14px 'VCR OSD Mono',
    'Courier New',
    monospace;
  letter-spacing: 0.2em;
  color: var(--tape);
  opacity: 0.5;
  animation: pulse 1.6s infinite;
}
@keyframes dying-tube {
  0%,
  7%,
  9%,
  61%,
  63%,
  100% {
    opacity: 1;
  }
  8% {
    opacity: 0.15;
  }
  62% {
    opacity: 0.4;
  }
}
@media (prefers-reduced-motion: reduce) {
  #title h1 {
    animation: none;
  }
}
@keyframes pulse {
  50% {
    opacity: 0.2;
  }
}
#lost h2 {
  font-size: clamp(28px, 8vw, 64px);
  color: #e33;
}
#cam {
  position: fixed;
  inset: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  pointer-events: none;
  z-index: 5;
  display: none;
  font-size: clamp(13px, 2.4vw, 20px);
}
#cam.on {
  display: block;
}
#cam .c {
  position: absolute;
  width: 28px;
  height: 28px;
  border: 0 solid rgba(255, 255, 255, 0.85);
}
#cam .tl {
  top: 0;
  left: 0;
  border-width: 3px 0 0 3px;
}
#cam .tr {
  top: 0;
  right: 0;
  border-width: 3px 3px 0 0;
}
#cam .bl {
  bottom: 0;
  left: 0;
  border-width: 0 0 3px 3px;
}
#cam .br {
  bottom: 0;
  right: 0;
  border-width: 0 3px 3px 0;
}
#rec {
  position: absolute;
  top: 12px;
  left: 40px;
}
#rec i {
  color: #f22;
  font-style: normal;
  animation: pulse 1s steps(1) infinite;
}
#bat {
  position: absolute;
  top: 12px;
  right: 40px;
}
#date {
  position: absolute;
  bottom: 12px;
  left: 40px;
}
#tc {
  position: absolute;
  bottom: 12px;
  right: 40px;
}
#nvTag {
  position: absolute;
  top: 40px;
  left: 40px;
  color: #6f6;
  display: none;
}
#stam {
  position: absolute;
  bottom: 44px;
  left: 50%;
  width: 120px;
  height: 4px;
  margin-left: -60px;
  background: rgba(255, 255, 255, 0.15);
  opacity: 0;
  transition: opacity 0.4s;
}
#stam div {
  height: 100%;
  background: rgba(255, 255, 255, 0.8);
}
#joy {
  position: fixed;
  width: 132px;
  height: 132px;
  margin: -66px 0 0 -66px;
  border-radius: 50%;
  z-index: 4;
  display: none;
  pointer-events: none;
  border: 2px dashed rgba(237, 230, 204, 0.4);
  background: radial-gradient(circle, rgba(12, 10, 6, 0.28) 55%, transparent 72%);
}
#knob {
  position: absolute;
  left: 38px;
  top: 38px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid var(--tape);
  background: rgba(237, 230, 204, 0.22);
  box-shadow: 0 0 12px rgba(237, 230, 204, 0.25);
}
.tbtn {
  --size: 68px;
  position: fixed;
  z-index: 6;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  border: 2px solid rgba(237, 230, 204, 0.6);
  background: var(--glass);
  box-shadow: inset 0 0 0 4px rgba(0, 0, 0, 0.28);
  color: var(--tape);
  font:
    700 9px/1 'VCR OSD Mono',
    'Courier New',
    monospace;
  letter-spacing: 0.08em;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.8);
  transition:
    transform 0.08s,
    background-color 0.15s;
}
.tbtn svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(1px 1px 0 rgba(0, 0, 0, 0.7));
}
.tbtn.on {
  display: flex;
}
.tbtn:active {
  transform: scale(0.93);
}
.tbtn.active {
  background: var(--tape);
  color: var(--ink);
  text-shadow: none;
}
.tbtn.active svg {
  filter: none;
}
#bCam.active {
  background: var(--glass);
  color: var(--rec);
  border-color: var(--rec);
  box-shadow:
    inset 0 0 0 4px rgba(0, 0, 0, 0.28),
    0 0 14px rgba(232, 52, 42, 0.45);
}
#bNv.active {
  background: var(--glass);
  color: var(--night);
  border-color: var(--night);
  box-shadow:
    inset 0 0 0 4px rgba(0, 0, 0, 0.28),
    0 0 14px rgba(124, 255, 122, 0.4);
}
#bRun {
  --size: 88px;
  right: calc(env(safe-area-inset-right) + 24px);
  bottom: calc(env(safe-area-inset-bottom) + 24px);
  font-size: 10px;
}
#bRun svg {
  width: 36px;
  height: 36px;
}
#bCrouch {
  right: calc(env(safe-area-inset-right) + 134px);
  bottom: calc(env(safe-area-inset-bottom) + 26px);
}
#bCam {
  right: calc(env(safe-area-inset-right) + 34px);
  bottom: calc(env(safe-area-inset-bottom) + 134px);
}
#bNv {
  right: calc(env(safe-area-inset-right) + 112px);
  bottom: calc(env(safe-area-inset-bottom) + 108px);
}
#bZoom {
  right: calc(env(safe-area-inset-right) + 196px);
  bottom: calc(env(safe-area-inset-bottom) + 116px);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-width: 260px;
  min-height: 58px;
  padding: 14px 28px;
  font:
    700 18px/1 'VCR OSD Mono',
    'Courier New',
    monospace;
  letter-spacing: 0.14em;
  cursor: pointer;
  transition: transform 0.08s;
}
.btn .glyph {
  font-size: 15px;
  letter-spacing: -0.1em;
}
.btn:active {
  transform: translate(2px, 2px);
}
.btn:focus-visible {
  outline: 2px dashed var(--tape);
  outline-offset: 5px;
}
.btn-play {
  color: var(--ink);
  background: var(--label);
  border: 3px solid var(--ink);
  box-shadow:
    0 0 0 3px var(--label),
    6px 6px 0 3px rgba(0, 0, 0, 0.55);
}
.btn-play:active {
  box-shadow:
    0 0 0 3px var(--label),
    3px 3px 0 3px rgba(0, 0, 0, 0.55);
}
.btn-rewind {
  color: var(--tape);
  background: transparent;
  border: 2px solid rgba(237, 230, 204, 0.7);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.8);
}
.tape-link {
  max-width: min(90vw, 560px);
  padding: 12px 16px;
  font-size: 15px;
  word-break: break-all;
  background: #1b1b17;
  border-left: 4px solid var(--wall);
  text-align: left;
}
.lbox {
  position: fixed;
  top: 0;
  bottom: 0;
  width: max(0px, calc(50vw - 66.667vh));
  background: #000;
  z-index: 4;
  display: none;
  pointer-events: none;
}
.lbox.l {
  left: 0;
}
.lbox.r {
  right: 0;
}
body.viewfinder .lbox {
  display: block;
}
body.viewfinder #cam {
  left: max(14px, calc(50vw - 66.667vh + 14px));
  right: max(14px, calc(50vw - 66.667vh + 14px));
}
#blink {
  position: fixed;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  z-index: 7;
}

.invite-status {
  min-height: 1.2em;
  font-size: 15px;
  color: var(--wall);
  animation: pulse 1.6s infinite;
}
#toast {
  position: fixed;
  top: max(18px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  padding: 10px 18px;
  font-size: 15px;
  color: var(--tape);
  background: var(--glass);
  border-left: 4px solid var(--wall);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
}
#toast.on {
  opacity: 1;
}
