:root {
  --screen: #b7cde0;
  --screen-ink: #0f1a2b;
  --ink: #111;
  --paper: #f2efe8;
  --yellow: #ffd400;
  --blue: #1727ff;
  --mono: "Sometype Mono", ui-monospace, monospace;
  --display: "Archivo", system-ui, sans-serif;
}
@font-face {
  font-family: "Sampanis Hand";
  src: url("../assets/fonts/SampanisHand-Regular.woff2") format("woff2");
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; color: var(--paper); overflow: hidden; }
body { font-family: var(--mono); -webkit-font-smoothing: antialiased; user-select: none; -webkit-user-select: none; }
button { font: inherit; }

.layer { position: fixed; inset: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- lockup (two stacked windows) ---------- */
.lockup { display: inline-flex; flex-direction: column; align-items: flex-start; line-height: 1; }
.lockup .w1 { font: 700 28px var(--mono); background: var(--paper); color: var(--ink); padding: 10px 14px 18px; border-top: 3px solid var(--ink); }
.lockup .w2 { font: 800 38px var(--display); background: var(--ink); color: var(--paper); padding: 8px 16px 10px; margin: -8px 0 0 110px; border: 3px solid var(--paper); }
.lockup.small .w1 { font-size: 13px; padding: 5px 7px 9px; }
.lockup.small .w2 { font-size: 18px; padding: 4px 8px 5px; margin: -5px 0 0 52px; border-width: 2px; }

.btn {
  appearance: none; cursor: pointer; border: 2px solid var(--paper);
  background: var(--paper); color: var(--ink);
  font: 700 14px var(--mono); letter-spacing: .06em; text-transform: uppercase;
  padding: 12px 18px;
}
.btn:hover { background: var(--yellow); border-color: var(--yellow); }
.btn.ghost { background: transparent; color: var(--paper); }
.btn.ghost:hover { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.btn:focus-visible, .menu-list li:focus-visible { outline: 2px dashed var(--yellow); outline-offset: 3px; }

.hint { font: 400 12px var(--mono); letter-spacing: .08em; text-transform: uppercase; opacity: .7; margin: 0; }

/* ---------- door ---------- */
#door { z-index: 50; display: grid; place-items: center; background: radial-gradient(ellipse at 50% 40%, #1b1a17 0%, #000 70%); }
.door-inner { display: grid; justify-items: center; gap: 22px; text-align: center; padding: 16px; }
.door-sub { margin: 8px 0 12px; letter-spacing: .3em; font-size: 12px; opacity: .8; }
.door-hint { margin: 0; font-size: 11px; letter-spacing: .2em; text-transform: uppercase; opacity: .45; }

/* ---------- store ---------- */
#store { visibility: hidden; }
#store-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: filter .6s ease; }
#store.inspecting #store-bg { filter: blur(6px) brightness(.55) saturate(.8); }
#flicker { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 20%, #ffc98a, #ff9a4d 70%); mix-blend-mode: soft-light; opacity: 0.08; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.store-hud { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: flex-start; padding: 18px 20px; pointer-events: none; }
.hud-right { font-size: 12px; letter-spacing: .14em; background: var(--ink); padding: 6px 10px; }
#shelf-hint { position: absolute; left: 0; right: 0; bottom: 22px; text-align: center; text-shadow: 0 1px 6px #000; transition: opacity .4s; }
.tag {
  position: absolute; pointer-events: none; transform: translate(-50%, -100%);
  background: var(--yellow); color: var(--ink); font: 700 12px var(--mono); padding: 5px 8px;
  letter-spacing: .05em; white-space: nowrap; opacity: 0; transition: opacity .15s;
}
#inspect {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 20px 20px 26px;
  display: grid; justify-items: center; gap: 12px; text-align: center;
  opacity: 0; pointer-events: none; transform: translateY(12px);
  transition: opacity .35s, transform .35s;
  background: linear-gradient(transparent, rgba(0,0,0,.6));
}
#store.inspecting #inspect { opacity: 1; pointer-events: auto; transform: none; }
#store.inspecting #shelf-hint { opacity: 0; }
.inspect-info { display: none; }
.inspect-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ---------- room ---------- */
#room { visibility: hidden; overflow: hidden; background: #000; }
#stage { position: absolute; left: 50%; top: 50%; transform-origin: 0 0; will-change: transform; }
#stage.boxed { -webkit-mask-image: linear-gradient(transparent, #000 10%, #000 90%, transparent); mask-image: linear-gradient(transparent, #000 10%, #000 90%, transparent); }
#room-still, #room-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#room-video { opacity: 0; }
#tv-screen { position: absolute; border-radius: 3% / 4%; background: var(--screen); opacity: 0; overflow: hidden; }
/* eyelids: a soft, blurred elliptical opening. --o is how open the eyes are */
#eyes {
  --o: 0; position: absolute; inset: 0; z-index: 3; pointer-events: none;
  background: radial-gradient(ellipse 150% calc(var(--o) * 70%) at 50% 50%,
    rgba(0,0,0,0) 0%, rgba(0,0,0,.35) 45%, rgba(0,0,0,.9) 80%, #000 100%);
}

/* ---------- guest application ---------- */
#form { position: absolute; inset: 0; opacity: 0; }
#form .hand {
  position: absolute; background: transparent; border: 0; outline: 0; padding: 0; margin: 0;
  resize: none; overflow: hidden; white-space: pre-wrap; overflow-wrap: break-word;
  font-family: "Sampanis Hand", "Comic Sans MS", cursive; color: #1a2140; caret-color: #1a2140;
  line-height: 1; user-select: text; -webkit-user-select: text; transform-origin: left center;
  text-shadow: 0 0 .5px rgba(26,33,64,.6);
}
#form .hand:hover, #form .hand:focus { background: rgba(255, 212, 0, .07); }
#form .hand.sign { color: #10163a; }
#stamp {
  position: absolute; opacity: 0; pointer-events: none; transform: rotate(-9deg);
  font: 700 1em var(--mono); letter-spacing: .12em; color: #c3281e;
  border: .14em solid #c3281e; padding: .15em .5em; mix-blend-mode: multiply;
}
#form-bar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 4; visibility: hidden;
  display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap;
  padding: 14px 16px 18px; background: linear-gradient(transparent, rgba(0,0,0,.7));
}
#form-msg { flex-basis: 100%; text-align: center; margin: 0; font-size: 12px; letter-spacing: .08em; color: var(--yellow); min-height: 1em; }

/* ---------- tv / dvd menu ---------- */
#tv { visibility: hidden; background: #000; overflow: hidden; }
#dvd-menu { position: absolute; inset: 0; display: grid; place-items: center; }
.menu-bg { position: absolute; inset: -10%; background: var(--screen); }
.menu-bg::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.25), transparent 50%),
              radial-gradient(circle at 75% 70%, rgba(0,0,0,.35), transparent 55%);
  animation: drift 12s ease-in-out infinite alternate;
}
@keyframes drift { to { transform: translate(4%, -3%) scale(1.08); } }
.menu-inner { position: relative; width: min(760px, 100% - 32px); color: var(--screen-ink); }
.menu-kicker { font: 700 13px var(--mono); letter-spacing: .2em; margin: 0 0 14px; }
.menu-guest { font: 800 clamp(40px, 8vw, 96px) var(--display); line-height: .95; margin: 0; text-shadow: 0 0 18px rgba(255,255,255,.25); }
.menu-title { font: 700 clamp(16px, 2.2vw, 22px) var(--mono); margin: 12px 0 34px; }
.menu-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.menu-list li { font: 700 clamp(18px, 2.4vw, 26px) var(--mono); cursor: pointer; padding: 4px 0 4px 34px; position: relative; width: max-content; }
.menu-list li::before { content: "▶"; position: absolute; left: 0; opacity: 0; }
.menu-list li:hover::before, .menu-list li.on::before { opacity: 1; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.menu-msg { min-height: 3em; margin: 26px 0 0; font-size: 14px; line-height: 1.5; max-width: 52ch; }
#player { position: absolute; inset: 0; display: none; background: #000; }
#player.on { display: block; }
#player video, #player iframe { width: 100%; height: 100%; border: 0; object-fit: contain; }
.crt { position: absolute; inset: 0; pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,.18) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.55) 100%);
  transition: opacity 1.5s; }
#tv.clean .crt { opacity: .25; }

/* ---------- overlays ---------- */
#blackout { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; z-index: 40; }
#grain {
  position: fixed; inset: -50%; pointer-events: none; z-index: 45; opacity: .09;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain .5s steps(4) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); } 25% { transform: translate(-3%, 2%); }
  50% { transform: translate(2%, -3%); } 75% { transform: translate(-2%, -1%); }
}

@media (max-width: 640px) {
  .lockup .w1 { font-size: 20px; } .lockup .w2 { font-size: 28px; margin-left: 78px; }
  .hud-right { font-size: 10px; }
  .btn { padding: 11px 14px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  #grain { animation: none; }
  .menu-bg::after { animation: none; }
}
