/* Hallmark · shape: app screen · genre: playful · theme: custom (deal: manual)
 * signature: the live 3d hall behind the entry form · states: empty, full, closed, offline · v2.0.0 */
/* Hallmark · pre-emit critique: weakest: type, system faces keep the template free of font downloads on phones */
:root {
  --ink: #f6eedf;
  --ink-soft: #d8c9b1;
  --night: #17120f;
  --night-solid: rgb(23 18 15 / .94);
  --night-glass: rgb(23 18 15 / .78);
  --night-veil: rgb(23 18 15 / .55);
  --line: rgb(246 238 223 / .32);
  --gold: #e0b354;
  --danger: #ffb4a2;
  --font-display: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-body: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ad-safe: 16px;
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --key: clamp(44px, 13vh, 56px);
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow-x: clip; background: var(--night); color: var(--ink);
  font-family: var(--font-body); font-size: 16px; -webkit-text-size-adjust: 100%;
}
body { overflow-y: clip; position: fixed; inset: 0; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
body.playing { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

#lobby {
  position: fixed; inset: 0; overflow-y: auto; display: flex; align-items: center;
  padding: 24px max(24px, var(--safe-r)) 96px max(24px, var(--safe-l));
  background: linear-gradient(90deg, var(--night-solid) 0, var(--night-glass) 42%, transparent 78%);
}
.lobby__in { width: min(100%, 1180px); margin-inline: auto; }
.lobby__in > * { max-width: 520px; }
.lobby__owner { margin: 0 0 8px; color: var(--gold); font-size: 17px; }
h1 {
  margin: 0; font-family: var(--font-display); font-weight: 700; line-height: 1.02;
  font-size: clamp(38px, 7vw, 76px); overflow-wrap: break-word; min-width: 0; text-wrap: balance;
}
.lobby__lead { margin: 16px 0 24px; font-size: 18px; line-height: 1.45; color: var(--ink-soft); }
#join label { display: block; margin-bottom: 8px; font-size: 15px; color: var(--ink-soft); }
.join__row { display: flex; gap: 8px; }
#player-name {
  flex: 1; min-width: 0; height: 52px; padding: 0 16px; background: var(--night-glass);
  border: 2px solid var(--line); border-radius: 0; font-size: 17px;
}
#player-name:hover { border-color: var(--ink-soft); }
#enter {
  flex: none; height: 52px; padding: 0 24px; border: 0; border-radius: 0; background: var(--gold);
  color: var(--night); font-weight: 700; box-shadow: inset 0 -4px 0 var(--night-veil);
}
#enter:hover { background: var(--ink); }
#enter:active { transform: translateY(2px); box-shadow: none; }
#enter:disabled { opacity: .5; cursor: not-allowed; }
#room-status { min-height: 22px; margin: 8px 0 0; font-size: 15px; color: var(--ink-soft); }
#room-status[data-state="err"] { color: var(--danger); }
.lobby__keys { margin: 16px 0 0; font-size: 15px; line-height: 1.4; color: var(--ink-soft); }
.lobby__keys--touch { display: none; }
#exhibits { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); margin: 0; padding: 0; }
.no-js #exhibits { position: static; width: auto; height: auto; clip-path: none; }

#players {
  position: fixed; top: max(10px, env(safe-area-inset-top, 0px)); left: calc(10px + var(--safe-l));
  margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; pointer-events: none;
}
#players li { padding: 4px 8px; background: var(--night-glass); border-left: 4px solid var(--who, var(--gold)); font-size: 14px; }
#crosshair { position: fixed; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; pointer-events: none; mix-blend-mode: difference; }
#crosshair::before, #crosshair::after { content: ""; position: absolute; background: var(--ink); }
#crosshair::before { left: 7px; top: 0; width: 2px; height: 16px; }
#crosshair::after { top: 7px; left: 0; height: 2px; width: 16px; }
#prompt {
  position: fixed; left: 50%; top: 60%; transform: translateX(-50%); margin: 0; max-width: min(70vw, 460px);
  padding: 8px 16px; text-align: center; background: var(--night-glass); font-size: 15px; pointer-events: none;
}
.chip { position: fixed; top: max(10px, env(safe-area-inset-top, 0px)); right: calc(10px + var(--safe-r)); margin: 0; padding: 8px 12px; background: var(--night-glass); border: 1px solid var(--line); font-size: 14px; }
#net { top: 52px; color: var(--danger); }
button.chip:hover { background: var(--night); border-color: var(--ink); }

#pad {
  display: none; position: fixed; left: calc(18px + var(--safe-l)); bottom: var(--ad-safe);
  grid-template: repeat(3, var(--key)) / repeat(3, var(--key)); gap: 4px; touch-action: none;
}
#pad button, #jump {
  display: grid; place-items: center; padding: 0; background: var(--night-veil); border: 2px solid var(--line); border-radius: 0;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
#pad svg { width: 46%; fill: var(--ink); pointer-events: none; }
#pad [data-move="f"] { grid-area: 1 / 2; }
#pad [data-move="l"] { grid-area: 2 / 1; }
#pad [data-move="b"] { grid-area: 3 / 2; }
#pad [data-move="r"] { grid-area: 2 / 3; }
#pad button.on, #jump.on { background: var(--gold); border-color: var(--gold); }
#pad button.on svg { fill: var(--night); }
#jump.on { color: var(--night); }
#jump {
  display: none; position: fixed; right: calc(22px + var(--safe-r)); bottom: var(--ad-safe);
  width: calc(var(--key) * 1.7); height: calc(var(--key) * 1.7); font-size: 15px; font-weight: 600;
}

#pause, #rotate {
  position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 24px; text-align: center; background: var(--night-glass);
}
#pause h2, #rotate h2 { margin: 0; font-family: var(--font-display); font-size: 34px; }
#rotate { z-index: 60; background: var(--night); }
#rotate p { margin: 0; color: var(--ink-soft); }
#rotate svg { width: 88px; fill: none; stroke: var(--gold); stroke-width: 3; animation: tilt 1.8s ease-in-out 3 forwards; }
@keyframes tilt { 0%, 30% { transform: rotate(-90deg); } 70%, 100% { transform: rotate(0); } }
#resume { height: 50px; padding: 0 24px; background: var(--gold); color: var(--night); border: 0; font-weight: 700; }
#resume:hover { background: var(--ink); }

#viewer { position: fixed; inset: 0; z-index: 40; background: var(--night); animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; } }
#viewer-stage { position: absolute; inset: 0; overflow: hidden; display: grid; place-items: center; touch-action: none; cursor: zoom-in; }
#viewer-stage.zoomed { cursor: grab; }
#viewer-stage img, #viewer-stage video {
  max-width: 100%; max-height: 100%; object-fit: contain; display: block; transform-origin: center; will-change: transform;
  -webkit-user-drag: none; user-select: none; pointer-events: none;
}
.viewer__bar {
  position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 12px max(12px, var(--safe-r)) 22px max(12px, var(--safe-l));
  background: linear-gradient(180deg, var(--night-glass), transparent); pointer-events: none;
}
.viewer__text { min-width: 0; }
.viewer__text h2 { margin: 0; font-family: var(--font-display); font-size: 22px; overflow-wrap: break-word; }
.viewer__text p { margin: 2px 0 0; color: var(--ink-soft); font-size: 14px; }
.viewer__tools { display: flex; gap: 4px; flex: none; pointer-events: auto; }
.viewer__tools button { min-width: 44px; height: 44px; padding: 0 12px; background: var(--night-glass); border: 1px solid var(--line); font-size: 15px; }
.viewer__tools button:hover { background: var(--ink); color: var(--night); }
#v-close { background: var(--gold); color: var(--night); border-color: var(--gold); font-weight: 700; }

#video-bank { position: fixed; left: 0; top: 0; width: 2px; height: 2px; overflow: hidden; opacity: .01; pointer-events: none; }
#video-bank video { width: 2px; height: 2px; }

body.touch #pad { display: grid; }
body.touch #jump { display: grid; }
body.touch #crosshair { display: none; }
body.touch .lobby__keys--desk { display: none; }
body.touch .lobby__keys--touch { display: block; }

@media (max-height: 480px) {
  #lobby { align-items: flex-start; padding-top: 16px; padding-bottom: 92px; }
  .lobby__owner { margin-bottom: 2px; font-size: 15px; }
  h1 { font-size: clamp(28px, 10vh, 42px); }
  .lobby__lead { margin: 8px 0 12px; font-size: 15px; }
  #join label { display: none; }
  #player-name, #enter { height: 44px; }
  .lobby__keys { display: none !important; }
}
@media (max-width: 560px) {
  .join__row { flex-direction: column; }
  #lobby { background: var(--night-glass); }
}
@media (prefers-reduced-motion: reduce) {
  #rotate svg, #viewer { animation: none; }
  #enter:active { transform: none; }
}
