:root { color-scheme: dark;
  --bg: #14171c; --panel: #1d2128; --panel2: #262b33; --line: #343a44;
  --text: #e8eaee; --muted: #9aa3ae; --accent: #e0a526; --good: #3fae6a; --bad: #d4483b;
  --side-blue: #2f6fe0; --side-yellow: #f4d000; --side-red: #d23b2e; --side-green: #2e9d4f;
  --side-orange: #f07f1d; --side-purple: #8a4fd6; --side-white: #f2f2f2; --side-black: #0b0b0b; --side-gray: #7d8590;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* Never let the page slide sideways on a phone, whatever a wide glyph or long name does */
html, body { overflow-x: clip; max-width: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
main { max-width: 1280px; margin: 0 auto; padding: 0 16px 40px; }
button, select, input { font: inherit; color: inherit; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: #0f1216; border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; flex: 1; white-space: nowrap; }
.round { color: var(--accent); margin-left: 6px; }
.me { color: var(--muted); font-size: 14px; display: flex; align-items: center; gap: 6px; }
.me select { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; max-width: 40vw; }
.live { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); flex: none; }
.live.on { background: var(--good); }

.phases { display: flex; max-width: 1280px; margin: 12px auto 0; padding: 0 16px; gap: 3px; }
/* chevrons: each phase's right side is an arrow into the next; the next one's left side is notched to fit */
.phases span { --tip: 14px; flex: 1; text-align: center; padding: 8px calc(var(--tip) + 2px); background: var(--panel);
  color: var(--muted); font-size: 14px; font-weight: 600; white-space: nowrap;
  clip-path: polygon(0 0, calc(100% - var(--tip)) 0, 100% 50%, calc(100% - var(--tip)) 100%, 0 100%, var(--tip) 50%);
  margin-left: calc(var(--tip) * -1 + 3px); }
.phases span:first-child { margin-left: 0; border-radius: 8px 0 0 8px;
  clip-path: polygon(0 0, calc(100% - var(--tip)) 0, 100% 50%, calc(100% - var(--tip)) 100%, 0 100%); }
.phases span.done { color: var(--text); opacity: .55; }
.phases span.now { background: var(--accent); color: #111; }
@media (max-width: 600px) { .phases span { --tip: 10px; font-size: 13px; padding: 8px 12px; } }

.banner { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; margin: 14px 0; padding: 16px; border-radius: 12px; background: var(--panel);
  border-left: 10px solid var(--line); }
.banner .big { font-size: 22px; font-weight: 700; }
.banner .sub { color: var(--muted); margin-top: 4px; }
.banner.mine { box-shadow: 0 0 0 3px var(--accent); animation: pulse 1.6s ease-in-out infinite; }
.banner .you { display: inline-block; background: var(--accent); color: #111; font-weight: 800;
  border-radius: 6px; padding: 2px 8px; margin-bottom: 6px; letter-spacing: .04em; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(224,165,38,.35); } }
@media (prefers-reduced-motion: reduce) { .banner.mine { animation: none; } }

.card { background: var(--panel); border-radius: 12px; padding: 14px; margin-bottom: 14px; }
.card h3 { margin: 0 0 10px; font-size: 16px; }
.muted { color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.sides { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
@media (max-width: 700px) { .sides { grid-template-columns: 1fr; } }
.side { background: var(--panel); border-radius: 12px; overflow: hidden; border-top: 8px solid var(--c, var(--line)); }
.side.active { box-shadow: 0 0 0 2px var(--c); }
.side-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 6px; }
.side-head .name { font-weight: 700; font-size: 18px; flex: 1; }
.tag { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--panel2); color: var(--muted); }
.tag.first { background: var(--accent); color: #111; }
.side .sum { padding: 0 14px 8px; color: var(--muted); font-size: 14px; }
.players { list-style: none; margin: 0; padding: 0; }
.player { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line); }
.player.me { background: rgba(224,165,38,.08); }
.player.out { opacity: .45; }
.player .pname { flex: 1; min-width: 0; }
.player .pname b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player .pname small { color: var(--muted); }
.pips { display: inline-flex; gap: 3px; vertical-align: middle; margin-left: 4px; }
.pips i { width: 10px; height: 10px; border-radius: 3px; border: 1px solid var(--muted); }
.pips i.on { background: var(--good); border-color: var(--good); }

.btn { border: 1px solid var(--line); background: var(--panel2); border-radius: 10px; padding: 10px 14px;
  min-height: 44px; cursor: pointer; font-weight: 600; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #111; }
.btn.go { background: var(--good); border-color: var(--good); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { border-color: var(--bad); color: #ff8b80; background: transparent; }
.btn.small { min-height: 34px; padding: 4px 10px; font-size: 14px; }
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper b { min-width: 1.6em; text-align: center; }

.controls { display: flex; gap: 8px; margin: 6px 0 14px; position: sticky; bottom: 0; padding: 10px 0;
  background: linear-gradient(transparent, var(--bg) 30%); }
.controls #next { flex: 1; }

.order { display: flex; flex-wrap: wrap; gap: 6px; }
.order .step { display: flex; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); font-size: 13px; font-weight: 700; }
.order .step span { padding: 4px 8px; background: var(--c); color: var(--fg); }
.order .step.done { opacity: .35; }
.order .step.current { outline: 2px solid var(--accent); outline-offset: 1px; }

input[type=text], input[type=number], select.in { background: var(--panel2); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 10px; min-height: 44px; }
input[type=number] { width: 5em; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); cursor: pointer; padding: 0; }
.swatch.sel { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg) inset; }
.setup-side { border-left: 6px solid var(--c); padding-left: 10px; margin-bottom: 14px; }
.reminders { margin: 0; padding-left: 20px; }
.reminders li { margin: 4px 0; }

.log, .admin { background: var(--panel); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; }
.log summary, .admin summary { cursor: pointer; font-weight: 600; color: var(--muted); }
.log ol { list-style: none; padding: 0; margin: 8px 0 0; max-height: 300px; overflow: auto; font-size: 14px; }
.log li { padding: 3px 0; border-bottom: 1px solid var(--line); }
.log li span { color: var(--muted); margin-right: 6px; }
.admin .row { margin-top: 10px; }
.foot { color: var(--muted); font-size: 12px; text-align: center; }

.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: #3a1f1c;
  border: 1px solid var(--bad); color: #ffd6d1; padding: 10px 16px; border-radius: 10px; max-width: calc(100% - 32px); z-index: 10; }

.dice { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; }
.dice .roll { display: flex; align-items: center; gap: 8px; }
.dice .faces { font-size: 34px; line-height: 1; }
.dice .total { font-size: 22px; font-weight: 800; }
.dice .win { font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 99px; background: var(--accent); color: #111; }
.ties { font-size: 14px; margin-top: 6px; }
.slots { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(130px, 100%), 1fr)); gap: 6px; }
.slots li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; background: var(--panel2);
  border-left: 6px solid var(--c); font-size: 14px; min-width: 0; }
.slots li .n { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 1.4em; }
.slots li .who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slots li.done { opacity: .35; }
.slots li.now { outline: 2px solid var(--accent); background: #3a3220; font-weight: 700; }
.slots li.mine .who { text-decoration: underline; text-underline-offset: 3px; }
.order-h { display: flex; justify-content: space-between; align-items: baseline; margin: 14px 0 8px; }
.order-h:first-of-type { margin-top: 0; }
.order-h h3 { margin: 0; }
.btn.huge { font-size: 20px; min-height: 64px; width: 100%; }
.banner .btext { flex: 1 1 220px; min-width: 0; }
.banner .done-btn { margin-left: auto; font-size: 18px; min-height: 56px; padding: 10px 18px; }
.banner .who-big { font-size: clamp(54px, 11vw, 96px); font-weight: 800; line-height: 1.12; letter-spacing: -.01em;
  overflow-wrap: anywhere; max-width: 100%; }

.rules { width: min(720px, calc(100% - 32px)); max-height: calc(100% - 48px); padding: 0; border: 1px solid var(--line);
  border-radius: 14px; background: var(--panel); color: var(--text); }
.rules::backdrop { background: rgba(0,0,0,.65); }
.rules-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.rules-head h2 { margin: 0; font-size: 20px; }
.rules-body { padding: 4px 16px 18px; }
.rules-body h3 { display: flex; align-items: center; gap: 10px; margin: 18px 0 6px; font-size: 17px; }
.rules-body .num { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #111; font-weight: 800; font-size: 15px; }
.rules-body ul { margin: 0; padding-left: 22px; }
.rules-body li { margin: 5px 0; }
.ratio { border-collapse: collapse; margin: 10px 0 0 22px; font-size: 14px; }
.ratio caption { text-align: left; color: var(--muted); padding-bottom: 6px; caption-side: top; }
.ratio th, .ratio td { border: 1px solid var(--line); padding: 4px 10px; text-align: center; }
.ratio th { background: var(--panel2); }
#rules-open { white-space: nowrap; }
@media (max-width: 600px) {
  .top { gap: 8px; }
  .top .brand { font-size: 15px; }
  .me-label { display: none; }
  .ratio { margin-left: 0; }
}

/* a player is up: details top left; name centred; instruction right, level with the name; button under the name */
.banner.player-turn { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 16px 16px;
  grid-template-areas: "meta name action" ". btn crit"; }
.banner.player-turn .meta { grid-area: meta; align-self: start; color: var(--muted); font-weight: 400; }
.banner.player-turn .meta .you { margin: 0 6px 0 0; }
.banner.player-turn .who-big { grid-area: name; text-align: center; }
.banner.player-turn .action { grid-area: action; justify-self: end; text-align: right; font-size: 22px; font-weight: 700; }
.banner.player-turn .btn-cell { grid-area: btn; justify-self: center; align-self: start; position: relative; z-index: 1; }
.banner.player-turn .crit-cell { grid-area: crit; justify-self: end; align-self: end; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.btn.done-btn.others { background: var(--panel2); border-color: var(--line); color: var(--muted); opacity: .55; cursor: not-allowed; }
.banner.player-turn .done-btn { margin: 0; }
.banner.player-turn .btn-cell { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.btn.done-btn.started { background: transparent; border-color: var(--good); color: var(--good); opacity: .8; cursor: default; }
.btn.done-btn.started.slow { border-color: var(--bad); color: #ff6b5e; background: rgba(212, 72, 59, .12); opacity: 1; }
.crit-table.ack-table td:first-child, .crit-table.ack-table th:first-child { text-align: left; width: auto; font-weight: 600; white-space: nowrap; }
.ack-table td { text-align: center; }
.ack-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); margin-right: 8px; }
/* Phones: one column. Details, then the name, what to do, a full-width done button, the crit buttons side by side. */
@media (max-width: 600px) {
  .banner.player-turn { grid-template-columns: 1fr; grid-template-areas: "meta" "name" "action" "btn" "crit";
    gap: 6px; padding: 12px 14px 14px; text-align: center; }
  .banner.player-turn .meta { justify-self: stretch; text-align: left; font-size: 14px; }
  .banner.player-turn .who-big { font-size: clamp(52px, 17vw, 76px); margin-top: 2px; justify-self: stretch;
    white-space: nowrap; overflow: hidden; overflow-wrap: normal; }
  .banner.player-turn .action { justify-self: center; text-align: center; font-size: 20px; }
  .banner.player-turn .btn-cell { justify-self: stretch; margin-top: 8px; }
  .banner.player-turn .btn-cell { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .banner.player-turn .done-btn { width: 100%; font-size: 16px; padding: 8px 10px; }
  .banner.player-turn .crit-cell { justify-self: stretch; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
  .banner.player-turn .crit-cell .btn { width: 100%; }
}
.banner.late1 .who-big, .banner.late1 .action { animation: late-grey 1.6s steps(1) infinite; }
.banner.late2 .who-big, .banner.late2 .action { animation: late-red 1.6s steps(1) infinite; }
.banner.late3 .who-big, .banner.late3 .action { animation: late-red .6s steps(1) infinite; }
@keyframes late-grey { 0% { color: var(--accent); } 50% { color: #6b727c; } }
@keyframes late-red { 0% { color: var(--accent); } 50% { color: #ff3b2f; } }

/* Initiative: side A left, title + winner in the middle, side B right */
.init-card { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 12px; }
.init-side .init-name { font-weight: 700; }
.init-side.right { text-align: right; }
.init-roll { display: flex; align-items: center; gap: 8px; min-width: 0; }
.init-side { min-width: 0; }
.init-side .init-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.init-roll .faces { font-family: "DejaVu Sans", "Noto Sans Symbols 2", "Segoe UI Symbol", sans-serif; white-space: nowrap; }
.init-side.right .init-roll { justify-content: flex-end; }
.init-roll .faces { font-size: 38px; line-height: 1; }
.init-roll .total { font-size: 24px; font-weight: 800; }
.init-mid { text-align: center; }
.init-title { font-weight: 700; color: var(--muted); }
.init-winner { display: inline-block; margin-top: 6px; padding: 4px 14px; border-radius: 99px; font-weight: 800;
  font-size: 18px; background: var(--c); color: var(--fg); }
.init-mid .ties { font-size: 12px; margin-top: 4px; }
@media (max-width: 600px) {
  main { padding: 0 12px 40px; }
  .phases { padding: 0 12px; }
  .init-card { gap: 8px; padding: 12px; }
  .init-roll .faces { font-size: 28px; }
  .init-roll .total { font-size: 20px; }
  .init-title { font-size: 13px; }
  .init-winner { font-size: 15px; padding: 3px 10px; }
}

/* 5-minute nag */
.nag { width: min(900px, calc(100% - 24px)); padding: 28px 20px; border: 4px solid #ff2a1f; border-radius: 18px;
  background: #120606; color: #fff; text-align: center; }
.nag::backdrop { background: rgba(60, 0, 0, .8); }
.nag-name { font-size: clamp(64px, 18vw, 180px); font-weight: 900; line-height: 1; overflow-wrap: anywhere;
  animation: nag-a var(--nag-speed, .5s) steps(1) infinite; }
.nag-text { font-size: clamp(30px, 8vw, 72px); font-weight: 900; margin: 16px 0 26px;
  animation: nag-b var(--nag-speed, .5s) steps(1) infinite; }
.nag-ok { font-size: 18px; min-height: 56px; white-space: normal; }
@keyframes nag-a { 0% { color: #ff2a1f; } 50% { color: #fff; } }
@keyframes nag-b { 0% { color: #fff; } 50% { color: #ff2a1f; } }
#initcard .init-card { margin: 14px 0 0; }

/* Crit tables */
.crit-table { border-collapse: collapse; width: 100%; font-size: 15px; margin: 6px 0 4px; }
.crit-table th, .crit-table td { border: 1px solid var(--line); padding: 5px 8px; text-align: left; }
.crit-table th { background: var(--panel2); }
.crit-table td:first-child, .crit-table th:first-child { text-align: center; width: 3.5em; font-weight: 700; }
.crit-table td.none { color: var(--muted); }
.crit-table td.kill { color: #ff8b80; font-weight: 700; }
.rules-body dl { margin: 6px 0 0; }
.rules-body dt { font-weight: 700; margin-top: 8px; }
.rules-body dd { margin: 2px 0 0 0; color: var(--text); }

/* firing arcs diagram (Movement popup) */
.arcs { margin: 12px 0 4px; }
.arcs svg { display: block; width: 100%; max-width: 420px; margin: 0 auto; height: auto; }
.arc-front { fill: rgba(63, 174, 106, .28); stroke: var(--good); stroke-width: 1.5; }
.arc-rear { fill: rgba(154, 163, 174, .10); stroke: var(--line); stroke-width: 1.5; stroke-dasharray: 4 4; }
.arc-hit { fill: rgba(212, 72, 59, .38); stroke: var(--bad); stroke-width: 1.5; }
.arc-line { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.arc-hex { fill: var(--panel2); stroke: var(--text); stroke-width: 2; }
.arc-rearside { stroke: #ff5a4d; stroke-width: 5; stroke-linecap: round; }
.arc-arrow { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.arc-t { fill: var(--text); font-size: 13px; text-anchor: middle; font-family: inherit; }
.arc-t.big { font-size: 17px; font-weight: 800; fill: #8fe0ad; }
.arc-t.small { font-size: 12px; fill: var(--muted); }
.arc-t.tiny { font-size: 10px; fill: var(--accent); font-weight: 700; }
.arc-t.hit { font-size: 13px; font-weight: 700; fill: #ff8b80; }
.arcs figcaption { color: var(--muted); font-size: 14px; margin-top: 6px; }

.rounds summary { cursor: pointer; list-style-position: inside; }
.rounds[open] summary { margin-bottom: 8px; }
.ack-table tfoot td { font-weight: 700; }
.ack-table tfoot tr.first td { border-top: 2px solid var(--muted); }

/* timer under "Starting my turn" */
#start { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15; }
.btn-timer { display: block; font-size: 11px; font-weight: 600; opacity: .75; margin-top: 2px; font-variant-numeric: tabular-nums; letter-spacing: .03em; }

/* footer link + settings */
.linkish { background: none; border: none; padding: 4px 2px; color: var(--muted); font-size: 12px; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.linkish:hover { color: var(--text); }
.set-grid { display: grid; grid-template-columns: 1fr auto; gap: 10px 14px; align-items: center; }
.set-grid input { width: 5.5em; }
.give-dlg { max-width: 460px; }
.roster { display: grid; gap: 14px; }
.rules-body .roster ul.players { padding: 0; }
.rules-body .roster li.player { margin: 0; }
@media (max-width: 600px) {
  .roster .player { flex-wrap: wrap; row-gap: 6px; }
  .roster .player .pname { flex: 1 0 100%; }
  .roster .player .pname small { display: none; }
  .roster .join-row { flex-wrap: wrap; }
  .roster .join-row input[type=text] { flex: 1 0 100%; }
}
.roster-side { border: 1px solid var(--line); border-top-width: 8px; border-top-color: var(--c); }
.roster-side .side-head .muted { font-size: 14px; }
.give-grid { grid-template-columns: auto minmax(0, 1fr); }
.give-grid select { width: 100%; }
.join-row { margin: 0; padding: 10px 14px 12px; border-top: 1px solid var(--line); flex-wrap: nowrap; }
.join-row input[type=text] { flex: 1; min-width: 0; }
.join-row input[type=number] { width: 3.5em; }
.set-teams { grid-template-columns: auto minmax(0, 1fr); margin-bottom: 18px; }
.set-teams input { width: 100%; }
.set-err { color: #ff8b80; min-height: 1.2em; margin: 12px 0 0; font-size: 14px; }

/* escalating wording: red flash = instruction in capitals; fast flash = also "!!!" and the name in capitals */
.banner.late2 .action, .banner.late3 .action { text-transform: uppercase; }
.banner.late3 .action::after { content: "!!!"; }
.banner.late3 .who-big { text-transform: uppercase; }
.nag-wait { font-size: 18px; font-weight: 700; color: #ffb3ab; margin: -14px 0 22px; font-variant-numeric: tabular-nums; }
.nag.nag-hot { animation: nag-shake .4s ease-in-out infinite; }
@keyframes nag-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px) rotate(-.4deg); } 75% { transform: translateX(6px) rotate(.4deg); } }
@media (prefers-reduced-motion: reduce) { .nag.nag-hot { animation: none; } }
.nag-name { text-transform: uppercase; }
