/* space2 — TV screen UI. Direction: soft premium, one sheet, one accent (sunlight). */
:root {
  --ink: #f3f5ff;
  --ink-2: rgba(243, 245, 255, 0.58);
  --glass: rgba(20, 20, 22, 0.74);
  --well: rgba(255, 255, 255, 0.08);
  --well-hi: rgba(255, 255, 255, 0.14);
  --sun: #ffffff;
  --sun-ink: #111113;
  --danger: #ff6b5e;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --font: system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #03040b; overflow: hidden; }
body { font-family: var(--font); color: var(--ink); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }

#stage { position: fixed; inset: 0; }
.bg-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; }
.bg-video.on { opacity: 1; }
.desk-note { position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translate(-50%, 12px); margin: 0; padding: 10px 16px; max-width: min(88vw, 420px); border-radius: 14px; background: var(--glass); color: var(--ink); font-size: 14px; line-height: 1.35; text-align: center; opacity: 0; pointer-events: none; transition: opacity 0.6s ease, transform 0.6s ease; -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.desk-note.show { opacity: 1; transform: translate(-50%, 0); }
#stage canvas { position: relative; display: block; width: 100%; height: 100%; opacity: 0; transition: opacity 1.6s ease; }
body.ready #stage canvas { opacity: 1; }
body.idle { cursor: none; }

/* preloader: a moon on an orbit, nothing else */
.pre { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 28px; background: #03040b; transition: opacity 1.2s ease; z-index: 5; }
body.ready .pre { opacity: 0; pointer-events: none; }
.pre-orbit { width: 64px; height: 64px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px rgba(243, 245, 255, 0.14); animation: spin 2.4s linear infinite; }
.pre-orbit i { display: block; width: 10px; height: 10px; margin: -5px auto 0; border-radius: 50%; background: var(--sun); box-shadow: 0 0 18px var(--sun); }
.pre-bar { width: 120px; height: 3px; border-radius: 3px; background: rgba(243, 245, 255, 0.1); overflow: hidden; }
.pre-fill { height: 100%; background: var(--ink); transform: scaleX(0); transform-origin: left; transition: transform 0.5s var(--ease); }
@keyframes spin { to { transform: rotate(360deg); } }

/* menu button: just two hairlines, no chrome at all */
.menu-btn, .fs-btn {
  position: fixed; z-index: 10; top: max(14px, env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right));
  width: 48px; height: 48px; padding: 0; border: 0; border-radius: 50%; cursor: pointer; background: none;
  color: #fff; opacity: 0.4; transition: opacity 0.5s ease, transform 0.35s var(--ease);
}
.fs-btn { right: calc(max(14px, env(safe-area-inset-right)) + 46px); display: grid; place-items: center; }
.menu-btn span { position: absolute; left: 15px; width: 18px; height: 1.5px; border-radius: 2px; background: currentColor; transition: transform 0.4s var(--ease); }
.menu-btn span:first-child { top: 20px; }
.menu-btn span:last-child { top: 27px; }
.menu-btn.open span:first-child { transform: translateY(3.5px) rotate(45deg); }
.menu-btn.open span:last-child { transform: translateY(-3.5px) rotate(-45deg); }
.menu-btn:hover, .fs-btn:hover, .menu-btn.open { opacity: 0.95; }
.menu-btn:active, .fs-btn:active { transform: scale(0.92); }
body.idle .menu-btn:not(.open), body.idle .fs-btn { opacity: 0; }
@media (hover: none) { body.idle .menu-btn:not(.open) { opacity: 0.22; } }
body.menu-light .menu-btn.open { color: #111113; }

/* sheet */
.sheet {
  position: fixed; z-index: 9; top: max(84px, calc(env(safe-area-inset-top) + 64px)); right: max(20px, env(safe-area-inset-right));
  width: 268px; max-height: calc(100dvh - 104px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none;
  padding: 20px; border-radius: 30px;
  background: var(--glass); backdrop-filter: blur(28px); -webkit-backdrop-filter: blur(28px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  display: grid; gap: 20px;
  opacity: 0; visibility: hidden; transform: translateY(-10px) scale(0.97); transform-origin: top right;
  transition: opacity 0.3s ease, transform 0.45s var(--ease), visibility 0s linear 0.3s;
}
.sheet::-webkit-scrollbar { display: none; }
.sheet.open { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.grabber { display: none; }

.scan-open { display: grid; justify-items: center; gap: 14px; }
.qr { display: block; width: 168px; height: 168px; padding: 10px; border-radius: 24px; background: #fff; transition: transform 0.35s var(--ease); }
.qr:hover { transform: scale(1.03); }
.qr svg { display: block; width: 100%; height: 100%; }
.pin { display: block; text-decoration: none; }
.pin b { font-size: 34px; font-weight: 700; letter-spacing: 0.22em; text-indent: 0.22em; font-variant-numeric: tabular-nums; color: var(--ink); }

.scan-locked > div { display: grid; justify-items: center; gap: 12px; }
.lock { width: 26px; height: 26px; color: var(--ink-2); }
.pin-input {
  width: 100%; height: 64px; border: 0; border-radius: 20px; outline: 0; background: var(--well);
  font: 700 30px/1 var(--font); letter-spacing: 0.5em; text-indent: 0.5em; text-align: center; color: var(--ink); caret-color: var(--ink);
  transition: background-color 0.25s ease, box-shadow 0.25s ease;
}
.pin-input::placeholder { color: rgba(243, 245, 255, 0.22); }
.pin-input:focus { background: var(--well-hi); box-shadow: 0 0 0 1.5px var(--ink-2); }
.pin-msg { margin: 0; min-height: 16px; font-size: 13px; color: var(--danger); }

/* one row of round icon tools; words live only in tooltips */
.tools { display: flex; justify-content: center; gap: 12px; }
.tool { position: relative; flex: none; width: 48px; height: 48px; padding: 0; border: 0; border-radius: 50%; display: grid; place-items: center; cursor: pointer; background: var(--well); color: var(--ink); text-decoration: none; transition: background-color 0.2s ease, transform 0.3s var(--ease), color 0.2s ease; }
.tool:hover { background: var(--well-hi); }
.tool:active { transform: scale(0.9); }
.tool .off { display: none; }
.tool[aria-checked="false"] { color: var(--ink-2); }
.tool[aria-checked="false"] .on { display: none; }
.tool[aria-checked="false"] .off { display: inline; }
.tool.owned { color: #f2a33a; }
.tool.owned svg { fill: currentColor; }
.tool.me { overflow: hidden; background: var(--well-hi); font-weight: 700; font-size: 17px; }
.tool.me img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.tool.me.here { box-shadow: 0 0 0 2px var(--ink); }
.lang-tool b { font-size: 13px; font-weight: 700; letter-spacing: 0.06em; pointer-events: none; }
.lang { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; appearance: none; -webkit-appearance: none; font-size: 16px; }
.lang option { color: #111; background: #fff; }

.crew { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.crew:empty { display: none; }
.face { position: relative; aspect-ratio: 1; padding: 0; border: 0; border-radius: 50%; overflow: hidden; cursor: pointer; background: #e9edf8; transition: transform 0.35s var(--ease), box-shadow 0.25s ease; }
.face img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 50% 12%; transform: scale(1.9); transform-origin: 50% 14%; }
.face:hover { transform: scale(1.06); }
.face.picked { box-shadow: 0 0 0 2px var(--glass), 0 0 0 4px var(--ink); transform: scale(1.04); }
.crew:has(.picked) .face:not(.picked) { opacity: 0.4; }
.tool.danger { color: #fff; background: var(--danger); }
.tool.danger:hover { background: #ff8479; }
.tool.danger.armed { color: var(--danger); background: #fff; box-shadow: 0 0 0 3px var(--danger); }
.face.armed { box-shadow: 0 0 0 3px var(--danger); }
.face.armed::after {
  content: ""; position: absolute; inset: 0; background: rgba(255, 107, 94, 0.82)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.6' stroke-linecap='round'%3E%3Cpath d='M7 7l10 10M17 7L7 17'/%3E%3C/svg%3E") center / 46% no-repeat;
}
.manage { display: flex; justify-content: center; gap: 12px; margin-top: 18px; }
.tool.quiet { width: 40px; height: 40px; background: none; color: var(--ink-2); }
.tool.quiet svg { width: 19px; height: 19px; }
.tool.quiet:hover { color: var(--ink); background: var(--well); }
.tool.quiet.armed { color: #fff; background: var(--danger); }

:where(button, a, input):focus-visible { outline: 2px solid var(--sun); outline-offset: 3px; }

/* phone: the same sheet rises from the bottom */
@media (max-width: 600px) {
  .menu-btn { top: max(8px, env(safe-area-inset-top)); right: 8px; }
  .fs-btn { top: max(8px, env(safe-area-inset-top)); right: 52px; }
  .sheet {
    top: auto; right: 0; left: 0; bottom: 0; width: auto; max-height: 86dvh;
    padding: 10px 20px calc(24px + env(safe-area-inset-bottom)); border-radius: 30px 30px 0 0;
    transform: translateY(104%); transform-origin: bottom; opacity: 1;
    transition: transform 0.5s var(--ease), visibility 0s linear 0.5s;
  }
  .sheet.open { transform: none; }
  .grabber { display: block; width: 28px; height: 3px; margin: 0 auto -6px; border-radius: 3px; background: rgba(243, 245, 255, 0.1); }
  .crew { grid-template-columns: repeat(5, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .sheet, .menu-btn, .menu-btn span, .switch i, .face, a.row { transition-duration: 0.01s; }
  .pre-orbit { animation: none; }
}

/* light variant: ?menu=light */
body.menu-light { --ink: #111113; --ink-2: rgba(17, 17, 19, 0.56); --glass: rgba(250, 250, 250, 0.84); --well: rgba(0, 0, 0, 0.06); --well-hi: rgba(0, 0, 0, 0.11); --sun: #111113; --sun-ink: #ffffff; }
body.menu-light .pre { --ink: #f3f5ff; }
body.menu-light .qr { box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08); }
body.menu-light .pin-input::placeholder { color: rgba(17, 17, 19, 0.25); }
body.menu-light .grabber { background: rgba(17, 17, 19, 0.1); }


/* captions: where we are and what that thing is. Quiet, bottom-left, gone in 15 s */
.place { position: fixed; z-index: 4; left: max(4vw, env(safe-area-inset-left)); bottom: max(6vh, env(safe-area-inset-bottom)); max-width: min(80vw, 34em); display: grid; gap: 0.35em; color: #fff; opacity: 0; pointer-events: none; text-shadow: 0 1px 18px rgba(0, 0, 0, 0.7); font-size: clamp(15px, 1.5vw, 30px); }
.place b { font-size: 1.9em; font-weight: 300; letter-spacing: 0.02em; line-height: 1.05; }
.place span { font-weight: 400; line-height: 1.3; opacity: 0.82; }
.place img { width: min(18vw, 260px); height: auto; border-radius: 2px; margin-bottom: 0.5em; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.28), 0 12px 40px rgba(0, 0, 0, 0.6); }
.place.show { animation: place 15s ease both; }
@keyframes place { 0% { opacity: 0; transform: translateY(10px); } 8% { opacity: 1; transform: none; } 85% { opacity: 1; } 100% { opacity: 0; } }

/* a screen that cannot run the game */
.old { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 6vw; background: #03040b; color: #f3f5ff; text-align: center; font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif; }
.old[hidden] { display: none; }
.old b { display: block; font-size: clamp(26px, 4vw, 54px); line-height: 1.1; letter-spacing: -0.02em; }
.old p { margin: 18px auto 14px; max-width: 26em; font-size: clamp(17px, 2vw, 28px); line-height: 1.4; color: rgba(243, 245, 255, 0.66); }
.old a { font-size: clamp(19px, 2.4vw, 34px); color: #fff; }
