/* Shared base for all Rowbusters screens. Brand palette: deep violet grounds, lime and
   hot pink accents; Bungee for the logo and titles, Space Grotesk for everything else.
   The block and special colours (js/engine.js) are not part of the brand palette. */
:root {
  --bg: #160B2E;
  --bar: #1A0E36;
  --well: #10071F;      /* sunken areas: playfield, chat, log */
  --panel: #1F1240;
  --panel-2: #251550;
  --row: #1A0F38;       /* list rows inside panels */
  --line: #34205E;
  --line-2: #3D2870;
  --text: #F5F0FF;
  --soft: #C4B8E3;
  --dim: #A99BCB;
  --accent: #C6FF3D;    /* lime */
  --pink: #FF2E88;
  --ink: #160B2E;       /* text on lime or pink */
  --font: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: Bungee, "Arial Black", Impact, system-ui, sans-serif;
  --blue: #2f5bff;
  --red: #e3343c;
  --green: #27c24c;
  --purple: #a63de0;
  --yellow: #f2cf1d;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overscroll-behavior: none;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

canvas { display: block; width: 100%; height: 100%; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: none; }

.hidden { display: none !important; }

/* ---------- overlays */
.rb-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b));
  background: rgba(16, 7, 31, 0.8);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.rb-panel {
  width: 100%; max-width: 340px; margin: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px 18px 16px;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 20px 60px rgba(8, 3, 20, 0.6);
}
.rb-logo { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 30px; }
.rb-mark-wrap { display: flex; }
.rb-mark { width: 1.75em; height: 1.75em; flex: none; }
.rb-word { font: 400 1em/0.95 var(--display); letter-spacing: .01em; color: var(--text); white-space: nowrap; }
.rb-word b { font-weight: 400; color: var(--accent); }
.rb-tagline { text-align: center; color: var(--soft); font-size: 15px; font-weight: 500; margin-top: -4px; }
.rb-title { font: 400 30px/1.1 var(--display); text-align: center; color: var(--text); }
.rb-title span { color: var(--accent); }
.rb-sub { text-align: center; color: var(--accent); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 0.14em; }
.rb-hint { color: var(--dim); font-size: 13px; line-height: 1.45; text-align: center; }
.rb-panel label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--dim); flex: 1; }
.rb-panel input, .rb-panel select {
  font: inherit; font-size: 16px; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; width: 100%;
  -webkit-user-select: text; user-select: text;
}
.rb-row { display: flex; gap: 8px; }
.rb-row label { min-width: 0; }
.rb-panel select { padding: 10px 8px; }
.rb-panel .rb-check { flex-direction: row; align-items: center; gap: 10px; font-size: 14px; color: var(--text); }
.rb-panel .rb-check input { width: 20px; height: 20px; accent-color: var(--accent); }
.rb-fs-hint { font-size: 12px; }
.rb-fs-hint b { color: var(--text); }
.rb-btn-primary {
  background: var(--accent); color: var(--ink); font-weight: 800; font-size: 16px;
  padding: 14px; border-radius: 12px; touch-action: manipulation;
}
.rb-btn-secondary {
  flex: 1; background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  font-weight: 700; font-size: 14px; padding: 12px 8px; border-radius: 12px; touch-action: manipulation;
}
.rb-sound-test { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.rb-sound-test span { font-size: 11px; color: var(--dim); }
.rb-panel-room { max-width: 440px; height: 100%; max-height: 760px; padding: 12px 14px; gap: 8px; }
.rb-panel-room .rb-on-logo { display: none; }
.rb-room { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.rb-room-head { display: flex; gap: 8px; align-items: stretch; }
.rb-room-head .rb-code-box { flex: 1; padding: 4px 8px; }
.rb-room-head .rb-code-box b { font-size: 26px; }
.rb-room-head .rb-btn-secondary { flex: 0 0 96px; }
.rb-panel-room .rb-plist { flex-direction: row; flex-wrap: wrap; gap: 6px; }
.rb-panel-room .rb-plist li { padding: 4px 9px; font-size: 13px; }
.rb-chat { flex: 1; min-height: 120px; overflow-y: auto; -webkit-overflow-scrolling: touch; background: var(--well); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font: 500 14px/20px var(--font); -webkit-user-select: text; user-select: text; }
.rb-chat div { white-space: normal; overflow-wrap: anywhere; }
.rb-chat-form { display: flex; gap: 6px; }
.rb-chat-form input { flex: 1; min-width: 0; font-size: 16px; padding: 10px 12px; border-radius: 10px; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); -webkit-user-select: text; user-select: text; }
.rb-chat-form button { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); font-weight: 700; padding: 0 14px; border-radius: 10px; touch-action: manipulation; }
.rb-host-row { display: flex; gap: 8px; align-items: flex-end; }
.rb-host-row label { flex: 0 0 84px; }
.rb-host-row .rb-btn-primary { flex: 1; }
.rb-version { text-align: center; font-size: 11px; color: var(--dim); }
.rb-linkbtn { color: var(--dim); text-decoration: underline; font-size: 11px; padding: 4px; touch-action: manipulation; }
.rb-room-foot { justify-content: space-between; }
.rb-room-foot .rb-btn-ghost { flex: 1; font-size: 13px; }
.rb-diag { flex: 1; min-height: 160px; overflow: auto; -webkit-overflow-scrolling: touch; background: var(--well); border: 1px solid var(--line); border-radius: 10px; padding: 8px; font: 11px/15px ui-monospace, Menlo, monospace; color: var(--text); white-space: pre-wrap; word-break: break-word; -webkit-user-select: text; user-select: text; }
#rb-diag-sheet { z-index: 70; }
.rb-mp-btn { width: 100%; font-size: 15px; padding: 13px 8px; border-color: var(--pink); color: #fff; background: #3A1540; }
.rb-private-row .rb-btn-secondary { font-size: 13px; padding: 10px 6px; }
.rb-mp-panel { max-width: 460px; gap: 8px; padding: 12px; }
.rb-mp-top { display: flex; align-items: center; gap: 8px; }
.rb-mp-top .rb-logo { font-size: 17px; gap: 7px; justify-content: flex-start; }
.rb-mp-top > span { flex: 1; text-align: right; font-size: 12px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .12em; }
.rb-mp-me { font-size: 12px; color: var(--dim); }
.rb-mp-me b { color: var(--text); }
.rb-h2 { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .12em; margin-top: 4px; }
.rb-rooms { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.rb-rcard { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.rb-rcard .head { display: flex; align-items: baseline; gap: 6px; }
.rb-rcard .name { font: 400 14px var(--display); letter-spacing: .02em; }
.rb-rcard .state { margin-left: auto; font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 999px; white-space: nowrap; }
.st-empty { background: #2A1A55; color: var(--dim); }
.st-wait { background: #2B3A12; color: var(--accent); }
.st-play { background: #4A1238; color: #FF8AC0; }
.rb-seats { display: flex; gap: 3px; }
.rb-seat { flex: 1; min-width: 0; height: 20px; border-radius: 6px; background: var(--well); border: 1px dashed var(--line); font-size: 9px; display: flex; align-items: center; justify-content: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding: 0 2px; color: var(--dim); }
.rb-seat.p { border-style: solid; color: var(--text); font-weight: 700; }
.rb-seat.p1 { background: #1a2a6a; border-color: #2f5bff; }
.rb-seat.p2 { background: #4a3c08; border-color: #f2cf1d; }
.rb-seat.p3 { background: #0f3d1d; border-color: #27c24c; }
.rb-seat.p4 { background: #3b1652; border-color: #a63de0; }
.rb-join { background: var(--accent); color: var(--ink); font-weight: 800; font-size: 13px; padding: 9px 4px; border-radius: 9px; touch-action: manipulation; }
.rb-join:disabled { background: var(--line); color: var(--dim); }
.rb-rank { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.rb-period { display: flex; gap: 4px; margin-bottom: 6px; }
.rb-period button { flex: 1; font-size: 11px; font-weight: 700; padding: 5px; border-radius: 6px; color: var(--dim); background: var(--row); touch-action: manipulation; }
.rb-period button.on { color: var(--ink); background: var(--accent); }
.rb-rank ol { list-style: none; display: flex; flex-direction: column; gap: 3px; }
.rb-rank li { display: grid; grid-template-columns: 22px 1fr auto; gap: 6px; align-items: center; font-size: 13px; padding: 5px 6px; border-radius: 7px; background: var(--row); }
.rb-rank li.empty { display: block; color: var(--dim); font-size: 12px; text-align: center; padding: 10px; }
.rb-rank li .n { font-weight: 800; color: var(--dim); text-align: center; }
.rb-rank li:nth-child(1) .n { color: #ffd84d; } .rb-rank li:nth-child(2) .n { color: #d6dcff; } .rb-rank li:nth-child(3) .n { color: #e0a060; }
.rb-rank li .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.rb-rank li .w { font: 700 13px var(--font); font-variant-numeric: tabular-nums; color: var(--accent); text-align: right; }
.rb-rank li .w small { display: block; font-size: 9px; color: var(--dim); font-weight: 600; }
.rb-rank li.you { outline: 1px solid var(--accent); background: #2B3511; }
.rb-rank-note { font-size: 10px; margin-top: 6px; }
.rb-code-box b.rb-room-name { letter-spacing: .04em; }
.rb-join.watch { background: var(--pink); color: var(--ink); }
.rb-rcard .eye { font-size: 10px; color: var(--dim); }
.rb-plist li.watcher { color: var(--dim); }
.rb-divider { display: flex; align-items: center; gap: 8px; color: var(--dim); font-size: 12px; }
.rb-divider::before, .rb-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.rb-stack { display: flex; flex-direction: column; gap: 10px; }
.rb-code-box { text-align: center; background: var(--panel-2); border: 1px dashed var(--line); border-radius: 12px; padding: 8px; }
.rb-code-box small { display: block; color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; }
.rb-code-box b { font: 400 32px/1.2 var(--display); letter-spacing: .12em; color: var(--accent); }
#rb-code { text-transform: uppercase; font: 400 22px var(--display); letter-spacing: .2em; text-align: center; }
.rb-plist { list-style: none; display: flex; flex-direction: column; gap: 4px; counter-reset: p; }
.rb-plist li { counter-increment: p; background: var(--panel-2); border-radius: 8px; padding: 7px 10px; font-size: 14px; }
.rb-plist li::before { content: counter(p) ". "; color: var(--dim); }
.rb-plist em { font-style: normal; font-size: 11px; color: var(--ink); background: var(--accent); border-radius: 4px; padding: 1px 5px; margin-left: 4px; }
.rb-status { font-size: 13px; color: var(--dim); text-align: center; min-height: 1em; word-break: break-all; }
.rb-status:empty { display: none; }
.rb-status.error { color: #FF8AC0; }
.rb-btn-ghost { color: var(--dim); padding: 8px; touch-action: manipulation; }
.rb-back { color: var(--dim); text-align: center; font-size: 13px; text-decoration: none; }
.rb-winlist { list-style: none; counter-reset: w; display: flex; flex-direction: column; gap: 4px; }
.rb-winlist li {
  counter-increment: w; display: flex; justify-content: space-between;
  background: var(--panel-2); border-radius: 8px; padding: 8px 10px; font-size: 14px;
}
.rb-winlist li span::before { content: counter(w) ". "; color: var(--dim); }
.rb-winlist li b { color: var(--accent); }

/* ---------- log lines (shared colors) */
.log-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log-attack { color: #ff7a7a; }
.log-special { color: #7ad7ff; }
.log-self { color: #9be89b; }
.log-lines { color: #ffd166; }
.log-death { color: #ff5050; font-weight: 700; }
.log-system { color: var(--accent); font-weight: 700; }
.log-chat { color: var(--soft); }
.log-info { color: var(--dim); }

.pressed { filter: brightness(1.5); transform: scale(0.96); }

/* Short screens (phones in landscape): compact lobby so it fits without scrolling. */
@media (max-height: 500px) {
  .rb-overlay { padding-top: calc(8px + var(--safe-t)); padding-bottom: calc(8px + var(--safe-b)); }
  .rb-panel { max-width: 460px; padding: 12px 16px 10px; gap: 7px; }
  .rb-logo { font-size: 22px; }
  .rb-tagline { display: none; }
  .rb-sub { font-size: 11px; }
  .rb-panel > .rb-hint:not(.rb-fs-hint) { display: none; }
  .rb-panel input:not([type=checkbox]), .rb-panel select { padding: 7px 10px; }
  .rb-btn-primary { padding: 10px; }
  .rb-btn-ghost, .rb-back { padding: 2px; }
}
/* Round stats card in the Partyline chat (public rooms) */
.rb-chat .rb-stats { margin: 6px 0; padding: 7px 6px 5px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 9px; font: 500 11px/15px var(--font); }
.rb-stats .rb-st-head { font: 400 12px var(--display); letter-spacing: .02em; color: var(--accent); margin: 0 2px 4px; display: flex; }
.rb-stats .rb-st-head span { margin-left: auto; color: var(--dim); font-weight: 700; }
.rb-stats table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.rb-stats th, .rb-stats td { padding: 3px 2px; text-align: center; white-space: nowrap; }
.rb-stats th { color: var(--dim); font-size: 9px; font-weight: 700; text-transform: uppercase; }
.rb-stats .nm { text-align: left; font-weight: 700; width: 100%; max-width: 0; overflow: hidden; text-overflow: ellipsis; }   /* name takes what's left */
.rb-stats td.nm i { font-style: normal; color: var(--dim); font-weight: 400; font-size: 9px; }
.rb-stats tbody tr { border-top: 1px solid var(--line); }
.rb-stats tr.you td { background: #2B3511; }
.rb-stats ul { list-style: none; margin: 5px 2px 0; display: flex; flex-direction: column; gap: 1px; }
.rb-stats p { margin: 4px 2px 0; color: var(--dim); font-size: 9px; }
.rb-mp-me small { display: block; margin-top: 2px; }
/* Rooms with a special game mode (SNS, Fast) */
.rb-rmode { font-size: 10px; color: var(--dim); margin-top: -3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rb-rmode b { color: var(--ink); background: #3DFFE0; border-radius: 4px; padding: 0 4px; margin-right: 3px; font-weight: 800; }
/* Teams room (room 3): team badges and the A/B picker in the Partyline */
.rb-tm { display: inline-block; min-width: 15px; text-align: center; border-radius: 4px; padding: 0 3px; font-size: 10px; font-weight: 800; color: #fff; line-height: 15px; }
.rb-tm-A { background: #2f7bff; } .rb-tm-B { background: #e0533d; }
.rb-teams { display: flex; gap: 8px; }
.rb-teams button { flex: 1; padding: 8px 6px; border-radius: 10px; font-weight: 800; font-size: 14px; color: #fff; opacity: .55; border: 2px solid transparent; touch-action: manipulation; }
.rb-teams button small { display: block; font-size: 10px; font-weight: 600; opacity: .9; }
.rb-teams button.on { opacity: 1; border-color: #fff; }
.rb-teams button:disabled { opacity: .25; }
/* An odd last room card (room 7) spans the full width of the 2-column grid */
.rb-rooms .rb-rcard:last-child:nth-child(odd) { grid-column: 1 / -1; }
.rb-chat .log-system { font-weight: 600; }
