/* ==========================================================================
   Werwolf Manager – styles
   Colours are central variables; body.is-day / body.is-night switch the mood.
   ========================================================================== */
:root {
  --bg: #0b0f1f;
  --bg-2: #141a33;
  --panel: rgba(23, 29, 56, .78);
  --panel-solid: #171d38;
  --panel-2: rgba(255, 255, 255, .05);
  --line: rgba(255, 255, 255, .10);
  --line-strong: rgba(255, 255, 255, .22);
  --text: #eef0fa;
  --muted: #a3a9c7;
  --faint: #6f7698;
  --gold: #f0b85a;
  --gold-soft: rgba(240, 184, 90, .16);
  --danger: #ff5d6c;
  --ok: #4fd1a5;
  --team-dorf: #4fd1a5;
  --team-wolf: #ff5d6c;
  --team-vampir: #b884ff;
  --team-solo: #f7a74b;
  --team-love: #ff7fbf;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .45);
  --font-title: 'Cinzel', Georgia, serif;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font); color: var(--text); background: var(--bg);
  font-size: 16px; line-height: 1.45; overscroll-behavior-y: none;
  transition: background-color .8s ease;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- Sky (two layers, soft crossfade) ---------- */
.sky { position: fixed; inset: 0; z-index: -1; pointer-events: none; transition: opacity 1.4s ease; }
.sky-night {
  background:
    radial-gradient(1.5px 1.5px at 12% 18%, #fff8 50%, transparent 51%),
    radial-gradient(1px 1px at 72% 12%, #fff9 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 85% 40%, #fff6 50%, transparent 51%),
    radial-gradient(1px 1px at 30% 62%, #fff7 50%, transparent 51%),
    radial-gradient(1px 1px at 55% 30%, #fff5 50%, transparent 51%),
    radial-gradient(1.2px 1.2px at 92% 78%, #fff6 50%, transparent 51%),
    radial-gradient(1px 1px at 8% 85%, #fff5 50%, transparent 51%),
    radial-gradient(circle at 82% -5%, rgba(240, 184, 90, .22), transparent 32%),
    radial-gradient(ellipse at 50% 120%, #2a1d4d 0%, transparent 60%),
    linear-gradient(180deg, #070a17 0%, #0d1330 60%, #171238 100%);
}
.sky-night::after { content: ''; position: absolute; inset: 0; background: radial-gradient(1px 1px at 40% 20%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 65% 55%, #fff 50%, transparent 51%), radial-gradient(1.4px 1.4px at 20% 40%, #fff 50%, transparent 51%); animation: twinkle 4s ease-in-out infinite; }
@keyframes twinkle { 50% { opacity: .2; } }
.sky-day {
  opacity: 0;
  background:
    radial-gradient(circle at 80% 0%, rgba(255, 196, 110, .55), transparent 38%),
    radial-gradient(ellipse at 20% 110%, rgba(255, 120, 90, .35), transparent 55%),
    linear-gradient(180deg, #3d2a4a 0%, #6a3d4f 55%, #a8574d 100%);
}
body.is-day .sky-day { opacity: 1; }
body.is-day .sky-night { opacity: 0; }
body.is-day { --bg: #2a1f2e; --panel: rgba(58, 40, 52, .78); --panel-solid: #3a2834; }
body { transition: background-color 1.4s ease; }

/* ---------- Base layout ---------- */
#app { max-width: 620px; margin: 0 auto; padding: 16px 16px calc(150px + var(--safe-b)); min-height: 100vh; }
.topbar { display: flex; align-items: center; gap: 10px; margin: 4px 0 18px; }
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand h1 { font-family: var(--font-title); font-size: 1.7rem; margin: 0; letter-spacing: .06em; }
.brand .logo { font-size: 2rem; filter: drop-shadow(0 0 12px rgba(240, 184, 90, .35)); }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: .72rem; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: var(--gold-soft); color: var(--gold); letter-spacing: .03em; border: 1px solid rgba(240, 184, 90, .35); }
.badge.new { background: rgba(79, 209, 165, .15); color: var(--ok); border-color: rgba(79, 209, 165, .35); }
.phase-title { font-family: var(--font-title); font-size: 1.35rem; margin: 0; flex: 1; letter-spacing: .04em; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: var(--shadow); }
.panel h2 { font-size: 1.05rem; margin: 0 0 4px; display: flex; align-items: center; gap: 8px; }
.panel .sub { color: var(--muted); font-size: .88rem; margin: 0 0 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
hr.soft { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* ---------- Buttons ---------- */
.btn { border: 1px solid var(--line-strong); background: var(--panel-2); border-radius: var(--radius-sm); padding: 12px 16px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; transition: transform .08s, background .2s, opacity .2s; user-select: none; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .38; cursor: not-allowed; transform: none; }
.btn.primary { background: linear-gradient(180deg, #f6c46d, #e4a243); color: #1d1405; border-color: transparent; box-shadow: 0 8px 24px rgba(240, 184, 90, .28); }
.btn.danger { background: rgba(255, 93, 108, .16); border-color: rgba(255, 93, 108, .5); color: #ffc2c8; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.block { width: 100%; }
.btn.big { min-height: 58px; font-size: 1.08rem; border-radius: 16px; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); display: inline-grid; place-items: center; font-size: 1.15rem; flex: none; }
.icon-btn:disabled { opacity: .35; }
.btn-col { display: grid; gap: 10px; }
.btn-row { display: flex; gap: 10px; }
.btn-row > * { flex: 1; }

/* ---------- Inputs ---------- */
.input { width: 100%; border: 1px solid var(--line-strong); background: rgba(0, 0, 0, .25); border-radius: var(--radius-sm); padding: 12px 14px; min-height: 46px; outline: none; }
.input:focus { border-color: var(--gold); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--panel-2); border-radius: 99px; padding: 7px 13px; font-size: .88rem; font-weight: 600; }
.chip.on { background: var(--gold-soft); border-color: rgba(240, 184, 90, .6); color: var(--gold); }

/* ---------- Player list (setup) ---------- */
.player-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.player-list li { display: flex; align-items: center; gap: 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 6px 6px 6px 12px; }
.player-list .seat { width: 24px; color: var(--faint); font-size: .8rem; font-variant-numeric: tabular-nums; }
.player-list .pname { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-list .icon-btn { width: 36px; height: 36px; font-size: .95rem; }

/* ---------- Role grid ---------- */
.role-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }
.role-card { position: relative; border: 1px solid var(--line); background: var(--panel-2); border-radius: 14px; padding: 12px 10px 10px; display: flex; flex-direction: column; gap: 8px; border-top: 3px solid var(--tc, var(--line)); transition: background .2s, border-color .2s; }
.role-card.active { background: rgba(255, 255, 255, .09); border-color: var(--line-strong); border-top-color: var(--tc); }
.role-card .head { display: flex; align-items: center; gap: 8px; background: none; border: 0; padding: 0; text-align: left; }
.role-card .emo { font-size: 1.6rem; line-height: 1; }
.role-card .rname { font-weight: 700; font-size: .92rem; line-height: 1.15; }
.role-card .team { font-size: .72rem; color: var(--muted); }
.role-card .new-txt { color: var(--ok); font-weight: 700; }
.stepper { display: flex; align-items: center; justify-content: space-between; background: rgba(0, 0, 0, .25); border-radius: 10px; }
.stepper button { width: 40px; height: 34px; border: 0; background: none; font-size: 1.2rem; font-weight: 700; }
.stepper button:disabled { opacity: .25; }
.stepper .val { font-weight: 800; font-variant-numeric: tabular-nums; }

.balance { margin-top: 14px; }
.balance .bar { position: relative; height: 10px; border-radius: 99px; background: linear-gradient(90deg, var(--team-wolf), #6b6f8f 50%, var(--team-dorf)); }
.balance .knob { position: absolute; top: 50%; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 3px solid var(--bg); transform: translate(-50%, -50%); box-shadow: 0 0 0 2px #fff4; transition: left .3s; }
.balance .labels { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); margin-top: 6px; }

/* ---------- Sticky footer ---------- */
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 12px 16px calc(12px + var(--safe-b)); background: linear-gradient(180deg, transparent, rgba(5, 7, 16, .92) 30%); }
.dock .inner { max-width: 620px; margin: 0 auto; display: grid; gap: 8px; }
.msgs { display: grid; gap: 4px; font-size: .85rem; }
.msg { padding: 6px 10px; border-radius: 10px; }
.msg.err { background: rgba(255, 93, 108, .14); color: #ffc2c8; }
.msg.warn { background: rgba(247, 167, 75, .14); color: #ffd9a8; }

/* ---------- Reveal ---------- */
.reveal-wrap { min-height: calc(100vh - 140px); display: flex; flex-direction: column; justify-content: center; gap: 22px; text-align: center; }
.pass-name { font-family: var(--font-title); font-size: clamp(2.2rem, 9vw, 3.4rem); margin: 6px 0; color: var(--gold); word-break: break-word; }
.pass-hint { color: var(--muted); }
.progress-dots { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.progress-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.progress-dots i.done { background: var(--gold); }
.progress-dots i.now { background: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, .2); }

.card-stage { position: relative; width: min(330px, 86vw); aspect-ratio: 3 / 4.3; margin: 0 auto; user-select: none; -webkit-user-select: none; touch-action: none; }
.role-face, .card-cover { position: absolute; inset: 0; border-radius: 24px; }
.role-face { background: radial-gradient(circle at 50% 22%, rgba(255, 255, 255, .12), transparent 55%), var(--panel-solid); border: 2px solid var(--tc, var(--gold)); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 22px; gap: 10px; }
.role-face .emo { font-size: 4.2rem; line-height: 1; }
.role-face .rname { font-family: var(--font-title); font-size: 1.6rem; }
.role-face .team-tag { font-size: .8rem; font-weight: 700; padding: 4px 10px; border-radius: 99px; background: color-mix(in srgb, var(--tc) 18%, transparent); color: var(--tc); }
.role-face p { margin: 4px 0 0; font-size: .92rem; color: var(--muted); }
.card-cover { background:
    repeating-linear-gradient(45deg, rgba(240, 184, 90, .06) 0 10px, transparent 10px 20px),
    radial-gradient(circle at 50% 35%, #2b2453, #12162e 70%);
  border: 2px solid rgba(240, 184, 90, .45); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--gold); cursor: grab; transition: transform .25s cubic-bezier(.2, .8, .3, 1.2), opacity .2s; box-shadow: var(--shadow); }
.card-cover.dragging { transition: none; cursor: grabbing; }
.card-cover .moon { font-size: 4rem; }
.card-cover .hint { font-weight: 700; letter-spacing: .02em; }
.card-cover .hint2 { font-size: .82rem; color: var(--muted); }
.card-cover .arrow { animation: bob 1.6s ease-in-out infinite; font-size: 1.4rem; }
@keyframes bob { 50% { transform: translateY(-6px); } }

/* ---------- Game master ---------- */
.step-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.step-head .emo { font-size: 2.2rem; width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line); flex: none; }
.step-head h2 { margin: 0; font-size: 1.25rem; }
.step-head .who { color: var(--muted); font-size: .88rem; }
.narration { background: rgba(0, 0, 0, .28); border-left: 3px solid var(--gold); border-radius: 0 12px 12px 0; padding: 12px 14px; font-size: 1.08rem; font-style: italic; margin: 0 0 12px; display: flex; gap: 10px; align-items: flex-start; }
.narration .txt { flex: 1; }
.narration .say { flex: none; background: none; border: 0; font-size: 1.2rem; padding: 0; opacity: .8; }
.fake-note { background: rgba(247, 167, 75, .12); border: 1px dashed rgba(247, 167, 75, .5); border-radius: 12px; padding: 10px 12px; color: #ffd9a8; font-size: .9rem; margin-bottom: 12px; }
.info-line { background: var(--gold-soft); color: #ffe2ad; border-radius: 12px; padding: 10px 12px; font-weight: 600; margin-bottom: 12px; }
.result { border-radius: 14px; padding: 14px; font-weight: 700; font-size: 1.05rem; margin: 12px 0 0; text-align: center; animation: pop .25s ease-out; }
.result.good { background: rgba(79, 209, 165, .15); border: 1px solid rgba(79, 209, 165, .45); }
.result.bad { background: rgba(255, 93, 108, .15); border: 1px solid rgba(255, 93, 108, .5); }
@keyframes pop { from { transform: scale(.94); opacity: 0; } }

.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px; }
.pick { border: 1px solid var(--line); background: var(--panel-2); border-radius: 12px; padding: 11px 10px; text-align: left; font-weight: 600; min-height: 50px; display: flex; align-items: center; gap: 8px; transition: background .15s, border-color .15s; }
.pick .tag { font-size: .72rem; color: var(--muted); font-weight: 500; display: block; }
.pick.sel { background: var(--gold-soft); border-color: var(--gold); color: #fff; box-shadow: inset 0 0 0 1px var(--gold); }
.pick.dim { opacity: .45; }
.pick .mark { margin-left: auto; font-size: 1.1rem; }

.steps-progress { display: flex; gap: 4px; margin: -4px 0 14px; }
.steps-progress i { flex: 1; height: 4px; border-radius: 99px; background: var(--line); }
.steps-progress i.done { background: var(--gold); }

.potion { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--line); margin-bottom: 10px; }
.potion .emo { font-size: 1.6rem; }
.potion .lbl { flex: 1; font-weight: 600; }
.potion .lbl small { display: block; color: var(--muted); font-weight: 500; }
.switch { position: relative; width: 52px; height: 30px; border-radius: 99px; background: var(--line-strong); border: 0; flex: none; transition: background .2s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch.on { background: var(--ok); }
.switch.on::after { transform: translateX(22px); }
.switch:disabled { opacity: .35; }

.news-list { list-style: none; padding: 0; margin: 0 0 6px; display: grid; gap: 8px; }
.news-list li { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; font-size: 1.02rem; }
.secret-box { margin-top: 12px; border: 1px dashed var(--line-strong); border-radius: 14px; overflow: hidden; }
.secret-box summary { padding: 11px 13px; cursor: pointer; font-weight: 600; color: var(--muted); list-style: none; display: flex; align-items: center; gap: 8px; }
.secret-box summary::-webkit-details-marker { display: none; }
.secret-box ul { margin: 0; padding: 0 13px 12px 30px; color: #ffe2ad; font-size: .92rem; display: grid; gap: 6px; }

.timer { text-align: center; margin: 6px 0 14px; }
.timer .digits { font-family: var(--font-title); font-size: clamp(3.2rem, 15vw, 4.6rem); font-variant-numeric: tabular-nums; letter-spacing: .04em; line-height: 1.1; }
.timer .digits.low { color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.timer .bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 8px 0 12px; }
.timer .bar i { display: block; height: 100%; background: var(--gold); transition: width 1s linear; }

.reminders { display: grid; gap: 6px; margin-bottom: 14px; }
.reminder { font-size: .9rem; padding: 8px 12px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }

.vote-list { display: grid; gap: 6px; }
.vote-row { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); }
.vote-row.lead { border-color: var(--gold); background: var(--gold-soft); }
.vote-row .vname { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.vote-row .extra { font-size: .72rem; color: var(--gold); font-weight: 700; }
.vote-row .count { width: 34px; text-align: center; font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.vote-row .icon-btn { width: 40px; height: 40px; }
.vote-row .crown { opacity: .3; }
.vote-row .crown.on { opacity: 1; background: var(--gold-soft); border-color: var(--gold); }

/* ---------- Player overview ---------- */
.grid-players { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.pcard { text-align: left; border: 1px solid var(--line); border-left: 4px solid var(--tc); background: var(--panel-2); border-radius: 12px; padding: 10px; display: grid; gap: 2px; }
.pcard.dead { opacity: .5; filter: grayscale(.7); }
.pcard .pn { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.pcard .pr { font-size: .8rem; color: var(--muted); }
.pcard .flags { font-size: .9rem; min-height: 1.2em; letter-spacing: 2px; }

.winner-hero { text-align: center; padding: 26px 18px; }
.winner-hero .big { font-size: 4rem; }
.winner-hero h2 { font-family: var(--font-title); font-size: 1.8rem; margin: 6px 0; justify-content: center; }
.pcard.win { box-shadow: inset 0 0 0 2px var(--gold); }

.log-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: .9rem; }
.log-list li { padding: 8px 10px; border-radius: 10px; background: var(--panel-2); }
.log-list li.secret { color: #ffe2ad; border-left: 3px solid var(--gold); }
.log-list .lbl { color: var(--faint); font-size: .74rem; display: block; }

/* ---------- Modals ---------- */
.modal-back { position: fixed; inset: 0; z-index: 50; background: rgba(3, 4, 12, .66); backdrop-filter: blur(4px); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
@media (min-width: 640px) { .modal-back { align-items: center; } }
.modal { width: 100%; max-width: 560px; max-height: 88vh; overflow: auto; background: var(--panel-solid); border: 1px solid var(--line-strong); border-radius: 22px 22px 0 0; padding: 20px 18px calc(20px + var(--safe-b)); box-shadow: var(--shadow); animation: up .25s ease-out; }
@media (min-width: 640px) { .modal { border-radius: 22px; } }
.modal h2 { margin: 0 0 8px; font-size: 1.25rem; display: flex; align-items: center; gap: 8px; }
.modal .close { margin-left: auto; }
.modal h3 { font-size: 1rem; margin: 18px 0 6px; }
.modal ul.feat { margin: 0; padding-left: 20px; color: var(--muted); display: grid; gap: 4px; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.setting { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.setting .lbl { flex: 1; }
.setting .lbl small { display: block; color: var(--muted); }
.seg { display: inline-flex; background: rgba(0, 0, 0, .25); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; padding: 7px 10px; border-radius: 8px; font-size: .85rem; font-weight: 600; }
.seg button.on { background: var(--gold); color: #1d1405; }

#toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: #000d; color: #fff; padding: 10px 16px; border-radius: 99px; font-size: .9rem; opacity: 0; pointer-events: none; transition: .25s; z-index: 60; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%); }

.resume { display: flex; align-items: center; gap: 12px; background: linear-gradient(90deg, var(--gold-soft), transparent); border: 1px solid rgba(240, 184, 90, .45); }
.resume .emo { font-size: 1.8rem; }

@media (max-width: 380px) {
  #app { padding-left: 12px; padding-right: 12px; }
  .role-grid { grid-template-columns: 1fr 1fr; }
  .pick-grid { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }


/* ==========================================================================
   Language, navigation, no-game-master mode, animations
   ========================================================================== */
.topbar.slim { margin-bottom: 0; }
.lang-chip { display: inline-flex; border: 1px solid var(--line-strong); background: rgba(0, 0, 0, .25); border-radius: 99px; padding: 3px; gap: 2px; flex: none; }
.lang-chip span { font-size: .72rem; font-weight: 800; padding: 6px 8px; border-radius: 99px; color: var(--muted); transition: background .25s, color .25s; }
.lang-chip span.on { background: var(--gold); color: #1d1405; }

/* Game mode */
.mode-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0 6px; }
.mode-card { border: 1px solid var(--line); background: var(--panel-2); border-radius: 16px; padding: 14px 12px; text-align: left; display: grid; gap: 4px; transition: transform .2s, border-color .2s, background .2s, box-shadow .2s; }
.mode-card .emo { font-size: 1.8rem; }
.mode-card small { color: var(--muted); font-size: .78rem; line-height: 1.3; }
.mode-card.on { border-color: var(--gold); background: var(--gold-soft); box-shadow: 0 0 0 1px var(--gold) inset, 0 10px 30px rgba(240, 184, 90, .15); transform: translateY(-2px); }
.setting.compact { border-bottom: 0; padding-bottom: 0; }

/* Balance bar */
.balance.sticky { position: sticky; top: 8px; z-index: 6; margin: -4px -6px 14px; padding: 10px 12px; border-radius: 14px; background: color-mix(in srgb, var(--panel-solid) 92%, transparent); border: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: 0 8px 24px rgba(0, 0, 0, .3); }
.bal-head { display: flex; justify-content: space-between; align-items: center; font-size: .82rem; margin-bottom: 7px; }
.balance[data-verdict="bal.even"] .bal-head strong { color: var(--ok); }
.balance[data-verdict="bal.evil"] .bal-head strong { color: var(--team-wolf); }
.balance[data-verdict="bal.village"] .bal-head strong { color: #8fe3c6; }
.bal-bar { position: relative; display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: var(--line); }
.bal-bar i { display: block; height: 100%; transition: width .5s cubic-bezier(.2, .8, .2, 1); }
.bal-bar .bal-mid { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 2px; background: #fff8; }
.seg-dorf { background: var(--team-dorf); } .seg-wolf { background: var(--team-wolf); } .seg-vampir { background: var(--team-vampir); } .seg-solo { background: var(--team-solo); }
.bal-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 7px; font-size: .72rem; color: var(--muted); }
.bal-legend .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }

.actions { margin-bottom: 8px; }

/* Screen transitions & staggered lists */
.screen.enter { animation: screenIn .45s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes screenIn { from { opacity: 0; transform: translateY(14px) scale(.985); filter: blur(3px); } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
.enter .stagger > *, .stagger.enter > * { animation: rise .42s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i, 0) * 32ms + 80ms); }
.pop { animation: popIn .5s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes popIn { from { transform: scale(.6); opacity: 0; } }
.big-emo { font-size: 4rem; line-height: 1; }
.float { animation: float 3.5s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-8px); } }
.btn.primary { position: relative; overflow: hidden; }
.btn.primary:not(:disabled)::after { content: ''; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .35) 50%, transparent 70%); transform: translateX(-120%); animation: shine 4.5s ease-in-out infinite; }
@keyframes shine { 0%, 70% { transform: translateX(-120%); } 100% { transform: translateX(120%); } }
.steps-progress i { transition: background .4s; }
.steps-progress i.now { background: linear-gradient(90deg, var(--gold), transparent); animation: pulse 1.6s infinite; }
.news-list li { border-left: 3px solid var(--gold); }
.result.big { font-size: 1.3rem; padding: 22px; }

/* Dialogs */
.modal-back.closing { animation: fadeOut .2s forwards; }
.modal-back.closing .modal { animation: down .2s forwards; }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes down { to { transform: translateY(40px); opacity: 0; } }
.modal h3 { padding-top: 6px; border-top: 1px solid var(--line); }
.modal h3:first-of-type { border-top: 0; }
.modal .older { opacity: .75; }
.range { width: 140px; accent-color: var(--gold); }
.light-list { display: grid; gap: 6px; max-height: 240px; overflow: auto; }
.light-item { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); }
.light-item input { width: 20px; height: 20px; accent-color: var(--gold); }
.ok-text { color: var(--ok); } .err-text { color: #ffc2c8; }

/* Reveal */
/* The face is invisible (and has no glow) until the card is touched – no team colour can shine through. */
.card-stage[data-sealed] .role-face { visibility: hidden; }
.card-stage[data-sealed].peek .role-face { visibility: visible; }
.card-stage.open .role-face { animation: glow 1.6s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 70px color-mix(in srgb, var(--tc, var(--gold)) 55%, transparent); } }
.qr-box { width: min(280px, 78vw); aspect-ratio: 1; margin: 0 auto; background: #fff; border-radius: 20px; padding: 14px; display: grid; place-items: center; box-shadow: 0 0 50px rgba(240, 184, 90, .25); animation: popIn .5s cubic-bezier(.2, 1.4, .4, 1) both; }
.qr-box svg { width: 100%; height: 100%; }
.qr-box p { color: #333; text-align: center; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 4px solid #ddd; border-top-color: #e4a243; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* No game master */
.auto-stage { min-height: calc(100vh - 230px); display: flex; flex-direction: column; justify-content: center; align-items: stretch; gap: 18px; text-align: center; }
.auto-stage h2 { font-family: var(--font-title); font-size: 1.5rem; margin: 0; }
.auto-stage .step-head { justify-content: center; }
.auto-stage.blank { color: var(--faint); }
.moon-pulse { font-size: 4.5rem; animation: breathe 4s ease-in-out infinite; filter: drop-shadow(0 0 20px rgba(240, 184, 90, .3)); }
@keyframes breathe { 50% { transform: scale(1.08); opacity: .55; } }
body.auto-blank .sky-night { opacity: .35; }
body.auto-blank .game-head { opacity: .25; transition: opacity .6s; }
.night-panel.auto { border-color: rgba(240, 184, 90, .35); }

/* Voting */
.vote-row { position: relative; overflow: hidden; }
.vote-row .vbar { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, var(--gold-soft), transparent); transition: width .8s cubic-bezier(.2, .8, .2, 1); pointer-events: none; }
.vote-list.readonly .vote-row .vbar { width: var(--w); }
.vote-list.readonly .vote-row { padding: 12px 14px; }
.vote-row > *:not(.vbar) { position: relative; }
.pass-panel .pass-name { font-size: clamp(2rem, 8vw, 3rem); }
.pass-panel { display: grid; gap: 12px; }

/* Victory */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 40; }
.confetti i { position: absolute; top: -10vh; left: var(--x); font-style: normal; font-size: calc(1.4rem * var(--s)); animation: fall 3.4s cubic-bezier(.3, .4, .6, 1) var(--d) forwards; opacity: 0; }
@keyframes fall { 0% { opacity: 1; transform: translateY(0) rotate(0); } 100% { opacity: 0; transform: translateY(115vh) rotate(540deg); } }
.winner-hero .big { animation: popIn .7s cubic-bezier(.2, 1.4, .4, 1) both; }

.phase-title .badge { font-family: var(--font); vertical-align: middle; }
.setting { flex-wrap: wrap; }
.setting .lbl { flex: 1 1 55%; min-width: 150px; }

/* ==========================================================================
   Header, toolbar, dialogs, Home Assistant, setup hints
   ========================================================================== */
/* Home header: name stacked over version so nothing gets squeezed */
.topbar { gap: 8px; }
.topbar.home { margin-bottom: 16px; }
.brand { gap: 10px; }
.brand .logo { font-size: 2.2rem; line-height: 1; }
.brand-text { display: grid; min-width: 0; }
.brand h1 { font-size: 1.6rem; line-height: 1.05; letter-spacing: .08em; white-space: nowrap; }
.brand-sub { font-size: .78rem; color: var(--muted); letter-spacing: .12em; text-transform: uppercase; font-weight: 600; white-space: nowrap; }
.linkish { border: 0; background: none; padding: 0; color: var(--gold); font: inherit; letter-spacing: inherit; text-transform: none; cursor: pointer; }
.top-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.top-actions .icon-btn { width: 40px; height: 40px; font-size: 1.05rem; }
@media (max-width: 380px) { .brand h1 { font-size: 1.35rem; } .brand .logo { font-size: 1.8rem; } }

/* Game header with toolbar (tools, not pages) */
.game-head { position: sticky; top: 0; z-index: 25; margin: -16px -16px 14px; padding: 12px 16px 10px; background: linear-gradient(180deg, color-mix(in srgb, var(--bg) 96%, transparent) 70%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.game-head .topbar { margin: 0 0 8px; }
.phase-title { font-size: 1.25rem; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toolbar { display: flex; gap: 6px; }
.tool { flex: 1 1 auto; display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-height: 36px; padding: 6px 10px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel-2); font-size: .82rem; font-weight: 600; white-space: nowrap; transition: background .2s, transform .1s, opacity .2s; }
.tool.icon { flex: 0 0 auto; width: 40px; padding: 0; font-size: 1rem; }
.tool:active { transform: scale(.95); background: var(--gold-soft); }
.tool:disabled { opacity: .35; }
#app:has(.game-head) { padding-bottom: calc(40px + var(--safe-b)); }

/* Centered dialog (welcome) with breathing room around it */
.modal-back.centered { align-items: center; padding: calc(28px + env(safe-area-inset-top, 0px)) 14px calc(20px + var(--safe-b)); }
.modal.centered { position: relative; max-width: 520px; max-height: calc(100dvh - 72px); border-radius: 22px; padding: 22px 20px 20px; animation: popIn .35s cubic-bezier(.2, 1.2, .4, 1) both; }
.modal-back.closing .modal.centered { animation: fadeOut .2s forwards; }
.close.floating { position: absolute; top: 12px; right: 12px; }
.news-hero { text-align: center; margin: 4px 0 6px; }
.news-hero .logo { font-size: 3rem; display: inline-block; filter: drop-shadow(0 0 16px rgba(240, 184, 90, .4)); }
.news-hero h2 { justify-content: center; font-family: var(--font-title); font-size: 1.35rem; margin: 6px 0 0; }

/* Setup: start button shows status; problems only after trying */
.btn.big.block[data-act="startGame"] { flex-direction: column; gap: 0; line-height: 1.2; }
.start-status { font-size: .74rem; font-weight: 600; opacity: .75; }
.btn.primary.soft { filter: saturate(.35) brightness(.85); box-shadow: none; }
.msg.err { display: grid; gap: 3px; }
.hints { display: grid; gap: 6px; margin: 4px 0 2px; }
.hint-line { font-size: .82rem; color: #ffd9a8; background: rgba(247, 167, 75, .1); border-radius: 10px; padding: 7px 10px; }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* Settings extras */
.sub-label { font-size: .8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 14px 0 8px; }
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.preset { display: grid; gap: 2px; text-align: left; padding: 10px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel-2); transition: border-color .2s, background .2s; }
.preset.on { border-color: var(--gold); background: var(--gold-soft); }
.preset .sw { display: block; height: 22px; border-radius: 8px; margin-bottom: 6px; background: linear-gradient(90deg, var(--a) 0 50%, var(--b) 50% 100%); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .15); }
.preset small { color: var(--muted); font-size: .72rem; }
.small-input { min-height: 40px; padding: 8px 12px; margin-bottom: 8px; }
.light-list { max-height: 300px; gap: 10px; }
.light-group { display: grid; gap: 4px; }
.light-group[hidden], .light-item[hidden] { display: none; }
.lg-head { font-size: .76rem; font-weight: 700; color: var(--gold); position: sticky; top: 0; background: var(--panel-solid); padding: 4px 2px; z-index: 1; }
.light-item { padding: 7px 10px; }
.small-btn { min-height: 40px; padding: 6px 12px; }

/* Lovers phone round */
.pass-card { padding: 24px 18px; border-radius: 20px; background: var(--panel); border: 1px solid var(--line-strong); display: grid; gap: 8px; animation: popIn .4s cubic-bezier(.2, 1.3, .4, 1) both; }
.pass-card h2 { font-size: 1.35rem; }
.brand { overflow: hidden; }
.msg.err { background: rgba(70, 16, 26, .96); border: 1px solid rgba(255, 93, 108, .45); }
@media (max-width: 360px) { .brand-sub { letter-spacing: .04em; font-size: .72rem; } .top-actions .lang-chip span { padding: 6px 6px; } }
/* Installed app (home screen): keep clear of the status bar */
#app { padding-top: calc(16px + env(safe-area-inset-top, 0px)); }
.game-head { margin-top: calc(-16px - env(safe-area-inset-top, 0px)); padding-top: calc(12px + env(safe-area-inset-top, 0px)); }
/* No pull-to-refresh: pulling down must never reload the page (Chrome uses the root element) */
html, body { overscroll-behavior-y: none; }
.modal, .light-list { overscroll-behavior: contain; }
/* New roles: custom role card, ghost hand drawing, morning sign */
.custom-txt { color: var(--team-love); font-weight: 700; }
.role-card.add-custom { align-items: center; justify-content: center; gap: 4px; min-height: 104px; border: 2px dashed var(--line-strong); background: transparent; color: var(--muted); font-weight: 700; text-align: center; }
.role-card.add-custom .plus { font-size: 1.8rem; line-height: 1; color: var(--gold); }
.role-card.add-custom:active { background: var(--gold-soft); }
.emoji-input { width: 64px; flex: none; text-align: center; font-size: 1.4rem; padding: 8px; }
textarea.input { resize: vertical; min-height: 80px; }
.draw-pad { display: block; width: 100%; max-width: 360px; aspect-ratio: 1; margin: 0 auto; border-radius: 18px; border: 2px dashed rgba(240, 184, 90, .45); background: #0d1126; touch-action: none; cursor: crosshair; }
.sign-box { margin-top: 14px; text-align: center; }
.sign-box img { width: 100%; max-width: 340px; aspect-ratio: 1; border-radius: 18px; border: 2px solid rgba(240, 184, 90, .5); box-shadow: 0 0 40px rgba(240, 184, 90, .2); animation: popIn .6s cubic-bezier(.2, 1.3, .4, 1) both; }
textarea { font: inherit; color: inherit; }
