/* Setback — mobile-first table layout
   Palette: deep felt green, ivory, brass accent. Serif display (Fraunces) for
   the wordmark, headings and score numerals; Source Sans 3 for everything else. */

:root {
  --felt: #1d5a40;
  --felt-light: #276b4d;
  --felt-dark: #143d2c;
  --ink: #0b1d15;
  --panel: rgba(8, 26, 19, 0.78);
  --panel-solid: #0f2a1f;
  --line: rgba(255, 255, 255, 0.11);
  --line-strong: rgba(255, 255, 255, 0.22);
  --cream: #f3ecdc;
  --ivory: #faf6ec;
  --muted: rgba(243, 236, 220, 0.62);
  --faint: rgba(243, 236, 220, 0.4);
  --brass: #d9b45a;
  --brass-deep: #b8923a;
  --red: #b5262e;
  --black: #1a1a1a;
  --ew: #e6c46a;
  --ns: #8fd0ee;
  --card-w: clamp(46px, 14.6vw, 84px);
  --card-h: calc(var(--card-w) * 1.42);
  --trick-w: clamp(38px, 11.5vw, 66px);
  --radius: 10px;
  --display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --noise: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 .07 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

@media (orientation: landscape) and (max-height: 500px) {
  :root {
    --card-w: clamp(40px, 11vh, 64px);
    --trick-w: clamp(32px, 9vh, 52px);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--felt-dark);
  color: var(--cream);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.35;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

a {
  color: var(--cream);
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

h1, h2, h3 {
  font-family: var(--display);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

#app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  background-color: var(--felt);
  background-image:
    var(--noise),
    radial-gradient(110% 80% at 50% 45%, var(--felt-light) 0%, var(--felt) 50%, var(--felt-dark) 100%);
}

/* ------------------------------------------------------------ header */

.top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 12px;
  background: rgba(8, 26, 19, 0.9);
  border-bottom: 1px solid var(--line);
}

.scores {
  display: flex;
  gap: 14px;
}

.score-team {
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  align-items: baseline;
  column-gap: 8px;
  line-height: 1;
}

.score-team .lbl {
  grid-column: 1;
  grid-row: 1;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  max-width: 96px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-team .pts {
  grid-column: 1;
  grid-row: 2;
  margin-top: 3px;
  font-family: var(--display);
  font-size: 24px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.score-team .side {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 10px;
  color: var(--muted);
  padding-left: 8px;
  border-left: 1px solid var(--line);
  white-space: nowrap;
}

.score-team .games::before { content: "games "; color: var(--faint); }
.score-team .sets::before { content: "set "; color: var(--faint); }
.score-team .games:empty, .score-team .sets:empty { display: none; }

.contract {
  flex: 1;
  text-align: center;
  font-size: 12.5px;
  line-height: 1.3;
  color: var(--cream);
}

.contract strong { font-weight: 600; }
.contract .suit-red { color: #f28b8b; }

.menu-btn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: transparent;
  color: var(--cream);
  font-size: 20px;
  line-height: 1;
}

/* ------------------------------------------------------------ status */

.status {
  display: flex;
  justify-content: center;
  gap: 5px;
  padding: 6px 8px 0;
  min-height: 28px;
  flex-wrap: wrap;
}

.chip {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(8, 26, 19, 0.45);
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.chip b { color: var(--cream); font-weight: 600; }
.chip .pt-card { color: var(--cream); font-weight: 700; }
.chip .pt-card.suit-red { color: #f28b8b; }
.chip.ew b { color: var(--ew); }
.chip.ns b { color: var(--ns); }

/* ------------------------------------------------------------- table */

.table {
  position: relative;
  flex: 1;
  min-height: 0;
}

.seat {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  z-index: 2;
}

.pos-top { top: 6px; left: 50%; transform: translateX(-50%); }
.pos-left { left: 6px; top: 50%; transform: translateY(-50%); }
.pos-right { right: 6px; top: 50%; transform: translateY(-50%); }
.pos-bottom { bottom: 4px; left: 50%; transform: translateX(-50%); }

.name {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--cream);
}

/* turn changes are an instant highlight: no transitions here */
.seat.active .name {
  background: var(--brass);
  border-color: var(--brass);
  color: var(--ink);
}

.seat.winner .name {
  background: var(--ivory);
  border-color: var(--brass);
  color: var(--ink);
}

.dealer-badge {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--brass);
  color: var(--ink);
  font-size: 9px;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
}

.seat.active .dealer-badge, .seat.winner .dealer-badge { background: var(--ink); color: var(--brass); }

.backs {
  display: flex;
  gap: 2px;
}

.mini-back, .card.back {
  background-color: #7a1f2b;
  background-image:
    repeating-linear-gradient(45deg, rgba(255, 244, 220, 0.22) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(-45deg, rgba(255, 244, 220, 0.22) 0 1px, transparent 1px 5px);
}

.mini-back {
  width: 12px;
  height: 18px;
  border-radius: 2.5px;
  box-shadow: inset 0 0 0 1.5px var(--ivory), 0 1px 2px rgba(0, 0, 0, 0.35);
}

.pos-left .backs, .pos-right .backs { flex-direction: column; }
.pos-left .mini-back, .pos-right .mini-back { width: 18px; height: 12px; }

.bubble {
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--ivory);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.bubble.pop { animation: pop 0.25s ease-out; }

.bubble.pass { background: rgba(8, 26, 19, 0.5); border: 1px solid var(--line); color: var(--muted); font-weight: 500; }
.bubble.won { background: var(--brass); }

/* ---- trick area */

.trick {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -52%);
  display: grid;
  grid-template-columns: repeat(3, var(--trick-w));
  grid-template-rows: repeat(3, calc(var(--trick-w) * 1.0));
  gap: 2px;
  z-index: 1;
}

.slot { position: relative; }
.slot-top { grid-column: 2; grid-row: 1; }
.slot-left { grid-column: 1; grid-row: 2; }
.slot-right { grid-column: 3; grid-row: 2; }
.slot-bottom { grid-column: 2; grid-row: 3; }

.slot .card {
  position: absolute;
  left: 0;
  top: 0;
}

.slot-left .card { top: 50%; transform: translateY(-50%); }
.slot-right .card { top: 50%; transform: translateY(-50%); }
.slot-top .card { top: auto; bottom: -25%; }
.slot-bottom .card { top: -25%; }

.slot .card.win {
  box-shadow: 0 0 0 2.5px var(--brass), 0 6px 16px rgba(0, 0, 0, 0.45);
}

/* -------------------------------------------------------------- cards */

.card {
  --w: var(--card-w);
  position: relative;
  width: var(--w);
  height: calc(var(--w) * 1.42);
  border-radius: calc(var(--w) * 0.09);
  background: var(--ivory);
  color: var(--black);
  border: 1px solid rgba(0, 0, 0, 0.16);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 4px 10px rgba(0, 0, 0, 0.22);
  padding: 0;
  font-family: var(--sans);
  font-weight: 700;
  flex: 0 0 auto;
  overflow: hidden;
}

.card.small { --w: var(--trick-w); }

.card.red { color: var(--red); }

.card .corner {
  position: absolute;
  top: 5%;
  left: 7%;
  font-size: calc(var(--w) * 0.28);
  line-height: 0.95;
  letter-spacing: -0.02em;
  text-align: center;
}

.card .corner small {
  display: block;
  font-size: 0.78em;
}

.card .corner.br {
  top: auto;
  left: auto;
  bottom: 5%;
  right: 7%;
  transform: rotate(180deg);
}

.card .pip {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--w) * 0.6);
  line-height: 1;
  padding-top: 6%;
}

/* court cards: serif letter inside a thin frame */
.card.face .pip {
  font-family: var(--display);
  font-weight: 600;
  font-size: calc(var(--w) * 0.5);
  padding-top: 4%;
}

.card.face::before {
  content: "";
  position: absolute;
  inset: 22% 24%;
  border: 1px solid currentColor;
  opacity: 0.35;
  border-radius: 2px;
}

.card.trump {
  box-shadow: 0 0 0 2.5px var(--brass), 0 1px 2px rgba(0, 0, 0, 0.25), 0 4px 10px rgba(0, 0, 0, 0.22);
}

.card.back {
  border: 1px solid rgba(0, 0, 0, 0.25);
  box-shadow: inset 0 0 0 calc(var(--w) * 0.05) var(--ivory), 0 1px 2px rgba(0, 0, 0, 0.25), 0 4px 10px rgba(0, 0, 0, 0.22);
}

.hand .card.legal {
  transform: translateY(-8px);
}

.hand .card.dim {
  opacity: 0.45;
}

.hand .card.hint::after {
  content: "★";
  position: absolute;
  top: 3px;
  right: 4px;
  font-size: calc(var(--w) * 0.24);
  color: var(--brass-deep);
}

.card.pop { animation: pop 0.22s ease-out; }
.card.deal { animation: dealIn 0.35s ease-out both; }

@keyframes pop {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes dealIn {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.slot-left .card.pop, .slot-right .card.pop { animation: popSide 0.22s ease-out; }
@keyframes popSide {
  from { transform: translateY(-50%) scale(0.6); opacity: 0; }
  to { transform: translateY(-50%) scale(1); opacity: 1; }
}

/* --------------------------------------------------------- hand area */

.hand-area {
  padding: 6px 8px calc(10px + env(safe-area-inset-bottom));
  background: rgba(8, 26, 19, 0.5);
  border-top: 1px solid var(--line);
}

.prompt {
  text-align: center;
  font-size: 13px;
  min-height: 20px;
  margin-bottom: 8px;
  color: var(--muted);
}

.prompt.you { color: var(--brass); font-weight: 600; }

.hand {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 4px;
  min-height: calc(var(--card-h) + 8px);
  padding-top: 8px;
}

/* ---------------------------------------------------------- bid panel */

.bid-panel {
  position: absolute;
  left: 50%;
  bottom: 12%;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(4, minmax(56px, 72px));
  gap: 8px;
  padding: 10px;
  border-radius: 14px;
  background: rgba(8, 26, 19, 0.9);
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  z-index: 5;
  animation: popX 0.2s ease-out;
}

@keyframes popX {
  from { transform: translateX(-50%) scale(0.7); opacity: 0; }
  to { transform: translateX(-50%) scale(1); opacity: 1; }
}

.bid-panel[hidden] { display: none; }

.bid-btn {
  height: 56px;
  border: 0;
  border-radius: 8px;
  background: var(--ivory);
  color: var(--ink);
  font-family: var(--display);
  font-size: 22px;
  font-weight: 600;
  line-height: 1;
}

.bid-btn[data-bid="0"] {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--cream);
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
}

.bid-btn:disabled {
  background: rgba(243, 236, 220, 0.08);
  border: 1px solid var(--line);
  color: var(--faint);
}

.bid-btn.hint {
  box-shadow: 0 0 0 2.5px var(--brass);
}

.bid-btn small {
  display: block;
  margin-top: 4px;
  font-family: var(--sans);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.6;
}

/* -------------------------------------------------------------- toast */

.toast {
  position: absolute;
  left: 50%;
  top: 34%;
  transform: translate(-50%, -50%);
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(8, 26, 19, 0.92);
  border: 1px solid var(--line-strong);
  color: var(--cream);
  font-size: 15px;
  text-align: center;
  z-index: 6;
  animation: popXY 0.2s ease-out;
  max-width: 80%;
}

@keyframes popXY {
  from { transform: translate(-50%, -50%) scale(0.7); opacity: 0; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.toast[hidden] { display: none; }

/* ------------------------------------------------------------ overlay */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 12, 9, 0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}

.overlay[hidden] { display: none; }

.sheet {
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--panel-solid);
  color: var(--cream);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 16px 16px 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

.sheet h2.win { color: var(--brass); }

.sheet p { margin: 6px 0; line-height: 1.45; }
.sheet .sub { color: var(--muted); font-size: 13.5px; }

.sheet table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 14px;
}

.sheet th, .sheet td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.sheet th:first-child, .sheet td:first-child { text-align: left; }
.sheet th { color: var(--muted); font-weight: 600; font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; }
.sheet td.tot { font-family: var(--display); font-weight: 600; font-size: 17px; }
.sheet td.neg { color: #f0a3a3; }

.sheet .actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

/* ------------------------------------------------------------ buttons */

.btn {
  width: 100%;
  min-height: 50px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--ivory);
  color: var(--ink);
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: 0.005em;
  padding: 0 16px;
}

.btn.secondary {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--cream);
  font-weight: 600;
}

.btn.danger { background: transparent; border-color: rgba(240, 120, 120, 0.4); color: #f0a3a3; font-weight: 600; }

.btn.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  text-align: left;
}

.btn.row span:last-child { color: var(--brass-deep); font-weight: 700; flex: 0 0 auto; }
.btn.secondary.row span:last-child { color: var(--brass); }

.btn.big {
  position: relative;
  min-height: 62px;
  padding: 10px 44px 10px 18px;
  text-align: left;
  font-size: 17px;
}

.btn.big::after {
  content: "›";
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--display);
  font-size: 26px;
  font-weight: 500;
  opacity: 0.55;
  line-height: 1;
}

.btn.big:disabled::after { content: none; }
.btn.big small { display: block; font-size: 12.5px; font-weight: 400; opacity: 0.7; margin-top: 2px; letter-spacing: 0; }
.btn.small { min-height: 38px; font-size: 13.5px; width: auto; padding: 0 14px; }
.btn.row small { display: block; font-size: 12px; font-weight: 400; opacity: 0.7; }
.btn.team.on { border-color: var(--brass); box-shadow: inset 0 0 0 1px var(--brass); }
.btn:disabled { opacity: 0.4; }

.credit {
  margin-top: 16px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

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

.screen {
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(16px + env(safe-area-inset-top)) 18px calc(28px + env(safe-area-inset-bottom));
  background-color: var(--felt);
  background-image:
    var(--noise),
    radial-gradient(120% 90% at 50% 30%, var(--felt-light) 0%, var(--felt) 48%, var(--felt-dark) 100%);
}

.screen[hidden] { display: none; }

.panel {
  max-width: 440px;
  margin: 0 auto;
}

.panel h1 { font-size: 30px; margin: 4px 0 10px; }
.panel h3 {
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brass);
  margin: 22px 0 8px;
}
.panel h3 .sub { text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 400; }
.panel .sub { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 4px 0 12px; }
.panel .center { text-align: center; }
.panel .error { color: #f0a3a3; font-size: 14px; margin: 8px 0; }
.panel .actions { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }

/* ---- home */

.home { text-align: center; padding-top: 7vh; }

.home .fan {
  position: relative;
  height: calc(var(--card-w) * 1.42 + 24px);
  width: calc(var(--card-w) * 2);
  margin: 0 auto 10px;
}

.home .fan .card {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform-origin: 50% 120%;
  cursor: default;
  pointer-events: none;
}

.home .fan .card:nth-child(1) { transform: translateX(-50%) rotate(-16deg); }
.home .fan .card:nth-child(2) { transform: translateX(-50%) rotate(0deg) translateY(-6px); z-index: 1; }
.home .fan .card:nth-child(3) { transform: translateX(-50%) rotate(16deg); }

.home h1 {
  font-size: 48px;
  font-weight: 600;
  margin: 8px 0 4px;
  letter-spacing: -0.02em;
}

.home .tagline {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin: 2px 0 8px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brass);
}

.home .tagline::before, .home .tagline::after {
  content: "";
  width: 28px;
  height: 1px;
  background: var(--brass);
  opacity: 0.6;
}

.home .sub { margin: 0 auto 22px; max-width: 320px; }
.home .actions { margin-top: 20px; text-align: left; }
.home .credit { margin-top: 26px; }

.link-btn {
  background: none; border: 0; color: var(--muted); font-size: 14px; font-weight: 600; padding: 6px 0; margin-bottom: 4px;
}

.input {
  width: 100%;
  min-height: 54px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: rgba(8, 26, 19, 0.45);
  color: var(--cream);
  font-size: 18px;
  padding: 0 14px;
  outline: none;
}

.input::placeholder { color: var(--faint); }
.input:focus { border-color: var(--brass); box-shadow: 0 0 0 1px var(--brass); }
.input.code { text-align: center; letter-spacing: 0.35em; font-family: var(--display); font-size: 30px; font-weight: 600; text-transform: uppercase; }
.lbl { display: block; font-size: 10.5px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin: 8px 0 8px; }

.code-box {
  text-align: center;
  padding: 16px 14px 8px;
  border-radius: 12px;
  background: rgba(8, 26, 19, 0.5);
  border: 1px solid var(--line);
}

.code-big { font-family: var(--display); font-size: 46px; font-weight: 600; letter-spacing: 0.22em; padding-left: 0.22em; line-height: 1; }
.code-actions { display: flex; justify-content: center; gap: 8px; margin: 14px 0 8px; }
.code-box .sub { margin-bottom: 6px; font-size: 13px; }

.players { list-style: none; margin: 0; padding: 0; }
.players li {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: 8px; background: rgba(8, 26, 19, 0.45); border: 1px solid var(--line); margin-bottom: 6px; font-size: 15px; font-weight: 600;
}
.players .team-tag { margin-left: auto; font-size: 12px; font-weight: 400; color: var(--muted); }
.tag { font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; padding: 2px 6px; border-radius: 4px; background: rgba(243, 236, 220, 0.12); color: var(--muted); }

.dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: #6fd59a; box-shadow: 0 0 0 2px rgba(8, 26, 19, 0.35); vertical-align: middle;
}
.dot.off { background: #d06060; }
.name .dot { margin-right: 2px; }

.timer { font-variant-numeric: tabular-nums; font-size: 11px; font-weight: 500; opacity: 0.75; margin-left: 2px; }

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

.chat-btn { position: relative; font-size: 17px; }
.chat-btn[hidden] { display: none; }
.badge {
  position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: #d94a46; color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}
.badge[hidden] { display: none; }

.chat {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  max-width: 560px; margin: 0 auto; height: min(62vh, 520px);
  display: flex; flex-direction: column;
  background: var(--panel-solid); color: var(--cream);
  border: 1px solid var(--line); border-bottom: 0;
  border-radius: 16px 16px 0 0; box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.5);
  padding-bottom: env(safe-area-inset-bottom);
}
.chat[hidden] { display: none; }
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px; font-family: var(--display); font-size: 18px; font-weight: 600; }
.chat-close { background: transparent; border: 1px solid var(--line-strong); color: var(--cream); width: 34px; height: 34px; border-radius: 8px; font-size: 13px; }
.chat-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 14px; display: flex; flex-direction: column; gap: 6px; }
.chat-list .empty { color: var(--muted); font-size: 13px; text-align: center; margin-top: 20px; }
.msg { max-width: 82%; padding: 7px 11px; border-radius: 12px; background: rgba(243, 236, 220, 0.1); border: 1px solid var(--line); font-size: 15px; line-height: 1.35; word-wrap: break-word; align-self: flex-start; }
.msg.mine { align-self: flex-end; background: rgba(217, 180, 90, 0.18); border-color: rgba(217, 180, 90, 0.3); }
.msg .who { display: block; font-size: 11px; color: var(--muted); margin-bottom: 1px; }
.chat-quick { display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px 4px; scrollbar-width: none; }
.chat-quick::-webkit-scrollbar { display: none; }
.chat-quick button { flex: 0 0 auto; border: 1px solid var(--line-strong); border-radius: 999px; padding: 7px 12px; background: transparent; color: var(--cream); font-size: 14px; }
.chat-form { display: flex; gap: 8px; padding: 6px 12px 12px; }
.chat-form .input { min-height: 46px; font-size: 16px; flex: 1; }
.chat-form .btn { min-height: 46px; }

.speech {
  position: absolute; z-index: 6; max-width: 150px;
  padding: 6px 10px; border-radius: 10px; background: var(--ivory); color: var(--ink);
  font-size: 13px; line-height: 1.3; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35); word-wrap: break-word;
}
.pos-top .speech { top: 100%; left: 50%; transform: translateX(-50%); margin-top: 6px; }
.pos-left .speech { left: 100%; top: 0; margin-left: 6px; }
.pos-right .speech { right: 100%; top: 0; margin-right: 6px; }
.pos-bottom .speech { bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 6px; }
