:root {
  --ink: #111418;
  --muted: #4a5563;
  --line: #d4d9e0;
  --paper: #ffffff;
  --wash: #f2f4f7;
  --accent: #1F5FBF;
  --good: #1A7F37;
  --bad: #C8102E;
  --warn: #B85C00;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--paper); }
button, input, select { font: inherit; color: inherit; }
button {
  border: 2px solid var(--ink); background: var(--paper); border-radius: 10px;
  padding: .45em 1em; cursor: pointer; font-weight: 600;
}
button:hover { background: var(--wash); }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--ink); color: #fff; }
button.primary:hover { background: #2b3138; }
button.good { border-color: var(--good); color: var(--good); }
button.good.on { background: var(--good); color: #fff; }
button.bad { border-color: var(--bad); color: var(--bad); }
button.bad.on { background: var(--bad); color: #fff; }
button.small { padding: .2em .6em; font-size: .85em; border-radius: 8px; }
input, select { border: 2px solid var(--line); border-radius: 10px; padding: .45em .7em; background: #fff; }
input:focus, select:focus, button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.chip { background: var(--c, #444); display: inline-block; padding: .1em .6em; border-radius: 999px; color: #fff; font-weight: 700; font-size: .85em; white-space: nowrap; }
.offline { position: fixed; top: 0; left: 0; right: 0; background: var(--warn); color: #fff; text-align: center; padding: .3em; font-weight: 700; z-index: 9; }

/* ---------- host ---------- */
.host { display: grid; grid-template-rows: auto 1fr auto; height: 100vh; }
.host header { display: flex; align-items: center; gap: 1rem; padding: .6rem 1.2rem; border-bottom: 2px solid var(--line); }
.host header h1 { font-size: 1.2rem; margin: 0; }
.host header .join-mini { font-size: 1.15rem; }
.host header .join-mini b { font-size: 1.5rem; letter-spacing: .12em; }
.host main { overflow: auto; padding: 1.2rem; }
.host footer { border-top: 2px solid var(--line); padding: .6rem 1.2rem; }

.lobby { display: grid; grid-template-columns: minmax(300px, 30%) 1fr; gap: 2rem; height: 100%; }
.joinbox { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .6rem; }
.joinbox .label { font-size: 1.3rem; color: var(--muted); }
.joinbox .code { font-size: clamp(4rem, 9vw, 8rem); font-weight: 800; letter-spacing: .15em; line-height: 1; }
.joinbox .url { font-size: 1.5rem; font-weight: 600; word-break: break-all; }
.joinbox img { width: min(100%, 320px); height: auto; border: 2px solid var(--line); border-radius: 12px; }
.joinbox .count { font-size: 1.6rem; font-weight: 700; }
.warnbox { background: #fff4e5; border: 2px solid var(--warn); border-radius: 10px; padding: .5rem .8rem; font-size: .95rem; text-align: left; }

.teams { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-content: start; }
.team { border: 3px solid var(--c); border-radius: 14px; overflow: hidden; min-height: 180px; }
.team h3 { margin: 0; background: var(--c); color: #fff; padding: .5rem .8rem; font-size: 1.4rem; display: flex; justify-content: space-between; }
.team ul { list-style: none; margin: 0; padding: .5rem .8rem; columns: 1; }
.team li { font-size: 1.35rem; padding: .15rem 0; display: flex; justify-content: space-between; gap: .5rem; }
.team li button { visibility: hidden; border-width: 1px; padding: 0 .4em; font-size: .8rem; }
.team li:hover button { visibility: visible; }

.host main:has(.board:not(.hidden)) { padding: .5rem; overflow: hidden; }
.board { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 26%); gap: .6rem; height: 100%; min-height: 0; }
.board.nobell { grid-template-columns: minmax(0, 1fr); }
.stage { display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 0; overflow: hidden; }
.stage img, .stage video { max-width: 100%; max-height: 100%; width: auto; height: auto; display: block; }
.bellpanel { border: 2px solid var(--line); border-radius: 14px; padding: .7rem; display: flex; flex-direction: column; gap: .6rem; min-height: 0; overflow: auto; }
.bellstatus { font-size: 1.05rem; font-weight: 700; padding: .3em .7em; border-radius: 10px; background: var(--wash); text-align: center; }
.bellstatus.open { background: var(--good); color: #fff; }
.bellstatus.closed { background: var(--warn); color: #fff; }
.firstcard { border-radius: 14px; padding: .8rem; background: var(--wash); text-align: center; }
.firstcard.rung { background: var(--c); color: #fff; }
.firsthead { font-size: 1.15rem; font-weight: 700; }
.firstname { font-size: clamp(2.2rem, 4.4vw, 4.4rem); font-weight: 900; line-height: 1.1; overflow-wrap: anywhere; }
.firstteam { font-size: 1.1rem; font-weight: 600; margin-bottom: .5rem; }
.firstcard .verdicts { justify-content: center; }
.firstcard button.small { background: #fff; }
.firstcard button.good.on { background: var(--good); }
.firstcard button.bad.on { background: var(--bad); }
.slidenum { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gotonum { width: 4.6em; }
.segmented { display: inline-flex; gap: .25rem; }
.segmented button.on { background: var(--ink); color: #fff; }
button.jump { border-color: var(--accent); color: var(--accent); }
button.jump.on { background: var(--accent); color: #fff; }
.linkbtn { border: 2px solid var(--accent); color: var(--accent); border-radius: 8px; padding: .2em .6em; font-size: .85em; font-weight: 600; text-decoration: none; }
.firstby { text-align: center; font-size: 1.4rem; font-weight: 800; }
.workspacelink { text-align: center; font-size: 1.1rem; font-weight: 700; color: var(--accent); }
.runpage { max-width: 1400px; margin: 0 auto; padding: 1rem; }
.runpage h1 { font-size: 1.5rem; margin: 0 0 .6rem; }
.runpage table { border-collapse: collapse; width: 100%; font-size: .95rem; }
.runpage th, .runpage td { border: 1px solid var(--line); padding: .35rem .5rem; text-align: left; vertical-align: top; }
.runpage th { background: var(--wash); }
.runpage td.time { white-space: nowrap; font-weight: 700; font-variant-numeric: tabular-nums; }
.runpage p { margin: .6rem 0 0; }

.timer { font-size: 4.5rem; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 3ch; text-align: right; }
.timer.low { color: var(--bad); }
.timer.off { font-size: 1.6rem; color: var(--muted); font-weight: 700; }
.timerctl { display: flex; align-items: center; gap: .5rem; }
.timerctl input { width: 5.2em; }
.switch { border-radius: 999px; min-width: 9.5em; }
.switch.on { background: var(--good); border-color: var(--good); color: #fff; }

.buzzlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.buzz { display: grid; grid-template-columns: 2.2em 1fr auto; gap: .2rem .6rem; align-items: center; padding: .45rem .6rem; border-radius: 10px; border-left: 10px solid var(--c); background: var(--wash); }
.buzz .pos { font-size: 1.6rem; font-weight: 800; }
.buzz .who { font-size: 1.35rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.buzz .t { font-variant-numeric: tabular-nums; font-size: 1.1rem; text-align: right; }
.buzz .sub { grid-column: 2 / 4; display: flex; gap: .5rem; align-items: center; font-size: .95rem; color: var(--muted); }
.buzz .sub .spacer { flex: 1; }
.buzz.v-correct { background: #e6f4ea; }
.buzz.v-wrong { background: #fde8eb; }
.empty { color: var(--muted); font-size: 1.2rem; padding: 1rem 0; }

.scoreboard { display: flex; flex-direction: column; gap: 1rem; max-width: 1100px; margin: 0 auto; }
.scoreboard h2 { font-size: 2.4rem; margin: 0 0 .5rem; }
.sbrow { display: grid; grid-template-columns: 11em 1fr 4em auto; gap: 1rem; align-items: center; font-size: 1.8rem; font-weight: 700; }
.sbbar { height: 2.2rem; border-radius: 8px; background: var(--c); min-width: 6px; }
.sbscore { text-align: right; font-variant-numeric: tabular-nums; }
.miniscore { display: flex; gap: .5rem; flex-wrap: wrap; }
.miniscore .chip { font-size: 1rem; }

.login { max-width: 420px; margin: 15vh auto; display: flex; flex-direction: column; gap: .8rem; }
.err { color: var(--bad); font-weight: 600; min-height: 1.3em; }

/* ---------- player ---------- */
.play { min-height: 100vh; display: flex; flex-direction: column; }
.play .band { background: var(--c, var(--ink)); color: #fff; padding: .9rem 1rem; display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.play .band .tname { font-size: 1.5rem; font-weight: 800; }
.play .band .me { font-size: 1.1rem; font-weight: 600; text-align: right; }
.play .body { flex: 1; display: flex; flex-direction: column; align-items: stretch; gap: 1rem; padding: 1rem; max-width: 720px; width: 100%; margin: 0 auto; }
.play .msg { font-size: 1.6rem; font-weight: 700; text-align: center; margin-top: 1rem; }
.play .q { font-size: 1.3rem; font-weight: 600; line-height: 1.3; }
.play .members { font-size: 1.1rem; color: var(--muted); text-align: center; }
.joinform { max-width: 420px; width: 100%; margin: 10vh auto 0; display: flex; flex-direction: column; gap: .8rem; padding: 1rem; }
.joinform h1 { margin: 0; font-size: 2rem; }
.joinform input { font-size: 1.4rem; padding: .6rem .8rem; }
.joinform input.code { text-transform: uppercase; letter-spacing: .2em; font-weight: 800; }
.joinform button { font-size: 1.4rem; padding: .6rem; }
.bigbuzz {
  flex: 1; min-height: 45vh; width: 100%; border-radius: 28px; border: 0;
  background: var(--c, var(--bad)); color: #fff; font-size: clamp(3rem, 14vw, 6rem); font-weight: 900; letter-spacing: .05em;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
  box-shadow: 0 10px 0 rgba(0,0,0,.25);
}
.bigbuzz:hover { background: var(--c, var(--bad)); filter: brightness(1.08); }
.bigbuzz:active { transform: translateY(6px); box-shadow: 0 4px 0 rgba(0,0,0,.25); }
.bigbuzz small { display: block; font-size: 1.1rem; font-weight: 600; letter-spacing: 0; opacity: .9; }
.bigbuzz:disabled { background: #9aa3ad; box-shadow: none; opacity: 1; }
.pscores { display: flex; flex-direction: column; gap: .4rem; }
.pscores div { display: flex; justify-content: space-between; padding: .5rem .8rem; border-radius: 10px; color: #fff; background: var(--c); font-size: 1.3rem; font-weight: 700; }
.leave { align-self: center; border-width: 1px; font-size: .9rem; color: var(--muted); border-color: var(--line); }
