:root {
  --bg: #0d0f14;
  --panel: #161a22;
  --line: #262c38;
  --text: #e9ecf2;
  --muted: #9097a6;
  --blue: #3b7bff;
  --yellow: #ffc93c;
  --red: #ff4a3d;
  --plate: #efe8d8;
  --plate-edge: #c9bea6;
  --plate-shadow: #8f846c;
  --radius: 18px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Warm glow behind everything while the lamp is on */
.glow {
  position: fixed;
  inset: -20% -20% auto -20%;
  height: 90vh;
  background: radial-gradient(closest-side, rgba(255, 201, 60, .22), rgba(255, 201, 60, 0));
  opacity: 0;
  transition: opacity .6s ease;
  pointer-events: none;
  z-index: 0;
}
body.is-on .glow { opacity: 1; }

.top, .stage, .foot { position: relative; z-index: 1; }

.top {
  text-align: center;
  padding: 28px 16px 8px;
}

.wordmark {
  margin: 0;
  font-family: "Racing Sans One", system-ui, sans-serif;
  font-weight: 400;
  font-size: clamp(2.2rem, 7vw, 3.4rem);
  line-height: 1;
  letter-spacing: .02em;
  text-shadow: 0 3px 0 #0a1a40;
}
.w-light { color: var(--yellow); }
.w-switch { color: var(--blue); }

.tagline {
  margin: 10px auto 0;
  max-width: 34em;
  color: var(--muted);
}

/* ---------- layout ---------- */
.stage {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 18px 16px 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 24px;
  align-items: center;
}

@media (max-width: 760px) {
  .stage { grid-template-columns: 1fr; gap: 18px; }
}

/* ---------- video ---------- */
.screen {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #050608;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .45);
}

#video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.badge, .watching {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(10, 12, 16, .72);
  backdrop-filter: blur(4px);
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .04em;
}
.badge { top: 12px; left: 12px; text-transform: uppercase; }
.watching { bottom: 12px; right: 12px; font-weight: 500; color: #cfd4de; }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}
.badge.is-live .dot {
  background: var(--red);
  box-shadow: 0 0 0 0 rgba(255, 74, 61, .6);
  animation: pulse 1.6s ease-out infinite;
}
@keyframes pulse {
  to { box-shadow: 0 0 0 8px rgba(255, 74, 61, 0); }
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  text-align: center;
  background: rgba(5, 6, 8, .78);
  color: #cfd4de;
  transition: opacity .25s ease;
}
.overlay[hidden] { display: flex; opacity: 0; pointer-events: none; }
.overlay p { margin: 0; max-width: 24em; }

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255, 255, 255, .15);
  border-top-color: var(--yellow);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- the switch ---------- */
.control {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.plate {
  position: relative;
  width: 132px;
  height: 208px;
  padding: 18px 0;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(160deg, #fbf7ee, var(--plate) 55%, #e2d9c5);
  box-shadow:
    inset 0 -3px 0 var(--plate-edge),
    inset 0 2px 0 #fffdf7,
    0 10px 24px rgba(0, 0, 0, .5),
    0 2px 0 var(--plate-shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform .1s ease, filter .2s ease;
}
.plate:active:not(:disabled) { transform: scale(.98); }
.plate:focus-visible { outline: 3px solid var(--blue); outline-offset: 5px; }
.plate:disabled { cursor: not-allowed; filter: saturate(.4) brightness(.72); }
.plate.is-cooling { cursor: progress; }

.screw {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, #c6bba3 70%);
  box-shadow: inset 0 0 0 1px #a99d83;
  position: relative;
}
.screw::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  top: 50%;
  height: 2px;
  margin-top: -1px;
  background: #9a8e74;
  transform: rotate(-30deg);
}

.slot {
  position: relative;
  width: 40px;
  height: 92px;
  border-radius: 8px;
  background: linear-gradient(#cfc5ad, #ddd4bf);
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, .28), inset 0 -1px 0 #fff8e8;
  overflow: hidden;
}

/* The lever: down (off) by default, up when on */
.lever {
  position: absolute;
  left: 4px;
  right: 4px;
  height: 50px;
  bottom: 4px;
  border-radius: 6px;
  background: linear-gradient(#fffdf7, #e8dfca);
  box-shadow: 0 -4px 6px rgba(0, 0, 0, .18), inset 0 -2px 0 #cfc4ab;
  transition: bottom .16s cubic-bezier(.3, 1.4, .6, 1), box-shadow .16s ease;
}
.plate[aria-checked="true"] .lever {
  bottom: 38px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, .18), inset 0 2px 0 #fff, inset 0 -2px 0 #cfc4ab;
}

.plate.is-pending .lever { opacity: .75; }

.status {
  margin: 18px 0 0;
  font-size: 1.15rem;
  font-weight: 600;
}
.status .on { color: var(--yellow); }
.status .off { color: #c4cad6; }
.status .bad { color: var(--red); }

.cool {
  width: 180px;
  margin-top: 10px;
}
.cool-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.cool-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--blue);
  border-radius: inherit;
}
.cool p, .last {
  margin: 6px 0 0;
  font-size: .9rem;
  color: var(--muted);
}

.foot {
  margin-top: auto;
  padding: 24px 16px 28px;
  text-align: center;
  font-size: .85rem;
  color: var(--muted);
}
.foot p { margin: 0; }

@media (max-width: 760px) {
  .top { padding-top: 20px; }
  .plate { width: 112px; height: 176px; }
  .slot { height: 78px; }
  .lever { height: 42px; }
  .plate[aria-checked="true"] .lever { bottom: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
