:root {
  --paper: #F5F3EC;
  --card: #FFFFFF;
  --ink: #181A2E;
  --muted: rgba(245, 243, 236, 0.65);
  --pen: #2742E8;
  --red: #E8402A;
  --hi: #FFD43B;
  --bg: #0d0f18;
  --grid: rgba(245, 243, 236, 0.06);
  --disp: "Anton", sans-serif;
  --body: "Hanken Grotesk", sans-serif;
  --hand: "Caveat", cursive;
  --mono: "JetBrains Mono", monospace;
  --shadow: 5px 5px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--paper);
  font-family: var(--body);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image: radial-gradient(rgba(245, 243, 236, 0.08) 1.2px, transparent 1.2px);
  background-size: 26px 26px;
  pointer-events: none;
}

[hidden] {
  display: none !important;
}

.scene {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 0 16px 12vh;
  text-align: center;
  pointer-events: none;
  z-index: 1;
}

.scene .time {
  font: 700 12px/1 var(--mono);
  letter-spacing: 0.16em;
  color: var(--hi);
  margin-bottom: 18px;
  background: var(--ink);
  padding: 4px 12px;
  border-radius: 6px;
  border: 1.5px solid var(--paper);
}

.scene h1 {
  font-family: var(--disp);
  font-weight: 400;
  text-transform: uppercase;
  font-size: clamp(40px, 7.5vw, 92px);
  letter-spacing: 0.01em;
  line-height: 0.98;
  color: var(--paper);
}

.scene h1 em {
  font-style: normal;
  color: var(--hi);
  border-bottom: 3px solid var(--red);
}

.scene p {
  margin-top: 18px;
  font-family: var(--body);
  font-size: 1.05rem;
  color: rgba(245, 243, 236, 0.75);
  max-width: 56ch;
}

canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  font-family: var(--mono);
  color: var(--paper);
  z-index: 2;
}

.hud > * {
  position: absolute;
  pointer-events: auto;
}

.tl {
  top: 20px;
  left: 20px;
  letter-spacing: 0.04em;
  line-height: 1.7;
  font-size: 0.82rem;
  background: var(--ink);
  padding: 10px 16px;
  border-radius: 10px;
  border: 2px solid var(--paper);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.5);
}

.tl a {
  color: var(--hi);
  font-weight: 700;
  text-decoration: none;
  border-bottom: 1.5px dashed var(--hi);
}

.tl a:hover {
  color: #fff;
  border-bottom-style: solid;
}

.tl b {
  font-weight: 700;
  color: var(--paper);
}

.tr {
  top: 18px;
  right: 18px;
  background: var(--ink);
  border: 2px solid var(--paper);
  border-radius: 9px;
  color: var(--paper);
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 8px 14px;
  cursor: pointer;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.5);
  transition: transform 0.15s, box-shadow 0.15s;
}

.tr:hover {
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
  background: var(--pen);
}

.hint {
  left: 0;
  right: 0;
  bottom: 22px;
  text-align: center;
  pointer-events: none;
  padding: 0 16px;
  font-family: var(--hand);
  font-size: 1.45rem;
  color: var(--hi);
  letter-spacing: 0.02em;
}

.reset {
  left: 50%;
  bottom: 60px;
  transform: translateX(-50%);
  background: var(--red);
  color: #ffffff;
  border: 2px solid var(--ink);
  border-radius: 10px;
  font-family: var(--body);
  font-weight: 800;
  font-size: 0.95rem;
  padding: 12px 22px;
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--ink);
  animation: rise 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  transition: transform 0.15s ease, background 0.15s ease;
}

.reset:hover {
  background: #ff523b;
  transform: translateX(-50%) translateY(-2px);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translate(-50%, 12px);
  }
}

/* Wall Switch */
.switch {
  right: max(24px, 8vw);
  top: 50%;
  transform: translateY(-50%);
  width: 76px;
  height: 124px;
  border-radius: 12px;
  background: linear-gradient(160deg, #1e202e, #141520 60%, #0c0d15);
  border: 2px solid var(--paper);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    0 8px 24px rgba(0, 0, 0, 0.6);
  cursor: pointer;
  outline: none;
}

.switch:focus-visible {
  outline: 3px solid var(--pen);
  outline-offset: 3px;
}

.switch.knock {
  animation: knock 0.32s cubic-bezier(0.3, 0.7, 0.4, 1);
}

@keyframes knock {
  0% {
    transform: translateY(-50%) translate(var(--kx, 0), var(--ky, 0)) rotate(var(--kr, 0deg));
  }
  100% {
    transform: translateY(-50%);
  }
}

.screw {
  position: absolute;
  left: 50%;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #8b8d96, #2d2f3b 70%);
}

.screw::after {
  content: "";
  position: absolute;
  left: 1px;
  right: 1px;
  top: 3.5px;
  height: 1px;
  background: rgba(0, 0, 0, 0.8);
  transform: rotate(35deg);
}

.screw.t {
  top: 9px;
}

.screw.b {
  bottom: 9px;
}

.slot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 26px;
  height: 52px;
  margin: -26px 0 0 -13px;
  border-radius: 5px;
  background: linear-gradient(#08090f, #12131d);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.9);
  perspective: 120px;
}

.lever {
  position: absolute;
  left: 3px;
  right: 3px;
  top: 3px;
  bottom: 3px;
  border-radius: 3px;
  transition: transform 0.14s cubic-bezier(0.3, 1.6, 0.5, 1);
  transform-origin: 50% 50%;
  transform: rotateX(-26deg);
  background: linear-gradient(#b0ad9e 0%, #ece6da 38%, #a09d94 52%, #68655e 100%);
  box-shadow: 0 5px 6px rgba(0, 0, 0, 0.6);
}

.switch[aria-checked="false"] .lever {
  transform: rotateX(26deg);
  background: linear-gradient(#4b4840 0%, #807c74 48%, #c5bfb4 64%, #88847c 100%);
  box-shadow: 0 -5px 6px rgba(0, 0, 0, 0.6);
}

.engrave {
  position: absolute;
  left: 0;
  right: 0;
  text-align: center;
  font: 700 8px/1 var(--mono);
  letter-spacing: 0.18em;
  color: var(--paper);
  opacity: 0.6;
}

.engrave.on {
  top: 20px;
}

.engrave.off {
  bottom: 20px;
}

.pilot {
  position: absolute;
  right: 9px;
  top: 50%;
  width: 5px;
  height: 5px;
  margin-top: -2.5px;
  border-radius: 50%;
  background: #3a2a1a;
  transition: background 0.2s, box-shadow 0.2s;
}

.switch[aria-checked="true"] .pilot {
  background: var(--hi);
  box-shadow: 0 0 8px 2px rgba(255, 212, 59, 0.95);
}

.mob {
  display: none;
}

@media (max-width: 640px) {
  .scene {
    padding-bottom: 168px;
  }
  .scene .time {
    font-size: 11px;
    margin-bottom: 14px;
  }
  .scene h1 {
    font-size: clamp(34px, 11vw, 44px);
  }
  .scene p {
    margin-top: 14px;
    font-size: 15px;
    max-width: 30ch;
  }
  .desk,
  .hint {
    display: none;
  }
  .mob {
    display: inline;
  }
  .tl {
    top: 14px;
    left: 14px;
    font-size: 11px;
  }
  .tr {
    top: 10px;
    right: 10px;
    font-size: 11px;
    padding: 6px 10px;
  }
  .switch {
    right: 14px;
    top: 36%;
    scale: 0.8;
    transform-origin: right center;
  }
}
