/* Mystery Manor — cozy pixel UI. Colors come from data/ui.json (set as CSS vars at boot). */
@font-face { font-family: 'Pixelify Sans'; src: url('/assets/fonts/pixelify-sans-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Pixelify Sans'; src: url('/assets/fonts/pixelify-sans-latin-600-normal.woff2') format('woff2'); font-weight: 500 600; font-display: swap; }
@font-face { font-family: 'Pixelify Sans'; src: url('/assets/fonts/pixelify-sans-latin-700-normal.woff2') format('woff2'); font-weight: 700 900; font-display: swap; }

:root {
  --bg: #1b1426; --bg2: #2a1f3b; --panel: #f6e7c8; --panel-dark: #e3cc9f;
  --ink: #3b2433; --ink-soft: #7a5a66; --accent: #e0577a; --accent2: #f3c74f;
  --good: #3fae6a; --bad: #d9534f; --maybe: #e8a23a;
  --panel-img: none; --panel-slice: 8;
  --radius: 10px;
  --font: 'Pixelify Sans', 'Trebuchet MS', system-ui, sans-serif;
  font-size: 16px;
  color-scheme: dark;
}
:root[data-ui-scale="small"] { font-size: 14px; }
:root[data-ui-scale="large"] { font-size: 19px; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--panel); font-family: var(--font); -webkit-tap-highlight-color: transparent; }
body { overflow: hidden; background: radial-gradient(ellipse at top, var(--bg2), var(--bg) 70%); }
button, input, select { font-family: inherit; font-size: inherit; }
.pixel, canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
#app { position: fixed; inset: 0; overflow: hidden; }
#screen-root { position: absolute; inset: 0; }
#fx-canvas { position: fixed; inset: 0; pointer-events: none; z-index: 60; }
.boot { position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.3rem; color: var(--accent2); letter-spacing: 1px; }
[hidden] { display: none !important; }

/* ---------- screens ---------- */
.screen { position: absolute; inset: 0; transition: opacity .25s ease, transform .25s ease; }
.screen-enter { opacity: 0; transform: translateY(10px); }
.screen-leave { opacity: 0; pointer-events: none; }

/* ---------- panels & text ---------- */
.panel {
  background: var(--panel); color: var(--ink);
  border: 8px solid transparent; border-image: var(--panel-img) var(--panel-slice) fill / 12px stretch;
  border-radius: 6px; padding: .6rem .8rem;
  box-shadow: 0 6px 0 rgba(0,0,0,.25);
}
@supports not (border-image: url(x) 1) { .panel { border: 3px solid var(--ink); } }
.panel h3, .panel h4 { margin: .2rem 0 .5rem; }
h1, h2, h3, h4 { font-weight: 700; letter-spacing: .5px; }
.panel-title { margin: .1rem 0 .8rem; text-align: center; font-size: 1.6rem; color: var(--ink); }
.muted { color: var(--ink-soft); }
.small { font-size: .85rem; }
.center { text-align: center; display: flex; flex-direction: column; align-items: center; gap: .4rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.big-text { font-size: 1.25rem; font-weight: 700; }
.hint { background: #fff4c8; border: 2px dashed var(--maybe); padding: .3rem .5rem; border-radius: 6px; margin-top: .4rem; font-size: .9rem; }
.error-text { color: var(--bad); }
.badge { display: inline-block; font-size: .75rem; padding: 0 .35rem; border-radius: 4px; margin-left: .3rem; background: var(--accent2); color: var(--ink); }
.badge.good { background: var(--good); color: #fff; }
.badge.bad { background: var(--bad); color: #fff; }

/* ---------- buttons & inputs ---------- */
.btn {
  --b: #f6e7c8; --bt: var(--ink);
  min-height: 44px; padding: .45rem 1rem; border: 3px solid var(--ink); border-radius: 8px;
  background: var(--b); color: var(--bt); font-weight: 600; cursor: pointer;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.18), 0 3px 0 var(--ink);
  transition: transform .08s ease, filter .12s ease, box-shadow .08s ease;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; text-align: center;
}
.btn:hover:not([disabled]) { transform: translateY(-2px); filter: brightness(1.07); box-shadow: inset 0 -4px 0 rgba(0,0,0,.18), 0 5px 0 var(--ink); }
.btn:active:not([disabled]) { transform: translateY(2px); box-shadow: inset 0 -2px 0 rgba(0,0,0,.18), 0 1px 0 var(--ink); }
.btn:focus-visible, .pick:focus-visible, .char-card:focus-visible, .card.clickable:focus-visible, .choice-card:focus-visible, .nb-status:focus-visible, .nb-cell:focus-visible, .tab:focus-visible, .icon-btn:focus-visible { outline: 3px solid var(--accent2); outline-offset: 2px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-primary { --b: var(--accent); --bt: #fff; }
.btn-danger { --b: var(--bad); --bt: #fff; }
.btn-ghost { --b: transparent; --bt: inherit; box-shadow: none; border-color: currentColor; }
.btn-small { min-height: 34px; padding: .2rem .7rem; font-size: .9rem; }
.btn-big { min-height: 54px; font-size: 1.15rem; padding: .5rem 1.4rem; }
.icon-btn { min-width: 40px; height: 40px; border-radius: 8px; border: 2px solid currentColor; background: rgba(255,255,255,.08); color: inherit; cursor: pointer; font-size: 1.1rem; }
.icon-btn:hover { background: rgba(255,255,255,.18); }
.link-btn { background: none; border: none; color: var(--accent); text-decoration: underline; cursor: pointer; padding: .3rem; }
.back-btn { position: absolute; top: .3rem; left: .3rem; background: none; border: none; color: var(--ink-soft); cursor: pointer; font-size: 1rem; padding: .4rem; }
.back-btn:hover { color: var(--ink); }
.input {
  min-height: 44px; padding: .4rem .7rem; border: 3px solid var(--ink); border-radius: 8px; background: #fffaf0; color: var(--ink);
  box-shadow: inset 0 3px 0 rgba(0,0,0,.08); min-width: 0;
}
.input:focus { outline: 3px solid var(--accent2); }
select.input { cursor: pointer; }
.code-input { text-transform: uppercase; letter-spacing: .5em; font-size: 1.8rem; text-align: center; width: 9.5rem; font-weight: 700; padding-left: .9rem; }
.field { display: flex; flex-direction: column; gap: .25rem; font-weight: 600; }
.field .input { width: 100%; }

/* ---------- main menu ---------- */
.menu-screen { display: flex; align-items: center; justify-content: center; }
.menu-backdrop { position: absolute; inset: 0; overflow: hidden; background: #2a2050; }
.menu-bg { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); min-width: 100%; min-height: 100%; width: auto; height: auto; aspect-ratio: 16 / 9; object-fit: cover; }
@media (min-aspect-ratio: 16/9) { .menu-bg { width: 100%; height: auto; } }
@media (max-aspect-ratio: 16/9) { .menu-bg { height: 100%; width: auto; } }
.menu-backdrop.dimmed::after { content: ''; position: absolute; inset: 0; background: rgba(20, 12, 30, .55); }
.menu-content { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 1.2rem; padding: 1rem; width: min(440px, 100%); }
.title-block { text-align: center; animation: float 4s ease-in-out infinite; }
.title-kicker { color: var(--accent2); letter-spacing: 3px; font-size: .95rem; text-shadow: 0 2px 0 #000; }
.game-title {
  margin: .2rem 0; font-size: clamp(2rem, 7vw, 3.4rem); line-height: 1; color: #fff6e0;
  text-shadow: 0 3px 0 var(--accent), 0 6px 0 var(--ink), 0 0 24px rgba(243, 199, 79, .45);
}
.title-sub { color: #e9d9ff; text-shadow: 0 2px 0 #000; }
.menu-list { display: flex; flex-direction: column; gap: .55rem; width: min(300px, 100%); }
.menu-btn { width: 100%; font-size: 1.1rem; }
.menu-list .btn-ghost { color: #fff6e0; }
.menu-footer { position: absolute; bottom: .4rem; right: .6rem; font-size: .8rem; color: rgba(255,255,255,.5); z-index: 2; }
@keyframes float { 50% { transform: translateY(-6px); } }

/* ---------- setup screens ---------- */
.setup-content { position: relative; z-index: 2; width: min(620px, 100%); max-height: 100%; overflow: auto; padding: 1rem; }
.setup-panel { position: relative; padding: 1rem 1.1rem 1.2rem; }
.host-options { display: grid; gap: .8rem; }
.choice-card {
  display: flex; flex-direction: column; gap: .3rem; text-align: left; padding: .9rem 1rem; border: 3px solid var(--ink); border-radius: 10px;
  background: #fffaf0; color: var(--ink); cursor: pointer; box-shadow: 0 4px 0 var(--ink); transition: transform .1s;
}
.choice-card:not(.static):hover { transform: translateY(-3px); background: #fff; }
.choice-card.static { cursor: default; }
.choice-icon { font-size: 1.8rem; }
.choice-title { font-size: 1.2rem; font-weight: 700; }
.choice-desc { color: var(--ink-soft); font-size: .95rem; }
.choice-card .row .input { flex: 1; }
.load-btn { color: var(--ink); justify-self: center; }
.join-form { display: flex; flex-direction: column; gap: .8rem; align-items: stretch; }
.join-form .code-input { align-self: center; }
.join-links { display: flex; flex-direction: column; align-items: center; }
.claim-list { display: grid; gap: .5rem; }
.claim-seat { display: flex; align-items: center; gap: .7rem; padding: .5rem; border: 3px solid var(--ink); border-radius: 10px; background: #fffaf0; cursor: pointer; text-align: left; color: var(--ink); }
.claim-seat[disabled] { opacity: .5; cursor: not-allowed; }
.claim-seat:not([disabled]):hover { background: #fff; transform: translateY(-2px); }
.claim-name { font-weight: 700; font-size: 1.1rem; }

/* ---------- how to / settings / credits ---------- */
.howto-page { min-height: 12rem; }
.howto-page h3 { color: var(--accent); font-size: 1.4rem; }
.howto-page p { line-height: 1.45; margin: .4rem 0; }
.howto-dots { display: flex; justify-content: center; gap: .35rem; margin: .8rem 0; }
.dot { width: 10px; height: 10px; border-radius: 2px; background: var(--panel-dark); border: 2px solid var(--ink); }
.dot.on { background: var(--accent); }
.slide-in { animation: slideIn .28s ease; }
@keyframes slideIn { from { opacity: 0; transform: translateX(18px); } }
.settings { display: flex; flex-direction: column; gap: .5rem; }
.settings h4 { margin: .6rem 0 .1rem; color: var(--accent); }
.setting { display: grid; grid-template-columns: 1fr minmax(120px, 1.2fr) auto; align-items: center; gap: .6rem; }
.setting .input, .setting .btn { grid-column: 2 / 4; }
.setting input[type=range] { accent-color: var(--accent); width: 100%; height: 28px; }
.setting-val { min-width: 3em; text-align: right; font-variant-numeric: tabular-nums; }
.toggle { position: relative; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch { grid-column: 3; width: 48px; height: 26px; border: 3px solid var(--ink); border-radius: 14px; background: var(--panel-dark); position: relative; transition: background .15s; justify-self: end; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--ink); transition: left .15s; }
.toggle input:checked + .switch { background: var(--good); }
.toggle input:checked + .switch::after { left: 24px; background: #fff; }
.toggle input:focus-visible + .switch { outline: 3px solid var(--accent2); }
.credits { text-align: center; }
.credits-title { font-size: 1.5rem; font-weight: 700; color: var(--accent); margin-bottom: .6rem; }
.credit-section h4 { margin: .8rem 0 .2rem; color: var(--ink-soft); text-transform: uppercase; font-size: .85rem; letter-spacing: 2px; }
.credit-name { font-size: 1.1rem; }
.credits-parade { display: flex; justify-content: center; gap: .2rem; margin: 1rem 0 .3rem; flex-wrap: wrap; }

/* ---------- lobby ---------- */
.lobby-screen { display: flex; flex-direction: column; overflow: auto; padding: .6rem; gap: .6rem; }
.lobby-header { display: flex; align-items: center; gap: .8rem; justify-content: space-between; flex-wrap: wrap; }
.lobby-title { font-size: 1.3rem; font-weight: 700; color: #fff6e0; text-shadow: 0 2px 0 var(--accent); }
.code-box { background: var(--panel); color: var(--ink); border: 3px solid var(--ink); border-radius: 10px; padding: .2rem .9rem; text-align: center; box-shadow: 0 4px 0 #000; }
.code-label { font-size: .7rem; text-transform: uppercase; letter-spacing: 2px; color: var(--ink-soft); }
.code-big { font-size: 2rem; font-weight: 700; letter-spacing: .35em; padding-left: .35em; line-height: 1.1; }
.lobby-header .btn-ghost { color: #fff6e0; }
.lobby-display { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: .8rem; align-items: start; }
.join-card { text-align: center; }
.join-steps { text-align: left; font-size: 1.15rem; line-height: 1.7; margin: .3rem 0 .6rem; }
.join-url { font-weight: 700; color: var(--accent); word-break: break-all; }
.code-inline { letter-spacing: .15em; background: var(--accent2); padding: 0 .3rem; border-radius: 4px; }
.qr { width: min(200px, 60%); aspect-ratio: 1; image-rendering: pixelated; border: 3px solid var(--ink); border-radius: 8px; display: block; margin: .3rem auto; background: var(--panel); }
.lobby-players { display: flex; flex-direction: column; gap: .4rem; }
.lobby-player { display: flex; align-items: center; gap: .5rem; padding: .3rem .5rem; border-radius: 8px; background: rgba(255,255,255,.55); border-left: 6px solid var(--pc); }
.lobby-player.me { background: #fff; box-shadow: 0 0 0 2px var(--accent2); }
.lp-text { flex: 1; min-width: 0; }
.lp-name { font-weight: 700; }
.lp-char { font-size: .85rem; color: var(--ink-soft); }
.conn-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--bad); border: 2px solid var(--ink); flex: none; }
.conn-dot.on { background: var(--good); }
.sprite-placeholder { width: 64px; height: 64px; }
.lobby-player-view { display: grid; grid-template-columns: 1fr; gap: .8rem; }
@media (min-width: 900px) { .lobby-player-view { grid-template-columns: 1fr 340px; align-items: start; } }
.lobby-side { display: flex; flex-direction: column; gap: .8rem; }
.name-row { margin-bottom: .4rem; }
.name-row .input { flex: 1; }
.field-label { font-weight: 700; }
.char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.char-card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: .15rem; padding: .5rem .4rem .6rem; border: 3px solid var(--ink); border-radius: 12px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--cc) 30%, #fffaf0), #fffaf0 55%); color: var(--ink); cursor: pointer;
  box-shadow: 0 4px 0 var(--ink); transition: transform .12s ease, box-shadow .12s;
}
.char-card:hover:not([disabled]) { transform: translateY(-3px) rotate(-.5deg); }
.char-card.selected { box-shadow: 0 0 0 4px var(--cc), 0 4px 0 var(--ink); transform: translateY(-2px); }
.char-card.selected::after { content: '✓ You'; position: absolute; top: -10px; right: -6px; background: var(--cc); color: #fff; border: 2px solid var(--ink); border-radius: 6px; padding: 0 .4rem; font-size: .85rem; font-weight: 700; }
.char-card.taken { opacity: .55; filter: grayscale(.6); cursor: not-allowed; }
.char-portrait .portrait { border-radius: 8px; }
.char-sprite { position: absolute; top: 4px; left: 4px; }
.char-sprite canvas { width: 40px !important; height: 40px !important; }
.char-name { font-size: 1.2rem; font-weight: 700; }
.char-title { font-size: .8rem; color: var(--cc); font-weight: 700; filter: brightness(.75); text-align: center; }
.char-desc { font-size: .8rem; color: var(--ink-soft); text-align: center; line-height: 1.25; }
.char-taken { position: absolute; bottom: 45%; background: var(--ink); color: #fff; padding: .1rem .5rem; border-radius: 6px; font-size: .85rem; }
.rules { display: flex; flex-direction: column; gap: .45rem; }
.rule-row { display: grid; grid-template-columns: 1fr auto; gap: .2rem .6rem; align-items: center; }
.rule-row select { max-width: 12rem; }
.rule-label { font-weight: 600; }
.rule-val { font-weight: 700; color: var(--accent); }
.rule-desc { grid-column: 1 / -1; font-size: .78rem; color: var(--ink-soft); }
.rule-row.toggle .switch { grid-column: 2; }
.start-area { margin-top: .8rem; display: flex; flex-direction: column; align-items: center; gap: .3rem; }
.waiting-pill { background: var(--ink); color: var(--panel); padding: .4rem .9rem; border-radius: 20px; animation: pulse 1.6s ease-in-out infinite; }
.invite-card { display: flex; gap: .5rem; align-items: center; }
.invite-card .qr { width: 96px; margin: 0; }
@keyframes pulse { 50% { opacity: .65; } }

/* ---------- cards ---------- */
.card { --w: 92px; width: var(--w); aspect-ratio: 5 / 7; perspective: 600px; flex: none; position: relative; }
.card-xxs { --w: 18px; } .card-xs { --w: 52px; } .card-sm { --w: 72px; } .card-md { --w: 92px; } .card-lg { --w: 116px; }
.card-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .5s cubic-bezier(.3,1.4,.5,1); }
.card.flipped .card-inner { transform: rotateY(180deg); }
.card-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: calc(var(--w) * .09); overflow: hidden; }
.card-front {
  background: #fffaf0; border: 3px solid var(--ink); display: flex; flex-direction: column; align-items: center;
  box-shadow: inset 0 0 0 2px var(--card-color, #c8963e), 0 3px 0 rgba(0,0,0,.35); color: var(--ink);
}
.card-xs .card-front, .card-xxs .card-front { border-width: 2px; }
.card-back { transform: rotateY(180deg); background: var(--ink); }
.card-back img { width: 100%; height: 100%; display: block; }
.card-type { width: 100%; text-align: center; background: var(--card-color, #c8963e); color: #fff; font-size: calc(var(--w) * .11); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; padding: 1px 0; text-shadow: 0 1px 0 rgba(0,0,0,.4); }
.card-art { flex: 1; width: 100%; display: grid; place-items: center; padding: 6%; min-height: 0; }
.card-art img { max-width: 100%; max-height: 100%; width: 80%; object-fit: contain; image-rendering: pixelated; }
.card-art-room img { width: 100%; height: 100%; object-fit: cover; border-radius: 4px; border: 2px solid var(--ink); }
.card-name { font-size: calc(var(--w) * .135); font-weight: 700; padding: 0 3px 4px; text-align: center; line-height: 1.05; }
.card-xs .card-type, .card-xxs .card-type, .card-xxs .card-name { display: none; }
.card-xs .card-name { font-size: 9px; padding-bottom: 2px; }
.card-owner { font-size: .7rem; color: var(--ink-soft); padding-bottom: 3px; }
.card.clickable { cursor: pointer; transition: transform .12s; }
.card.clickable:hover { transform: translateY(-4px) rotate(-1deg); }
.card.selected { transform: translateY(-6px); }
.card.selected .card-front { box-shadow: 0 0 0 4px var(--accent2), 0 0 18px var(--accent2); }
.card.dim { opacity: .45; }
.card.glow .card-front { animation: cardGlow 1.6s ease-in-out infinite; }
@keyframes cardGlow { 50% { box-shadow: 0 0 0 4px var(--accent2), 0 0 28px 6px rgba(243,199,79,.8); } }
.card-row { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: center; padding: .3rem 0; }
.card-row.small { gap: .3rem; justify-content: flex-start; }
.room-chip { display: inline-block; background-size: cover; background-position: center; border: 2px solid var(--ink); border-radius: 4px; image-rendering: pixelated; vertical-align: middle; flex: none; }

/* ---------- modals ---------- */
#modal-root { position: absolute; inset: 0; pointer-events: none; z-index: 40; }
.modal-wrap {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: .6rem;
  background: rgba(15, 8, 22, .62); pointer-events: auto; animation: fadeIn .18s ease; backdrop-filter: blur(2px);
}
.modal-wrap.modal-leave { opacity: 0; transition: opacity .18s; }
.modal { position: relative; width: min(520px, 100%); max-height: 100%; overflow: auto; animation: modalPop .26s cubic-bezier(.3,1.5,.5,1); }
.modal.wide { width: min(760px, 100%); }
.modal-title { margin: 0 2rem .6rem 0; font-size: 1.4rem; color: var(--ink); }
.modal-x { position: absolute; top: .1rem; right: .2rem; width: 40px; height: 40px; border: none; background: none; font-size: 1.8rem; color: var(--ink-soft); cursor: pointer; line-height: 1; }
.modal-x:hover { color: var(--ink); }
.modal-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: .9rem; flex-wrap: wrap; }
.modal-body p { line-height: 1.4; }
.modal-body h4 { margin: .7rem 0 .35rem; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes modalPop { from { opacity: 0; transform: scale(.9) translateY(12px); } }

.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: .4rem; }
.pick {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: .2rem; padding: .4rem .2rem; min-height: 44px;
  border: 3px solid var(--ink); border-radius: 10px; background: #fffaf0; color: var(--ink); cursor: pointer; transition: transform .1s;
}
.pick:hover { transform: translateY(-2px); background: #fff; }
.pick.selected { background: var(--accent2); box-shadow: 0 0 0 3px var(--accent); transform: translateY(-2px); }
.pick .portrait { border-radius: 6px; }
.pick-name { font-size: .85rem; font-weight: 700; text-align: center; text-transform: capitalize; }
.pick-mark { position: absolute; top: 2px; right: 4px; font-weight: 900; font-size: .9rem; }
.mark-no { color: var(--bad); } .mark-maybe { color: var(--maybe); } .mark-yes { color: var(--good); }
.fixed-room { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.1rem; padding: .3rem .6rem; background: #fffaf0; border: 3px dashed var(--ink-soft); border-radius: 10px; width: fit-content; }
.theory-line { font-size: 1.1rem; font-weight: 700; color: var(--accent); margin: .6rem 0; text-align: center; }
.respond-modal .modal-title { color: var(--accent); }
.respond-head { display: flex; gap: .7rem; align-items: center; }
.respond-head .portrait { border-radius: 8px; flex: none; }
.respond-head .theory-line { text-align: left; margin: .2rem 0; }
.reveal-list { display: flex; flex-direction: column; gap: .5rem; margin: .5rem 0 1rem; }
.reveal-row { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: .6rem; padding: .3rem .4rem; background: #fffaf0; border-radius: 10px; border: 2px solid var(--panel-dark); }
.reveal-row .portrait { border-radius: 6px; }
.reveal-who { font-weight: 700; }
.reveal-outcome { display: flex; align-items: center; gap: .5rem; }
.reveal-note.good { color: var(--good); font-weight: 700; }
.reveal-nobody { text-align: center; font-size: 1.2rem; font-weight: 700; color: var(--accent); }
.accuse-warning { background: #3a1420; color: #ffe8ea; }
.accuse-warning .panel, .accuse-warning .modal-title { color: #fff; }
.modal.accuse-warning { border-image: none; border: 4px solid var(--bad); box-shadow: 0 0 40px rgba(217,83,79,.6); }
.accuse-warning .modal-x { color: #fff; }
.accuse-icon { font-size: 3.4rem; animation: swing 1.4s ease-in-out infinite; }
@keyframes swing { 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }
.accusation-result { text-align: center; }
.accuse-kicker { font-size: 1.3rem; font-weight: 700; }
.accusation-face { margin: .6rem 0; }
.accusation-face .portrait { border-radius: 12px; animation: pop .4s ease; }
.verdict { min-height: 4.5rem; }
.verdict-text { font-size: 2.6rem; font-weight: 900; letter-spacing: 3px; animation: pop .35s cubic-bezier(.3,1.8,.5,1); }
.verdict-text.good { color: var(--good); text-shadow: 0 3px 0 var(--ink), 0 0 24px rgba(63,174,106,.8); }
.verdict-text.bad { color: var(--bad); text-shadow: 0 3px 0 var(--ink); }
.emote-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; }
.menu-modal-list { display: flex; flex-direction: column; gap: .5rem; }
.menu-modal-list .btn-ghost { color: var(--ink); }

/* ---------- toasts ---------- */
#toast-root { position: absolute; left: 50%; top: .6rem; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: .4rem; align-items: center; pointer-events: none; width: min(460px, 94vw); }
.toast {
  display: flex; align-items: center; gap: .5rem; padding: .5rem .8rem; border-radius: 10px; background: var(--panel); color: var(--ink);
  border: 3px solid var(--ink); box-shadow: 0 4px 0 rgba(0,0,0,.35); animation: toastIn .3s cubic-bezier(.3,1.5,.5,1); font-weight: 600; max-width: 100%;
}
.toast-good { background: #d9f5df; border-color: var(--good); }
.toast-error { background: #ffe0de; border-color: var(--bad); }
.toast-icon { width: 28px; height: 28px; border-radius: 4px; }
.toast-leave { opacity: 0; transform: translateY(-10px); transition: all .35s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px) scale(.95); } }

/* ---------- game screen ---------- */
.game-screen { display: flex; flex-direction: column; height: 100%; }
.game-top {
  display: flex; align-items: center; gap: .5rem; padding: .35rem .5rem; padding-top: max(.35rem, env(safe-area-inset-top));
  background: linear-gradient(180deg, #2f2142, #241a33); border-bottom: 3px solid #120b1a; flex: none; color: #fff6e0;
}
.game-top-title { font-weight: 700; font-size: 1.15rem; color: var(--accent2); }
.code-chip { font-weight: 700; letter-spacing: .2em; background: var(--panel); color: var(--ink); border-radius: 6px; padding: .1rem .4rem .1rem .55rem; border: 2px solid var(--ink); }
.turn-banner { flex: 1; display: flex; align-items: center; gap: .45rem; font-weight: 700; min-width: 0; padding: .1rem .5rem; border-radius: 8px; border-left: 5px solid var(--pc, var(--accent)); background: rgba(255,255,255,.06); white-space: nowrap; overflow: hidden; }
.turn-banner > span:first-of-type { overflow: hidden; text-overflow: ellipsis; }
.turn-banner .portrait { border-radius: 4px; flex: none; }
.turn-banner.mine { background: color-mix(in srgb, var(--pc) 35%, transparent); animation: pulse 2s ease-in-out infinite; }
.turn-num { margin-left: auto; font-size: .8rem; color: rgba(255,255,255,.6); font-weight: 400; }
.game-main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.board-wrap { min-width: 0; min-height: 0; overflow: hidden; flex: none; width: 100%; aspect-ratio: 16 / 9; max-height: 42vh; display: flex; align-items: center; justify-content: center; background: #120b1a; position: relative; }
.board-canvas { display: block; touch-action: manipulation; }
.side { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--panel); color: var(--ink); }
.tabs { display: flex; flex: none; background: var(--panel-dark); border-bottom: 3px solid var(--ink); overflow-x: auto; }
.tab { flex: 1; min-height: 44px; border: none; background: none; color: var(--ink-soft); font-weight: 700; cursor: pointer; padding: .3rem .4rem; white-space: nowrap; border-bottom: 4px solid transparent; }
.tab.active { color: var(--ink); background: var(--panel); border-bottom-color: var(--accent); }
.tab-body { flex: 1; min-height: 0; overflow-y: auto; padding: .6rem; padding-bottom: max(.6rem, env(safe-area-inset-bottom)); }
.action-card { background: #fffaf0; border: 2px solid var(--panel-dark); border-radius: 10px; padding: .6rem; margin-bottom: .6rem; }
.action-card h4 { margin: 0 0 .45rem; }
.action-card.compact { padding: .4rem .6rem; }
.action-card.my-turn { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent2); }
.action-card > .btn-big { width: 100%; }
.action-head { display: flex; align-items: center; gap: .6rem; }
.action-head .portrait { border-radius: 8px; flex: none; }
.move-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .4rem; margin-bottom: .3rem; }
.move-btn { justify-content: flex-start; }
.secret-tag { margin-left: auto; }
.player-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: .4rem; }
.ps-item { display: flex; flex-direction: column; align-items: center; padding: .3rem .2rem; border-radius: 8px; border: 2px solid transparent; border-bottom: 4px solid var(--pc); background: rgba(0,0,0,.04); }
.ps-item.active { border-color: var(--accent2); background: #fff4c8; animation: bob 1.4s ease-in-out infinite; }
.ps-item.out { opacity: .6; }
.ps-item .portrait { border-radius: 6px; }
.ps-name { font-weight: 700; font-size: .85rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ps-meta { font-size: .75rem; color: var(--ink-soft); }
.offline { color: var(--bad); }
.out-tag { color: var(--bad); font-weight: 900; }
.pending-box .theory-line { margin: .3rem 0; text-align: left; }
.pending-list { list-style: none; padding: 0; margin: .4rem 0; display: flex; flex-direction: column; gap: .25rem; }
.pending-list li { display: flex; align-items: center; gap: .35rem; }
.pending-list li .portrait { border-radius: 4px; }
.pending-list li.waiting i { animation: pulse 1.2s infinite; color: var(--accent); }
.hand { justify-content: flex-start; }
@keyframes bob { 50% { transform: translateY(-2px); } }

/* Wide / landscape: board beside the panel */
@media (min-width: 860px), (orientation: landscape) and (max-height: 560px) {
  .game-screen.player .game-main { flex-direction: row; }
  .game-screen.player .board-wrap { flex: 1; aspect-ratio: auto; max-height: none; height: 100%; }
  .game-screen.player .side { flex: none; width: clamp(320px, 38vw, 460px); border-left: 3px solid #120b1a; }
}
@media (orientation: landscape) and (max-height: 560px) {
  .game-screen.player .side { width: 46vw; }
  .game-top { padding-top: .2rem; padding-bottom: .2rem; }
}

/* Board display (laptop / TV) */
.game-screen.display .game-main { flex-direction: row; }
.game-screen.display .board-wrap { flex: 1; aspect-ratio: auto; max-height: none; height: 100%; padding: .5rem; }
.display-side { flex: none; width: clamp(300px, 28vw, 400px); display: flex; flex-direction: column; gap: .5rem; padding: .5rem; overflow: hidden; }
.side-card { flex: none; overflow: hidden; }
.side-card.grow { flex: 1; min-height: 0; overflow-y: auto; }
.side-card .player-strip { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 760px) {
  .game-screen.display .game-main { flex-direction: column; }
  .display-side { width: 100%; flex: 1; overflow-y: auto; }
  .game-screen.display .board-wrap { flex: none; height: auto; aspect-ratio: 16/9; }
}

/* ---------- notebook ---------- */
.notebook { display: flex; flex-direction: column; gap: .6rem; }
.nb-legend { display: flex; flex-wrap: wrap; gap: .3rem .8rem; font-size: .8rem; background: #fffaf0; padding: .35rem .5rem; border-radius: 8px; border: 2px dashed var(--panel-dark); }
.nb-legend .st-no { color: var(--bad); } .nb-legend .st-maybe { color: var(--maybe); } .nb-legend .st-yes { color: var(--good); }
.nb-section { background: #fffaf0; border-radius: 10px; border: 2px solid var(--panel-dark); overflow: hidden;
  background-image: repeating-linear-gradient(180deg, transparent 0 35px, rgba(59,36,51,.07) 35px 36px); }
.nb-head, .nb-row { display: grid; grid-template-columns: minmax(0, 1fr) 36px auto 30px; align-items: center; gap: .3rem; padding: .15rem .35rem; }
.nb-head { background: var(--panel-dark); position: sticky; top: 0; z-index: 1; }
.nb-section-title { font-weight: 700; text-transform: uppercase; letter-spacing: 1px; font-size: .85rem; }
.nb-cells { display: flex; gap: 2px; }
.nb-col-head { width: 28px; display: flex; flex-direction: column; align-items: center; font-size: .6rem; font-weight: 700; border-bottom: 3px solid var(--pc); line-height: 1.1; overflow: hidden; }
.nb-col-head .portrait { border-radius: 3px; }
.nb-row { min-height: 36px; border-top: 1px solid rgba(59,36,51,.08); }
.nb-name { display: flex; align-items: center; gap: .35rem; min-width: 0; font-weight: 600; flex-wrap: wrap; }
.nb-name > span:first-of-type { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nb-row.st-no .nb-name > span:not(.nb-tag) { text-decoration: line-through; text-decoration-thickness: 2px; color: var(--ink-soft); }
.nb-row.st-yes { background: rgba(63,174,106,.15); }
.nb-row.st-maybe { background: rgba(232,162,58,.12); }
.nb-tag { font-size: .62rem; padding: 0 .3rem; border-radius: 4px; background: var(--ink); color: #fff; text-transform: uppercase; }
.nb-note-text { flex-basis: 100%; font-size: .75rem; color: var(--accent); font-style: italic; font-weight: 400; padding-left: 26px; }
.nb-status { width: 34px; height: 30px; border: 2px solid var(--ink); border-radius: 6px; background: #fff; cursor: pointer; font-weight: 900; font-size: 1rem; color: var(--ink-soft); }
.nb-status.st-no { background: #ffe0de; color: var(--bad); }
.nb-status.st-maybe { background: #fff1d6; color: var(--maybe); }
.nb-status.st-yes { background: #d9f5df; color: var(--good); }
.nb-cell { width: 28px; height: 28px; border: 2px solid color-mix(in srgb, var(--pc) 60%, #fff); border-radius: 5px; background: #fff; cursor: pointer; font-weight: 900; font-size: .85rem; padding: 0; color: var(--ink); }
.nb-cell.ow-has { background: var(--pc); color: #fff; border-color: var(--ink); }
.nb-cell.ow-not { color: var(--bad); background: #fff4f4; }
.nb-cell.ow-maybe { color: var(--maybe); }
.nb-note { width: 28px; height: 28px; border: 2px solid var(--panel-dark); border-radius: 6px; background: none; cursor: pointer; color: var(--ink-soft); font-weight: 700; }
.nb-note.has-note { background: var(--accent2); color: var(--ink); border-color: var(--ink); }

/* ---------- history ---------- */
.history { display: flex; flex-direction: column; gap: .5rem; }
.hist-entry { background: #fffaf0; border: 2px solid var(--panel-dark); border-radius: 10px; padding: .45rem .55rem; animation: slideIn .3s ease; }
.hist-accuse.good { border-color: var(--good); background: #e8f8ec; }
.hist-accuse.bad { border-color: var(--bad); background: #fff0ef; }
.hist-head { display: flex; gap: .5rem; align-items: flex-start; }
.hist-head .portrait { border-radius: 5px; flex: none; }
.hist-turn { font-size: .72rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 1px; }
.hist-cards { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .2rem; }
.hist-card { display: inline-flex; align-items: center; gap: .2rem; background: var(--panel); border-radius: 5px; padding: 0 .3rem 0 .15rem; font-size: .85rem; font-weight: 600; }
.hist-results { margin: .35rem 0 0; padding-left: 1.2rem; font-size: .9rem; }
.hist-results li.good { color: #1f7a45; }
.hist-results li.muted { color: var(--ink-soft); }
.hist-summary { font-size: .8rem; color: var(--ink-soft); margin-top: .2rem; }
.hist-result { font-weight: 700; margin-top: .2rem; }
.history.compact .hist-results { font-size: .8rem; }
.history.compact .hist-entry { padding: .3rem .45rem; }

/* ---------- end screen ---------- */
.end-overlay { position: absolute; inset: 0; z-index: 30; background: rgba(15, 8, 22, .78); display: flex; justify-content: center; overflow-y: auto; padding: .8rem; animation: fadeIn .4s ease; }
.end-panel { width: min(820px, 100%); height: fit-content; margin: auto; animation: modalPop .4s cubic-bezier(.3,1.5,.5,1); }
.end-banner { text-align: center; }
.end-winner .portrait { border-radius: 16px; }
.glow-ring { box-shadow: 0 0 0 4px var(--accent2), 0 0 30px 8px rgba(243,199,79,.7); animation: pop .5s ease, glowPulse 2s ease-in-out infinite; }
@keyframes glowPulse { 50% { box-shadow: 0 0 0 4px var(--accent2), 0 0 44px 14px rgba(243,199,79,.85); } }
.end-title { margin: .5rem 0 .2rem; font-size: clamp(1.6rem, 5vw, 2.4rem); color: var(--accent); text-shadow: 0 2px 0 var(--ink); }
.end-quote { font-style: italic; color: var(--ink-soft); }
.solution-row { gap: .8rem; }
.end-meta { margin-bottom: .5rem; }
.end-details { margin: .5rem 0; background: #fffaf0; border-radius: 10px; border: 2px solid var(--panel-dark); padding: .3rem .6rem; }
.end-details summary { cursor: pointer; font-weight: 700; padding: .3rem 0; min-height: 32px; }
.end-hands { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .6rem; padding: .4rem 0; }
.end-hand-head { display: flex; align-items: center; gap: .3rem; }
.end-stats { width: 100%; border-collapse: collapse; font-size: .9rem; }
.end-stats th, .end-stats td { padding: .3rem; text-align: center; border-bottom: 1px solid var(--panel-dark); }
.end-stats th:first-child, .end-stats td:first-child { text-align: left; }
.end-actions { display: flex; flex-direction: column; align-items: center; gap: .5rem; margin-top: .8rem; }
.end-actions .btn-ghost { color: var(--ink); }

/* ---------- animations ---------- */
.pop { animation: pop .4s cubic-bezier(.3,1.8,.5,1); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.bounce-in { animation: bounceIn .55s cubic-bezier(.3,1.8,.5,1); }
@keyframes bounceIn { from { transform: translateY(-20px) scale(.7); opacity: 0; } }
.shake { animation: shake .4s ease; }
.shake-big { animation: shake .6s ease; }
@keyframes shake {
  10%, 90% { transform: translate(-2px, 1px); } 20%, 80% { transform: translate(4px, -2px); }
  30%, 50%, 70% { transform: translate(-6px, 2px); } 40%, 60% { transform: translate(6px, -1px); }
}
.portrait { display: inline-block; vertical-align: middle; }

.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
@media (prefers-reduced-motion: reduce) { .title-block, .waiting-pill, .turn-banner.mine, .ps-item.active { animation: none; } }

/* Narrow phones */
@media (max-width: 480px) {
  .tab { font-size: .8rem; padding: .2rem .15rem; }
  .turn-num { display: none; }
  .game-top { gap: .35rem; }
  .game-top .icon-btn { min-width: 36px; height: 36px; font-size: 1rem; }
  .code-chip { font-size: .85rem; letter-spacing: .1em; }
  .nb-name { font-size: .85rem; }
}

/* Soft shadow behind the menu so the title reads clearly over the mansion art */
.menu-content::before { content: ''; position: absolute; inset: -10% -25%; z-index: -1; background: radial-gradient(ellipse at center, rgba(20, 12, 34, .55), transparent 70%); pointer-events: none; }
.tabs { scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
@media (orientation: landscape) and (max-height: 560px) {
  .tab { font-size: .78rem; padding: .2rem .1rem; min-height: 38px; }
}

.net-banner { position: fixed; left: 0; right: 0; bottom: 0; z-index: 70; background: var(--bad); color: #fff; padding: .5rem .8rem; padding-bottom: max(.5rem, env(safe-area-inset-bottom)); font-size: .9rem; text-align: center; border-top: 3px solid var(--ink); }

/* ---------- phone game layout v2: turn bar + bottom navigation ---------- */
.board-wrap { max-height: 48vh; }
.turn-panel {
  flex: none; padding: .5rem .6rem; background: #fffaf0; color: var(--ink);
  border-bottom: 3px solid var(--panel-dark); border-left: 6px solid var(--pc, var(--panel-dark));
}
.turn-panel.mine { background: linear-gradient(180deg, #fff4c8, #fffaf0); }
.tp-line { display: flex; align-items: center; gap: .55rem; min-width: 0; }
.tp-line .portrait { border-radius: 6px; flex: none; }
.tp-text { min-width: 0; line-height: 1.25; }
.tp-text b { font-size: 1.05rem; }
.tp-sub { font-size: .85rem; color: var(--ink-soft); }
.tp-theory { color: var(--accent); font-weight: 700; }
.tp-actions { display: flex; gap: .4rem; margin-top: .5rem; }
.tp-actions .btn { flex: 1 1 0; min-height: 46px; padding: .25rem .4rem; font-size: .95rem; white-space: nowrap; }
.tp-actions .btn-primary { flex-grow: 1.6; }
.tabs { order: 99; border-bottom: none; border-top: 3px solid var(--ink); padding-bottom: env(safe-area-inset-bottom); background: var(--panel-dark); }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; min-height: 52px; border-bottom: none; border-top: 4px solid transparent; font-size: .78rem; }
.tab.active { border-top-color: var(--accent); border-bottom: none; }
.tab-ic { font-size: 1.25rem; line-height: 1.1; position: relative; }
.tab-count { position: absolute; top: -4px; right: -14px; font-size: .62rem; background: var(--accent); color: #fff; border-radius: 8px; padding: 0 4px; font-weight: 700; line-height: 1.4; }
.tab-count:empty { display: none; }
.tab-lb { font-size: .72rem; }
.players-tab .player-strip { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
@media (max-width: 480px) { .tab { font-size: .72rem; } }
@media (orientation: landscape) and (max-height: 560px) {
  .tab { min-height: 42px; flex-direction: row; gap: .3rem; }
  .tab-ic { font-size: 1rem; }
  .turn-panel { padding: .35rem .5rem; }
  .tp-actions { margin-top: .3rem; }
  .tp-actions .btn { min-height: 40px; }
}

/* ---------- lobby v2 ---------- */
.lobby-screen.lobby-display-mode, .lobby-screen.lobby-phone-mode {
  padding: 0; display: block;
  background: linear-gradient(rgba(18, 10, 26, .3), rgba(18, 10, 26, .5)), var(--lobby-bg, none);
  background-size: cover; background-position: center;
}
.stage { position: relative; min-height: 100%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 2vw; align-items: center; padding: 3vh 3vw; }
.stage-leave { position: absolute; top: .6rem; left: .8rem; background: none; border: none; color: rgba(255,246,224,.75); font: inherit; font-size: 1rem; cursor: pointer; z-index: 2; }
.stage-leave:hover { color: #fff; }
.checkin { text-align: center; color: #fff6e0; display: flex; flex-direction: column; align-items: center; transform: rotate(-2deg); }
.ck-go, .ck-sub { font-size: clamp(1.2rem, 2.6vw, 2.2rem); font-weight: 700; text-shadow: 0 3px 0 #2a1426; }
.ck-url { font-size: clamp(1.6rem, 4.2vw, 3.6rem); font-weight: 900; color: var(--accent2); line-height: 1.1; margin: .2rem 0; text-shadow: 0 4px 0 #2a1426, 0 0 24px rgba(243,199,79,.35); word-break: break-all; }
.ck-code-label { margin-top: 4vh; font-size: clamp(1.1rem, 2.2vw, 1.8rem); font-weight: 700; letter-spacing: 2px; text-shadow: 0 3px 0 #2a1426; }
.ck-code { display: flex; gap: .6vw; margin-top: .4rem; }
.code-tile {
  display: grid; place-items: center; width: clamp(3rem, 7vw, 6.5rem); aspect-ratio: 4 / 5; font-size: clamp(2.2rem, 5.5vw, 5rem); font-weight: 900;
  background: #fff6e0; color: var(--ink); border: 4px solid var(--ink); border-radius: 10px; box-shadow: 0 6px 0 #2a1426, inset 0 -6px 0 rgba(0,0,0,.12);
  animation: tileDrop .6s cubic-bezier(.3,1.6,.5,1) both;
}
.code-tile:nth-child(even) { rotate: 3deg; }
.code-tile:nth-child(odd) { rotate: -2deg; }
@keyframes tileDrop { from { opacity: 0; transform: translateY(-30px); } }
.ck-qr-row { display: flex; align-items: center; gap: .8rem; margin-top: 3vh; }
.ck-qr-row .qr { width: clamp(84px, 10vw, 130px); margin: 0; }
.ck-qr-text { font-size: 1rem; text-align: left; color: rgba(255,246,224,.85); }

.rack-wrap { display: flex; flex-direction: column; gap: 1rem; }
.rack {
  background: linear-gradient(180deg, #6b4226, #4e2e1a); border: 6px solid #2e1a10; border-radius: 10px; padding: .6rem .8rem 1rem;
  box-shadow: 0 10px 0 rgba(0,0,0,.35), inset 0 0 0 3px #8a5a34;
}
.rack-title { text-align: center; color: var(--accent2); font-weight: 700; letter-spacing: 3px; text-transform: uppercase; margin-bottom: .5rem; text-shadow: 0 2px 0 #2e1a10; }
.rack-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem; }
.key-slot {
  position: relative; aspect-ratio: 1 / 1; border-radius: 6px; background: #2e1a10; box-shadow: inset 0 6px 10px rgba(0,0,0,.55), inset 0 0 0 2px #3e2416;
  display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff6e0; overflow: hidden;
}
.key-slot.empty .key-tag {
  width: 2.6rem; height: 2.6rem; display: grid; place-items: center; font-weight: 900; font-size: 1.4rem; color: #3b2433;
  background: linear-gradient(#e8c25a, #c8963e); border: 3px solid #5a3a10; border-radius: 6px; transform: rotate(-8deg); opacity: .55;
  box-shadow: 0 3px 0 rgba(0,0,0,.4);
}
.key-wait { margin-top: .5rem; font-size: .85rem; color: rgba(255,246,224,.45); }
.key-slot.filled { background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--cc) 55%, #2e1a10), #2e1a10 75%); animation: pop .45s cubic-bezier(.3,1.8,.5,1); }
.key-num { position: absolute; top: 4px; left: 6px; font-weight: 900; color: var(--accent2); font-size: .95rem; }
.key-crown { position: absolute; top: 2px; right: 6px; font-size: 1rem; }
.key-sprite canvas { width: clamp(56px, 7vw, 96px) !important; height: auto !important; }
.key-name { font-weight: 900; font-size: clamp(.95rem, 1.5vw, 1.25rem); text-shadow: 0 2px 0 #000; max-width: 95%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.key-char { font-size: .8rem; color: rgba(255,246,224,.75); }
.key-offline { font-size: .7rem; color: #ff9a9a; }
.key-kick { position: absolute; bottom: 4px; right: 4px; background: rgba(0,0,0,.4); border: none; color: #fff; border-radius: 4px; width: 26px; height: 26px; cursor: pointer; opacity: 0; transition: opacity .15s; }
.key-slot:hover .key-kick, .key-kick:focus-visible { opacity: 1; }
.stage-controls { display: flex; flex-direction: column; align-items: center; gap: .5rem; }
.start-btn { min-width: 60%; font-size: 1.3rem; }
.stage-rules { color: rgba(255,246,224,.8); font-size: .9rem; display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; justify-content: center; }
.link-btn.light { color: var(--accent2); }
@media (max-width: 760px) {
  .stage { grid-template-columns: 1fr; padding-top: 2.5rem; }
  .checkin { transform: none; }
}

/* phone lobby */
.phone-lobby { min-height: 100%; display: flex; flex-direction: column; gap: .6rem; padding: .5rem .6rem 0; max-width: 560px; margin: 0 auto; }
.pl-top { display: flex; align-items: center; justify-content: space-between; color: #fff6e0; gap: .5rem; }
.pl-code b { letter-spacing: .15em; color: var(--accent2); font-size: 1.15rem; }
.pl-count { font-size: .85rem; color: rgba(255,246,224,.75); }
.pl-card { display: flex; flex-direction: column; gap: .6rem; }
.pick-hero {
  display: flex; gap: .7rem; align-items: center; padding: .5rem; border-radius: 10px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--cc) 35%, #fffaf0), #fffaf0 70%); border: 3px solid var(--cc);
}
.pick-hero.empty { justify-content: center; padding: 1.2rem; border: 3px dashed var(--panel-dark); color: var(--ink-soft); background: #fffaf0; }
.hero-art { position: relative; flex: none; }
.hero-art .portrait { border-radius: 10px; border: 3px solid var(--ink); }
.hero-sprite { position: absolute; bottom: -10px; right: -14px; }
.hero-name { font-size: 1.4rem; font-weight: 900; line-height: 1; }
.hero-title { font-size: .85rem; font-weight: 700; color: var(--cc); filter: brightness(.7); }
.hero-desc { font-size: .85rem; color: var(--ink-soft); line-height: 1.3; margin-top: .2rem; }
.pl-name { display: flex; align-items: center; gap: .5rem; font-weight: 700; }
.pl-name .input { flex: 1; }
.tile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .45rem; }
.char-tile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: .1rem; padding: .35rem .2rem; border-radius: 10px; cursor: pointer;
  border: 3px solid var(--ink); background: color-mix(in srgb, var(--cc) 18%, #fffaf0); color: var(--ink); box-shadow: 0 3px 0 var(--ink); transition: transform .1s;
}
.char-tile .portrait { border-radius: 6px; }
.char-tile:active { transform: translateY(2px); }
.char-tile.selected { background: color-mix(in srgb, var(--cc) 45%, #fffaf0); box-shadow: 0 0 0 3px var(--cc), 0 3px 0 var(--ink); }
.char-tile.taken { opacity: .45; filter: grayscale(.7); cursor: not-allowed; }
.tile-name { font-weight: 700; font-size: .95rem; }
.tile-owner { position: absolute; top: 34%; background: var(--ink); color: #fff; font-size: .7rem; padding: 0 .35rem; border-radius: 4px; }
.pl-players { display: flex; gap: .4rem; flex-wrap: wrap; }
.mini-player { display: flex; align-items: center; gap: .3rem; background: rgba(255,246,224,.9); color: var(--ink); border-radius: 20px; padding: .15rem .55rem .15rem .2rem; font-size: .85rem; font-weight: 700; }
.mini-player.me { box-shadow: 0 0 0 2px var(--accent2); }
.mini-player .portrait { border-radius: 50%; }
.mini-blank { width: 30px; height: 30px; border-radius: 50%; background: var(--panel-dark); }
.pl-footer {
  position: sticky; bottom: 0; margin-top: auto; display: flex; flex-direction: column; gap: .35rem; align-items: stretch;
  padding: .6rem 0 max(.6rem, env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(18,10,26,.95) 30%);
}
.pl-footer .start-btn { width: 100%; }
.pl-footer .waiting-pill { text-align: center; }
.pl-footer-row { display: flex; justify-content: space-between; align-items: center; gap: .5rem; font-size: .8rem; color: rgba(255,246,224,.75); flex-wrap: wrap; }
.lobby-phone-mode { overflow-y: auto; }
.ck-url .join-url, .pl-invite .join-url { color: inherit; }
.key-slot { aspect-ratio: auto; height: clamp(72px, 22vh, 180px); }
.lobby-display-mode { overflow-y: auto; }
.key-sprite canvas { height: clamp(40px, 12vh, 110px) !important; width: auto !important; }
.hero-sprite canvas { height: 56px !important; width: auto !important; }
