/* Buzzer components. Colours / shapes come from tokens.css (same language as Group Checklist). */

/* ------------------------------------------------------------ base */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; background: var(--paper); }
body {
  margin: 0; background: var(--paper); color: var(--text);
  font: 500 var(--fs)/1.4 var(--font);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
input, select, button, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid var(--purple); outline-offset: 3px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.icon { display: inline-flex; width: 1.25em; height: 1.25em; flex: none; }
.icon svg { width: 100%; height: 100%; }
.muted { color: var(--muted); }

/* ------------------------------------------------------------ buttons (as Group Checklist) */
.btn, .sq {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--surface); color: var(--text);
  border: var(--bw) solid var(--ink); box-shadow: var(--sh);
  font-weight: 700; cursor: pointer; text-decoration: none; touch-action: manipulation; user-select: none;
  transition: transform var(--t-press) var(--ease-out), box-shadow var(--t-press) var(--ease-out), background-color var(--t-ui) ease;
}
.btn { min-height: 48px; padding: 0 16px; border-radius: var(--r-btn); }
.btn.sm { min-height: 38px; padding: 0 12px; font-size: 14px; border-width: var(--bw-sm); border-radius: 9px; box-shadow: var(--sh-sm); }
.btn.big { min-height: 58px; font-size: var(--fs-lg); font-weight: 800; padding: 0 22px; }
.btn.block { width: 100%; }
.btn.yellow, .sq.yellow { background: var(--yellow); color: var(--on-color); }
.btn.green, .sq.green { background: var(--green); color: var(--on-color); }
.btn.orange { background: var(--orange); color: var(--on-color); }
.btn.danger, .sq.danger { color: var(--red); }
.btn.ghost { box-shadow: none; border-style: dashed; background: transparent; }
.btn .icon { width: 20px; height: 20px; }
.btn.sm .icon { width: 17px; height: 17px; }
.btn kbd { font: 800 12px/1 var(--font); padding: 3px 6px; border: var(--bw-sm) solid currentColor; border-radius: 6px; opacity: .65; }
.sq { width: 50px; height: 50px; padding: 0; border-radius: 13px; flex: none; }
.sq .icon { width: 24px; height: 24px; }
.sq.sm { width: 38px; height: 38px; border-radius: 10px; border-width: var(--bw-sm); box-shadow: var(--sh-sm); }
.sq.sm .icon { width: 18px; height: 18px; }
.sq[aria-pressed="true"] { background: var(--yellow); color: var(--on-color); }
@media (hover: hover) and (pointer: fine) {
  .btn:hover:not(:disabled), .sq:hover:not(:disabled) { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--shadow); }
  .btn.sm:hover:not(:disabled), .sq.sm:hover:not(:disabled) { box-shadow: 3px 3px 0 var(--shadow); }
}
.btn:active:not(:disabled), .sq:active:not(:disabled) { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--shadow); }
.btn.sm:active:not(:disabled), .sq.sm:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--shadow); }
.btn:disabled, .sq:disabled { opacity: .45; cursor: default; }

.card { position: relative; background: var(--surface); border: var(--bw) solid var(--ink); border-radius: var(--r); box-shadow: var(--sh-lg); padding: 16px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 999px; border: var(--bw-sm) solid var(--ink);
  background: var(--surface); font-size: 14px; font-weight: 800; white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--ink); background: var(--gray); flex: none; }
.dot.online { background: var(--green); }
.dot.reconnecting { background: var(--yellow); animation: blink 1s steps(2) infinite; }
.dot.offline { background: var(--red); }
@keyframes blink { 50% { opacity: .35; } }

/* ------------------------------------------------------------ fields */
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 800; color: var(--text); }
.input {
  width: 100%; min-width: 0; min-height: 52px; padding: 0 14px;
  background: var(--surface); color: var(--text);
  border: var(--bw-sm) solid var(--ink); border-radius: var(--r-sm);
  font-size: 17px; font-weight: 600;  /* ≥16px stops iOS zooming in */
  transition: box-shadow var(--t-press) var(--ease-out);
}
.input::placeholder { color: var(--muted); font-weight: 500; opacity: .8; }
.input:focus { outline: none; box-shadow: 3px 3px 0 var(--purple); }
.input.code { font-size: 30px; font-weight: 800; letter-spacing: .35em; text-transform: uppercase; text-align: center; padding-left: calc(14px + .35em); }
.status { min-height: 1.3em; margin: 0; font-size: 15px; font-weight: 700; color: var(--bad); }
.status:empty { min-height: 0; }
.stack { display: grid; gap: 14px; }

/* ------------------------------------------------------------ brand: logos + event banner */
.brandbar { display: flex; align-items: center; gap: 12px; min-width: 0; }
.crest { width: 46px; height: 46px; flex: none; border-radius: 50%; border: var(--bw) solid var(--ink); box-shadow: var(--sh-sm); background: var(--navy); }
.brandbar .words { display: flex; flex-direction: column; min-width: 0; line-height: 1.1; }
.brandbar small { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.brandbar strong { font-size: 20px; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Yellow banner with an orange circle + maroon slab (the Group Checklist banner, in Dinamika colours) */
.banner {
  position: relative; overflow: hidden; isolation: isolate;
  background: var(--yellow); color: var(--on-color); padding: 20px;
}
.banner::before {
  content: ""; position: absolute; z-index: -1; width: 160px; height: 160px; border-radius: 50%;
  border: var(--bw) solid var(--ink); background: var(--orange); right: -60px; top: -76px;
}
.banner::after {
  content: ""; position: absolute; z-index: -1; width: 220px; height: 110px;
  border: var(--bw) solid var(--ink); background: var(--maroon); right: -90px; bottom: -78px; transform: rotate(-14deg);
}
.event { display: flex; align-items: center; gap: 14px; }
.event .mark { width: 92px; height: auto; flex: none; filter: drop-shadow(3px 3px 0 rgba(18,18,18,.9)); }
.event .eyebrow { font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.hero { font-size: var(--fs-hero); line-height: .95; font-weight: 800; letter-spacing: -.035em; margin: 0; }
.hero .two { color: inherit; }
.sub { margin: 8px 0 0; font-weight: 700; font-size: 17px; }
.motto { text-align: center; font-size: 13px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 26px 0 0; }

/* ------------------------------------------------------------ player: join screen */
.join { max-width: 460px; margin: 0 auto; padding: calc(16px + var(--safe-t)) 16px calc(28px + var(--safe-b)); display: grid; gap: 18px; }
.join .top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* ------------------------------------------------------------ player: buzz screen */
/* full-screen, no scroll, no selection, no long-press menu, no pull-to-refresh */
body.buzzing { position: fixed; inset: 0; overflow: hidden; overscroll-behavior: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.stage { position: fixed; inset: 0; display: grid; grid-template-rows: auto auto 1fr auto; gap: 10px;
  padding: calc(10px + var(--safe-t)) 14px calc(12px + var(--safe-b)); background: var(--paper); }
.stage .bar { display: flex; align-items: center; gap: 10px; min-width: 0; }
.stage .me { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.stage .me strong { font-size: 19px; font-weight: 800; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage .crest { width: 38px; height: 38px; }
.stage .info { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }

.buzz-wrap { display: grid; place-items: center; min-height: 0; }
.buzz {
  --c: var(--gray); --depth: 10px;
  position: relative; width: min(84vw, 56vh, 440px); aspect-ratio: 1; border-radius: 50%;
  display: grid; place-content: center; gap: 4px; text-align: center; padding: 0 8%;
  background: var(--c); color: var(--on-color);
  border: 5px solid var(--ink); box-shadow: 0 var(--depth) 0 var(--shadow);
  font-family: var(--font); cursor: pointer;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: transform 70ms var(--ease-out), box-shadow 70ms var(--ease-out), background-color 120ms ease;
}
.buzz::after { /* glossy rim so the colour reads as a physical button */
  content: ""; position: absolute; inset: 7%; border-radius: 50%; border: 3px solid rgba(255,255,255,.4); pointer-events: none;
}
.buzz .big { font-size: clamp(42px, 15vw, 84px); font-weight: 800; letter-spacing: -.04em; line-height: .95; }
.buzz .small { font-size: clamp(16px, 4.6vw, 22px); font-weight: 800; }
.buzz.down { transform: translateY(calc(var(--depth) - 2px)); box-shadow: 0 2px 0 var(--shadow); }
.buzz[data-s="wait"], .buzz[data-s="closed"] { --c: var(--gray); }
.buzz[data-s="open"] { --c: var(--green); animation: ready 900ms var(--ease-in-out) infinite alternate; }
.buzz[data-s="sent"] { --c: var(--yellow); }
.buzz[data-s="first"] { --c: var(--pink); }
.buzz[data-s="pos"] { --c: var(--yellow); }
.buzz[data-s="out"] { --c: var(--red); color: #fff; }
.buzz[data-s="early"] { --c: var(--orange); animation: shake 320ms var(--ease-out); }
.buzz[data-s="offline"] { --c: var(--purple); color: #fff; }
@keyframes ready { from { box-shadow: 0 var(--depth) 0 var(--shadow), 0 0 0 0 rgba(63,202,69,.0); } to { box-shadow: 0 var(--depth) 0 var(--shadow), 0 0 0 16px rgba(63,202,69,.28); } }
@keyframes shake { 20% { transform: translateX(-10px); } 45% { transform: translateX(9px); } 70% { transform: translateX(-5px); } 100% { transform: none; } }
@media (prefers-reduced-motion: reduce) { .buzz[data-s="open"], .buzz[data-s="early"] { animation: none; } }

.board { display: grid; gap: 6px; max-height: 26vh; overflow: auto; }
.board:empty { display: none; }
.brow { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 6px 10px;
  background: var(--surface); border: var(--bw-sm) solid var(--ink); border-radius: 10px; font-weight: 700; }
.brow .p { font-weight: 800; }
.brow .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brow .g { font-size: 14px; color: var(--muted); }
.brow.first { background: var(--pink); color: var(--on-color); }
.brow.first .g { color: var(--on-color); }
.brow.me { box-shadow: 3px 3px 0 var(--purple); }
.brow.out { opacity: .55; }
.brow.out .n { text-decoration: line-through; }

/* banner shown while the connection is down */
.netbar { position: fixed; z-index: 30; left: 12px; right: 12px; top: calc(10px + var(--safe-t)); padding: 10px 14px;
  background: var(--purple); color: #fff; border: var(--bw) solid var(--ink); border-radius: 12px; box-shadow: var(--sh);
  font-weight: 800; text-align: center; }

/* ------------------------------------------------------------ host */
.host { max-width: 1880px; margin: 0 auto; padding: calc(16px + var(--safe-t)) 18px 40px; }
.host .topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.host .topbar nav { display: flex; gap: 10px; margin-left: auto; }
.host-grid { display: grid; gap: 20px; }
@media (min-width: 1100px) {
  .host-grid { grid-template-columns: 330px minmax(0, 1fr) 360px; align-items: start; }
}
.panel-title { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
.panel-title .count { font-size: 14px; color: var(--muted); }

.joincard { display: grid; gap: 12px; text-align: center; }
.joincard .lbl { font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.joincard .code { font-size: clamp(54px, 5vw, 84px); font-weight: 800; letter-spacing: .12em; line-height: 1; padding-left: .12em; }
.joincard .qr { width: 100%; max-width: 280px; margin: 0 auto; aspect-ratio: 1; background: #fff; border: var(--bw) solid var(--ink); border-radius: 12px; padding: 10px; }
.joincard .qr svg { display: block; width: 100%; height: 100%; }
.joincard .url { font-weight: 800; font-size: 15px; overflow-wrap: anywhere; }

.round-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.round-head h2 { margin: 0; font-size: clamp(28px, 2.6vw, 40px); font-weight: 800; letter-spacing: -.03em; }
.state { font-size: 16px; padding: 5px 14px; }
.state[data-s="idle"] { background: var(--sunk); }
.state[data-s="open"] { background: var(--green); color: var(--on-color); }
.state[data-s="collecting"] { background: var(--yellow); color: var(--on-color); }
.state[data-s="locked"] { background: var(--red); color: #fff; }
.controls { display: grid; gap: 10px; }
.controls .primary { width: 100%; min-height: 76px; font-size: clamp(22px, 2.2vw, 30px); font-weight: 800; letter-spacing: -.01em; }
.controls .primary .icon { width: 28px; height: 28px; }
.ctrl-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; min-height: 38px; }
.ctrl-hint { margin: 0; font-size: 15px; font-weight: 700; color: var(--muted); flex: 1 1 260px; }

.results { margin-top: 18px; display: grid; gap: 12px; container-type: inline-size; }
.hint-big { display: grid; place-items: center; min-height: 260px; padding: 24px; text-align: center; border: var(--bw) dashed var(--ink);
  border-radius: var(--r); color: var(--muted); font-size: clamp(20px, 2vw, 28px); font-weight: 800; }
.hint-big.go { background: var(--green-soft); color: var(--text); border-style: solid; }
.winner { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "place btn" "who who"; align-items: center; gap: 6px 18px; padding: 18px 22px;
  background: var(--pink); color: var(--on-color); border: var(--bw) solid var(--ink); border-radius: var(--r); box-shadow: var(--sh-lg);
  animation: pop 260ms var(--ease-out); }
.winner .place { grid-area: place; font-size: clamp(28px, 6cqi, 48px); font-weight: 800; letter-spacing: -.04em; line-height: 1; }
.winner .whobox { grid-area: who; min-width: 0; }
.winner > .sq { grid-area: btn; }
/* the name scales with the results panel and only breaks between words (a single over-long word may still wrap) */
.winner .who { font-size: clamp(30px, 11cqi, 104px); font-weight: 800; letter-spacing: -.035em; line-height: 1;
  overflow-wrap: break-word; word-break: normal; hyphens: none; text-wrap: balance; }
@container (min-width: 760px) {
  .winner { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "place who btn"; gap: 18px; padding: 22px 26px; }
  .winner .place { font-size: clamp(48px, 9cqi, 100px); line-height: .9; }
  .winner .who { font-size: clamp(40px, 8cqi, 104px); }
}
.winner .meta { font-size: 15px; font-weight: 700; opacity: .8; margin-top: 6px; }
.winner.out { background: var(--sunk); color: var(--muted); }
.winner.out .who { text-decoration: line-through; }
@keyframes pop { from { transform: scale(.96); opacity: .4; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .winner { animation: none; } }

.order { display: grid; gap: 8px; }
.orow { display: grid; grid-template-columns: 54px minmax(0, 1fr) auto auto; align-items: center; gap: 12px; padding: 10px 12px;
  background: var(--surface); border: var(--bw-sm) solid var(--ink); border-radius: 12px; box-shadow: var(--sh-sm); }
.orow .p { font-size: 24px; font-weight: 800; }
.orow .n { font-size: 24px; font-weight: 800; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.orow .g { font-size: 22px; font-weight: 800; }
.orow .d { display: block; font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: 0; }
.orow.out { opacity: .55; }
.orow.out .n { text-decoration: line-through; }

.plist { display: grid; gap: 8px; }
.prow { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 8px 8px 8px 12px;
  background: var(--surface); border: var(--bw-sm) solid var(--ink); border-radius: 12px; }
.prow .n { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow .n small { display: block; font-size: 12px; font-weight: 700; color: var(--muted); }
.prow .ping { font-size: 13px; font-weight: 800; padding: 2px 8px; border-radius: 999px; border: var(--bw-sm) solid var(--ink); }
.ping.good { background: var(--green-soft); } .ping.ok { background: var(--yellow-soft); } .ping.bad { background: var(--red); color: #fff; } .ping.none { background: var(--sunk); color: var(--muted); }
.prow .acts { display: flex; gap: 6px; }
.prow.lo { background: var(--sunk); }
.empty { padding: 22px 14px; text-align: center; border: var(--bw) dashed var(--ink); border-radius: var(--r); color: var(--muted); font-weight: 700; }

.create { max-width: 560px; margin: 6vh auto 0; display: grid; gap: 18px; }

/* dialog */
.dlg { border: var(--bw) solid var(--ink); border-radius: var(--r); box-shadow: var(--sh-lg); padding: 20px; width: min(440px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); }
.dlg::backdrop { background: rgba(18,18,18,.45); }
.dlg h3 { margin: 0 0 14px; font-size: 21px; font-weight: 800; }
.dlg .row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.dlg .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dlg .help { font-size: 13px; font-weight: 600; color: var(--muted); margin: 10px 0 0; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.check input { width: 22px; height: 22px; accent-color: var(--green); }

.toast { position: fixed; z-index: 40; left: 50%; bottom: calc(18px + var(--safe-b)); transform: translateX(-50%); padding: 10px 16px;
  background: var(--text); color: var(--paper); border-radius: 12px; font-weight: 800; box-shadow: var(--sh); max-width: calc(100vw - 32px); }
.keep { position: fixed; left: 0; bottom: 0; width: 1px; height: 1px; opacity: .01; pointer-events: none; }
.create .lead { margin: 0; font-weight: 700; }
.create .hint { margin: 0; font-size: 14px; font-weight: 600; color: var(--muted); }
.minimark { width: 58px; height: auto; flex: none; filter: drop-shadow(2px 2px 0 var(--shadow)); }
.stage .minimark { width: 44px; }
/* projector: buzz order in two columns so 18 results fit without scrolling */
@media (min-width: 1100px) {
  .order { grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); }
  .orow { padding: 8px 10px; }
  .orow .n, .orow .p { font-size: 22px; }
  .orow .g { font-size: 20px; }
}
/* banner title sized by the banner itself: logo above the title when narrow, beside it when wide */
.banner { container-type: inline-size; }
.event { flex-direction: column; align-items: flex-start; gap: 10px; }
.event .mark { width: 84px; }
.hero { font-size: clamp(30px, 13cqi, 60px); }
@container (min-width: 500px) {
  .event { flex-direction: row; align-items: center; gap: 16px; }
  .event .mark { width: 96px; }
  .hero { font-size: clamp(30px, 9cqi, 60px); }
}

/* dark mode: inputs on a deeper well so the box and the typed text stand out */
:root[data-theme="dark"] .input { background: var(--sunk); border-color: #8f8a99; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .input { background: var(--sunk); border-color: #8f8a99; } }
