:root {
  --bg: #070709;
  --bg-2: #0e0d11;
  --panel: rgba(20, 18, 23, .82);
  --panel-solid: #151318;
  --line: rgba(233, 225, 207, .14);
  --line-strong: rgba(233, 225, 207, .28);
  --bone: #e9e1cf;
  --muted: #9a9286;
  --blood: #b0232f;
  --blood-bright: #e04350;
  --blood-dim: #5d1219;
  --green: #5fbf8a;
  --amber: #d9a441;
  --shadow: 0 24px 80px rgba(0, 0, 0, .55);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--bone);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(1200px 700px at 15% -10%, rgba(176, 35, 47, .20), transparent 60%),
    radial-gradient(900px 600px at 100% 0%, rgba(90, 30, 80, .14), transparent 55%),
    radial-gradient(800px 800px at 50% 120%, rgba(30, 55, 60, .12), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .05;
  z-index: 9999;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

a { color: inherit; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; }

.boot {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 1.1rem;
  letter-spacing: .08em;
}

.fog {
  position: fixed;
  inset: -20%;
  pointer-events: none;
  background:
    radial-gradient(closest-side at 30% 40%, rgba(176, 35, 47, .10), transparent),
    radial-gradient(closest-side at 70% 60%, rgba(120, 120, 140, .06), transparent);
  filter: blur(30px);
  animation: drift 22s ease-in-out infinite alternate;
}

@keyframes drift {
  from { transform: translate3d(-2%, -1%, 0) scale(1); }
  to { transform: translate3d(2%, 2%, 0) scale(1.06); }
}

/* ------------------------------------------------------------- home page */

.home {
  position: relative;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 6vh 5vw;
}

.home-inner {
  position: relative;
  z-index: 2;
  max-width: 980px;
  text-align: center;
}

.kicker {
  margin: 0 0 1.4rem;
  color: var(--blood-bright);
  font-size: .72rem;
  letter-spacing: .32em;
  text-transform: uppercase;
}

.title {
  margin: 0;
  font-size: clamp(3.4rem, 12vw, 8.8rem);
  line-height: .84;
  text-transform: uppercase;
  letter-spacing: .02em;
  text-shadow: 0 0 40px rgba(176, 35, 47, .25);
}

.title span { color: var(--blood-bright); }

.flicker { animation: flicker 6s infinite; }

@keyframes flicker {
  0%, 18%, 22%, 25%, 53%, 57%, 100% { opacity: 1; }
  20%, 24%, 55% { opacity: .55; }
}

.lede {
  max-width: 640px;
  margin: 2rem auto 0;
  color: #c9c1b2;
  font-size: clamp(1rem, 2.2vw, 1.18rem);
  line-height: 1.65;
}

.home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  margin: 2.6rem 0 1.2rem;
}

.hint {
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.5;
}

.home-rules {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin-top: 4rem;
  border: 1px solid var(--line);
  background: var(--line);
}

.home-rules div {
  background: rgba(10, 9, 12, .78);
  padding: 1.1rem 1rem;
  display: grid;
  gap: .3rem;
}

.home-rules strong {
  font-family: var(--serif);
  font-weight: 600;
  color: var(--bone);
  font-size: 1rem;
}

.home-rules span { color: var(--muted); font-size: .76rem; line-height: 1.4; }

/* ---------------------------------------------------------------- buttons */

.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: rgba(233, 225, 207, .04);
  color: var(--bone);
  font: inherit;
  font-weight: 600;
  font-size: .92rem;
  letter-spacing: .04em;
  padding: .85rem 1.25rem;
  border-radius: 3px;
  cursor: pointer;
  transition: transform .12s ease, background .15s ease, border-color .15s ease, opacity .15s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: 44px;
}

.btn:hover { background: rgba(233, 225, 207, .09); border-color: rgba(233, 225, 207, .45); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .38; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(180deg, #c42a37, #8e1a24);
  border-color: #d64a56;
  color: #fff4ee;
  box-shadow: 0 8px 30px rgba(176, 35, 47, .28);
}
.btn-primary:hover { background: linear-gradient(180deg, #d53543, #9d1e29); }

.btn-ghost { background: transparent; }
.btn-danger { border-color: var(--blood-dim); color: #e9a2a8; }
.btn-small { padding: .5rem .7rem; font-size: .78rem; min-height: 36px; }
.btn-xl { padding: 1.05rem 1.7rem; font-size: 1rem; }

/* ------------------------------------------------------------------ shell */

.shell {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 1.2rem clamp(1rem, 3vw, 2.4rem) 4rem;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: .4rem 0 1.1rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.4rem;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: .7rem;
  margin-right: auto;
}

.brand strong {
  font-family: var(--serif);
  font-size: clamp(1.2rem, 2.4vw, 1.6rem);
  letter-spacing: .02em;
}

.brand span { color: var(--muted); font-size: .72rem; letter-spacing: .18em; text-transform: uppercase; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .35rem .7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: .74rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(0, 0, 0, .2);
  white-space: nowrap;
}

.chip.live { color: #eab0b4; border-color: var(--blood-dim); }
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.chip.live .dot { background: var(--blood-bright); box-shadow: 0 0 8px var(--blood-bright); animation: pulse 1.6s infinite; }

@keyframes pulse { 50% { opacity: .25; } }

.clock {
  font-family: var(--mono);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  letter-spacing: .06em;
  color: var(--bone);
  font-variant-numeric: tabular-nums;
}

.clock.danger { color: var(--blood-bright); animation: pulse 1s infinite; }

/* ----------------------------------------------------------------- panels */

.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: clamp(1rem, 2.4vw, 1.5rem);
  border-radius: 4px;
}

.panel + .panel { margin-top: 1rem; }

.panel h2, .panel h3 { margin: 0 0 .3rem; }
.panel h2 { font-size: 1.25rem; }
.panel h3 { font-size: 1.02rem; }
.panel p { margin: .35rem 0; color: #c4bcae; line-height: 1.55; }
.muted { color: var(--muted); }
.tiny { font-size: .74rem; line-height: 1.45; }
.eyebrow {
  margin: 0 0 .6rem;
  color: var(--blood-bright);
  font-size: .68rem;
  letter-spacing: .24em;
  text-transform: uppercase;
}
.row { display: flex; gap: .7rem; flex-wrap: wrap; align-items: center; }
.spread { justify-content: space-between; }
.grow { flex: 1; }
.stack { display: grid; gap: .8rem; }
.hr { height: 1px; background: var(--line); margin: 1rem 0; border: 0; }

.field { display: grid; gap: .4rem; }
.field label { font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.field input, .field select {
  width: 100%;
  background: #0b0a0d;
  color: var(--bone);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  padding: .8rem .85rem;
  font: inherit;
  font-size: 1rem;
  min-height: 46px;
}
.field input:focus, .field select:focus { outline: 2px solid var(--blood-dim); border-color: var(--blood); }

/* ------------------------------------------------------------ master layout */

.master-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
  gap: 1rem;
  align-items: start;
}

.master-col { display: grid; gap: 1rem; }

.turn-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--blood-dim);
  background:
    radial-gradient(500px 200px at 0% 0%, rgba(176, 35, 47, .15), transparent 70%),
    var(--panel);
  padding: 1.3rem;
  border-radius: 4px;
}

.turn-card .who {
  font-family: var(--serif);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  margin: .1rem 0 .4rem;
}

.turn-card .where {
  color: #d8cebd;
  font-size: 1.05rem;
  line-height: 1.5;
  font-style: italic;
}

.riddle-text {
  font-family: var(--serif);
  font-size: 1.08rem;
  line-height: 1.65;
  color: #e2d9c7;
}

.answer-tag {
  display: inline-block;
  margin-top: .6rem;
  font-size: .72rem;
  color: var(--amber);
  letter-spacing: .12em;
  text-transform: uppercase;
}

.join-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: .8rem;
}

.join-card {
  border: 1px solid var(--line);
  background: #0c0b0e;
  padding: .7rem;
  border-radius: 4px;
  text-align: center;
  display: grid;
  gap: .45rem;
}

.join-card img { width: 100%; height: auto; display: block; border-radius: 2px; background: #fff; }
.join-card .pname { font-family: var(--serif); font-size: 1rem; }
.join-card .pcode { font-family: var(--mono); font-size: 1.15rem; letter-spacing: .18em; color: var(--amber); }
.join-card .pstatus { font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.join-card.is-in { border-color: rgba(95, 191, 138, .5); }
.join-card.is-in .pstatus { color: var(--green); }
.join-card.is-ok { border-color: var(--blood); box-shadow: 0 0 0 1px rgba(176, 35, 47, .25) inset; }
.join-card.is-ok .pstatus { color: var(--blood-bright); }
.join-card.is-new { border-color: var(--amber); box-shadow: 0 0 0 1px rgba(217, 164, 65, .25) inset; }
.join-card.is-new .pname { color: var(--amber); }

.join-focus {
  display: grid;
  place-items: center;
  gap: .7rem;
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid var(--amber);
  border-radius: 4px;
  background: radial-gradient(420px 260px at 50% 0%, rgba(217, 164, 65, .10), transparent 70%);
  text-align: center;
}
.join-focus .join-card {
  width: min(360px, 100%);
  border: 0;
  background: transparent;
  padding: 0;
}
.join-focus .join-card img { width: 100%; height: auto; }
.join-focus .pname { font-size: 1.25rem; }
.join-focus .pcode { font-size: 1.5rem; }

.setup-list { display: grid; gap: .35rem; margin-top: .8rem; }
.join-card.is-off .pstatus { color: var(--muted); }

.players {
  display: grid;
  gap: .45rem;
}

.player-row {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem .7rem;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, .18);
  border-radius: 3px;
  font-size: .86rem;
}
.player-row .num {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--line-strong);
  font-family: var(--mono); font-size: .78rem;
}
.player-row.is-turn { border-color: var(--blood); background: rgba(176, 35, 47, .10); }
.player-row .state { margin-left: auto; font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.player-row .state.on { color: var(--green); }

.progress {
  height: 6px;
  background: rgba(233, 225, 207, .09);
  border-radius: 999px;
  overflow: hidden;
}
.progress > div { height: 100%; background: linear-gradient(90deg, var(--blood), var(--blood-bright)); transition: width .4s ease; }

.letters { display: flex; flex-wrap: wrap; gap: .28rem; }
.letter {
  width: 1.9rem; height: 2.2rem;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 2px;
  font-family: var(--mono);
  font-size: .95rem;
  color: var(--muted);
  background: rgba(0, 0, 0, .25);
}
.letter.correct { border-color: rgba(95, 191, 138, .55); color: #bdf0d3; background: rgba(95, 191, 138, .10); }
.letter.wrong { border-color: rgba(224, 67, 80, .55); color: #f3b5ba; background: rgba(224, 67, 80, .10); }
.letter.empty { border-style: dashed; }

.attempt-list { display: grid; gap: .45rem; max-height: 240px; overflow: auto; }
.attempt { font-family: var(--mono); font-size: .8rem; color: var(--muted); }
.attempt b { color: var(--bone); font-weight: 500; letter-spacing: .18em; }

.log { display: grid; gap: .3rem; max-height: 240px; overflow: auto; font-size: .74rem; color: var(--muted); }
.log-entry { display: flex; gap: .6rem; border-bottom: 1px dashed rgba(233, 225, 207, .07); padding-bottom: .3rem; }
.log-entry time { font-family: var(--mono); color: #6f6a61; white-space: nowrap; }

details.secret summary { cursor: pointer; color: var(--amber); font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; }
details.secret > div { margin-top: .8rem; display: grid; gap: .7rem; }
.secret-code {
  font-family: var(--mono);
  letter-spacing: .34em;
  color: var(--blood-bright);
  font-size: 1.25rem;
  word-break: break-all;
}
.placement { width: 100%; border-collapse: collapse; font-size: .76rem; }
.placement th, .placement td { text-align: left; padding: .32rem .4rem; border-bottom: 1px solid rgba(233, 225, 207, .08); }
.placement th { color: var(--muted); font-weight: 500; font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; }
.placement td:first-child { font-family: var(--mono); color: var(--amber); }

/* ------------------------------------------------------------- player page */

.player-shell {
  width: min(680px, 100%);
  margin: 0 auto;
  padding: max(1rem, env(safe-area-inset-top)) 1rem max(2rem, env(safe-area-inset-bottom));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.player-top {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .3rem 0 .9rem;
  border-bottom: 1px solid var(--line);
}
.player-top .name { font-family: var(--serif); font-size: 1.1rem; margin-right: auto; }
.player-top .clock { font-size: 1.5rem; }

.turn-banner {
  margin: 1rem 0;
  padding: .9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(0, 0, 0, .25);
  text-align: center;
  color: var(--muted);
  font-size: .88rem;
}
.turn-banner.mine {
  border-color: var(--blood);
  background: linear-gradient(180deg, rgba(176, 35, 47, .18), rgba(176, 35, 47, .06));
  color: #f0c9cc;
  font-weight: 600;
  letter-spacing: .04em;
}

.big-card {
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--panel);
  padding: 1.3rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.big-card h2 { font-size: 1.45rem; margin: 0 0 .6rem; }
.text { font-family: var(--serif); font-size: 1.08rem; line-height: 1.65; color: #e4dbc9; }

.qr-target {
  display: flex;
  align-items: center;
  gap: .8rem;
  margin-bottom: .9rem;
  padding: .7rem .9rem;
  border: 1px solid var(--amber);
  border-radius: 4px;
  background: rgba(217, 164, 65, .08);
  color: var(--amber);
  font-size: .78rem;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.qr-target strong {
  font-family: var(--mono);
  font-size: clamp(2rem, 10vw, 3rem);
  line-height: 1;
  letter-spacing: .05em;
  color: #ffe2a8;
}
.manual-scan { margin-top: 1rem; display: grid; gap: .45rem; }
.manual-scan label { font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.manual-scan input {
  flex: 1;
  min-width: 0;
  background: #08070a;
  border: 1px solid var(--line-strong);
  color: var(--bone);
  font-family: var(--mono);
  font-size: 1.15rem;
  text-align: center;
  padding: .7rem;
  border-radius: 3px;
  min-height: 46px;
}
.manual-scan-wrap { margin-top: 1rem; }
.manual-scan-wrap summary { cursor: pointer; color: var(--muted); font-size: .78rem; }
.manual-scan-wrap[open] summary { margin-bottom: .4rem; }

.position-badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  border: 1px solid var(--amber);
  color: var(--amber);
  font-family: var(--mono);
  font-size: .74rem;
  letter-spacing: .12em;
  padding: .3rem .55rem;
  border-radius: 2px;
  margin-bottom: .8rem;
}

.listening {
  display: flex;
  align-items: center;
  gap: .7rem;
  color: var(--muted);
  font-size: .86rem;
}
.waves { display: inline-flex; gap: 3px; align-items: flex-end; height: 18px; }
.waves i { width: 3px; background: var(--blood-bright); animation: wave 1s ease-in-out infinite; }
.waves i:nth-child(2) { animation-delay: .15s; }
.waves i:nth-child(3) { animation-delay: .3s; }
.waves i:nth-child(4) { animation-delay: .45s; }
.waves i:nth-child(5) { animation-delay: .6s; }
@keyframes wave { 0%, 100% { height: 4px; } 50% { height: 16px; } }

.scan-stage { display: grid; gap: 1rem; }
#qr-reader {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  overflow: hidden;
  background: #000;
  min-height: 260px;
}
#qr-reader video { width: 100% !important; height: auto !important; }
#qr-reader__dashboard { padding: .4rem !important; background: #0d0c10 !important; }
#qr-reader__dashboard button { min-height: 38px; }

.modal-back {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(3, 3, 4, .82);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 1rem;
}
.modal {
  width: min(520px, 100%);
  border: 1px solid var(--line-strong);
  background: var(--panel-solid);
  box-shadow: var(--shadow);
  padding: 1.3rem;
  border-radius: 4px;
  max-height: 90dvh;
  overflow: auto;
}
.modal h2 { margin-top: 0; }
.password-input {
  width: 100%;
  background: #08070a;
  border: 1px solid var(--line-strong);
  color: var(--bone);
  font-family: var(--mono);
  font-size: clamp(1.4rem, 7vw, 2rem);
  letter-spacing: .26em;
  text-align: center;
  text-transform: uppercase;
  padding: .8rem .6rem;
  border-radius: 3px;
  min-height: 62px;
}
.password-input:focus { outline: 2px solid var(--blood-dim); border-color: var(--blood); }

.feedback-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  justify-content: center;
}
.feedback-grid .letter { width: 2.1rem; height: 2.5rem; font-size: 1.05rem; }

.result {
  min-height: 70dvh;
  display: grid;
  place-items: center;
  text-align: center;
  gap: .6rem;
  padding: 2rem 0;
}
.result h1 { font-size: clamp(2.4rem, 12vw, 4.6rem); margin: 0; line-height: .9; text-transform: uppercase; }
.result.won h1 { color: var(--blood-bright); text-shadow: 0 0 60px rgba(224, 67, 80, .35); }
.result.lost h1 { color: #8d8578; }
.lock-code {
  font-family: var(--mono);
  font-size: clamp(3.2rem, 18vw, 6.2rem);
  letter-spacing: .18em;
  color: #fff2e6;
  border: 1px solid var(--blood);
  padding: .3em .2em .3em .4em;
  margin: 1.2rem auto .6rem;
  background: radial-gradient(300px 160px at 50% 20%, rgba(176, 35, 47, .35), transparent 70%);
  box-shadow: 0 0 80px rgba(176, 35, 47, .25);
  border-radius: 4px;
}

.role-card {
  border: 1px solid var(--blood-dim);
  background: radial-gradient(400px 240px at 50% 0%, rgba(176, 35, 47, .18), transparent 70%), var(--panel);
  padding: 2rem 1.3rem;
  text-align: center;
  border-radius: 4px;
  margin-top: 8vh;
}
.role-card .role {
  font-family: var(--serif);
  font-size: clamp(1.8rem, 8vw, 2.8rem);
  margin: .5rem 0 1.4rem;
}

.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 80;
  display: grid;
  gap: .4rem;
  width: min(560px, calc(100% - 2rem));
  pointer-events: none;
}
.toast {
  border: 1px solid var(--line-strong);
  background: #17141a;
  color: var(--bone);
  padding: .7rem .9rem;
  font-size: .82rem;
  border-radius: 3px;
  box-shadow: var(--shadow);
  animation: toast-in .18s ease;
}
.toast.warn { border-color: var(--amber); color: #f0d59a; }
.toast.error { border-color: var(--blood); color: #f3b5ba; }
.toast.ok { border-color: var(--green); color: #c7f0d9; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.banner {
  border: 1px solid var(--amber);
  color: #efd9a8;
  background: rgba(217, 164, 65, .08);
  padding: .6rem .8rem;
  font-size: .78rem;
  border-radius: 3px;
  margin-bottom: .8rem;
}

.offline { border-color: var(--blood); color: #f3b5ba; background: rgba(176, 35, 47, .10); }

/* ----------------------------------------------------------------- mobile */

@media (max-width: 860px) {
  .master-grid { grid-template-columns: 1fr; }
  .home-rules { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 520px) {
  .shell { padding-left: .8rem; padding-right: .8rem; }
  .home-rules { grid-template-columns: 1fr; }
  .join-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { gap: .5rem; }
  .brand span { display: none; }
  .letters .letter { width: 1.6rem; height: 2rem; font-size: .82rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ------------------------------------------------------- master dashboard */
/* The master is a kiosk: the page never scrolls; only inner lists do. */
body.page-master {
  height: 100dvh;
  overflow: hidden;
}
.master-shell {
  height: 100dvh;
  padding: .8rem clamp(1rem, 2.5vw, 2rem) .3rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.master-shell .topbar {
  flex: 0 0 auto;
  margin-bottom: .7rem;
  padding-bottom: .6rem;
}
.master-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
.master-content > .master-grid {
  height: 100%;
  min-height: 0;
}
.master-content .master-col {
  min-height: 0;
  overflow: auto;
  padding-right: .15rem;
}
.master-content > .panel {
  max-height: 100%;
  overflow: auto;
}
.master-content .result {
  min-height: 0;
  height: 100%;
  padding: 0;
}
.action-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 58px;
  padding: .65rem 0 max(.4rem, env(safe-area-inset-bottom));
  margin-top: .55rem;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, transparent, rgba(7, 7, 9, .92) 35%);
}
.action-hint {
  color: var(--muted);
  font-size: .74rem;
  line-height: 1.35;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.action-buttons {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .55rem;
  flex-wrap: wrap;
}
.action-buttons .btn { min-height: 42px; }

/* Joining: one QR at a time, list on the side; both fit the viewport. */
.joining-layout {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(250px, .85fr) minmax(0, 1.15fr);
  gap: 1rem;
}
.join-focus-panel {
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.join-focus {
  margin: 0;
  width: 100%;
  max-height: 100%;
  overflow: auto;
}
.join-focus .join-card { width: min(280px, 100%); }
.join-focus .join-card img {
  width: auto;
  max-width: 100%;
  max-height: 36vh;
  margin: 0 auto;
  object-fit: contain;
}
.join-list-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.join-list-panel .setup-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  margin-top: .6rem;
}
.join-list-panel .setup-summary { flex: 0 0 auto; margin-top: .5rem; }

@media (max-width: 900px) {
  .joining-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: auto;
  }
  .join-focus .join-card img { max-height: 28vh; }
  .action-bar {
    flex-direction: column;
    align-items: stretch;
    gap: .45rem;
  }
  .action-hint { white-space: normal; }
  .action-buttons { justify-content: stretch; }
  .action-buttons .btn { flex: 1 1 auto; }
}
