/* Cabinet, screen geometry, knobs. Phase 1 frame is CSS only:
   warm wood, thick bezel, dark room, screen as the only light source.
   Frame PNG rotation is Phase 2. */

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: #070605;
  overflow: hidden;
  font-family: "Segoe UI", system-ui, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

:focus-visible {
  outline: 3px solid #ffd27a;
  outline-offset: 3px;
}

/* .room is now defined in room.css with per-frame atmosphere gradients */

/* ---- cabinet -------------------------------------------------------- */

.tv {
  display: flex;
  align-items: stretch;
  gap: clamp(14px, 2vw, 26px);
  padding: clamp(16px, 2.6vw, 34px);
  /* colors, border, shadow, border-radius are set per-frame in frames.css */
  transition: background 0.8s ease, border-radius 0.8s ease, box-shadow 0.8s ease;
}

.screen-shell {
  background: linear-gradient(150deg, #1b1512 0%, #120e0b 100%);
  padding: clamp(10px, 1.6vw, 22px);
  border-radius: 14px;
  box-shadow:
    inset 0 2px 10px rgba(0, 0, 0, 0.85),
    inset 0 -1px 0 rgba(255, 220, 170, 0.06);
}

/* ---- screen --------------------------------------------------------- */

.screen {
  position: relative;
  width: min(62vw, calc((92vh - 170px) * 4 / 3), 920px);
  aspect-ratio: 4 / 3;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  container-type: size;
  touch-action: none;
  box-shadow: 0 0 90px 12px rgba(150, 185, 255, 0.10);
}

/* glass recess, sits above everything, never intercepts input */
.screen::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 5cqw rgba(0, 0, 0, 0.42);
  pointer-events: none;
  z-index: 6;
}

.surface {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.bug {
  position: absolute;
  right: 3.5%;
  bottom: 4.5%;
  z-index: 2;
  font-weight: 700;
  font-size: 3cqw;
  letter-spacing: 0.14em;
  color: rgba(255, 255, 255, 0.72);
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.45), 0 1px 2px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

.static-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  image-rendering: pixelated;
  opacity: 0;
  pointer-events: none;
  transition: opacity 50ms linear;
}

.static-canvas.on {
  opacity: 1;
  transition: none;
}

.osd {
  position: absolute;
  top: 4%;
  right: 4.5%;
  z-index: 4;
  font-family: "Consolas", "Menlo", "Courier New", monospace;
  font-size: 9cqw;
  line-height: 1;
  color: #4ff04f;
  text-shadow: 0 0 12px rgba(80, 255, 80, 0.65);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.osd.show {
  opacity: 1;
  transition: none;
}

/* ---- control panel --------------------------------------------------- */

.panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 3vh, 30px);
  min-width: 118px;
}

.knob-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
}

.knob {
  position: relative;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #40372e, #14100d 72%);
  box-shadow:
    0 0 0 6px #241a10,
    0 0 0 7px rgba(255, 220, 170, 0.10),
    0 6px 14px rgba(0, 0, 0, 0.6);
}

.knob.mini {
  width: 56px;
  height: 56px;
}

.knob-cap {
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #2e2620, #1a1410 45%, #0d0a08 80%);
  transition: transform 180ms cubic-bezier(0.3, 1.4, 0.5, 1);
  pointer-events: none;
}

.knob-cap::after {
  content: "";
  position: absolute;
  top: 5px;
  left: 50%;
  width: 4px;
  height: 27%;
  margin-left: -2px;
  border-radius: 2px;
  background: #dcc9a4;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}

.knob-hit {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.knob-hit.left {
  left: 0;
  border-radius: 44px 0 0 44px;
}

.knob-hit.right {
  right: 0;
  border-radius: 0 44px 44px 0;
}

.knob-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.28em;
  color: #c9b18c;
  opacity: 0.7;
}

.grille {
  width: 76%;
  height: 92px;
  border-radius: 6px;
  background: repeating-linear-gradient(0deg, #241a10 0 4px, #3a2a18 4px 8px);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6);
}

/* ---- small viewports ------------------------------------------------- */

@media (max-width: 720px), (max-height: 560px) {
  .tv {
    flex-direction: column;
    align-items: center;
  }

  .screen {
    /* leave room for cabinet + bezel padding inside the viewport */
    width: min(100vw - 76px, calc((74vh) * 4 / 3));
  }

  .panel {
    flex-direction: row;
    min-width: 0;
    gap: 26px;
  }

  .knob {
    width: 68px;
    height: 68px;
  }

  .knob.mini {
    width: 46px;
    height: 46px;
  }

  .grille {
    display: none;
  }
}
