/* Bomb Busters — styles */

:root {
  --bg-1: #16202e;
  --bg-2: #0a0f17;
  --ink: #eef3f9;
  --dim: #9fb0c3;
  --panel: #1a2432;
  --panel-2: #223044;
  --line: rgba(255, 255, 255, 0.11);
  --amber: #ffb020;
  --wire: #3da9fc;
  --wire-2: #1f7fd1;
  --yellow: #ffd166;
  --red: #ff5d5d;
  --good: #3ddc84;
  --shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: 'Avenir Next', Avenir, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1100px 700px at 50% -10%, rgba(61, 169, 252, 0.16), transparent 60%),
    radial-gradient(900px 600px at 88% 110%, rgba(255, 176, 32, 0.1), transparent 55%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
}

a {
  color: var(--amber);
}

.hidden {
  display: none !important;
}

/* 6 and 9 read upside-down alike — underline them everywhere, like on the tiles */
.u69 {
  text-decoration: underline;
  text-underline-offset: 0.14em;
  text-decoration-thickness: 0.09em;
}

/* ---------------------------------------------------------------- screens */

.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#screen-home,
#screen-lobby {
  justify-content: center;
  padding: 24px;
  gap: 14px;
}

.back-home {
  position: fixed;
  top: 14px;
  left: 16px;
  color: var(--dim);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  z-index: 5;
}

.back-home:hover {
  color: var(--ink);
}

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

.logo {
  margin: 0;
  font-size: clamp(34px, 8vw, 58px);
  font-weight: 900;
  letter-spacing: 0.02em;
  line-height: 1;
  text-shadow: 0 6px 30px rgba(0, 0, 0, 0.55);
}

.logo .spark {
  color: var(--amber);
  margin: 0 0.14em;
  font-size: 0.72em;
  display: inline-block;
  transform: rotate(-12deg);
  animation: snip 2.2s ease-in-out infinite;
}

@keyframes snip {
  0%, 100% { transform: rotate(-12deg) scale(1); }
  12% { transform: rotate(6deg) scale(1.12); }
  24% { transform: rotate(-12deg) scale(1); }
}

.tagline {
  margin: 0 0 10px;
  color: var(--dim);
  text-align: center;
  max-width: 44em;
  line-height: 1.6;
}

.field {
  width: min(340px, 86vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  font-size: 17px;
  padding: 13px 16px;
  outline: none;
}

.field:focus {
  border-color: rgba(255, 176, 32, 0.55);
}

.field::placeholder {
  color: #6e8095;
}

.btn {
  border-radius: var(--radius);
  padding: 13px 22px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.06s ease, filter 0.15s ease;
  box-shadow: var(--shadow);
}

.btn:active {
  transform: translateY(1px) scale(0.99);
}

.btn:disabled {
  filter: grayscale(0.55) brightness(0.65);
  cursor: default;
}

.btn.primary {
  background: linear-gradient(180deg, #ffcf5e, #f09c17);
  color: #40260a;
  width: min(340px, 86vw);
}

.btn.secondary {
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
  box-shadow: none;
  color: var(--dim);
  font-weight: 600;
  padding: 9px 16px;
  font-size: 14px;
}

.btn.slim {
  width: auto;
  padding: 10px 18px;
  font-size: 15px;
}

.join-row {
  display: flex;
  gap: 10px;
  width: min(340px, 86vw);
}

.join-row .field {
  flex: 1;
  width: auto;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
}

.divider {
  color: #6e8095;
  font-size: 13px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(340px, 86vw);
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

#home-status {
  min-height: 22px;
  color: var(--dim);
  text-align: center;
  max-width: 36em;
}

#home-status.error {
  color: #ff9c9c;
}

.small-print {
  color: #6e8095;
  font-size: 12.5px;
  text-align: center;
  max-width: 46em;
  line-height: 1.55;
}

/* ---------------------------------------------------------------- lobby */

.lobby-panel {
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 26px 28px;
  width: min(470px, 92vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 13px;
  box-shadow: var(--shadow);
}

.lobby-label {
  color: var(--dim);
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

#lobby-code {
  font-size: 46px;
  font-weight: 900;
  letter-spacing: 0.32em;
  margin-right: -0.32em;
  color: var(--amber);
  text-shadow: 0 4px 18px rgba(255, 176, 32, 0.25);
  user-select: all;
}

.copy-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

#lobby-players {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 34dvh;
  overflow-y: auto;
}

.seat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
}

.seat-row.empty {
  opacity: 0.4;
  border-style: dashed;
}

.seat-name {
  font-weight: 700;
}

.seat-name.dim {
  color: var(--dim);
  font-weight: 500;
}

.chip {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--dim);
}

.chip.you {
  background: rgba(255, 176, 32, 0.2);
  color: var(--amber);
}

.chip.bot {
  background: rgba(61, 169, 252, 0.24);
  color: #9fd2ff;
}

.kick {
  margin-left: auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--dim);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  flex: none;
}

.kick:hover {
  background: rgba(255, 93, 93, 0.32);
  color: #ffb4b4;
}

#mission-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: center;
}

.mission-pick {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--dim);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
}

.mission-pick.on {
  background: rgba(255, 176, 32, 0.16);
  border-color: rgba(255, 176, 32, 0.6);
  color: var(--amber);
}

.mission-pick:disabled {
  cursor: default;
}

#mission-blurb {
  color: var(--dim);
  font-size: 13.5px;
  text-align: center;
  max-width: 34em;
  line-height: 1.5;
  min-height: 20px;
}

#lobby-hint {
  color: var(--dim);
  font-size: 14px;
  text-align: center;
  min-height: 20px;
}

.av {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  flex: none;
  color: #101418;
}

.av.empty {
  background: rgba(255, 255, 255, 0.07);
  color: var(--dim);
}

.av.bot {
  background: #2c3c52;
  color: #cfe6ff;
  font-size: 17px;
}

.av.s0 { background: #ffb020; }
.av.s1 { background: #3da9fc; }
.av.s2 { background: #3ddc84; }
.av.s3 { background: #ff5d8f; }
.av.s4 { background: #b98aff; }
.av.s5 { background: #63e0dc; }
.av.s6 { background: #ff9c5e; }
.av.s7 { background: #d3e15c; }

/* ---------------------------------------------------------------- topbar */

.topbar {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  flex-wrap: wrap;
  min-height: 50px;
}

#room-chip,
#mission-chip {
  font-weight: 800;
  letter-spacing: 0.12em;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--dim);
}

#mission-chip {
  letter-spacing: 0.03em;
  color: var(--amber);
}

.topbar .spacer {
  flex: 1;
}

/* ---------------------------------------------------------------- board */

#board {
  width: min(1040px, 100%);
  padding: 4px 14px 0;
  display: flex;
  gap: 14px;
  align-items: stretch;
  flex-wrap: wrap;
}

#strip {
  flex: 1 1 460px;
  background: rgba(0, 0, 0, 0.26);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px 16px;
  position: relative;
}

.strip-cells {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 4px;
}

.cell {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 2px 4px;
  text-align: center;
  position: relative;
}

.cell .cv {
  font-weight: 900;
  font-size: 15px;
}

.cell .pips {
  display: flex;
  justify-content: center;
  gap: 2.5px;
  margin-top: 4px;
}

.cell .pip {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.cell .pip.on {
  background: var(--wire);
  border-color: var(--wire);
}

.cell.done {
  opacity: 0.45;
}

.cell.done::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 900;
  color: var(--good);
}

.gapmarks {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 1px;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  pointer-events: none;
}

.gapmark {
  grid-row: 1;
  justify-self: end;
  transform: translateX(50%);
  font-size: 10.5px;
  font-weight: 900;
  border-radius: 6px;
  padding: 1px 5px;
  border: 1px solid rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: 2px;
}

.gapmark.red {
  background: #5b1717;
  color: #ffb4b4;
  border-color: rgba(255, 93, 93, 0.5);
}

.gapmark.yellow {
  background: #574a14;
  color: #ffe9a8;
  border-color: rgba(255, 209, 102, 0.5);
}

.gapmark.gone {
  opacity: 0.42;
  text-decoration: line-through;
}

#board-side {
  flex: 1 1 300px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
}

#dial {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(0, 0, 0, 0.26);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
}

#dial .dlabel {
  font-size: 11.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 800;
  margin-right: 4px;
}

#dial .seg {
  width: 20px;
  height: 14px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid var(--line);
}

#dial .seg.lit {
  background: linear-gradient(180deg, #ff8a5e, #e5484d);
  border-color: #ff8a5e;
  box-shadow: 0 0 8px rgba(229, 72, 77, 0.7);
}

#dial .seg.skull {
  width: 24px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  background: rgba(229, 72, 77, 0.15);
  border-color: rgba(229, 72, 77, 0.5);
}

#dial .dleft {
  margin-left: auto;
  font-size: 12.5px;
  color: var(--dim);
  font-weight: 700;
  white-space: nowrap;
}

#dial.hot .dleft {
  color: #ffb4b4;
}

#dial.tick {
  animation: dialshake 0.5s ease;
}

@keyframes dialshake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

#equipment {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.eq {
  flex: 1 1 86px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  padding: 6px 8px;
  text-align: left;
  position: relative;
  min-width: 86px;
}

.eq .eqv {
  font-weight: 900;
  font-size: 15px;
  color: var(--wire);
}

.eq .eqn {
  display: block;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--ink);
}

.eq .eqs {
  display: block;
  font-size: 10px;
  color: var(--dim);
  margin-top: 2px;
}

.eq.locked {
  opacity: 0.55;
  filter: grayscale(0.6);
}

.eq.ready {
  border-color: rgba(255, 176, 32, 0.65);
  box-shadow: 0 0 10px rgba(255, 176, 32, 0.25);
  cursor: pointer;
}

.eq.ready .eqv {
  color: var(--amber);
}

.eq.used {
  opacity: 0.4;
}

.eq.used .eqn {
  text-decoration: line-through;
}

.eq.on {
  outline: 2px solid var(--amber);
}

/* ---------------------------------------------------------------- table & stands */

#table {
  width: min(1040px, 100%);
  padding: 8px 14px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.seat {
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 12px 10px;
  position: relative;
  min-height: 80px;
}

.seat.turn {
  border-color: rgba(255, 176, 32, 0.65);
  box-shadow: 0 0 0 1px rgba(255, 176, 32, 0.4), 0 0 18px rgba(255, 176, 32, 0.16);
}

.seat.offline {
  opacity: 0.6;
}

.seat-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 7px;
  flex-wrap: wrap;
}

.seat-head .av {
  width: 27px;
  height: 27px;
  font-size: 13px;
}

.seat-head .nm {
  font-weight: 800;
  font-size: 14.5px;
}

.seat-note {
  color: var(--dim);
  font-size: 12.5px;
  font-style: italic;
}

.seat-head .right {
  margin-left: auto;
  display: flex;
  gap: 6px;
  align-items: center;
}

.tag {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--dim);
}

.tag.turn {
  background: rgba(255, 176, 32, 0.22);
  color: var(--amber);
}

.tag.done {
  background: rgba(61, 220, 132, 0.18);
  color: var(--good);
}

.tag.char {
  background: rgba(61, 169, 252, 0.16);
  color: #9fd2ff;
}

.tag.char.spent {
  opacity: 0.5;
  text-decoration: line-through;
}

.stands {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stand {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  min-height: 62px;
  flex-wrap: wrap;
}

.stand-label {
  font-size: 10.5px;
  font-weight: 900;
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 6px;
  margin-right: 5px;
  align-self: center;
}

/* --- wire tiles --------------------------------------------------------- */

.wire {
  width: 34px;
  height: 50px;
  border-radius: 6px;
  position: relative;
  flex: none;
  padding: 0;
  margin-bottom: 12px; /* room for the token chip */
}

.wire .face {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 17px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  border: 1px solid rgba(0, 0, 0, 0.45);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
}

/* hidden back: a standing wire tile seen from behind */
.wire.back .face {
  background:
    linear-gradient(90deg, transparent 46%, rgba(61, 169, 252, 0.5) 46% 54%, transparent 54%),
    linear-gradient(180deg, #232f42, #17202e);
  color: transparent;
}

.wire.back .face::after {
  content: '';
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3da9fc;
  border: 1px solid #0a0f17;
}

button.wire {
  cursor: default;
}

button.wire.can {
  cursor: pointer;
}

button.wire.can:hover .face,
button.wire.can:focus-visible .face {
  transform: translateY(-5px);
  box-shadow: 0 8px 14px rgba(0, 0, 0, 0.5);
}

.wire.blue .face {
  background: linear-gradient(180deg, #56b7ff, #1f7fd1);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.wire.yellow .face {
  background: linear-gradient(180deg, #ffdd80, #f0b429);
  color: #4a3407;
}

.wire.red .face {
  background: linear-gradient(180deg, #ff7a7a, #d92f34);
  color: #fff;
}

.wire .sub {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 9px;
  font-weight: 800;
  opacity: 0.75;
}

.wire.cut {
  opacity: 0.5;
}

.wire.cut .face {
  transform: translateY(9px) scale(0.9);
  box-shadow: none;
}

.wire.cut .face::before {
  content: '✂';
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%) rotate(-90deg);
  font-size: 11px;
  color: var(--dim);
}

.wire.revealed .face {
  outline: 2px solid rgba(61, 220, 132, 0.7);
}

.wire.knownred .face {
  outline: 2px solid rgba(255, 93, 93, 0.85);
  background: linear-gradient(180deg, #3a2020, #251317);
  color: #ff9c9c;
}

.wire.sel .face {
  outline: 3px solid var(--amber);
  transform: translateY(-5px);
}

.wire.choosable .face {
  outline: 2px dashed rgba(255, 176, 32, 0.8);
  animation: pulse-out 1.1s ease-in-out infinite;
}

@keyframes pulse-out {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 176, 32, 0.35); }
  50% { box-shadow: 0 0 0 7px rgba(255, 176, 32, 0); }
}

.wire.ownmatch .face {
  outline: 2px dashed rgba(61, 220, 132, 0.8);
}

.wire.ownpick .face {
  outline: 3px solid var(--good);
}

.wire.boomed .face {
  animation: boomtile 0.8s ease;
  outline: 3px solid var(--red);
}

@keyframes boomtile {
  0% { transform: scale(1); }
  30% { transform: scale(1.35) rotate(6deg); }
  100% { transform: scale(1); }
}

.wire.fx-cut .face {
  animation: cutflash 0.9s ease;
}

@keyframes cutflash {
  0% { box-shadow: 0 0 0 0 rgba(61, 220, 132, 0.8); }
  100% { box-shadow: 0 0 0 14px rgba(61, 220, 132, 0); }
}

.wire.fx-fail .face {
  animation: failshake 0.5s ease;
}

@keyframes failshake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}

.tok {
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 900;
  padding: 1px 6px;
  border-radius: 6px;
  background: #fff;
  color: #1c2634;
  border: 1px solid rgba(0, 0, 0, 0.5);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
  z-index: 2;
}

.tok.yellow {
  background: var(--yellow);
  color: #4a3407;
}

/* ---------------------------------------------------------------- my zone */

#my-zone {
  width: min(1040px, 100%);
  padding: 8px 14px 0;
}

#my-zone .seat {
  background: rgba(61, 169, 252, 0.06);
}

#my-zone .seat.turn {
  border-color: rgba(255, 176, 32, 0.75);
}

/* ---------------------------------------------------------------- action bar */

#action-bar {
  width: min(1040px, 100%);
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 76px;
}

.abar-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  align-items: center;
}

.abar-label {
  color: var(--dim);
  font-size: 13.5px;
  font-weight: 600;
}

.pick {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 13px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}

.pick:hover:not(:disabled) {
  border-color: rgba(255, 176, 32, 0.6);
}

.pick.on {
  background: rgba(255, 176, 32, 0.18);
  border-color: var(--amber);
  color: var(--amber);
}

.pick:disabled {
  opacity: 0.35;
  cursor: default;
}

.pick.spent {
  opacity: 0.3;
  text-decoration: line-through;
}

.pick.mode {
  font-size: 13px;
  font-weight: 700;
}

.pick.go {
  background: linear-gradient(180deg, #ffcf5e, #f09c17);
  color: #40260a;
  border: 0;
}

.pick.solo {
  background: rgba(61, 220, 132, 0.14);
  border-color: rgba(61, 220, 132, 0.5);
}

.pick.danger {
  background: rgba(255, 93, 93, 0.12);
  border-color: rgba(255, 93, 93, 0.45);
}

/* ---------------------------------------------------------------- feed */

#feed {
  position: fixed;
  right: 12px;
  top: 58px;
  width: 300px;
  max-height: min(300px, 34dvh);
  overflow-y: auto;
  background: rgba(10, 14, 22, 0.86);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--dim);
  z-index: 6;
}

.feed-line {
  padding: 2px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.06);
}

.feed-line:last-child {
  border-bottom: 0;
}

/* ---------------------------------------------------------------- chat */

#chat {
  position: fixed;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  z-index: 7;
}

#chat-panel {
  width: 300px;
  height: 340px;
  max-height: 46dvh;
  background: rgba(12, 16, 24, 0.95);
  border: 1px solid var(--line);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.chat-head {
  padding: 9px 13px;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
  border-bottom: 1px solid var(--line);
}

#chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.chat-msg {
  font-size: 13.5px;
  line-height: 1.45;
  word-break: break-word;
}

.chat-time {
  color: #5c6b7e;
  font-size: 11px;
  margin-right: 6px;
  font-variant-numeric: tabular-nums;
}

.chat-name {
  font-weight: 800;
  margin-right: 6px;
}

.chat-name.s0 { color: #ffb020; }
.chat-name.s1 { color: #3da9fc; }
.chat-name.s2 { color: #3ddc84; }
.chat-name.s3 { color: #ff5d8f; }
.chat-name.s4 { color: #b98aff; }
.chat-name.s5 { color: #63e0dc; }
.chat-name.s6 { color: #ff9c5e; }
.chat-name.s7 { color: #d3e15c; }

.chat-msg.mine .chat-text {
  color: #ffe9c4;
}

#chat-form {
  display: flex;
  border-top: 1px solid var(--line);
}

#chat-input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--ink);
  font-size: 14px;
  padding: 11px 12px;
}

.chat-send {
  padding: 0 14px;
  color: var(--amber);
  cursor: pointer;
  font-size: 16px;
}

#chat-toggle {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 20px;
  cursor: pointer;
  box-shadow: var(--shadow);
  position: relative;
}

#chat-unread {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #e5484d;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

#chat-peek {
  max-width: 300px;
  background: rgba(12, 16, 24, 0.95);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow);
}

#chat-peek .chat-text {
  color: var(--dim);
}

.chat-bubble {
  position: absolute;
  top: -10px;
  left: 12px;
  transform: translateY(-100%);
  background: #fff;
  color: #1c2634;
  border-radius: 12px;
  padding: 6px 11px;
  font-size: 13px;
  font-weight: 600;
  max-width: 260px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  z-index: 8;
  pointer-events: none;
  word-break: break-word;
}

.chat-bubble::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 16px;
  border: 6px solid transparent;
  border-top-color: #fff;
  border-bottom: 0;
}

/* ---------------------------------------------------------------- modal */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 12, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 18px;
}

.panel {
  background: linear-gradient(180deg, #1d2836, #131b26);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px 26px;
  width: min(430px, 94vw);
  max-height: 88dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  box-shadow: var(--shadow);
  text-align: center;
}

.panel.wide {
  width: min(640px, 94vw);
  text-align: left;
  align-items: stretch;
}

.panel h2 {
  margin: 0;
  font-size: 24px;
}

.rules {
  margin: 0;
  padding-left: 20px;
  color: var(--dim);
  line-height: 1.6;
  font-size: 14.5px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.rules b,
.rules i {
  color: var(--ink);
}

#equip-ref {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13.5px;
  color: var(--dim);
}

#equip-ref b {
  color: var(--wire);
}

.credit {
  color: #6e8095;
  font-size: 12.5px;
  line-height: 1.55;
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

#res-sub {
  color: var(--dim);
  line-height: 1.5;
}

#res-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.stat-chip {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 13px;
  color: var(--dim);
}

.stat-chip b {
  color: var(--ink);
  font-size: 15px;
}

#res-wait {
  color: var(--dim);
  font-size: 13.5px;
}

/* ---------------------------------------------------------------- toasts, flash */

#toasts {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 30;
  align-items: center;
  pointer-events: none;
}

.toast {
  background: rgba(16, 21, 30, 0.95);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.toast.gone {
  opacity: 0;
  transform: translateY(-8px);
}

.flash {
  position: fixed;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(26px, 6vw, 44px);
  font-weight: 900;
  letter-spacing: 0.04em;
  padding: 14px 34px;
  border-radius: 18px;
  background: rgba(10, 14, 20, 0.92);
  border: 2px solid var(--amber);
  color: var(--amber);
  z-index: 25;
  animation: flashpop 1.6s ease forwards;
  text-align: center;
  pointer-events: none;
}

.flash.gold {
  border-color: var(--good);
  color: var(--good);
}

.flash.bad {
  border-color: var(--red);
  color: var(--red);
}

@keyframes flashpop {
  0% { transform: translate(-50%, -50%) scale(0.6); opacity: 0; }
  12% { transform: translate(-50%, -50%) scale(1.06); opacity: 1; }
  22% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

#boomflash {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 55%, rgba(255, 120, 60, 0.55), rgba(229, 72, 77, 0.35) 45%, rgba(120, 10, 10, 0.65));
  z-index: 24;
  animation: boomfade 1.5s ease forwards;
  pointer-events: none;
}

@keyframes boomfade {
  0% { opacity: 0; }
  8% { opacity: 1; }
  100% { opacity: 0; }
}

#confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 26;
  overflow: hidden;
}

#confetti i {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  0% { transform: translateY(-10px) rotate(0); opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translateY(105dvh) rotate(660deg); opacity: 0; }
}

/* ---------------------------------------------------------------- layout: desktop gutter */

@media (min-width: 1000px) {
  #screen-game {
    /* keep the docked log + chat column clear of the play area */
    padding-right: 320px;
  }
}

/* ---------------------------------------------------------------- narrow screens
   (keep this block at the END of the file: it must win the cascade) */

@media (max-width: 999px) {
  #feed {
    position: static;
    width: auto;
    margin: 8px 14px;
    max-height: 150px;
    order: 9;
  }

  #screen-game {
    padding-bottom: 90px;
  }

  #chat {
    bottom: 10px;
    right: 10px;
  }

  #chat-panel {
    width: min(300px, calc(100vw - 20px));
  }

  .wire {
    width: 28px;
    height: 42px;
  }

  .wire .face {
    font-size: 14px;
  }
}

/* Disconnect banner: the table stalls until the player returns or the host
   resolves it (neutral tones so it reads on any of our palettes) */
#dc-banner { display: none; }
#dc-banner.on { display: flex; flex-direction: column; gap: 6px; margin: 10px auto 2px; max-width: 620px; padding: 0 10px; }
#dc-banner .dc-row { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; background: rgba(255, 92, 92, 0.14); border: 1px solid rgba(255, 92, 92, 0.55); border-radius: 10px; padding: 7px 12px; font-size: 13px; line-height: 1.35; }
#dc-banner .dc-row.covered { background: rgba(127, 127, 127, 0.12); border-color: rgba(127, 127, 127, 0.45); }
#dc-banner .dc-btn { border: 1px solid rgba(127, 127, 127, 0.55); background: rgba(127, 127, 127, 0.16); color: inherit; border-radius: 8px; padding: 4px 10px; font: inherit; font-size: 12.5px; cursor: pointer; white-space: nowrap; }
#dc-banner .dc-btn:hover { background: rgba(127, 127, 127, 0.28); }

/* Observers: watch chip, lobby note, and the shadow-a-player bar */
#watch-chip { display: none; }
#watch-chip.on { display: inline-block; margin-left: 8px; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: rgba(127, 127, 127, 0.16); border: 1px solid rgba(127, 127, 127, 0.4); vertical-align: middle; }
#lobby-watch { display: none; }
#lobby-watch.on { display: block; margin: 6px auto 0; font-size: 12.5px; opacity: 0.85; text-align: center; }
#ob-bar { display: none; }
#ob-bar.on { display: flex; flex-direction: column; gap: 6px; margin: 10px auto 2px; max-width: 620px; padding: 0 10px; }
#ob-bar .ob-row { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; background: rgba(120, 160, 255, 0.12); border: 1px solid rgba(120, 160, 255, 0.5); border-radius: 10px; padding: 7px 12px; font-size: 13px; line-height: 1.35; }
#ob-bar .ob-switch { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
#ob-bar .ob-btn { border: 1px solid rgba(127, 127, 127, 0.55); background: rgba(127, 127, 127, 0.16); color: inherit; border-radius: 8px; padding: 3px 10px; font: inherit; font-size: 12.5px; cursor: pointer; }
#ob-bar .ob-btn:hover { background: rgba(127, 127, 127, 0.28); }
#ob-bar .ob-btn.on { background: rgba(120, 160, 255, 0.3); border-color: rgba(120, 160, 255, 0.75); cursor: default; }

/* Seat claiming / resigning */
#ob-bar .ob-btn.claim { background: rgba(120, 230, 160, 0.18); border-color: rgba(120, 230, 160, 0.6); }
#ob-bar .ob-btn.claim:hover { background: rgba(120, 230, 160, 0.3); }
#lobby-watch button { margin-left: 8px; border: 1px solid rgba(120, 230, 160, 0.6); background: rgba(120, 230, 160, 0.18); color: inherit; border-radius: 8px; padding: 3px 10px; font: inherit; font-size: 12.5px; cursor: pointer; }
#lobby-watch button:hover { background: rgba(120, 230, 160, 0.3); }

/* Announcements must survive any browser width: wrap instead of clipping */
.flash { max-width: min(92vw, 780px); width: max-content; white-space: normal; overflow-wrap: break-word; text-align: center; box-sizing: border-box; }

/* Bubbles on a fixed overlay: flicker-free, unclippable, above the seats */
#bubble-layer { position: fixed; inset: 0; pointer-events: none; z-index: 70; }
#bubble-layer .bubble-stack { position: absolute; display: flex; flex-direction: column; gap: 4px; transform: translate(-50%, calc(-100% - 10px)); }
#bubble-layer .chat-bubble { position: relative; left: auto; top: auto; bottom: auto; right: auto; margin: 0; transform: none; }
#bubble-layer .chat-bubble::after { display: none; }
#bubble-layer .chat-bubble:last-child::after { display: block; left: 50%; right: auto; bottom: -12px; top: auto; transform: translateX(-50%); border: 6px solid transparent; border-top-color: #fff; }
