/* ---------------------------------------------------------------------------
   Cabinet chrome around the canvas. The phosphor effects themselves live in
   src/crt.js (they are drawn on the canvas so screenshots capture them); this
   file is only the plastic: bezel, glow bleed, touch pads.
--------------------------------------------------------------------------- */

:root {
  --phos: #39ff7a;
  --phos-dim: #77b18d;
  --bg: #050706;
  --bezel: #15181a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: radial-gradient(circle at 50% 35%, #0a1410 0%, #050706 60%, #000 100%);
  color: var(--phos-dim);
  font-family: 'DejaVu Sans Mono', 'Ubuntu Mono', ui-monospace, monospace;
  overflow-x: hidden;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.cabinet {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, 1.2vh, 14px);
  padding: clamp(4px, 1.5vh, 18px);
}

.bezel {
  position: relative;
  border-radius: clamp(8px, 1.4vw, 22px);
  padding: clamp(6px, 1.1vw, 18px);
  background: linear-gradient(160deg, #22262a 0%, #101314 40%, #050708 100%);
  box-shadow:
    0 0 0 1px #2c3336,
    0 18px 50px rgba(0, 0, 0, 0.8),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  max-width: 100%;
  max-height: calc(100% - 90px);
}

canvas#screen {
  display: block;
  touch-action: none;
  /* Desktop uses a 16:10 tube; narrow windows switch to a portrait layout. */
  width: min(
    calc(100vw - clamp(28px, 4vw, 70px)),
    calc((100svh - 230px) * 1.6)
  );
  height: auto;
  max-width: calc(100vw - clamp(20px, 3vw, 50px));
  aspect-ratio: 16 / 10;
  background: #000;
  border-radius: clamp(4px, 0.8vw, 12px) / clamp(6px, 1.2vw, 18px);
  box-shadow:
    0 0 26px rgba(57, 255, 122, 0.18),
    0 0 90px rgba(57, 255, 122, 0.09),
    inset 0 0 40px rgba(0, 0, 0, 0.9);
}

/* A sheet of glass over the tube: a soft diagonal highlight and edge darkening. */
.glass {
  position: absolute;
  inset: clamp(6px, 1.1vw, 18px);
  border-radius: inherit;
  pointer-events: none;
  background:
    linear-gradient(125deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0) 32%),
    radial-gradient(120% 90% at 50% 50%, rgba(0, 0, 0, 0) 60%, rgba(0, 0, 0, 0.55) 100%);
  mix-blend-mode: screen;
}

.badge {
  position: absolute;
  left: 50%;
  bottom: clamp(2px, 0.5vh, 8px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 9px;
  letter-spacing: 3px;
  color: #46564e;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge .sep {
  opacity: 0.5;
}

.led {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--phos);
  box-shadow: 0 0 8px var(--phos);
  animation: hum 3.4s ease-in-out infinite;
}

@keyframes hum {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}

.pads {
  display: none;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

@media (pointer: coarse) {
  .pads {
    display: flex;
  }
}

.pad {
  appearance: none;
  border: 1px solid rgba(57, 255, 122, 0.35);
  background: rgba(6, 26, 16, 0.8);
  color: var(--phos);
  font: inherit;
  font-size: 15px;
  line-height: 1;
  padding: 12px 16px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 62px;
  box-shadow: 0 0 12px rgba(57, 255, 122, 0.12), inset 0 0 14px rgba(57, 255, 122, 0.06);
}

.pad small {
  font-size: 8px;
  letter-spacing: 2px;
  color: var(--phos-dim);
}

.pad.wide {
  min-width: 96px;
  font-size: 12px;
  letter-spacing: 2px;
}

.pad.is-down {
  background: rgba(57, 255, 122, 0.22);
  box-shadow: 0 0 22px rgba(57, 255, 122, 0.45);
}

.legend {
  margin: 0;
  font-size: 10px;
  letter-spacing: 1px;
  color: #7b9d8e;
  text-align: center;
  max-width: 1100px;
}

.legend b {
  color: var(--phos-dim);
  font-weight: 400;
}

/* The HTML controls remain usable even when the canvas is too small to read. */
.masthead {
  width: min(1100px, 100%);
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 0 8px 8px;
}
.eyebrow { font-size: 9px; letter-spacing: 3px; margin: 0 0 8px; }
h1 { color: #d6ffe2; font-size: clamp(18px, 2.5vw, 28px); letter-spacing: 3px; margin: 0; }
h1 span { color: var(--phos); }
.tagline { font-size: 11px; margin: 0 0 3px; }
.session-controls { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.session-controls .pad { min-height: 40px; padding: 12px 16px; cursor: pointer; }
.pad { touch-action: none; cursor: pointer; }
.pad:hover { border-color: var(--phos); }
.pad:focus-visible { outline: 2px solid #d6ffe2; outline-offset: 4px; }
.legend { line-height: 1.8; }
@media (max-height: 600px) and (min-width: 701px) {
  .cabinet { justify-content: flex-start; }
  canvas#screen { width: min(75vw, 800px); }
}
@media (prefers-reduced-motion: reduce) { .led { animation: none; } }

.gesture-hint { display: none; margin: 0; color: #a5cbb3; font-size: 12px; line-height: 1.8; text-align: center; }
@media (any-pointer: coarse) { .gesture-hint { display: block; } }
@media (max-width: 700px) {
  .cabinet { justify-content: flex-start; padding: 18px 8px; gap: 16px; }
  .masthead { display: block; min-width: 0; }
  .tagline { margin-top: 10px; }
  canvas#screen { width: calc(100vw - 38px); aspect-ratio: 3 / 5; }
  .badge { font-size: 6px; letter-spacing: 1px; }
  .pads { gap: 6px; }
  .pad { min-width: 54px; padding: 12px; }
  .hide-help .legend { display: none; }
  h1 { font-size: clamp(14px, 4.4vw, 25px); letter-spacing: 1px; overflow-wrap: anywhere; }
  .eyebrow { font-size: 8px; letter-spacing: 1px; }
  .session-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .session-controls .pad { min-width: 0; font-size: 10px; padding: 12px 8px; }
  .legend { font-size: 12px; letter-spacing: 0; padding: 8px; border-top: 1px solid #244a32; }
  .gesture-hint { display: block; }
}
