/* Love Letter — styles */

:root {
  --bg-1: #3b1230;
  --bg-2: #1c0a1c;
  --ink: #f7ecf2;
  --dim: #c0a3b4;
  --panel: #2a1026;
  --panel-2: #371634;
  --line: rgba(255, 255, 255, 0.12);
  --gold: #f2c14e;
  --rose: #e0568a;
  --shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
  --radius: 14px;
  /* card colour per value 0-9 */
  --c0: #64748b;
  --c1: #e5484d;
  --c2: #ef7d21;
  --c3: #d4a017;
  --c4: #4f9d38;
  --c5: #12a594;
  --c6: #3b7fe0;
  --c7: #8257e6;
  --c8: #d6409f;
  --c9: #e8a33d;

  /* Most numbers are shared by two characters, so each card gets its own
     shade of that number's hue: the pair reads as one family but never as
     the same card. */
  --k-assassin: #5b6675;
  --k-jester: #97a6bb;
  --k-guard: #e5484d;
  --k-priest: #ef7d21;
  --k-cardinal: #a84a15;
  --k-baron: #d4a017;
  --k-baroness: #8a6407;
  --k-handmaid: #57a83c;
  --k-sycophant: #276b28;
  --k-prince: #14b0a0;
  --k-count: #0a6a60;
  --k-king: #3b7fe0;
  --k-constable: #234f8e;
  --k-countess: #8f63ee;
  --k-dowager: #55309f;
  --k-princess: #d6409f;
  --k-bishop: #e8a33d;
}

* {
  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(224, 86, 138, 0.2), transparent 60%),
    radial-gradient(900px 600px at 85% 110%, rgba(130, 87, 230, 0.14), 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(--gold);
}

.hidden {
  display: none !important;
}

/* ---------------------------------------------------------------- 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;
}

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

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

.logo {
  margin: 0;
  font-size: clamp(40px, 9vw, 66px);
  font-weight: 900;
  letter-spacing: -0.01em;
  line-height: 1;
  text-shadow: 0 6px 30px rgba(0, 0, 0, 0.5);
}

.logo .heart {
  color: var(--rose);
  margin: 0 0.12em;
  font-size: 0.8em;
  display: inline-block;
  animation: beat 1.6s ease-in-out infinite;
}

@keyframes beat {
  0%, 100% { transform: scale(1); }
  18% { transform: scale(1.16); }
  36% { transform: scale(1); }
}

.tagline {
  margin: 0 0 10px;
  color: var(--dim);
  text-align: center;
  max-width: 38em;
  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(242, 193, 78, 0.55);
}

.field::placeholder {
  color: #8d7383;
}

.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, #ffd977, #e8a52c);
  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: #8d7383;
  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: #8d7383;
  font-size: 12.5px;
  text-align: center;
  max-width: 44em;
  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(430px, 92vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  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(--gold);
  text-shadow: 0 4px 18px rgba(242, 193, 78, 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: 44dvh;
  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(242, 193, 78, 0.2);
  color: var(--gold);
}

.chip.bot {
  background: rgba(130, 87, 230, 0.28);
  color: #cbb4f7;
}

.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(229, 72, 77, 0.32);
  color: #ffb4b4;
}

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

/* ---------------------------------------------------------------- avatars */

.av {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 16px;
  color: #fff;
  flex: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, 0.25);
}

.av.s0 { background: linear-gradient(160deg, #ff7a59, #d33a2c); }
.av.s1 { background: linear-gradient(160deg, #58a6ff, #2f6fd0); }
.av.s2 { background: linear-gradient(160deg, #3dd68c, #1f9d61); }
.av.s3 { background: linear-gradient(160deg, #c084fc, #8a3fd0); }
.av.s4 { background: linear-gradient(160deg, #ffc53d, #d98a0e); }
.av.s5 { background: linear-gradient(160deg, #f472b6, #be185d); }
.av.s6 { background: linear-gradient(160deg, #2dd4bf, #0d9488); }
.av.s7 { background: linear-gradient(160deg, #fb923c, #c2410c); }

.av.empty {
  background: rgba(255, 255, 255, 0.07);
  color: #8d7383;
}

.av.bot {
  background: linear-gradient(160deg, #7c8aa5, #46536e);
  font-size: 18px;
}

/* ---------------------------------------------------------------- game */

#screen-game {
  min-height: 100dvh;
  padding: 10px 14px calc(14px + env(safe-area-inset-bottom));
  gap: 10px;
}

.topbar {
  width: 100%;
  max-width: 1180px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  row-gap: 6px;
  min-height: 50px;
}

#room-chip,
#round-chip {
  font-weight: 800;
  background: rgba(0, 0, 0, 0.26);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12.5px;
  white-space: nowrap;
}

#room-chip {
  color: var(--gold);
  letter-spacing: 0.18em;
}

#round-chip {
  color: var(--dim);
}

.topbar .spacer {
  flex: 1;
}

/* seats */

#table {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  width: 100%;
  max-width: 1180px;
}

.seat {
  position: relative;
  background: rgba(0, 0, 0, 0.26);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 9px 12px;
  min-width: 178px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.seat.me {
  background: rgba(242, 193, 78, 0.08);
}

.seat.turn {
  border-color: rgba(242, 193, 78, 0.85);
  box-shadow: 0 0 0 2px rgba(242, 193, 78, 0.3), 0 0 22px rgba(242, 193, 78, 0.22);
}

.seat.out {
  opacity: 0.55;
}

.seat.offline {
  opacity: 0.42;
}

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

.seat-meta {
  min-width: 0;
}

.seat-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.seat-name-row .nm {
  font-weight: 700;
  font-size: 14px;
  max-width: 11ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shield {
  font-size: 12px;
}

.hearts {
  display: flex;
  gap: 2px;
  margin-top: 2px;
}

.heart {
  color: rgba(255, 255, 255, 0.18);
  font-size: 12px;
  line-height: 1;
}

.heart.on {
  color: var(--rose);
  text-shadow: 0 0 8px rgba(224, 86, 138, 0.6);
}

.tag {
  margin-left: auto;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  padding: 3px 7px;
  border-radius: 999px;
  flex: none;
}

.tag.out {
  background: #4a3040;
  color: #d9bcc9;
}

.tag.off {
  background: #3a3a3a;
  color: #bbb;
}

.tag.syc {
  background: var(--gold);
  color: #40260a;
}

.seat-note {
  color: var(--dim);
  font-size: 11px;
  font-style: italic;
  line-height: 1.35;
}

.pile {
  display: flex;
  gap: 3px;
  min-height: 40px;
  align-items: center;
  flex-wrap: wrap;
}

.pile-empty {
  color: #7d6473;
  font-size: 11px;
  font-style: italic;
}

/* cards */

.card {
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.82);
  color: #fff;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  flex: none;
  overflow: hidden;
  background-color: var(--kc, #5b6675);
  background-image: linear-gradient(165deg, rgba(255, 255, 255, 0.22), rgba(0, 0, 0, 0.1));
}

.k-assassin { --kc: var(--k-assassin); }
.k-jester { --kc: var(--k-jester); }
.k-guard { --kc: var(--k-guard); }
.k-priest { --kc: var(--k-priest); }
.k-cardinal { --kc: var(--k-cardinal); }
.k-baron { --kc: var(--k-baron); }
.k-baroness { --kc: var(--k-baroness); }
.k-handmaid { --kc: var(--k-handmaid); }
.k-sycophant { --kc: var(--k-sycophant); }
.k-prince { --kc: var(--k-prince); }
.k-count { --kc: var(--k-count); }
.k-king { --kc: var(--k-king); }
.k-constable { --kc: var(--k-constable); }
.k-countess { --kc: var(--k-countess); }
.k-dowager { --kc: var(--k-dowager); }
.k-princess { --kc: var(--k-princess); }
.k-bishop { --kc: var(--k-bishop); }


.card.mini {
  width: 34px;
  height: 46px;
  align-items: center;
  justify-content: flex-start;
  padding: 2px 0 0;
  border-width: 1.5px;
  border-radius: 6px;
}

.card.mini .card-val {
  font-size: 17px;
  font-weight: 900;
  line-height: 1;
}

.card.mini .card-name {
  font-size: 7px;
  font-weight: 700;
  text-align: center;
  line-height: 1.05;
  padding: 1px 1px 0;
  opacity: 0.95;
  overflow: hidden;
}

.card.big {
  width: 150px;
  min-height: 208px;
  padding: 10px 11px;
  border-radius: 12px;
  border-width: 3px;
  position: relative;
}

/* how many copies of this card the deck in play holds */
.card-count {
  position: absolute;
  top: 9px;
  right: 10px;
  font-size: 12px;
  font-weight: 800;
  background: rgba(0, 0, 0, 0.26);
  border-radius: 999px;
  padding: 2px 7px;
  letter-spacing: 0.02em;
}

.card.big .card-val {
  font-size: 34px;
  font-weight: 900;
  line-height: 1;
}

.card.big .card-name {
  font-size: 16px;
  font-weight: 800;
  margin-top: 2px;
}

.card.big .card-text {
  margin-top: 8px;
  font-size: 11.5px;
  line-height: 1.4;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.95);
}

/* middle strip */

#middle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  width: 100%;
  max-width: 1180px;
}

/* The deck and its label live in normal flow: an absolutely positioned label
   escapes this box and lands on whatever follows (the intel row). */
#deck {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  flex: none;
}

#deck .stack {
  width: 44px;
  height: 62px;
  border-radius: 8px;
  background: repeating-linear-gradient(135deg, #4a1f3d 0 6px, #5d2a4d 6px 12px);
  border: 2px solid #7b4268;
  box-shadow: -3px 3px 0 #2f1428, -6px 6px 0 #23101f;
  flex: none;
}

.deck-meta {
  display: flex;
  gap: 5px;
  align-items: baseline;
  white-space: nowrap;
}

#deck-count {
  font-weight: 800;
  font-size: 13px;
}

.deck-label {
  color: var(--dim);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

#faceup {
  display: flex;
  align-items: center;
  gap: 4px;
}

.faceup-label {
  color: var(--dim);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-right: 3px;
}

.status {
  min-height: 22px;
  color: var(--dim);
  font-weight: 600;
  text-align: center;
}

.status.mine {
  color: var(--gold);
  animation: glowText 1.4s ease infinite alternate;
}

@keyframes glowText {
  from { text-shadow: 0 0 4px rgba(242, 193, 78, 0.2); }
  to { text-shadow: 0 0 16px rgba(242, 193, 78, 0.6); }
}

/* card tracker: what has been seen of each card type */

#tracker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  max-width: 780px;
}

.trk-label {
  color: var(--dim);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  align-self: center;
  margin-right: 2px;
}

.trk {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px 3px 4px;
}

.trk.spent {
  opacity: 0.45;
}

.trk-val {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 900;
  color: #fff;
  flex: none;
  background: var(--kc, #5b6675);
}


.trk-pips {
  display: flex;
  gap: 3px;
}

.pip {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.42);
  display: block;
}

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

/* intel chips */

#intel {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: center;
  min-height: 30px;
}

.intel-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(242, 193, 78, 0.13);
  border: 1px solid rgba(242, 193, 78, 0.4);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 12px;
}

.intel-chip .who {
  font-weight: 800;
}

.intel-chip .sep {
  color: var(--dim);
}

.intel-chip .what {
  font-weight: 800;
  color: var(--gold);
}

.intel-chip.bet {
  background: rgba(130, 87, 230, 0.16);
  border-color: rgba(180, 140, 250, 0.45);
  color: #d9c6f8;
}

/* hand */

#hand {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
  min-height: 120px;
  padding-top: 12px;
}

/* The button is a stationary hit target; only the artwork inside it lifts, so
   hovering can never move the card out from under the cursor. */
.hand-card {
  cursor: pointer;
  border-radius: 12px;
  position: relative;
  background: none;
  padding: 0;
}

.hand-card .card {
  transition: transform 0.12s ease, box-shadow 0.15s ease, filter 0.2s ease;
}

.hand-card:hover:not(:disabled) .card {
  transform: translateY(-6px);
}

.hand-card.sel .card {
  transform: translateY(-10px);
  box-shadow: 0 0 0 3px var(--gold), 0 0 20px rgba(242, 193, 78, 0.5);
}

.hand-card:disabled {
  cursor: default;
}

.hand-card:disabled .card {
  filter: saturate(0.8) brightness(0.88);
}

.hand-note {
  align-self: center;
  color: var(--dim);
  font-size: 13px;
  max-width: 22em;
  line-height: 1.5;
}

/* action bar */

#action-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 72px;
  max-width: 1000px;
}

#action-bar .ask {
  color: var(--dim);
  font-size: 13.5px;
}

#action-bar .playing {
  font-weight: 800;
  color: var(--gold);
}

.pickrow {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pick {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.pick:hover:not(:disabled) {
  border-color: rgba(242, 193, 78, 0.6);
}

.pick.on {
  background: linear-gradient(180deg, #ffd977, #e8a52c);
  color: #40260a;
  border-color: transparent;
}

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

/* a guess that cannot possibly be right: every copy is already face up */
.pick.spent {
  opacity: 0.3;
  text-decoration: line-through;
}

/* out pop */

.out-pop {
  position: absolute;
  left: 50%;
  top: 4px;
  transform: translateX(-50%);
  color: #ff8080;
  font-weight: 900;
  font-size: 20px;
  letter-spacing: 0.06em;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  animation: outPop 1.4s ease forwards;
}

@keyframes outPop {
  0% { transform: translateX(-50%) scale(0.5); opacity: 0; }
  25% { transform: translateX(-50%) scale(1.15); opacity: 1; }
  75% { opacity: 1; }
  100% { transform: translateX(-50%) translateY(-18px) scale(1); opacity: 0; }
}

/* log */

#feed {
  position: fixed;
  right: 12px;
  top: 60px;
  width: 234px;
  max-height: min(32dvh, 240px);
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.26);
  border: 1px solid var(--line);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
  z-index: 5;
}

#feed:empty {
  display: none;
}

#feed::-webkit-scrollbar {
  width: 8px;
}

#feed::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
}

.feed-line {
  font-size: 12px;
  color: #e7d5e0;
  background: rgba(0, 0, 0, 0.32);
  border-radius: 8px;
  padding: 4px 9px;
  flex: none;
}

@media (min-width: 1080px) {
  #screen-game {
    padding-right: 320px; /* log is 234px, chat panel 300px + 12px margin */
  }
}

/* Below the docked-log breakpoint there is no right-hand gutter, so a floating
   chat button would sit on top of the cards and the action buttons. Chat moves
   up beside the topbar buttons instead and drops its panel down from there. */
@media (max-width: 1079px) {
  #feed {
    position: static;
    width: min(100%, 460px);
    max-height: 96px;
    margin: 0 auto;
  }

  #screen-game {
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }
}

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

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

#chat-toggle {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 20px;
  cursor: pointer;
  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: grid;
  place-items: center;
  padding: 0 4px;
  box-shadow: 0 0 0 2px rgba(28, 10, 28, 0.9);
}

#chat-panel {
  width: min(300px, 92vw);
  background: rgba(22, 8, 22, 0.96);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

#chat-msgs {
  height: min(26dvh, 200px);
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.chat-time {
  margin-right: 6px;
  color: #8d7383;
  font-size: 10.5px;
  line-height: 1.7;
}

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

.chat-name.s0 { color: #ff8a70; }
.chat-name.s1 { color: #6cb1ff; }
.chat-name.s2 { color: #4fe3a3; }
.chat-name.s3 { color: #cf9bff; }
.chat-name.s4 { color: #ffd166; }
.chat-name.s5 { color: #ff9bd0; }
.chat-name.s6 { color: #5fe0d0; }
.chat-name.s7 { color: #ffa96b; }

.chat-msg.mine .chat-name {
  color: var(--gold);
}

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

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

#chat-input::placeholder {
  color: #8d7383;
}

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

#chat-peek {
  max-width: min(260px, 80vw);
  background: rgba(22, 8, 22, 0.96);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 8px 12px;
  font-size: 12.5px;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  word-break: break-word;
}

/* chat bubble over a seat */

.chat-bubble {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  max-width: 200px;
  width: max-content;
  background: linear-gradient(180deg, #fff3d6, #ffe4a8);
  color: #40260a;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  padding: 7px 11px;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
  z-index: 9;
  pointer-events: none;
  animation: bubbleIn 0.22s ease;
}

.chat-bubble::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #ffe4a8;
}

@keyframes bubbleIn {
  from {
    transform: translateX(-50%) translateY(5px) scale(0.9);
    opacity: 0;
  }
  to {
    transform: translateX(-50%) translateY(0) scale(1);
    opacity: 1;
  }
}

/* ---------------------------------------------------------------- overlays */

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

.toast {
  background: rgba(26, 8, 24, 0.94);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 9px 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  box-shadow: var(--shadow);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

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

.flash {
  position: fixed;
  top: 34%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(26px, 6vw, 50px);
  font-weight: 900;
  z-index: 55;
  pointer-events: none;
  text-shadow: 0 6px 30px rgba(0, 0, 0, 0.7);
  animation: flashPop 0.5s ease;
  white-space: nowrap;
  text-align: center;
}

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

@keyframes flashPop {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
  60% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); }
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 4, 10, 0.76);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 70;
  padding: 18px;
}

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

.panel.wide {
  width: min(680px, 94vw);
}

.panel h2 {
  margin: 0;
  font-size: 25px;
  text-align: center;
}

.panel h3 {
  margin: 6px 0 0;
  font-size: 15px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
}

.panel .rules {
  margin: 0;
  padding-left: 20px;
  color: #ecd9e4;
  line-height: 1.6;
  font-size: 14px;
}

.panel .rules li {
  margin-bottom: 7px;
}

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

.panel-label {
  color: var(--dim);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-top: 4px;
}

.credit {
  color: #8d7383;
  font-size: 12px;
  line-height: 1.5;
  margin: 0;
  text-align: center;
}

#card-ref {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.ref-row {
  display: grid;
  grid-template-columns: auto 8.5em 5.5em 1fr;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 6px 10px;
}

.ref-row.absent {
  opacity: 0.45;
}

.ref-count {
  font-weight: 800;
  font-size: 12px;
  color: var(--gold);
}

.ref-row.absent .ref-count {
  color: var(--dim);
  font-weight: 600;
}

.ref-name {
  font-weight: 800;
  font-size: 13px;
}

.ref-text {
  color: #d8c2cf;
  font-size: 12px;
  line-height: 1.4;
}

.reveal-list {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.reveal-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 6px 10px;
}

.reveal-row.won {
  border-color: rgba(242, 193, 78, 0.6);
  background: rgba(242, 193, 78, 0.1);
}

.reveal-name {
  flex: 1;
  font-weight: 700;
  font-size: 14px;
}

.reveal-score {
  font-weight: 800;
  color: var(--gold);
  font-size: 13px;
}

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

#go-rank,
#re-rank {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

#go-sub,
#re-sub {
  color: var(--dim);
  margin: -4px 0 2px;
  text-align: center;
}

.rank-row {
  display: flex;
  align-items: center;
  gap: 11px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 7px 11px;
}

.rank-row.me {
  border-color: rgba(242, 193, 78, 0.6);
}

.rank-row .av {
  width: 30px;
  height: 30px;
  font-size: 13px;
}

.rank-pos {
  font-weight: 900;
  width: 18px;
  text-align: center;
  color: var(--dim);
}

.rank-row:first-child .rank-pos {
  color: var(--gold);
}

.rank-name {
  flex: 1;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-score {
  color: var(--dim);
  font-size: 13px;
  font-weight: 700;
}

.rank-score .delta {
  color: var(--gold);
  font-weight: 900;
}

#go-wait,
#re-wait {
  color: var(--dim);
  font-size: 14px;
  text-align: center;
}

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

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

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

@keyframes fall {
  to {
    transform: translateY(105vh) rotate(720deg);
  }
}

/* ---------------------------------------------------------------- responsive */

@media (max-width: 640px) {
  /* the round chip is the least important thing in a cramped topbar */
  #round-chip {
    display: none;
  }

  #chat-msgs {
    height: min(22dvh, 150px);
  }

  .card.big {
    width: 132px;
    min-height: 190px;
  }

  .card.big .card-val { font-size: 28px; }
  .card.big .card-name { font-size: 14px; }
  .card.big .card-text { font-size: 11px; }

  .seat {
    min-width: 150px;
    padding: 8px 10px;
  }

  .ref-row {
    grid-template-columns: auto 1fr auto;
    grid-template-areas: 'card name count' 'text text text';
  }

  .ref-text {
    grid-area: text;
  }

  .ref-count {
    grid-area: count;
  }
}

/* Below the docked-log breakpoint there is no right-hand gutter, so a floating
   chat button would sit on top of the cards and the action buttons. Chat moves
   up beside the topbar buttons instead, dropping its panel down from there.
   (This block must come after the base #chat rules to win on order.) */
@media (max-width: 1079px) {
  #chat {
    top: 8px;
    bottom: auto;
    left: 12px;
    right: 12px;
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .topbar {
    padding-right: 52px;
  }

  #chat-panel {
    width: min(320px, 100%);
    align-self: flex-end;
  }

  #chat-toggle {
    align-self: flex-end;
    width: 38px;
    height: 38px;
    font-size: 17px;
  }

  #chat-peek {
    align-self: flex-end;
    max-width: min(320px, 100%);
  }
}

/* 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); }

/* Rectangular table: players face each other on the top and bottom edges;
   discard piles sit on each player's table-facing side */
.prow { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; width: 100%; max-width: 1180px; }

/* 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; }

/* Game table-talk: the same bubbles as chat, tinted as the game speaking */
.chat-bubble.say { border: 1px solid rgba(255, 205, 110, 0.75); background: rgba(66, 52, 22, 0.96); color: #ffe9c4; font-weight: 600; }

/* Top-row players speak toward the table: bubbles hang below their seat */
.chat-bubble { max-width: min(200px, 60vw); }
.chat-bubble.below { bottom: auto; top: calc(100% + 8px); }
.chat-bubble.below::after { top: auto; bottom: 100%; border-top-color: transparent; border-bottom-color: #fff3d6; }
.chat-bubble.say::after { border-top-color: rgba(66, 52, 22, 0.96); }
.chat-bubble.say.below::after { border-top-color: transparent; border-bottom-color: rgba(66, 52, 22, 0.96); }

/* Wide windows: round results read side by side instead of one long stack */
@media (min-width: 760px) {
  #roundend .panel { width: min(800px, 94vw); display: grid; grid-template-columns: 1fr 1fr; column-gap: 28px; align-items: start; }
  #roundend .panel > h2 { grid-column: 1 / -1; grid-row: 1; }
  #roundend .panel > #re-sub { grid-column: 1 / -1; grid-row: 2; }
  #roundend .panel > #re-reveal { grid-column: 1; grid-row: 3 / span 2; }
  #roundend .panel > .panel-label { grid-column: 2; grid-row: 3; }
  #roundend .panel > #re-rank { grid-column: 2; grid-row: 4; }
  #roundend .panel > #btn-next-round { grid-column: 1 / -1; grid-row: 5; justify-self: center; }
  #roundend .panel > #re-wait { grid-column: 1 / -1; grid-row: 6; text-align: center; }
}

/* 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: #ffe4a8; }
#bubble-layer .chat-bubble.say:last-child::after { border-top-color: rgba(66, 52, 22, 0.96); }
#row-top { margin-top: 84px; }
.seat { width: 190px; min-height: 176px; }
.seat-note { min-height: 15px; }
.prow .seat { flex: 0 0 190px; }
