:root {
  --x: 50vw;
  --y: 50vh;
  --r: 170px;
  --bg: #1c0f06;
  --orange: #ff7a1a;
  --amber: #ffb347;
  --cream: #fff1de;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--cream);
  font-family: "Caveat", cursive;
  cursor: none;
}

#room {
  position: fixed; inset: 0;
  background:
    radial-gradient(circle at 50% 50%, #3a1d0a, var(--bg) 70%),
    var(--bg);
}

/* the torch */
#dark {
  position: fixed; inset: 0; pointer-events: none;
  background: rgba(10, 4, 1, .985);
  --torch: radial-gradient(circle var(--r) at var(--x) var(--y), transparent 0 35%, #000 100%);
  --spot: radial-gradient(ellipse 90px 70px at var(--dx, -500px) var(--dy, -500px), transparent 0 30%, #000 100%);
  -webkit-mask-image: var(--torch), var(--spot);
  -webkit-mask-composite: source-in;
  mask-image: var(--torch), var(--spot);
  mask-composite: intersect;
  animation: flicker 4s infinite;
}

/* drone */
#drone {
  position: fixed; left: 0; top: 0; z-index: 5; width: 110px;
  cursor: none;
  will-change: transform;
}
#drone svg { width: 100%; overflow: visible; fill: none; stroke: var(--cream); stroke-width: 2; }
#drone .body { fill: #2a1609; }
#drone .arm { fill: #3a2210; }
#drone .cam { fill: var(--orange); stroke: none; }
#drone .rotor ellipse { fill: rgba(255, 241, 222, .35); stroke: none; }
#drone .rotor { transform-box: fill-box; transform-origin: center; animation: rotor .08s linear infinite alternate; }
@keyframes rotor { to { transform: scaleX(.2); } }
#drone .led { stroke: none; animation: led 1s steps(1) infinite; }
#drone .red { fill: #ff3b1a; }
#drone .green { fill: #3bff7a; animation-delay: .5s; }
@keyframes led { 50% { opacity: 0; } }
#drone .beam {
  position: absolute; left: 50%; top: 42px; width: 150px; height: 140px;
  transform: translateX(-50%);
  clip-path: polygon(46% 0, 54% 0, 100% 100%, 0 100%);
  background: linear-gradient(rgba(255, 179, 71, .35), rgba(255, 179, 71, 0));
  pointer-events: none;
}
#drone.zoom { transition: transform .9s cubic-bezier(.5, 0, .9, .3); }

/* jet */
#jet {
  position: fixed; top: 12%; left: 0; z-index: 5; width: 60px;
  display: flex; align-items: center;
  transform: translateX(-300px);
  pointer-events: none;
}
#jet svg { width: 60px; fill: var(--cream); filter: drop-shadow(0 0 6px var(--orange)); }
#jet .trail {
  position: absolute; right: 52px; width: 260px; height: 3px; border-radius: 3px;
  background: linear-gradient(90deg, transparent, var(--orange));
  box-shadow: 0 0 10px var(--orange);
}
#jet.fly { animation: fly 2.6s ease-in forwards; }
@keyframes fly {
  from { transform: translateX(-300px) translateY(0) rotate(-3deg); }
  to { transform: translateX(calc(100vw + 300px)) translateY(-60px) rotate(-6deg); }
}
@keyframes flicker {
  0%, 100% { opacity: 1; }
  92% { opacity: 1; }
  93% { opacity: .9; }
  94% { opacity: 1; }
  96% { opacity: .85; }
}

.giant {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -55%);
  margin: 0;
  font: italic 400 min(34vw, 420px) / 1 "Instrument Serif", serif;
  color: var(--orange);
  letter-spacing: -.04em;
}

.scrawl { position: absolute; margin: 0; font-size: 1.7rem; color: var(--amber); }
.scrawl a { color: inherit; text-decoration: none; cursor: none; }
.scrawl a:hover { text-decoration: underline; }
.s1 { left: 8%; top: 10%; transform: rotate(-6deg); }
.s2 { right: 12%; top: 18%; transform: rotate(4deg); }
.s3 { left: 26%; bottom: 34%; transform: rotate(-3deg); color: var(--cream); }
.s4 { right: 5%; bottom: 6%; font-size: 1.2rem; transform: rotate(2deg); opacity: .8; }
.s5 { left: 4%; top: 55%; transform: rotate(-90deg); transform-origin: left; font-size: 1.3rem; opacity: .7; }

.note {
  position: absolute; right: 9%; top: 34%;
  width: 220px; padding: 22px 18px 16px;
  background: #fbe3c0; color: #2a1609;
  transform: rotate(5deg);
  box-shadow: 4px 8px 18px rgba(0, 0, 0, .5);
}
.tape {
  position: absolute; top: -12px; left: 50%; width: 80px; height: 24px;
  transform: translateX(-50%) rotate(-4deg);
  background: rgba(255, 179, 71, .6);
}
.note p { margin: 0; }
.note-head { font-size: 1.1rem; opacity: .7; }
.note-title { font-size: 1.6rem; font-weight: 700; line-height: 1.1; margin: 4px 0 !important; }
.note-artist { font-size: 1.2rem; }
.live .note-head::after { content: " ♪"; color: var(--orange); animation: bob .6s ease-in-out infinite alternate; display: inline-block; }
@keyframes bob { to { transform: translateY(-4px); } }

.doodle { position: absolute; fill: none; stroke: var(--amber); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.d-sun { width: 110px; left: 18%; top: 22%; }
.d-sun g { transform-origin: 50px 50px; animation: spin 14s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.d-cat { position: static; width: 70px; stroke: var(--cream); }
.d-star { width: 50px; left: 60%; top: 8%; fill: var(--orange); stroke: none; }

.door {
  position: absolute; left: 12%; bottom: 12%;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 0; border: none; background: none; font: inherit;
  color: var(--cream); cursor: none;
}
.door-frame {
  position: relative; width: var(--door-w, 90px); height: var(--door-h, 150px);
  border: 4px solid var(--cream); border-bottom: none;
  background: linear-gradient(var(--orange), #b8400a);
  box-shadow: 0 0 40px rgba(255, 122, 26, .6);
  transform-origin: left;
  transition: transform .5s ease, width .9s cubic-bezier(.3, 1.5, .5, 1), height .9s cubic-bezier(.3, 1.5, .5, 1);
}
.knob {
  position: absolute; right: 12%; top: var(--knob-y, 50%);
  width: 10px; height: 10px; border-radius: 50%; background: var(--cream);
  transition: top .9s ease;
}
.door:hover .door-frame, .door:focus-visible .door-frame { transform: perspective(400px) rotateY(-35deg); }
.door.opening .door-frame { transform: perspective(400px) rotateY(-80deg); transition-duration: .35s; }
.door:focus-visible { outline: 2px dashed var(--amber); outline-offset: 6px; }
.door-label { font-size: 1.6rem; }

/* the messy desk */
.desk {
  position: absolute; left: 50%; bottom: 9%; transform: translateX(-50%);
  display: flex; align-items: flex-end; gap: 18px; padding: 0 24px;
}
.plank {
  position: absolute; left: 0; right: 0; bottom: -14px; height: 14px; border-radius: 3px;
  background: linear-gradient(#8a4a1c, #5a2d0e);
  box-shadow: 0 12px 24px rgba(0, 0, 0, .5);
}
.item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 0; border: none; background: none;
  font: 700 1.3rem "Caveat", cursive; color: var(--amber);
  cursor: none; transition: transform .2s;
}
.item svg { fill: none; stroke: var(--cream); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.item .fill { fill: var(--orange); stroke: none; }
.item-paper svg { width: 120px; transform: rotate(-8deg); }
.item-phones svg { width: 80px; transform: rotate(7deg); }
.item-sketch svg { width: 100px; transform: rotate(-3deg); }
.item:hover, .item:focus-visible { transform: translateY(-10px) rotate(-2deg); outline: none; }
.item:hover span, .item:focus-visible span { color: var(--orange); }

/* the light switch */
#switch {
  position: fixed; right: 3%; top: 46%; z-index: 6;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 0; border: none; background: none; cursor: none;
  font: .65rem "Silkscreen", monospace; letter-spacing: .15em; color: var(--amber);
}
.plate {
  display: grid; place-items: center; width: 34px; height: 54px;
  border: 2px solid var(--cream); border-radius: 6px; background: #2a1609;
  animation: glow 2.5s ease-in-out infinite;
}
.toggle {
  width: 12px; height: 24px; border-radius: 4px; background: var(--cream);
  transform: translateY(6px); transition: transform .15s;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .25);
}
@keyframes glow {
  0%, 100% { box-shadow: 0 0 6px rgba(255, 179, 71, .3); }
  50% { box-shadow: 0 0 18px rgba(255, 179, 71, .8); }
}

body.lights-on, body.lights-on * { cursor: auto; }
body.lights-on button { cursor: pointer; }
body.lights-on #dark { animation: none; opacity: 0; transition: opacity .6s; }
body.lights-on #room { background: radial-gradient(circle at 50% 40%, #7a4218, #2a1406 75%); }
body.lights-on #hint { opacity: 0; }
body.lights-on .toggle { transform: translateY(-6px); box-shadow: inset 0 6px 0 rgba(0, 0, 0, .25); }
body.lights-on .plate { animation: none; }

.time { position: absolute; left: 50%; bottom: 2%; transform: translateX(-50%); margin: 0; font-size: 1.3rem; color: var(--amber); }

#hint {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  margin: 0; pointer-events: none;
  font: .8rem "Silkscreen", monospace; letter-spacing: .2em; text-transform: uppercase;
  color: var(--amber); opacity: .7; transition: opacity 1s;
}
#hint.gone { opacity: 0; }

@media (max-width: 700px) {
  :root { --r: 130px; }
  .note { right: 5%; top: 62%; width: 180px; }
  .door { left: 8%; bottom: 8%; }
  .door-frame { max-width: 32vw; max-height: 28vh; }
  .s1, .s2, .s5, .d-cat { display: none; }
  .desk { top: 12%; bottom: auto; gap: 10px; padding: 0 12px; }
  .item { font-size: 1.05rem; }
  .item-paper svg { width: 84px; }
  .item-phones svg { width: 56px; }
  .item-sketch svg { width: 70px; }
  #switch { right: 4%; top: 40%; }
}
