:root {
  --gold: #d6a948;
  --gold-light: #f3d68e;
  --gold-deep: #9c7128;
  --ivory: #fbf5ea;
  --ink: #1d1611;
  --glass: rgba(24, 18, 13, 0.55);
  --glass-strong: rgba(20, 15, 11, 0.82);
  --line: rgba(243, 214, 142, 0.35);
  --eusha: #9cc3ff;
  --shoily: #ffd25e;
  --serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --script: 'Great Vibes', 'Cormorant Garamond', cursive;
  --sans: 'Jost', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #120d09; color: var(--ivory);
  font-family: var(--sans);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none;
  touch-action: none;
}
[hidden] { display: none !important; }

#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; outline: none; }

.script { font-family: var(--script); font-weight: 400; }
.title { font-family: var(--serif); font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; }
.eyebrow { font-family: var(--sans); font-size: 12px; letter-spacing: 0.32em; text-transform: uppercase; color: var(--gold-light); margin: 0 0 6px; opacity: 0.9; }
.muted { color: rgba(251, 245, 234, 0.72); font-family: var(--serif); font-size: 19px; margin: 6px 0; }
.small { font-size: 15px; }
.error { color: #ffb4a4; font-family: var(--serif); font-size: 18px; margin: 10px 0 0; }

/* ---------- full screens ---------- */
.screen {
  position: fixed; inset: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 16px;
  background: radial-gradient(ellipse at 50% 35%, #3a2a1c 0%, #18110c 60%, #0d0907 100%);
  transition: opacity 0.9s ease;
}
.screen.transparent { background: linear-gradient(180deg, rgba(10, 7, 5, 0.55) 0%, rgba(10, 7, 5, 0) 30%, rgba(10, 7, 5, 0) 55%, rgba(10, 7, 5, 0.7) 100%); justify-content: space-between; padding-top: calc(48px + var(--safe-t)); padding-bottom: calc(40px + var(--safe-b)); }
.screen.dim { background: rgba(8, 6, 4, 0.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.screen.fade { opacity: 0; pointer-events: none; }

.card {
  background: linear-gradient(160deg, rgba(48, 35, 24, 0.92), rgba(22, 16, 11, 0.94));
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 36px 32px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 236, 190, 0.12);
  text-align: center;
  width: min(440px, 100%);
}
.crest { font-size: 28px; color: var(--gold); margin-bottom: 8px; filter: drop-shadow(0 0 12px rgba(214, 169, 72, 0.6)); }
.gate-card h1, .loading-inner h1 { font-size: clamp(48px, 12vw, 72px); margin: 0; line-height: 1.1; color: var(--gold-light); text-shadow: 0 2px 30px rgba(214, 169, 72, 0.35); }
#gate-form { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
#gate-form input {
  flex: 1 1 180px; min-width: 0;
  background: rgba(255, 248, 235, 0.06); border: 1px solid var(--line); border-radius: 999px;
  padding: 14px 20px; color: var(--ivory); font: 17px var(--sans); outline: none;
  -webkit-user-select: text; user-select: text;
}
#gate-form input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(214, 169, 72, 0.2); }

.btn {
  appearance: none; border: 1px solid var(--line); border-radius: 999px;
  background: rgba(255, 248, 235, 0.06); color: var(--ivory);
  font: 500 15px var(--sans); letter-spacing: 0.06em;
  padding: 13px 22px; cursor: pointer; transition: transform 0.15s, background 0.2s, box-shadow 0.2s;
}
.btn:hover { background: rgba(255, 248, 235, 0.12); }
.btn:active { transform: scale(0.97); }
.btn.gold {
  background: linear-gradient(180deg, #f1d38a, #c9963b 55%, #a8772a);
  color: #2a1c0c; border-color: rgba(255, 235, 180, 0.7);
  box-shadow: 0 6px 22px rgba(201, 150, 59, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.btn.gold:hover { box-shadow: 0 8px 30px rgba(201, 150, 59, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.5); }
.btn.small { padding: 9px 16px; font-size: 14px; }

/* ---------- loading ---------- */
.loading-inner { text-align: center; width: min(420px, 100%); }
.bar { height: 2px; background: rgba(243, 214, 142, 0.15); border-radius: 2px; overflow: hidden; margin: 30px auto 14px; width: 80%; }
.bar span { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--gold-deep), var(--gold-light)); box-shadow: 0 0 12px var(--gold); transition: width 0.3s ease; }

/* ---------- lobby ---------- */
.lobby-head { text-align: center; text-shadow: 0 2px 20px rgba(0, 0, 0, 0.6); }
.lobby-head .title { font-size: clamp(30px, 7vw, 54px); margin: 0; color: var(--ivory); }
.choices { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; width: 100%; }
.choice {
  appearance: none; cursor: pointer;
  width: min(220px, 42vw); padding: 18px 12px 16px;
  background: linear-gradient(170deg, rgba(40, 29, 20, 0.78), rgba(18, 13, 9, 0.86));
  border: 1px solid var(--line); border-radius: 20px; color: var(--ivory);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: transform 0.25s ease, border-color 0.25s, box-shadow 0.25s;
}
.choice:hover, .choice:focus-visible { transform: translateY(-4px); border-color: var(--gold); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(214, 169, 72, 0.4); outline: none; }
.choice-name { font-size: clamp(40px, 9vw, 56px); line-height: 1.1; }
.choice[data-who="eusha"] .choice-name { color: #cfe0ff; }
.choice[data-who="shoily"] .choice-name { color: #ffe08a; }
.choice-status { font-size: 12px; letter-spacing: 0.22em; text-transform: uppercase; color: rgba(251, 245, 234, 0.6); }
.choice.inside .choice-status { color: #9ff0b5; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#hud > * { pointer-events: auto; }
.hud-top { position: absolute; top: calc(14px + var(--safe-t)); left: 16px; right: 16px; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; pointer-events: none; }
.hud-title { display: flex; flex-direction: column; text-shadow: 0 2px 12px rgba(0, 0, 0, 0.7); }
.hud-title .script { font-size: 30px; color: var(--gold-light); line-height: 1; }
.found { font-size: 13px; letter-spacing: 0.12em; color: rgba(251, 245, 234, 0.85); margin-top: 4px; }
.presence { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--glass); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px; font-size: 13px; letter-spacing: 0.04em;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: #6f6a63; }
.pill.on .dot { background: #7ee39a; box-shadow: 0 0 8px #7ee39a; }

.prompt {
  position: absolute; left: 50%; bottom: calc(120px + var(--safe-b)); transform: translateX(-50%);
  background: var(--glass-strong); border: 1px solid var(--line); border-radius: 999px;
  padding: 10px 20px; font-family: var(--serif); font-size: 19px; white-space: nowrap;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); pointer-events: none;
  animation: rise 0.25s ease;
}
.prompt kbd {
  font-family: var(--sans); font-size: 12px; font-weight: 500; color: #2a1c0c;
  background: linear-gradient(180deg, #f1d38a, #c9963b); border-radius: 6px; padding: 2px 7px; margin-right: 8px;
}

.minimap {
  position: absolute; right: 16px; top: calc(96px + var(--safe-t));
  width: 150px; height: 160px; border-radius: 16px;
  background: rgba(20, 15, 11, 0.55); border: 1px solid var(--line);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  cursor: pointer; transition: width 0.3s ease, height 0.3s ease;
}
.minimap.big { width: 280px; height: 300px; }
.room-title {
  position: absolute; left: 50%; top: 22%; transform: translateX(-50%);
  font-family: var(--script); font-size: clamp(44px, 7vw, 76px); color: var(--gold-light);
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.6), 0 0 30px rgba(214, 169, 72, 0.35);
  opacity: 0; pointer-events: none; white-space: nowrap;
}
.room-title.show { animation: roomtitle 3.2s ease forwards; }
@keyframes roomtitle { 0% { opacity: 0; transform: translate(-50%, 12px); } 15% { opacity: 1; transform: translate(-50%, 0); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -6px); } }
.hud-actions { position: absolute; right: 16px; bottom: calc(18px + var(--safe-b)); display: flex; gap: 8px; }
.icon-btn {
  width: 46px; height: 46px; border-radius: 50%; cursor: pointer;
  background: var(--glass); border: 1px solid var(--line); color: var(--ivory);
  font-size: 20px; display: grid; place-items: center;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: transform 0.15s, background 0.2s;
}
.icon-btn:hover { background: rgba(60, 44, 28, 0.75); }
.icon-btn svg { width: 20px; height: 20px; color: var(--gold-light); }
.icon-btn:active { transform: scale(0.92); }


.chat { position: absolute; left: 16px; bottom: calc(18px + var(--safe-b)); width: min(380px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.chat-log { display: flex; flex-direction: column; gap: 4px; max-height: 34vh; overflow-y: auto; mask-image: linear-gradient(180deg, transparent 0, #000 24px); -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 24px); padding-top: 20px; pointer-events: auto; scrollbar-width: none; }
.chat-log::-webkit-scrollbar { display: none; }
.chat-line {
  align-self: flex-start; max-width: 100%;
  background: var(--glass); border-radius: 14px; padding: 6px 12px;
  font-size: 15px; line-height: 1.35; word-wrap: break-word;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: opacity 1.2s ease;
  -webkit-user-select: text; user-select: text;
}
.chat-line b { font-weight: 500; margin-right: 6px; }
.chat-line b.eusha { color: var(--eusha); }
.chat-line b.shoily { color: var(--shoily); }
.chat-line.old { opacity: 0; }
.chat.open .chat-line.old { opacity: 1; }
.chat.open .chat-log { background: rgba(14, 10, 7, 0.4); border-radius: 14px; }
.chat-form { display: flex; gap: 8px; pointer-events: auto; }
.chat-form input {
  flex: 1; min-width: 0; background: var(--glass-strong); border: 1px solid var(--line); border-radius: 999px;
  padding: 11px 16px; color: var(--ivory); font: 15px var(--sans); outline: none;
  -webkit-user-select: text; user-select: text;
}
.chat-form input:focus { border-color: var(--gold); }

/* phone controls: always-visible joystick + run toggle (only in touch mode) */
.joyzone, .run-btn { display: none; }
body.touch .joyzone {
  display: block; position: absolute; left: 0; bottom: 0; width: max(36vw, 190px); height: calc(172px + var(--safe-b));
  touch-action: none; -webkit-user-select: none; user-select: none;
}
.joystick {
  position: absolute; left: calc(26px + env(safe-area-inset-left, 0px)); bottom: calc(26px + var(--safe-b));
  width: 132px; height: 132px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(20, 15, 11, 0.25), rgba(20, 15, 11, 0.5));
  border: 2px solid rgba(243, 214, 142, 0.55);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.35), inset 0 0 18px rgba(243, 214, 142, 0.15);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.joystick::before {
  content: ''; position: absolute; inset: 14px; border-radius: 50%;
  border: 1px dashed rgba(243, 214, 142, 0.25);
}
.joystick.active { border-color: var(--gold-light); box-shadow: 0 8px 26px rgba(0, 0, 0, 0.35), 0 0 22px rgba(214, 169, 72, 0.45); }
.joystick .knob {
  position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f6dfa2, #c9963b 70%);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transition: transform 0.08s linear;
}
body.touch .run-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  position: absolute; right: calc(26px + env(safe-area-inset-right, 0px)); bottom: calc(30px + var(--safe-b));
  width: 76px; height: 76px; border-radius: 50%; cursor: pointer;
  background: var(--glass-strong); border: 2px solid rgba(243, 214, 142, 0.5); color: var(--ivory);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4); touch-action: manipulation;
}
.run-btn .run-icon { font-size: 28px; line-height: 1; }
.run-btn .run-label { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; margin-top: 2px; }
body.touch .run-btn.on {
  background: linear-gradient(180deg, #f1d38a, #c9963b 55%, #a8772a); color: #2a1c0c; border-color: rgba(255, 240, 200, 0.9);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4), 0 0 22px rgba(214, 169, 72, 0.6);
}
body.touch .help { display: none; }
/* phone browsers re-blur these every frame over the moving 3D view — use solid glass instead */
body.touch #hud *, body.touch .viewer * { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
body.touch .pill, body.touch .icon-btn, body.touch .chat-line, body.touch .minimap, body.touch .joystick { background-color: rgba(20, 15, 11, 0.72); }
body.touch .prompt {
  pointer-events: auto; cursor: pointer; bottom: calc(34px + var(--safe-b));
  font-family: var(--sans); font-size: 14px; letter-spacing: 0.03em; padding: 8px 16px;
  border-color: rgba(243, 214, 142, 0.6);
}
body.touch .prompt:active { transform: translateX(-50%) scale(0.96); }
.prompt .tap-icon { margin-right: 6px; }
@media (orientation: portrait) {
  body.touch .prompt { bottom: calc(176px + var(--safe-b)); }
}

/* floating seat icons */
#hud > .seat-icons { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 3; }
#hud > .prompt { z-index: 3; }
.seat-icon {
  position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer;
  width: 54px; height: 54px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  background: rgba(20, 15, 11, 0.62); color: var(--gold-light);
  border: 2px solid rgba(243, 214, 142, 0.75);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4), 0 0 16px rgba(214, 169, 72, 0.35);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  touch-action: manipulation; will-change: transform;
}
.seat-icon svg { width: 24px; height: 24px; }
.seat-icon span { font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ivory); }
.seat-icon.stand { background: linear-gradient(180deg, rgba(241, 211, 138, 0.95), rgba(201, 150, 59, 0.95)); color: #2a1c0c; }
.seat-icon.stand span { color: #2a1c0c; }
.seat-icon:active { filter: brightness(1.2); }
body.touch .chat { bottom: calc(176px + var(--safe-b)); width: min(320px, 44vw); }
body.touch .chat-log { max-height: 22vh; }

.toasts { position: absolute; top: calc(70px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: calc(100vw - 32px); }
.toast {
  background: var(--glass-strong); border: 1px solid var(--line); border-radius: 999px;
  padding: 9px 18px; font-family: var(--serif); font-size: 18px; text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); animation: rise 0.35s ease; transition: opacity 0.6s, transform 0.6s;
  pointer-events: auto; max-width: 100%;
}
.toast button { margin-left: 10px; }
.toast.out { opacity: 0; transform: translateY(-8px); }

.help {
  position: absolute; left: 50%; bottom: calc(18px + var(--safe-b)); transform: translateX(-50%);
  display: flex; gap: 14px; font-size: 12px; color: rgba(251, 245, 234, 0.7); letter-spacing: 0.04em;
  background: var(--glass); border-radius: 999px; padding: 8px 16px; pointer-events: none;
  transition: opacity 1.5s ease; white-space: nowrap;
}
.help b { color: var(--gold-light); font-weight: 500; }
.help.gone { opacity: 0; }

/* ---------- name tags / bubbles ---------- */
#tags { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.tag { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); display: flex; flex-direction: column; align-items: center; gap: 6px; will-change: transform; }
.tag .name {
  font-family: var(--script); font-size: 26px; line-height: 1; padding: 2px 12px 4px;
  background: rgba(20, 15, 11, 0.45); border-radius: 999px; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}
.tag.eusha .name { color: #d7e6ff; }
.tag.shoily .name { color: #ffe08a; }
.tag .bubble {
  max-width: 240px; background: #fffaf0; color: var(--ink); border-radius: 16px; padding: 8px 14px;
  font-size: 15px; line-height: 1.3; text-align: center; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  position: relative; animation: pop 0.25s ease;
}
.tag .bubble::after { content: ''; position: absolute; left: 50%; bottom: -6px; width: 12px; height: 12px; background: #fffaf0; transform: translateX(-50%) rotate(45deg); }
.tags-hidden .tag .name { display: none; }

/* ---------- viewer ---------- */
.viewer {
  position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(30, 22, 15, 0.92), rgba(6, 4, 3, 0.97));
  animation: fadein 0.35s ease;
  padding: 16px;
}
.viewer-figure { margin: 0; display: flex; flex-direction: column; align-items: center; max-width: min(1100px, 100%); max-height: 100%; }
.viewer-media { display: flex; align-items: center; justify-content: center; }
.viewer-media img, .viewer-media video {
  max-width: min(1100px, calc(100vw - 32px)); max-height: calc(100vh - 160px); max-height: calc(100dvh - 160px);
  border: 10px solid transparent; border-image: linear-gradient(135deg, #f6dd9a, #b48231 40%, #f1d38a 60%, #9c7128) 1;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7); background: #000; display: block;
  animation: zoomin 0.4s cubic-bezier(.2, .8, .2, 1);
  -webkit-user-select: none; user-select: none;
}
.viewer-media video { width: min(1100px, calc(100vw - 32px)); object-fit: contain; }
.viewer figcaption { margin-top: 18px; text-align: center; display: flex; flex-direction: column; gap: 4px; }
.viewer-num { font-size: 12px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--gold-light); }
.viewer-caption { font-family: var(--serif); font-style: italic; font-size: 24px; color: var(--ivory); }
.viewer-close { position: absolute; top: calc(16px + var(--safe-t)); right: 16px; }
.viewer-close, .viewer-nav {
  width: 50px; height: 50px; border-radius: 50%; cursor: pointer; z-index: 2;
  background: rgba(255, 248, 235, 0.08); border: 1px solid var(--line); color: var(--ivory); font-size: 22px;
  display: grid; place-items: center;
}
.viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); font-size: 34px; line-height: 1; }
.viewer-nav.prev { left: 16px; }
.viewer-nav.next { right: 16px; }
.viewer-close:hover, .viewer-nav:hover { background: rgba(255, 248, 235, 0.16); }

/* ---------- settings ---------- */
.settings-card { text-align: left; }
.small-title { font-size: 24px; margin: 0 0 18px; text-align: center; color: var(--gold-light); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid rgba(243, 214, 142, 0.12); font-size: 15px; }
.row select { background: rgba(255, 248, 235, 0.08); color: var(--ivory); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; font: 14px var(--sans); }
.row select option { background: #241a12; }
.row input[type=range] { accent-color: var(--gold); width: 52%; }
.row input[type=checkbox] { accent-color: var(--gold); width: 20px; height: 20px; }
.settings-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 10px; justify-content: center; }

/* ---------- rotate-your-phone ---------- */
.rotate {
  position: fixed; inset: 0; z-index: 60; display: none;
  align-items: center; justify-content: center; text-align: center; padding: 24px 16px;
  background: radial-gradient(ellipse at 50% 40%, #3a2a1c 0%, #18110c 60%, #0d0907 100%);
}
@media (pointer: coarse) and (orientation: portrait) {
  .rotate { display: flex; }
}
.rotate.dismissed { display: none !important; }
.rotate-inner { max-width: 320px; }
.rotate-phone { width: 96px; height: 96px; color: var(--gold-light); animation: turn 2.4s ease-in-out infinite; filter: drop-shadow(0 0 14px rgba(214, 169, 72, 0.45)); }
.rotate h2 { font-size: 52px; margin: 10px 0 4px; color: var(--gold-light); font-weight: 400; }
.rotate .btn { margin-top: 18px; }
@keyframes turn { 0%, 20% { transform: rotate(0deg); } 50%, 75% { transform: rotate(-90deg); } 100% { transform: rotate(0deg); } }

@keyframes rise { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
.toast { animation-name: toastin; }
@keyframes toastin { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(0.7); } to { opacity: 1; transform: none; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes zoomin { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 0 18px rgba(214, 169, 72, 0.4); } 50% { box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 0 34px rgba(214, 169, 72, 0.8); } }

@media (max-width: 720px), (pointer: coarse) {
  .help { display: none; }
  .hud-title .script { font-size: 24px; }
  .icon-btn { width: 42px; height: 42px; font-size: 18px; }
  .hud-actions { top: calc(64px + var(--safe-t)); bottom: auto; flex-direction: column; }
  .presence { position: absolute; right: 0; top: 0; }
  .hud-top .presence { flex-direction: row; }
  .viewer-nav { top: auto; bottom: calc(18px + var(--safe-b)); transform: none; }
  .viewer-media img, .viewer-media video { max-height: calc(100dvh - 210px); border-width: 6px; }
  .chat { bottom: calc(18px + var(--safe-b)); width: calc(100vw - 140px); }
  .minimap { right: auto; left: 16px; top: calc(70px + var(--safe-t)); width: 96px; height: 102px; }
  .minimap.big { width: 220px; height: 236px; }
  .prompt { bottom: calc(190px + var(--safe-b)); font-size: 17px; }
}

/* phones held sideways: short screens */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 520px) {
  .hud-actions { top: auto; bottom: calc(12px + var(--safe-b)); right: calc(12px + env(safe-area-inset-right, 0px)); flex-direction: row; }
  .icon-btn { width: 40px; height: 40px; font-size: 17px; }
  body.touch .hud-actions { right: calc(116px + env(safe-area-inset-right, 0px)); bottom: calc(40px + var(--safe-b)); }
  body.touch .prompt { bottom: calc(96px + var(--safe-b)); }
  .minimap { top: calc(58px + var(--safe-t)); left: auto; right: calc(16px + env(safe-area-inset-right, 0px)); width: 84px; height: 90px; }
  .minimap.big { width: 180px; height: 192px; }
  .hud-top { left: calc(16px + env(safe-area-inset-left, 0px)); right: calc(16px + env(safe-area-inset-right, 0px)); }
  .chat { left: calc(16px + env(safe-area-inset-left, 0px)); width: min(320px, 40vw); bottom: calc(12px + var(--safe-b)); }
  .chat-log { max-height: 40vh; }
  .prompt { bottom: calc(80px + var(--safe-b)); }
  .room-title { top: 16%; font-size: 44px; }
  .toasts { top: calc(12px + var(--safe-t)); }
  .screen.transparent { padding-top: calc(16px + var(--safe-t)); padding-bottom: calc(14px + var(--safe-b)); }
  .lobby-head .title { font-size: 30px; }
  .lobby-head .muted { font-size: 16px; margin: 2px 0; }
  .choice { padding: 10px 12px 10px; width: min(200px, 30vw); }
  .choice-name { font-size: 38px; }
  .card { padding: 22px 24px; }
  .gate-card h1, .loading-inner h1 { font-size: 46px; }
  .viewer-media img, .viewer-media video { max-height: calc(100dvh - 90px); }
  .viewer figcaption { margin-top: 8px; }
  .viewer-caption { font-size: 18px; }
  .viewer-nav { top: 50%; bottom: auto; transform: translateY(-50%); }
  .settings-card { max-height: calc(100dvh - 24px); overflow-y: auto; }
}
