/* DrunkNDungeons: one terminal-ish stylesheet for every page. */
@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700;800&display=swap");

:root {
  --bg: #0d0f0c;
  --panel: #131611;
  --line: #2a3026;
  --fg: #c8d3c0;
  --dim: #6b7566;
  --accent: #f2b33d; /* amber, like a pint */
  --red: #ff6b5b;
  --green: #7bd88f;
  --blue: #6cc4ff;
  --font: "JetBrains Mono", "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font); }
body { min-height: 100vh; min-height: 100dvh; line-height: 1.45; -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { margin: 0 0 0.5em; color: var(--accent); letter-spacing: 0.06em; }
h2 { font-size: 0.85em; color: var(--dim); text-transform: uppercase; letter-spacing: 0.15em; }
a { color: var(--accent); }
.dim { color: var(--dim); }
.accent { color: var(--accent); }
.red { color: var(--red); }
.green { color: var(--green); }
.blue { color: var(--blue); }
.hidden { display: none !important; }
.center { text-align: center; }
pre { margin: 0; font-family: inherit; }

/* ---------- Buttons and inputs ---------- */
button, .btn {
  font: inherit; color: var(--accent); background: transparent; border: 1px solid var(--accent);
  padding: 0.7em 1em; cursor: pointer; text-decoration: none; display: inline-block; text-align: center;
  touch-action: manipulation; user-select: none;
}
button:hover:not(:disabled), .btn:hover { background: var(--accent); color: var(--bg); }
button:focus-visible, .btn:focus-visible, input:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
button:disabled { opacity: 0.35; cursor: not-allowed; }
button.selected { background: var(--accent); color: var(--bg); }
button.ghost-btn { border-color: var(--line); color: var(--dim); }
button.small { padding: 0.3em 0.6em; font-size: 0.8em; }
input {
  font: inherit; color: var(--fg); background: var(--panel); border: 1px solid var(--line);
  padding: 0.75em 0.9em; width: 100%;
}
input::placeholder { color: var(--dim); }
label { display: block; color: var(--dim); font-size: 0.85em; margin: 1em 0 0.35em; text-transform: uppercase; letter-spacing: 0.1em; }
.error-msg { color: var(--red); min-height: 1.4em; margin-top: 0.8em; }

/* ---------- Landing ---------- */
.landing { padding: 2rem; max-width: 34rem; margin: 0 auto; }
.landing .logo { color: var(--accent); font-size: clamp(0.5rem, 2.2vw, 0.85rem); line-height: 1.15; margin: 1rem 0; white-space: pre; overflow: hidden; }
.menu { display: flex; flex-direction: column; gap: 1rem; margin-top: 2rem; }
.menu .btn { font-size: 1.2rem; padding: 1rem 1.25rem; text-align: left; }
.card { border: 1px solid var(--line); background: var(--panel); padding: 1.25rem; }

/* ---------- Host / Table view ---------- */
body.host { font-size: clamp(15px, 1.35vw, 30px); display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
body.host #app { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 1.5em; padding: 0.5em 1em; border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.topbar .brand { color: var(--accent); font-weight: 800; letter-spacing: 0.1em; }
.topbar .room-code { font-weight: 800; letter-spacing: 0.25em; color: var(--fg); }
.topbar .spacer { flex: 1; }
.topbar .status { color: var(--dim); }
.timer { color: var(--accent); font-weight: 700; min-width: 3.5ch; display: inline-block; text-align: right; }
.timer.low { color: var(--red); }

.stage { flex: 1; min-height: 0; display: flex; overflow: hidden; }
.grid { flex: 1; display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: 1em; padding: 1em; min-height: 0; }
.panel { border: 1px solid var(--line); background: var(--panel); padding: 0.8em 1em; min-height: 0; }
.narration { display: flex; flex-direction: column; min-height: 0; }
.log { flex: 1; overflow-y: auto; scrollbar-width: thin; padding-right: 0.5em; }
.log .line { margin: 0.15em 0; white-space: pre-wrap; }
.log .line.typing::after { content: "▌"; color: var(--accent); animation: blink 0.7s steps(1) infinite; }
.tone-intro { color: var(--fg); }
.tone-info { color: var(--dim); }
.tone-roll { color: var(--fg); }
.tone-hit { color: var(--fg); }
.tone-miss { color: var(--dim); }
.tone-kill { color: var(--green); font-weight: 700; }
.tone-sip { color: var(--accent); }
.tone-nat1 { color: var(--red); font-weight: 800; }
.tone-nat20 { color: var(--accent); font-weight: 800; }
.tone-downed { color: var(--red); font-weight: 800; }
.tone-revive { color: var(--green); font-weight: 700; }
.tone-heal { color: var(--green); }
.tone-boss { color: var(--accent); font-weight: 700; }
.tone-loot { color: var(--accent); }
.tone-win { color: var(--green); font-weight: 800; }
.tone-lose { color: var(--red); font-weight: 800; }
.phase-line { border-top: 1px solid var(--line); margin-top: 0.6em; padding-top: 0.5em; display: flex; gap: 1em; justify-content: space-between; color: var(--dim); }
.phase-line .phase-name { color: var(--accent); white-space: nowrap; }

.side { display: flex; flex-direction: column; gap: 1em; min-height: 0; overflow-y: auto; }
.map { color: var(--dim); line-height: 1.2; }
.map .done { color: var(--dim); }
.map .current { color: var(--bg); background: var(--accent); font-weight: 800; }
.map .boss { color: var(--red); }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.2em 1em; align-items: baseline; margin: 0.3em 0; }
.row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { grid-column: 1 / -1; color: var(--dim); font-size: 0.85em; display: flex; gap: 1em; flex-wrap: wrap; }
.bar { letter-spacing: -0.05em; }
.bar.hp { color: var(--green); }
.bar.hp.mid { color: var(--accent); }
.bar.hp.low { color: var(--red); }
.bar.enemy { color: var(--red); }
.ghost .name { color: var(--dim); text-decoration: line-through; }
.offline { opacity: 0.5; }
.ready { color: var(--green); }
.waiting { color: var(--dim); }

.controls { border-top: 1px solid var(--line); padding: 0.6em 1em; display: flex; gap: 1em; align-items: center; }
.controls .spacer { flex: 1; }
.controls .hint { color: var(--dim); font-size: 0.8em; }

/* Lobby on the host */
.lobby { flex: 1; display: grid; grid-template-columns: 1.2fr 1fr; gap: 2em; padding: 2em; overflow-y: auto; }
.big-code { font-size: 5em; font-weight: 800; letter-spacing: 0.35em; color: var(--accent); line-height: 1; margin: 0.15em 0 0.3em; }
.join-url { font-size: 1.05em; word-break: break-all; }
.button-row { display: flex; gap: 0.75em; flex-wrap: wrap; margin: 1em 0; }
.seg { display: flex; flex-wrap: wrap; gap: 0.5em; margin-bottom: 1em; }
.seg button { padding: 0.45em 0.8em; }
.start-btn { font-size: 1.3em; padding: 0.8em 1.5em; margin-top: 1em; width: 100%; }
.party-list .member { display: flex; justify-content: space-between; align-items: center; padding: 0.35em 0; border-bottom: 1px dashed var(--line); }

/* Game over */
.gameover { flex: 1; padding: 2em; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 2em; }
.result-title { font-size: 3.5em; font-weight: 800; letter-spacing: 0.15em; }
.awards .award { display: flex; justify-content: space-between; gap: 1em; padding: 0.45em 0; border-bottom: 1px dashed var(--line); }
.awards .award .who { color: var(--accent); font-weight: 700; }
table.stats { width: 100%; border-collapse: collapse; }
table.stats th, table.stats td { text-align: right; padding: 0.3em 0.5em; border-bottom: 1px solid var(--line); }
table.stats th:first-child, table.stats td:first-child { text-align: left; }
table.stats th { color: var(--dim); font-weight: 400; font-size: 0.8em; text-transform: uppercase; }

/* Big flashes on the host (nat 20, nat 1, downed, phase two) */
.flash {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none; z-index: 50; animation: flash-in 1.8s ease-out forwards; text-align: center;
}
.flash .big { font-size: 7em; font-weight: 800; letter-spacing: 0.15em; text-shadow: 0 0 0.3em currentColor; }
.flash .small { font-size: 1.6em; margin-top: 0.3em; }
.flash.gold { color: var(--accent); background: radial-gradient(circle, rgba(242, 179, 61, 0.25), rgba(13, 15, 12, 0.85) 70%); }
.flash.red { color: var(--red); background: radial-gradient(circle, rgba(255, 107, 91, 0.25), rgba(13, 15, 12, 0.85) 70%); }
.flash.green { color: var(--green); background: radial-gradient(circle, rgba(123, 216, 143, 0.2), rgba(13, 15, 12, 0.85) 70%); }
.shake { animation: shake 0.45s; }

@keyframes flash-in {
  0% { opacity: 0; transform: scale(1.25); }
  12% { opacity: 1; transform: scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-0.4em, 0.2em); }
  40% { transform: translate(0.4em, -0.2em); }
  60% { transform: translate(-0.3em, -0.1em); }
  80% { transform: translate(0.3em, 0.1em); }
}
@keyframes blink { 50% { opacity: 0; } }

.toast {
  position: fixed; left: 50%; bottom: 1.5em; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--accent);
  color: var(--fg); padding: 0.6em 1em; z-index: 60; max-width: 90vw; animation: toast 3s forwards;
}
.toast.err { border-color: var(--red); color: var(--red); }
@keyframes toast { 0% { opacity: 0; } 8% { opacity: 1; } 85% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- Phone / player view ---------- */
body.play { font-size: 17px; }
.phone { max-width: 32rem; margin: 0 auto; padding: 0.8rem 1rem 3rem; }
.me-bar { display: flex; justify-content: space-between; align-items: center; gap: 0.5em; padding: 0.4em 0 0.6em; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.me-bar .who { font-weight: 700; color: var(--accent); }
.me-bar .stats { color: var(--dim); font-size: 0.9em; }
.conn { display: inline-block; width: 0.6em; height: 0.6em; border-radius: 50%; background: var(--green); margin-right: 0.4em; }
.conn.off { background: var(--red); animation: blink 1s steps(1) infinite; }
.timerbar { height: 4px; background: var(--line); margin: 0.6em 0 1em; overflow: hidden; }
.timerbar div { height: 100%; background: var(--accent); transition: width 1s linear; }
.prompt h2 { font-size: 1em; color: var(--accent); margin-top: 0.4em; }
.prompt .title { font-size: 1.6em; color: var(--accent); font-weight: 800; margin: 0.5em 0 0.3em; }
.prompt .text { font-size: 1.1em; }
.big-buttons { display: flex; flex-direction: column; gap: 0.7em; margin: 1em 0; }
.big-buttons button { font-size: 1.2em; padding: 1em; text-align: left; display: flex; flex-direction: column; gap: 0.15em; }
.big-buttons button .detail { font-size: 0.72em; opacity: 0.8; }
.big-buttons.two { flex-direction: row; }
.big-buttons.two button { flex: 1; text-align: center; align-items: center; }
.class-card { text-align: left; }
.class-card .stats { font-size: 0.75em; opacity: 0.85; }
.kbd { font-size: 0.7em; opacity: 0.6; }

.die {
  width: 11rem; height: 11rem; margin: 1.2rem auto; display: flex; align-items: center; justify-content: center;
  font-size: 4.5rem; font-weight: 800; color: var(--accent); cursor: pointer;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); background: var(--accent);
  touch-action: manipulation; user-select: none; position: relative; isolation: isolate;
}
/* The inner hexagon: the accent background around it shows as the outline. */
.die::before {
  content: ""; position: absolute; inset: 3px; z-index: -1; background: var(--panel);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
.die .tap { font-size: 1.1rem; letter-spacing: 0.1em; }
.die.spinning { animation: spin 0.25s linear infinite; }
.die.nat20 { color: var(--bg); }
.die.nat20::before { background: var(--accent); }
.die.nat1 { background: var(--red); color: var(--red); }
.die.done { cursor: default; }
@keyframes spin { 0% { transform: rotate(0); } 25% { transform: rotate(8deg) scale(1.04); } 75% { transform: rotate(-8deg) scale(0.97); } 100% { transform: rotate(0); } }
.roll-result { text-align: center; font-size: 1.2em; }

.extras { display: flex; flex-direction: column; gap: 0.8em; margin-top: 1.5em; }
.extra { border: 1px solid var(--line); background: var(--panel); padding: 0.9em; }
.extra.sip { border-color: var(--accent); }
.extra.give { border-color: var(--accent); box-shadow: 0 0 1rem rgba(242, 179, 61, 0.25); }
.extra h3 { font-size: 1em; margin-bottom: 0.5em; }
.alloc { display: flex; align-items: center; justify-content: space-between; padding: 0.3em 0; gap: 0.5em; }
.alloc .count { min-width: 2ch; text-align: center; font-weight: 800; color: var(--accent); }
.alloc button { padding: 0.35em 0.9em; }
.item { display: flex; justify-content: space-between; align-items: center; gap: 0.6em; padding: 0.4em 0; border-bottom: 1px dashed var(--line); }
.item:last-child { border-bottom: none; }
.item .desc { font-size: 0.8em; color: var(--dim); }
.targets { display: flex; flex-wrap: wrap; gap: 0.5em; margin-top: 0.6em; }

@media (max-width: 900px) {
  body.host { overflow: auto; height: auto; }
  .stage { overflow: visible; }
  .grid, .lobby, .gameover { grid-template-columns: 1fr; }
  .big-code { font-size: 3.2em; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* ---------- Pixel art battle scene (host + Table view) ---------- */
.main-col { display: flex; flex-direction: column; gap: 1em; min-height: 0; }
.main-col .narration { flex: 1; min-height: 6em; }
.scene {
  position: relative; flex: 0 0 56%; min-height: 0; overflow: hidden;
  border: 1px solid var(--line); background: #120f0d; image-rendering: pixelated;
  display: flex; align-items: flex-end; justify-content: space-between; padding: 0 4% 3%;
}
.scene-wall, .scene-floor { position: absolute; left: 0; right: 0; background-repeat: repeat; image-rendering: pixelated; }
.scene-wall { top: 0; height: 55%; filter: brightness(0.55); }
.scene-floor { bottom: 0; height: 45%; filter: brightness(0.75); box-shadow: inset 0 18px 24px -12px rgba(0, 0, 0, 0.8); }
.scene[data-room="tavern"] .scene-wall { filter: brightness(0.45) sepia(0.4); }
.scene[data-room="boss"] .scene-wall { filter: brightness(0.4) hue-rotate(-20deg) saturate(1.4); }
.scene::after { /* vignette */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 60%, transparent 45%, rgba(0, 0, 0, 0.65) 100%);
}
.scene-torch { position: absolute; top: 12%; z-index: 1; animation: flicker 0.9s steps(2) infinite; }
.scene-torch.left { left: 18%; }
.scene-torch.right { right: 18%; }
.scene-title {
  position: absolute; top: 0.4em; left: 0; right: 0; text-align: center; z-index: 3;
  color: var(--accent); font-weight: 800; letter-spacing: 0.08em; text-shadow: 0 2px 0 #000;
}
.scene-banner {
  position: absolute; top: 2em; left: 50%; transform: translate(-50%, -8px); z-index: 3; opacity: 0;
  background: rgba(0, 0, 0, 0.75); border: 1px solid var(--line); padding: 0.15em 0.9em; font-weight: 800;
  transition: opacity 0.25s, transform 0.25s;
}
.scene-banner.show { opacity: 1; transform: translate(-50%, 0); }
.scene-side { position: relative; z-index: 2; display: flex; align-items: flex-end; gap: 0.2em 0.6em; max-width: 48%; flex-wrap: wrap; }
.party-side { justify-content: flex-start; }
.foe-side { justify-content: flex-end; }

.actor { position: relative; display: flex; flex-direction: column; align-items: center; transform: translateY(calc(var(--row, 0) * -1.6em)); transition: opacity 0.6s, filter 0.6s; }
.actor .body { position: relative; animation: bob 1.6s ease-in-out infinite; }
.actor:nth-child(2n) .body { animation-delay: -0.8s; }
.actor .body::after { /* shadow */
  content: ""; position: absolute; left: 15%; right: 15%; bottom: -4px; height: 8px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.55); z-index: -1;
}
.actor .sprite { display: block; width: clamp(48px, 5.2vw, 110px); height: auto; filter: drop-shadow(0 0 1px #000); }
.actor.boss .sprite { width: clamp(110px, 12vw, 260px); }
.actor.prop .sprite { width: clamp(52px, 5.6vw, 120px); }
.actor .label { font-size: 0.7em; font-weight: 700; white-space: nowrap; max-width: 9em; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 0 #000, 0 0 4px #000; }
.actor .mini-hp { width: 70%; height: 5px; background: #2a1f1b; border: 1px solid #000; margin-top: 2px; }
.actor .mini-hp i { display: block; height: 100%; background: var(--green); transition: width 0.4s; }
.actor .mini-hp i.mid { background: var(--accent); }
.actor .mini-hp i.low { background: var(--red); }
.actor .badges { position: absolute; top: -1.1em; font-size: 0.75em; display: flex; gap: 0.15em; }
.actor.active::before { /* turn marker */
  content: "▼"; position: absolute; top: -2.1em; color: var(--accent); font-size: 0.9em; animation: bob 0.8s ease-in-out infinite;
}
.actor.active .sprite { filter: drop-shadow(0 0 1px #000) drop-shadow(0 0 8px rgba(245, 185, 66, 0.75)); }
.foe-side .actor.active .sprite { filter: drop-shadow(0 0 1px #000) drop-shadow(0 0 8px rgba(224, 90, 71, 0.8)); }
.actor.out { opacity: 0.45; filter: grayscale(1); }
.foe-side .actor.out { opacity: 0; transform: translateY(1em); }
.actor.defending .sprite { filter: drop-shadow(0 0 1px #000) drop-shadow(0 0 6px rgba(110, 170, 255, 0.8)); }

.actor.lunge-right .body { animation: lunge-right 0.5s ease-out; }
.actor.lunge-left .body { animation: lunge-left 0.5s ease-out; }
.actor.hurt .body { animation: hurt 0.5s steps(2); }
.actor.dodge .body { animation: dodge 0.5s ease-out; }
.actor.healed .sprite { animation: glow-green 0.9s ease-out; }
.actor.bond .sprite { animation: glow-blue 1.2s ease-out; }
.actor.my-turn .body { animation: hop 0.5s ease-out; }
.actor.dying .body { animation: dying 1.2s ease-in forwards; }

.float {
  position: absolute; top: -0.5em; left: 50%; transform: translateX(-50%); z-index: 5; pointer-events: none;
  font-weight: 800; white-space: nowrap; text-shadow: 0 2px 0 #000, 0 0 6px #000; animation: float-up 1.6s ease-out forwards;
}
.float.dmg { color: var(--red); font-size: 1.4em; }
.float.heal { color: var(--green); font-size: 1.2em; }
.float.miss { color: var(--dim); }
.float.sip { color: var(--accent); top: 1em; font-size: 0.85em; }
.float.roll { color: var(--fg); top: -1.6em; font-size: 0.9em; }
.float.nat20 { color: var(--accent); top: -1.6em; font-size: 1.3em; }
.float.nat1 { color: var(--red); top: -1.6em; font-size: 1.3em; }

@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes flicker { 0% { filter: brightness(1); } 50% { filter: brightness(1.35); } }
@keyframes lunge-right { 0% { transform: none; } 35% { transform: translateX(45%); } 100% { transform: none; } }
@keyframes lunge-left { 0% { transform: none; } 35% { transform: translateX(-45%); } 100% { transform: none; } }
@keyframes hurt { 0%, 100% { transform: translateX(0); filter: none; } 25% { transform: translateX(-6px); filter: brightness(3) saturate(0); } 75% { transform: translateX(6px); filter: brightness(2) sepia(1) hue-rotate(-50deg) saturate(5); } }
@keyframes dodge { 0%, 100% { transform: none; } 40% { transform: translateY(-14px); } }
@keyframes hop { 0%, 100% { transform: none; } 40% { transform: translateY(-12px); } }
@keyframes dying { 0% { transform: none; opacity: 1; } 30% { transform: rotate(-8deg); filter: brightness(3); } 100% { transform: translateY(20px) rotate(-90deg); opacity: 0; } }
@keyframes glow-green { 0%, 100% { filter: none; } 30% { filter: drop-shadow(0 0 10px #7ad67a) brightness(1.4); } }
@keyframes glow-blue { 0%, 100% { filter: none; } 30% { filter: drop-shadow(0 0 12px #6eaaff) brightness(1.3); } }
@keyframes float-up { 0% { opacity: 0; transform: translate(-50%, 8px); } 15% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, -2.2em); } }

/* Turn order list */
.turn-order { display: flex; flex-wrap: wrap; gap: 0.35em; }
.turn-order .slot { border: 1px solid var(--line); padding: 0.05em 0.45em; font-size: 0.85em; }
.turn-order .slot.enemy { color: var(--red); }
.turn-order .slot.active { border-color: var(--accent); color: var(--bg); background: var(--accent); font-weight: 800; }
.turn-order .slot.enemy.active { background: var(--red); border-color: var(--red); }
.turn-order .slot.out { opacity: 0.35; text-decoration: line-through; }

/* ---------- Phone extras ---------- */
.portrait { display: inline-block; vertical-align: middle; margin-right: 0.3em; }
.portrait .sprite { width: 34px; height: auto; display: block; }
.class-card .portrait .sprite { width: 56px; }
.class-card { display: grid !important; grid-template-columns: auto 1fr; column-gap: 0.8em; align-items: center; }
.class-card .portrait { grid-row: span 4; }
#turnStrip { display: flex; gap: 0.3em; flex-wrap: wrap; margin: 0.4em 0; font-size: 0.8em; }
#turnStrip .slot { border: 1px solid var(--line); padding: 0 0.35em; color: var(--dim); }
#turnStrip .slot.me { color: var(--fg); border-color: var(--fg); }
#turnStrip .slot.enemy { color: var(--red); }
#turnStrip .slot.active { background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 800; }
#turnStrip .slot.out { opacity: 0.35; text-decoration: line-through; }
.your-turn { text-align: center; font-size: 1.6em; font-weight: 800; color: var(--accent); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

/* Player POV */
.watch-banner { background: #1d3a5c; color: #cfe3ff; text-align: center; font-size: 0.8em; padding: 0.2em; margin-bottom: 0.4em; }
body.pov { margin: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
body.pov #app { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.pov-bar { flex: none; display: flex; align-items: center; gap: 0.8em; padding: 0.4em 0.8em; border-bottom: 1px solid var(--line); background: var(--panel); }
.pov-tabs { flex: 1; display: flex; gap: 0.35em; overflow-x: auto; }
.pov-tab { flex: none; font-size: 0.85em; padding: 0.3em 0.7em; background: transparent; border: 1px solid var(--line); color: var(--fg); }
.pov-tab.on { border-color: var(--accent); background: var(--accent); color: var(--bg); font-weight: 800; }
.pov-tab.on .dim { color: var(--bg); opacity: 0.7; }
.pov-tab.ghost { opacity: 0.6; }
.pov-frame { flex: 1; min-height: 0; position: relative; display: flex; justify-content: center; background: #050605; }
.pov-frame iframe { display: none; width: 100%; height: 100%; border: 0; background: var(--bg); }
.pov-frame iframe.shown { display: block; }
.pov-frame.phone-size { padding: 1em 0; }
.pov-frame.phone-size iframe { width: 390px; height: min(844px, 100%); border: 2px solid var(--line); border-radius: 18px; }
.tone-story { color: #e8c98a; font-style: italic; }
.tone-turn { color: var(--accent); }
.leave-btn { font-size: 0.85em; padding: 0.05em 0.45em; margin-left: 0.4em; background: transparent; border: 1px solid var(--line); color: var(--dim); }

/* ---------- Battle scene on phones (and Player POV) ---------- */
.phone-scene { flex: none; height: clamp(190px, 34vh, 300px); padding: 0 3% 4%; margin: 0.3em 0; font-size: 13px; }
.phone-scene .scene-title { font-size: 0.95em; }
.phone-scene .scene-banner { top: 1.9em; font-size: 0.95em; }
.phone-scene .scene-torch .sprite { width: 18px; height: auto; }
.phone-scene .actor .sprite { width: clamp(34px, 10vw, 56px); }
.phone-scene .actor.boss .sprite { width: clamp(84px, 26vw, 130px); }
.phone-scene .actor .label { font-size: 0.78em; max-width: 7em; }
.phone-scene .scene-side { gap: 0.1em 0.25em; }
.actor.selectable { cursor: pointer; }
.actor.selected::after { /* target reticle */
  content: ""; position: absolute; left: 50%; bottom: 1.1em; width: 115%; aspect-ratio: 1; transform: translateX(-50%);
  border: 2px dashed var(--red); border-radius: 50%; pointer-events: none; animation: reticle 6s linear infinite;
}
.actor.selected .label { color: var(--red) !important; }
@keyframes reticle { to { transform: translateX(-50%) rotate(360deg); } }
.ticker { border: 1px solid var(--line); background: var(--panel); padding: 0.3em 0.5em; font-size: 0.8em; min-height: 3.6em; }
.ticker .line { opacity: 0.55; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ticker .line.newest { opacity: 1; white-space: normal; }
.target-line { margin: 0.3em 0; }
.your-turn { font-size: 1.25em; margin: 0.1em 0; }
.action-bar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.4em; margin: 0.4em 0; }
.action-bar button { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 0.25em; padding: 0.7em 0.35em; min-height: 6.5em; text-align: center; font-size: 1em; }
.action-bar button > span:first-child { font-weight: 800; font-size: 1.05em; }
.action-bar .detail { font-size: 0.72em; line-height: 1.25; color: var(--dim); }
.action-bar .kbd { display: none; }
@media (hover: hover) and (pointer: fine) { .action-bar .kbd { display: inline; } }

/* ---------- Abilities, levels, statuses, shop ---------- */
.status-icon { font-size: 0.85em; margin-left: 0.05em; }
.lv { color: var(--bg); background: var(--accent); font-weight: 800; padding: 0 0.3em; font-size: 0.85em; }
.gold { color: #f5d77a; }
.bar.xp { color: #b27ae0; }
.action-bar button.ability { border-color: #6c9cff; }
.action-bar button.ability > span:first-child { color: #9dbcff; }
.action-bar button[disabled] { opacity: 0.45; }
.action-bar .tags, .learn .tags { display: flex; gap: 0.3em; justify-content: center; margin-top: auto; }
.tag { font-size: 0.65em; border: 1px solid var(--line); padding: 0 0.3em; color: var(--dim); }
.tag.sip { color: var(--accent); border-color: var(--accent); }
.learn { border-color: #b27ae0 !important; }
.learn > span:first-child { color: #d3adff; font-weight: 800; }
.text.story { color: #e8c98a; font-style: italic; }
.extra.shop .item button { min-width: 4.2em; }
details.extra summary { cursor: pointer; color: var(--accent); }
.float.ability { color: #9dbcff; top: -2.6em; font-size: 0.85em; }
.actor.casting .sprite { animation: glow-blue 0.8s ease-out; }
.party-level { text-transform: none; letter-spacing: 0; font-size: 0.85em; margin-left: 0.4em; }

/* ---------- Player HUD: fullscreen game screen on phones and desktop ---------- */
body.play.in-game { overflow: hidden; }
.hud {
  position: fixed; inset: 0; display: flex; flex-direction: column; background: #0a0c09;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.hud .watch-banner { margin: 0; flex: none; }

/* Top bar: who you are, HP/XP, numbers, timer, turn order */
.hud-top { flex: none; padding: 0.4em 0.7em 0.35em; background: linear-gradient(#171a14, #10120e); border-bottom: 1px solid var(--line); z-index: 6; }
.hud .me-bar { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.7em; padding: 0; border: 0; }
.hud-id { display: flex; align-items: center; gap: 0.4em; min-width: 0; }
.hud-id .portrait .sprite { width: 2.4em; height: auto; }
.hud-id .who { font-weight: 800; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 9em; }
.hud-id .cls { font-size: 0.78em; white-space: nowrap; }
.hud-vitals { display: flex; flex-direction: column; gap: 0.2em; min-width: 0; }
.hud-hp { position: relative; height: 1.15em; background: #2a1f1b; border: 1px solid #000; outline: 1px solid var(--line); overflow: hidden; }
.hud-hp i { position: absolute; inset: 0 auto 0 0; background: var(--green); transition: width 0.4s; }
.hud-hp.mid i { background: var(--accent); }
.hud-hp.low i { background: var(--red); }
.hud-hp span { position: relative; display: block; text-align: center; font-size: 0.75em; font-weight: 800; line-height: 1.5; color: #fff; text-shadow: 0 1px 0 #000, 0 0 3px #000; }
.hud-hp.ghost { background: #241418; }
.hud-hp.mini { display: inline-block; width: 7em; flex: none; }
.hud-xp { height: 4px; background: #241d2e; }
.hud-xp i { display: block; height: 100%; background: #b27ae0; transition: width 0.6s; }
.hud-statuses { min-height: 0; line-height: 1; }
.hud-nums { display: flex; flex-direction: column; align-items: flex-end; font-size: 0.8em; line-height: 1.3; white-space: nowrap; }
.hud .timerbar { margin: 0.35em 0 0; height: 3px; }
.hud #turnStrip { margin: 0.35em 0 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.hud #turnStrip::-webkit-scrollbar { display: none; }
.hud #turnStrip .slot { flex: none; }

/* The battle scene fills whatever space is left */
.hud-stage { position: relative; flex: 1 1 auto; min-height: 8rem; overflow: hidden; }
.hud-stage.hidden { display: none; }
.hud-scene { position: absolute; inset: 0; height: auto; margin: 0; border: 0; padding: 0 4% 6%; font-size: clamp(12px, 1.7vh, 18px); }
.hud-scene .scene-torch .sprite { width: clamp(16px, 2.6vh, 30px); height: auto; }
.hud-scene .actor .sprite { width: clamp(38px, min(13vw, 10vh), 128px); }
.hud-scene .actor.boss .sprite { width: clamp(84px, min(32vw, 24vh), 280px); }
.hud-scene .actor .label { max-width: 8em; }
.hud-scene .scene-side { gap: 0.2em 0.4em; }
.hud-popups { position: absolute; z-index: 12; top: 2.6em; left: 50%; transform: translateX(-50%); width: min(94%, 26rem); display: flex; flex-direction: column; gap: 0.5em; }
.hud-popups .extra { box-shadow: 0 6px 24px rgba(0, 0, 0, 0.7); animation: drop-in 0.25s ease-out; }
@keyframes drop-in { from { opacity: 0; transform: translateY(-0.8em); } }

.hud .ticker { flex: none; border: 0; border-top: 1px solid var(--line); background: #10120e; min-height: 0; padding: 0.3em 0.8em; font-size: 0.8em; }

/* The prompt: dock (your turn), banner (waiting), modal (card over the scene), full (no scene) */
.hud .prompt { flex: none; z-index: 8; }
.hud .prompt.dock { background: linear-gradient(#171a14, var(--panel)); border-top: 1px solid var(--accent); padding: 0.45em 0.6em 0.5em; }
.hud .prompt.banner { background: var(--panel); border-top: 1px solid var(--line); padding: 0.4em 0.8em; text-align: center; }
.hud .prompt.banner .title { font-size: 1em; margin: 0; }
.hud .prompt.banner .text { font-size: 0.85em; margin: 0.15em 0 0; color: var(--dim); }
.hud .prompt.banner > p.dim { display: none; }
.hud .prompt.modal {
  position: absolute; z-index: 20; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(92vw, 30rem); max-height: 84vh; overflow-y: auto; background: var(--panel);
  border: 1px solid var(--accent); padding: 0.6em 1em 1em;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.55), 0 0 2.5rem rgba(242, 179, 61, 0.25);
  animation: card-in 0.22s ease-out;
}
@keyframes card-in { from { opacity: 0; transform: translate(-50%, -46%) scale(0.96); } }
.hud .prompt.modal .die { width: 9rem; height: 9rem; font-size: 3.8rem; margin: 0.8rem auto; }
.hud .prompt.full { flex: 1 1 auto; overflow-y: auto; width: 100%; max-width: 40rem; margin: 0 auto; padding: 0.5em 1em 1.5em; }

/* Your turn: header line + ability grid */
.dock-head { display: flex; align-items: center; gap: 0.4em 0.8em; flex-wrap: wrap; margin-bottom: 0.4em; }
.dock-head .your-turn { font-size: 1.05em; margin: 0; }
.dock-head .target-line { margin: 0; font-size: 0.85em; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { font-size: 0.75em; padding: 0.3em 0.6em; border: 1px solid var(--accent); background: transparent; color: var(--accent); margin-left: auto; }
.chip.on { border-style: dashed; }
.hud .action-bar { grid-template-columns: repeat(auto-fill, minmax(7.2em, 1fr)); gap: 0.35em; margin: 0; max-height: 40vh; overflow-y: auto; }
.hud .action-bar button { min-height: 4.6em; padding: 0.45em 0.35em; gap: 0.15em; }
.hud .action-bar .name { font-weight: 800; font-size: 0.95em; line-height: 1.15; }
.hud .action-bar .detail { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 0.68em; }
.hud .action-bar button.attack { border-color: var(--red); }
.hud .action-bar button.attack .name { color: #ff9b8f; }
.hud .action-bar button.defend .name { color: var(--blue); }

/* Drawers and the bottom tab bar */
.sheet { flex: none; max-height: 50vh; overflow-y: auto; background: var(--panel); border-top: 2px solid var(--accent); padding: 0.5em 0.9em 0.8em; z-index: 9; animation: slide-up 0.2s ease-out; }
.sheet.hidden { display: none; }
@keyframes slide-up { from { transform: translateY(1.5em); opacity: 0; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.4em; color: var(--accent); }
.sheet .item .tags { display: flex; gap: 0.25em; flex: none; }
.sheet .portrait .sprite { width: 1.6em; height: auto; vertical-align: middle; }
.sheet-log { font-size: 0.85em; display: flex; flex-direction: column; gap: 0.2em; }
.hud-dock { flex: none; display: flex; gap: 0.3em; padding: 0.35em 0.5em calc(0.35em + env(safe-area-inset-bottom) * 0); background: #0d0f0b; border-top: 1px solid var(--line); z-index: 10; }
.hud-dock button {
  flex: 1 1 0; min-width: 0; position: relative; display: flex; flex-direction: column; align-items: center; gap: 0.05em;
  font-size: 1em; padding: 0.3em 0.2em; background: transparent; border: 1px solid var(--line); color: var(--fg);
}
.hud-dock button span { font-size: 0.65em; color: var(--dim); }
.hud-dock button.on { border-color: var(--accent); background: rgba(242, 179, 61, 0.1); }
.hud-dock button.on span { color: var(--accent); }
.hud-dock button.glow { border-color: #f5d77a; animation: pulse 1.2s ease-in-out infinite; }
.hud-dock button.drink { border-color: var(--accent); }
.hud-dock .badge { position: absolute; top: -0.45em; right: 0.1em; background: var(--accent); color: var(--bg); font-size: 0.62em; padding: 0 0.35em; font-weight: 800; }

/* Wider screens (desktop over Discord): more room for the scene and the action bar */
@media (min-width: 900px) {
  body.play { font-size: 18px; }
  .hud-top, .hud .ticker { padding-left: 1.5em; padding-right: 1.5em; }
  .hud .me-bar { grid-template-columns: auto minmax(12em, 28em) auto; justify-content: space-between; }
  .hud .prompt.dock { padding: 0.6em 1.5em 0.7em; }
  .hud .action-bar { grid-template-columns: repeat(auto-fill, minmax(10em, 1fr)); }
  .hud .action-bar .detail { -webkit-line-clamp: 3; }
  .hud-dock { justify-content: center; }
  .hud-dock button { flex: 0 0 6.5em; }
  .sheet { max-width: 44rem; width: 100%; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}
/* Short screens (phone in landscape): squeeze the chrome */
@media (max-height: 520px) {
  .hud-top { padding-top: 0.2em; padding-bottom: 0.2em; }
  .hud #turnStrip, .hud .ticker { display: none; }
  .hud .action-bar button { min-height: 3.4em; }
  .hud .action-bar .detail { display: none; }
}

/* ── Open world map (host, Table view, phones) ───────────────────────── */
.worldmap { position: relative; overflow: hidden; background: #07080a; border: 1px solid var(--line, #333); image-rendering: pixelated; }
.host-map { min-height: 46vh; flex: 1; }
.hud-map { position: absolute; inset: 0; border: 0; }
.wm-layer { position: absolute; left: 0; top: 0; transition: transform 0.16s linear; }
.wm-cell { position: absolute; background-size: 100% 100%; image-rendering: pixelated; }
.wm-fog { background-size: 100% 100%; }
.worldmap.night .wm-layer { filter: brightness(0.6) saturate(0.7) hue-rotate(200deg); }
.worldmap.can-travel .wm-cell:not(.wm-fog) { cursor: pointer; }
.worldmap.can-travel .wm-cell:not(.wm-fog):hover { outline: 2px solid var(--accent); outline-offset: -2px; z-index: 1; }
.wm-target { outline: 2px dashed var(--accent); outline-offset: -2px; z-index: 1; }
.wm-place { position: absolute; pointer-events: none; z-index: 2; display: flex; align-items: center; justify-content: center; }
.wm-place svg { width: 100%; height: 100%; }
.wm-place.cleared svg { opacity: 0.55; }
.wm-glyph { font-size: 1.4em; font-weight: 800; text-shadow: 0 0 3px #000; }
.wm-quest { position: absolute; top: -0.5em; right: -0.2em; color: var(--accent); font-size: 1.1em; text-shadow: 0 0 3px #000, 0 0 3px #000; animation: bob 1s ease-in-out infinite; }
.wm-cleared { position: absolute; bottom: -0.2em; right: -0.1em; color: #7ce07c; font-size: 0.8em; text-shadow: 0 0 3px #000; }
.wm-label { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 0.62rem; color: #fff; background: rgba(0, 0, 0, 0.65); padding: 0 0.3em; border-radius: 2px; }
.wm-label.big { font-size: 0.75rem; color: var(--accent); font-weight: 700; }
.wm-party { position: absolute; z-index: 3; transition: left 0.15s linear, top 0.15s linear; filter: drop-shadow(0 0 3px #000); pointer-events: none; }
.wm-party svg { width: 100%; height: 100%; }
.worldmap.walking .wm-party { animation: bob 0.32s ease-in-out infinite; }
.wm-hud { position: absolute; top: 0.4em; left: 0.4em; z-index: 4; display: flex; gap: 0.6em; background: rgba(0, 0, 0, 0.7); padding: 0.2em 0.55em; border-radius: 4px; font-size: 0.8rem; }
.wm-danger { color: #e05a47; }

/* Side panels: mini map and quests */
.mini-wrap { display: flex; justify-content: center; }
.minimap { max-width: 100%; height: auto; border: 1px solid var(--line, #333); }
.world-line { margin-top: 0.35em; font-size: 0.9em; }
.danger { color: #e05a47; }
.quest { display: flex; justify-content: space-between; gap: 0.6em; padding: 0.15em 0; }
.quest.main span:first-child { color: var(--accent); }
.quest.done { opacity: 0.5; text-decoration: line-through; }
.factions { display: flex; flex-wrap: wrap; gap: 0.3em 0.9em; margin-top: 0.5em; font-size: 0.85em; }
.faction.joined { color: #7ce07c; }
.campaign-card { margin-top: 1em; padding: 0.7em 0.9em; border: 1px solid var(--accent); }
.load-row { display: flex; gap: 0.5em; }
.load-row input { text-transform: uppercase; letter-spacing: 0.2em; max-width: 12ch; }

/* Phone: travel and town docks */
.dest-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(11em, 1fr)); gap: 0.4em; max-height: 34vh; overflow-y: auto; }
.dest, .town-grid button { display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: 0.1em; padding: 0.55em 0.7em; }
.dest.quest { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.dest.cleared { opacity: 0.7; }
.dest .detail, .town-grid .detail { font-size: 0.75em; opacity: 0.75; }
.town-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(12em, 1fr)); gap: 0.45em; }
.chip.on { background: var(--accent); color: var(--bg); }
.side > .panel { flex-shrink: 0; }
#quests { font-size: 0.85em; }
#mapTitle .party-level { font-size: 0.75em; }
@media (max-width: 600px) {
  .dest-list { grid-template-columns: 1fr 1fr; max-height: 24vh; }
  .dest { padding: 0.35em 0.5em; font-size: 0.85em; }
  .town-grid { grid-template-columns: 1fr 1fr; }
  .town-grid button { padding: 0.45em 0.55em; font-size: 0.85em; }
}

/* "Play too": the DM's own hero, docked to the right of the host / Table view */
body.host { --hero-w: clamp(340px, 30vw, 460px); }
body.host.with-hero #app { margin-right: var(--hero-w); }
.hero-panel { position: fixed; top: 0; right: 0; bottom: 0; width: var(--hero-w); border-left: 1px solid var(--accent); background: var(--bg); z-index: 50; }
.hero-panel iframe { width: 100%; height: 100%; border: 0; display: block; }
body.host.with-hero .topbar .ghost-btn { font-size: 0.7em; padding: 0.3em 0.55em; }

/* ---------- Battle scene backdrops (scene.js BACKDROPS) ---------- */
.scene-sky, .scene-glow { position: absolute; left: 0; right: 0; top: 0; pointer-events: none; display: none; }
.scene[data-outdoor="1"] .scene-sky { display: block; height: 60%; background: linear-gradient(#7fa7c9 0%, #b9d3e6 70%, #dfe9f1 100%); }
.scene[data-outdoor="1"][data-night="1"] .scene-sky {
  background: radial-gradient(1px 1px at 12% 20%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 38% 12%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 64% 26%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 86% 10%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 75% 18%, #e8f0ff 50%, transparent 51%), linear-gradient(#05070f 0%, #14203a 70%, #243553 100%);
}
/* Outdoors the "wall" is a band of trees, hills or peaks on the horizon. */
.scene[data-outdoor="1"] .scene-wall { top: 36%; height: 20%; filter: none; background-position: bottom; background-repeat: repeat-x; }
.scene[data-outdoor="1"][data-night="1"] .scene-wall { filter: brightness(0.45) saturate(0.6); }
.scene[data-outdoor="1"] .scene-floor { filter: brightness(0.95); box-shadow: inset 0 14px 18px -12px rgba(0, 0, 0, 0.35); }
.scene[data-outdoor="1"][data-night="1"] .scene-floor { filter: brightness(0.45) saturate(0.6) hue-rotate(190deg); }
.scene[data-outdoor="1"]::after { background: radial-gradient(ellipse at 50% 60%, transparent 55%, rgba(0, 0, 0, 0.4) 100%); }
.scene[data-outdoor="1"] .scene-title { text-shadow: 0 2px 0 #000, 0 0 6px #000; }
/* A burning town: smoky orange sky, the town wall on the horizon, firelight. */
.scene[data-backdrop="burning"] .scene-sky { background: linear-gradient(#1a0c08 0%, #6b2512 45%, #d9621f 80%, #f5a142 100%); }
.scene[data-backdrop="burning"] .scene-wall { filter: brightness(0.35) sepia(0.6) saturate(2); }
.scene[data-backdrop="burning"] .scene-floor { filter: brightness(0.6) sepia(0.4) saturate(1.6); }
.scene[data-backdrop="burning"] .scene-glow {
  display: block; bottom: 0; height: auto;
  background: radial-gradient(ellipse at 20% 100%, rgba(255, 120, 30, 0.35), transparent 60%), radial-gradient(ellipse at 85% 90%, rgba(255, 90, 20, 0.3), transparent 55%);
  animation: fireglow 1.6s ease-in-out infinite alternate;
}
@keyframes fireglow { from { opacity: 0.6; } to { opacity: 1; } }
/* Indoor variations on the stone dungeon: sepia first so hue-rotate has a colour to turn. */
.scene[data-backdrop="cave"] .scene-wall { filter: brightness(0.55) sepia(1) saturate(1.4) hue-rotate(-12deg); }
.scene[data-backdrop="cave"] .scene-floor { filter: brightness(0.6) sepia(1) saturate(1.2) hue-rotate(-18deg); }
.scene[data-backdrop="ruin"] .scene-wall { filter: brightness(0.6) sepia(0.8) hue-rotate(55deg) saturate(0.9); }
.scene[data-backdrop="ruin"] .scene-floor { filter: brightness(0.65) sepia(0.6) hue-rotate(45deg) saturate(0.8); }
.scene[data-backdrop="lair"] .scene-wall { filter: brightness(0.7) sepia(1) hue-rotate(165deg) saturate(1.8); }
.scene[data-backdrop="lair"] .scene-floor { filter: brightness(0.85); }
.scene[data-backdrop="fort"] .scene-wall { filter: brightness(0.75) sepia(0.3); }
.scene[data-backdrop="fort"] .scene-floor { filter: brightness(0.8); }

/* ---------- Game feel: shakes, crit impact, sound settings ---------- */
.shake-small { animation: shake-small 0.25s; }
.shake-big { animation: shake-big 0.55s; }
@keyframes shake-small {
  0%, 100% { transform: translate(0, 0); }
  33% { transform: translate(-0.15em, 0.1em); }
  66% { transform: translate(0.15em, -0.1em); }
}
@keyframes shake-big {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  10% { transform: translate(-0.8em, 0.4em) rotate(-0.4deg); }
  25% { transform: translate(0.8em, -0.4em) rotate(0.4deg); }
  40% { transform: translate(-0.6em, -0.3em); }
  55% { transform: translate(0.5em, 0.3em); }
  70% { transform: translate(-0.3em, 0.1em); }
  85% { transform: translate(0.2em, -0.1em); }
}
.scene.impact::before {
  content: ""; position: absolute; inset: 0; z-index: 6; pointer-events: none;
  background: radial-gradient(circle, #fff 0%, rgba(255, 240, 200, 0.7) 40%, transparent 75%);
  animation: impact 0.35s ease-out forwards;
}
@keyframes impact { 0% { opacity: 1; } 100% { opacity: 0; } }

.sound-popover {
  position: fixed; top: 4.2em; right: 1em; z-index: 60; width: min(26em, 92vw);
  background: var(--panel); border: 1px solid var(--accent); padding: 1em 1.1em; box-shadow: 0 1em 3em rgba(0, 0, 0, 0.6);
}
body.host .sound-popover { font-size: 0.75em; }
.feel-panel { display: flex; flex-direction: column; gap: 0.55em; margin: 0.6em 0 0.9em; }
.feel-row { display: flex; align-items: center; gap: 0.6em; cursor: pointer; flex-wrap: wrap; }
.feel-row input[type="checkbox"] { width: 1.2em; height: 1.2em; accent-color: var(--accent); }
.feel-row input[type="range"] { flex: 1; min-width: 8em; accent-color: var(--accent); }
.feel-test { display: flex; align-items: center; gap: 0.7em; flex-wrap: wrap; font-size: 0.9em; }
.feel-row { text-transform: none; letter-spacing: 0; font-size: 1em; margin: 0; color: var(--fg, #e8e2cf); }
.sound-popover h2 { margin-bottom: 0.2em; }
.topbar .ghost-btn { font-size: 0.8em; }

/* ── Assist taps: the host meter and the phone's big button ───────────── */
.main-col { position: relative; }
.assist-meter { position: absolute; top: 1em; left: 50%; transform: translateX(-50%); z-index: 20; width: min(80%, 34em);
  background: rgba(13, 15, 12, 0.92); border: 2px solid var(--accent); padding: 0.7em 1.1em; text-align: center;
  box-shadow: 0 0 2em rgba(242, 179, 61, 0.35); animation: assist-in 0.25s ease-out; }
.assist-meter.brace { border-color: var(--green); box-shadow: 0 0 2em rgba(123, 216, 143, 0.35); }
.assist-meter.full { animation: assist-throb 0.4s ease-in-out infinite; }
.assist-title { font-size: 2.4em; font-weight: 800; letter-spacing: 0.12em; color: var(--accent); }
.assist-meter.brace .assist-title { color: var(--green); }
.assist-line { margin: 0.2em 0 0.5em; }
.assist-count { margin-top: 0.3em; color: var(--dim); }
.assist-bar { height: 1.1em; background: #26291f; border: 1px solid var(--line); overflow: hidden; }
.assist-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #ffe08a); transition: width 0.15s linear; }
.brace .assist-fill { background: linear-gradient(90deg, var(--green), #c9f5d3); }
@keyframes assist-in { from { transform: translateX(-50%) scale(0.6); opacity: 0; } }
@keyframes assist-throb { 50% { box-shadow: 0 0 3.5em rgba(242, 179, 61, 0.8); } }

.assist-dock { display: flex; flex-direction: column; gap: 0.5em; }
.assist-head { display: flex; align-items: baseline; gap: 0.7em; flex-wrap: wrap; }
.tap-btn { position: relative; width: 100%; min-height: 6.5em; font-size: 1.9em; font-weight: 800; letter-spacing: 0.1em;
  background: var(--accent); color: var(--bg); border: 3px solid #ffe08a; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.assist-dock.brace .tap-btn { background: var(--green); border-color: #c9f5d3; }
.tap-btn:hover:not(:disabled) { background: var(--accent); color: var(--bg); }
.assist-dock.brace .tap-btn:hover { background: var(--green); }
.tap-btn.pop { animation: tap-pop 0.12s ease-out; }
.tap-btn.maxed { filter: brightness(1.15) saturate(1.3); }
.tap-count { position: absolute; right: 0.6em; bottom: 0.35em; font-size: 0.45em; opacity: 0.8; }
.tap-hint { text-align: center; font-size: 0.85em; }
@keyframes tap-pop { 0% { transform: scale(0.95); } 100% { transform: scale(1); } }

/* ── Big moments: the spotlight (host) and the phone's quick word ─────── */
.spotlight { position: fixed; inset: 0; z-index: 55; pointer-events: none; display: flex; align-items: center; justify-content: center; gap: 2.5em;
  animation: spot-in 1.3s ease-out forwards; }
.spotlight.big-moment { animation-duration: 2.1s; }
.spotlight.gold { color: var(--accent); background: radial-gradient(circle, rgba(242, 179, 61, 0.28), rgba(13, 15, 12, 0.8) 70%); }
.spotlight.red { color: var(--red); background: radial-gradient(circle, rgba(255, 107, 91, 0.22), rgba(13, 15, 12, 0.6) 70%); }
.spotlight.green { color: var(--green); background: radial-gradient(circle, rgba(123, 216, 143, 0.22), rgba(13, 15, 12, 0.7) 70%); }
.spot-portrait { image-rendering: pixelated; filter: drop-shadow(0 0 1.2em currentColor); animation: spot-portrait 2s ease-out; }
.spot-text .big { font-size: 6em; font-weight: 800; letter-spacing: 0.12em; text-shadow: 0 0 0.3em currentColor; line-height: 1; }
.spot-text .small { font-size: 1.8em; margin-top: 0.3em; color: var(--fg); }
@keyframes spot-in { 0% { opacity: 0; transform: scale(1.4); } 12% { opacity: 1; transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; } }
@keyframes spot-portrait { 0% { transform: translateX(-40%) rotate(-8deg); } 20% { transform: none; } }
.scene.slowmo { animation: slowmo 0.9s ease-out; }
.scene.slowmo * { animation-play-state: paused !important; transition: none !important; }
@keyframes slowmo { 0% { transform: scale(1); filter: none; } 20% { transform: scale(1.06); filter: contrast(1.3) saturate(1.4) brightness(1.15); } 100% { transform: scale(1); filter: none; } }

.phone-spot { position: absolute; inset: 0; z-index: 30; pointer-events: none; display: flex; flex-direction: column; align-items: center; justify-content: center;
  animation: spot-in 1.5s ease-out forwards; text-align: center; }
.phone-spot.gold { color: var(--accent); background: radial-gradient(circle, rgba(242, 179, 61, 0.3), transparent 70%); }
.phone-spot.red { color: var(--red); background: radial-gradient(circle, rgba(255, 107, 91, 0.25), transparent 70%); }
.phone-spot .big { font-size: 3em; font-weight: 800; letter-spacing: 0.1em; text-shadow: 0 0 0.3em currentColor, 0 2px 0 #000; }
.phone-spot .small { font-size: 1.1em; color: var(--fg); text-shadow: 0 1px 2px #000; }

/* ── Chests (phone) ──────────────────────────────────────────────────── */
.chest-card { text-align: center; cursor: pointer; border-width: 2px; }
.chest-card.common { border-color: #b8b2a0; }
.chest-card.rare { border-color: #5fb3ff; box-shadow: 0 0 1.5em rgba(95, 179, 255, 0.45); }
.chest-card.legendary { border-color: var(--accent); box-shadow: 0 0 2.2em rgba(242, 179, 61, 0.7); animation: legendary-glow 1s ease-in-out infinite; }
.chest-card.rare h3, .chest-card.rare .chest-rarity { color: #5fb3ff; }
.chest-card.legendary h3:first-of-type, .chest-card.legendary .chest-rarity { color: var(--accent); }
.chest-art { image-rendering: pixelated; display: inline-block; }
.chest-card.closed .chest-art { animation: chest-bob 1.2s ease-in-out infinite; }
.chest-card.opening .chest-art { animation: chest-shake 0.12s linear infinite; }
.chest-card.open .chest-art { animation: chest-pop 0.4s ease-out; }
.chest-rarity { font-weight: 800; letter-spacing: 0.25em; font-size: 0.9em; }
.chest-item { font-size: 1.15em; font-weight: 700; }
@keyframes chest-bob { 50% { transform: translateY(-4px); } }
@keyframes chest-shake { 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }
@keyframes chest-pop { 0% { transform: scale(0.6); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes legendary-glow { 50% { box-shadow: 0 0 3.5em rgba(242, 179, 61, 1); } }

/* ── Drop-in class picker (join screen) ──────────────────────────────── */
.join-classes { display: grid; grid-template-columns: repeat(auto-fill, minmax(6.5em, 1fr)); gap: 0.4em; margin-top: 0.4em; }
.join-class { display: flex; flex-direction: column; align-items: center; gap: 0.15em; padding: 0.45em 0.3em; font-size: 0.85em; }
.join-class svg { image-rendering: pixelated; }

/* ── Recap card ──────────────────────────────────────────────────────── */
.recap-modal { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.8); display: flex; align-items: center; justify-content: center; padding: 1.5em; }
.recap-box { background: var(--panel); border: 1px solid var(--accent); padding: 1em; width: min(1100px, 100%); }
.recap-preview svg { width: 100%; height: auto; display: block; }
.recap-actions { display: flex; align-items: center; gap: 0.7em; margin-top: 0.8em; flex-wrap: wrap; }
.recap-actions .spacer { flex: 1; }
.recap-section { grid-column: 1 / -1; }
