/* ---- Design tokens ----
 * The Aurora Borealis painting carries all the colour — the UI itself is a
 * neutral charcoal-and-gold frame painted in translucent layers so the sky
 * shines through. Use rgba for anything that covers the viewport; reserve
 * solid colours for small indicators. */
:root {
  /* Opaque neutrals, used only as fallbacks behind translucent panels. */
  --bg: #08090c;

  /* Translucent surfaces — the aurora shows through all of these. */
  --bg-2: rgba(14, 15, 18, 0.38);
  --bg-3: rgba(22, 24, 28, 0.38);
  --surface: rgba(10, 11, 14, 0.34);
  --surface-2: rgba(20, 22, 26, 0.48);

  /* Borders: warm off-white by default, gold when we want emphasis. */
  --border: rgba(235, 220, 185, 0.14);
  --border-strong: rgba(245, 199, 107, 0.55);

  /* Text: warm white + neutral dim / muted (no more violet tint). */
  --text: #f4efe2;
  --text-dim: #d4ccb8;
  --text-muted: #8f887a;

  --accent: #f5c76b;
  --accent-2: #ffe28a;
  --danger: #e05a7a;
  --ok: #6adf98;
  --info: #9ccbff;

  --card-w: 176px;
  --card-h: 302px;
  /* Hand-card hover/selected growth factor. Tune this (and/or --card-w /
     .hand-cards `gap`) if the hand ever wraps to a new row mid-hover. */
  --hover-scale: 1.10;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.65);

  /* Shared blur stack — kept light so the painting stays visible. */
  --frost: blur(5px) saturate(120%);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100vh;
  overflow: hidden;
}
body {
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  background-color: var(--bg);
  /* Aurora Borealis (Frederic Edwin Church) as the living backdrop. A thin
     dark wash keeps foreground text legible without hiding the painting. */
  background-image:
    linear-gradient(180deg, rgba(0,0,0,0.28) 0%, rgba(0,0,0,0.55) 100%),
    url("assets/aurora.jpg");
  background-repeat: no-repeat, no-repeat;
  background-size: cover, cover;
  background-position: center center, center center;
  background-attachment: fixed, fixed;
  color: var(--text);
  display: flex;
  flex-direction: column;
}

/* ---- Themed scrollbars ---- */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(245, 199, 107, 0.45) rgba(0, 0, 0, 0.35);
}
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.35);
  border-radius: 999px;
}
*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(245,199,107,0.55), rgba(245,199,107,0.28));
  border: 2px solid rgba(0, 0, 0, 0.25);
  border-radius: 999px;
}
*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(255,226,138,0.75), rgba(245,199,107,0.45));
}
*::-webkit-scrollbar-corner { background: transparent; }

h1, h2, h3, h4 { margin: 0; font-family: "Cinzel", "Georgia", serif; letter-spacing: 0.02em; }

button {
  font: inherit;
  color: var(--text);
  background: linear-gradient(180deg, rgba(40,42,48,0.55), rgba(18,19,22,0.65));
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  transition: transform 80ms ease, border-color 120ms ease, background 120ms ease;
  backdrop-filter: var(--frost);
  -webkit-backdrop-filter: var(--frost);
}
button:hover:not([disabled]) { border-color: var(--border-strong); }
button:active:not([disabled]) { transform: translateY(1px); }
button[disabled] { opacity: 0.5; cursor: not-allowed; }
button.primary {
  background: linear-gradient(180deg, rgba(40,32,14,0.82), rgba(18,14,6,0.88));
  border-color: rgba(245, 199, 107, 0.75);
  color: var(--accent-2);
  font-weight: 600;
}
button.primary:hover:not([disabled]) {
  background: linear-gradient(180deg, rgba(58,46,20,0.88), rgba(26,20,8,0.92));
  border-color: var(--accent);
}
button.accent {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  border-color: #c89a3c;
  color: #3a2a06;
  font-weight: 600;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
button.danger {
  background: linear-gradient(180deg, rgba(145, 40, 60, 0.82), rgba(80, 20, 34, 0.9));
  border-color: rgba(224, 90, 122, 0.7);
}
button.ghost {
  background: rgba(0, 0, 0, 0.25);
  border-color: var(--border);
}

input[type="text"], input[type="number"] {
  font: inherit;
  color: var(--text);
  background: rgba(0, 0, 0, 0.38);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  outline: none;
  backdrop-filter: var(--frost);
  -webkit-backdrop-filter: var(--frost);
}
input:focus { border-color: var(--border-strong); }

/* ---- Top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(6,7,10,0.48), rgba(6,7,10,0.24));
  position: relative;
  backdrop-filter: var(--frost);
  -webkit-backdrop-filter: var(--frost);
}
.topbar h1 {
  font-size: 22px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.topbar-right { margin-left: auto; display: flex; gap: 14px; align-items: center; flex: 0 0 auto; }
.help-button {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  font-weight: 700;
  color: var(--accent-2);
}
.player-tag { color: var(--text-dim); font-size: 14px; }
.conn-dot {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.40);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.conn-dot.ok { color: var(--ok); border-color: rgba(106, 223, 152, 0.45); background: rgba(18, 53, 32, 0.55); }
.conn-dot.bad { color: var(--danger); border-color: rgba(224, 90, 122, 0.45); background: rgba(58, 18, 32, 0.55); }

/* ---- Game info (in topbar) ---- */
.game-info {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-left: 24px;
  font-size: 14px;
  color: var(--text-dim);
  min-width: 0;
  flex: 0 0 auto;
  flex-wrap: wrap;
}
.game-info:empty { display: none; }
.game-info .gi-primary {
  font-family: "Cinzel", "Georgia", serif;
  color: var(--accent-2);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.04em;
}
.game-info .gi-sep { color: var(--accent); opacity: 0.45; }

/* ---- Turn indicator (absolutely centred in the topbar) ----
   We take the indicator out of flow so its position is based purely on the
   topbar's width, not on whatever happens to be sitting in the left/right
   slots. That sidesteps the classic "flex center with uneven siblings" offset
   problem. Individual children re-enable pointer events so the pill still
   hovers/clicks correctly. */
.turn-indicator {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  white-space: nowrap;
}
.turn-indicator > * { pointer-events: auto; }
.turn-indicator .your-turn-pill {
  padding: 4px 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: #2a1f06;
  font-weight: 700;
  letter-spacing: 0.06em;
  font-size: 12px;
  animation: pulse 1.2s ease-in-out infinite;
}
.turn-indicator .waiting-line {
  font-family: "Cinzel", "Georgia", serif;
  font-size: 14px;
  letter-spacing: 0.04em;
  line-height: 1.2;
  color: var(--accent-2);
  font-weight: 500;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(245,199,107,0.5); }
  50% { transform: scale(1.04); box-shadow: 0 0 0 10px rgba(245,199,107,0.0); }
}

.app { flex: 1; padding: 20px; overflow: auto; min-height: 0; }
/* In the game view we want everything to fit within the viewport and let the
   individual panels (log, hand, etc.) manage their own overflow. */
.app.app-game { overflow: hidden; padding: 14px 20px; }
.loading { text-align: center; color: var(--text-dim); padding: 60px 0; }

/* ---- Main view ---- */
.main-view { max-width: 900px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.panel {
  background: linear-gradient(180deg, rgba(10,11,14,0.38), rgba(10,11,14,0.22));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: var(--frost);
  -webkit-backdrop-filter: var(--frost);
}
.panel h2 { font-size: 20px; margin-bottom: 12px; color: var(--accent-2); }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { min-width: 0; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
button.compact {
  padding: 4px 8px;
  min-height: 0;
  line-height: 1.1;
  font-size: 12px;
}

.lobby-list { display: flex; flex-direction: column; gap: 8px; }
.lobby-list .empty { color: var(--text-muted); padding: 14px 0; text-align: center; }
.lobby-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.lobby-row .ll-name { font-weight: 600; }
.lobby-row .ll-host { color: var(--text-dim); font-size: 13px; }
.lobby-row .ll-count { color: var(--text-dim); font-size: 13px; }
.lobby-row .ll-mode {
  font-size: 12px;
  color: var(--info);
  background: rgba(156, 203, 255, 0.12);
  border: 1px solid rgba(156, 203, 255, 0.25);
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.lobby-row .ll-status { font-size: 12px; color: var(--info); }
.lobby-row .ll-status.in-progress { color: var(--accent); }

.mode-instructions ul { list-style: disc; }
.mode-instructions li { margin: 2px 0; }

/* ---- Lobby view ---- */
.lobby-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 440px);
  gap: 18px;
  max-width: 1200px;
  margin: 0 auto;
}
.lobby-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.lobby-header h2 { color: var(--accent-2); }
.lobby-view > .panel:first-child {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 120px);
}
.seat-list { display: flex; flex-direction: column; gap: 8px; }
.seat-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.seat-row .seat-idx { color: var(--text-muted); font-size: 12px; width: 22px; }
.seat-row .seat-name {
  font-weight: 600;
  letter-spacing: 0.01em;
}
.seat-row .seat-meta { font-size: 12px; color: var(--text-dim); }
.seat-row .badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.38);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.seat-row .badge.host { color: var(--accent); border-color: rgba(245,199,107,0.55); background: rgba(40, 30, 8, 0.55); }
.seat-row .badge.ready { color: var(--ok); border-color: rgba(106, 223, 152, 0.45); background: rgba(17, 42, 29, 0.55); }
.seat-row .badge.disconnected { color: var(--danger); border-color: rgba(224, 90, 122, 0.45); background: rgba(42, 15, 24, 0.55); }

.badge.mode {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--info);
  background: rgba(156, 203, 255, 0.12);
  border: 1px solid rgba(156, 203, 255, 0.35);
  letter-spacing: 0.02em;
}

.rules-panel {
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text-dim);
  font-size: 13px;
}
.rules-panel h3 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 15px;
}
.rules-panel h4 {
  margin: 10px 0 4px;
  color: var(--text);
  font-size: 13px;
}
.rules-panel ul.mode-instructions-list {
  margin: 0 0 8px;
  padding-left: 18px;
  list-style: disc;
}
.rules-panel ul.mode-instructions-list li {
  margin: 3px 0;
  line-height: 1.35;
}

.lobby-activity {
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  margin-top: auto;
  min-height: 280px;
  padding-top: 14px;
}
.lobby-activity .log-panel {
  flex: 1;
  max-height: 240px;
}

.lobby-rules {
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.lobby-log {
  display: flex;
  flex-direction: column;
  min-height: 200px;
}
.lobby-view .lobby-log { max-height: calc(100vh - 120px); }
.log-panel {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  padding-right: 4px;
  flex: 1;
  min-height: 0;
}
.log-entry {
  font-size: 13px;
  color: var(--text-dim);
  padding: 4px 0;
  border-bottom: 1px dashed rgba(255,255,255,0.05);
  line-height: 1.45;
}
.log-entry:last-child { border-bottom: none; }
.log-entry .log-ts { color: var(--text-muted); font-size: 11px; margin-right: 6px; }
/* Player mentions: coloured per-seat; NOT bold (bold is reserved for cards). */
.log-player {
  font-weight: 500;
  letter-spacing: 0.01em;
}
/* Card mentions: bold + italic, with a subtle underline cue that there's a
   tooltip. Hovering shows the full card tooltip with image. */
.log-card {
  color: var(--accent-2);
  font-weight: 700;
  font-style: italic;
  cursor: help;
  border-bottom: 1px dotted rgba(245, 199, 107, 0.45);
}
.log-card:hover { color: #fff2c8; border-bottom-color: rgba(245, 199, 107, 0.9); }
.log-entry.log-chat { color: var(--text); }
.log-chat-name { font-style: normal; }
.chat-bar {
  display: flex;
  gap: 6px;
  padding-top: 8px;
  margin-top: 4px;
  border-top: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}

/* ---- Game view ---- */
.game-view {
  display: grid;
  grid-template-columns: 1fr 340px;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
  height: 100%;
  max-width: 1700px;
  margin: 0 auto;
  padding: 0 8px;
}
.game-main {
  grid-row: 1 / span 3;
  grid-column: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  min-width: 0;
}
.game-sidebar {
  grid-row: 1 / span 3;
  grid-column: 2;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}

.table {
  flex: 1;
  background: radial-gradient(ellipse at center, rgba(14,15,20,0.22) 0%, rgba(6,7,10,0.55) 82%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow: hidden;
  position: relative;
  backdrop-filter: blur(3px) saturate(115%);
  -webkit-backdrop-filter: blur(3px) saturate(115%);
}

.trick-area {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex: 1;
  padding: 14px;
  min-height: 140px;
  flex-wrap: wrap;
}
.trick-play {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.trick-play.entering { animation: cardIn 300ms ease-out; }
.trick-play.winner .card { box-shadow: var(--shadow); }
.table-hint { color: var(--text-muted); font-size: 14px; }

@keyframes cardIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.9); }
  to { opacity: 1; transform: none; }
}

/* No divider, no info line. The action bar sits directly above the card
   row, and the generous `gap` reserves clearance for a hover-lifted card
   so the buttons stay uncovered. When the action bar is empty (trick
   phase) it collapses via :empty and the gap disappears too. */
.hand-area {
  display: flex;
  flex-direction: column;
  gap: 56px;
  padding-top: 6px;
  min-height: 0;
}
.hand-cards {
  --hand-gap: 8px;
  --hand-card-w: var(--card-w);
  --hand-card-h: var(--card-h);
  display: flex;
  gap: var(--hand-gap);
  flex-wrap: nowrap;
  justify-content: center;
  /* Bottom-align so a card that grows on hover/selected extends upward
     only; keeps every card's baseline flush with the action-bar gap. */
  align-items: flex-end;
  padding: 4px;
  min-width: 0;
  /* Reserve enough vertical room for a card at its hover/selected size.
     Without this, growing a hand card pushes .hand-area taller, which
     shrinks the flex:1 .trick-area above — causing the discard hint /
     action buttons / played cards to drift as they recenter.
     We add 16px on top of the grown card height: 8px covers the top+bottom
     padding (global box-sizing: border-box means min-height includes it,
     so otherwise the card clips the content area and expands the box),
     and the remaining 8px is slack so nothing shifts by a pixel or two. */
  min-height: calc(var(--hand-card-h) * var(--hover-scale) + 16px);
}
.action-bar {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  padding: 2px 10px;
  min-height: 0;
  position: relative;
  z-index: 2;
}
.action-bar .action-hint { color: var(--text-dim); font-size: 13px; }
.action-bar button { padding: 8px 18px; font-size: 14px; }
.action-bar:empty { display: none; }

.card {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.55);
  box-shadow: var(--shadow);
  background: #0a0b0e;
  position: relative;
  cursor: default;
  transition: transform 220ms cubic-bezier(0.2, 0.9, 0.3, 1.2),
              box-shadow 220ms ease;
  flex-shrink: 0;
}
.card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 5px;
  display: block;
  user-select: none;
  pointer-events: none;
}
.card.clickable { cursor: pointer; }
/* Small lift for generic clickable cards (outside the hand). */
.card.clickable:hover:not(.suppress-hover) {
  transform: translateY(-8px);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.65);
}
.card.illegal { opacity: 0.35; filter: grayscale(0.6); }
.card.small { --card-w: 102px; --card-h: 175px; }

/* Hand cards: hovered and selected share the exact same geometry.
 *   - hover  = transient lift while the mouse is on the card
 *   - selected = pinned lift (survives mouseleave) + gold ring
 *   - suppress-hover = the card was JUST unselected while still being
 *     hovered; we drop it back to base size until the mouse leaves and
 *     re-enters, then the normal hover lift resumes. */
/* Width/height animation is scoped here (not on `.card`) so it only fires
   for hand cards. Trick-area and generic `.card.small` cards keep their
   transform+shadow transition but never animate size, so nothing slides
   around in the trick area when sizes change (viewport breakpoints,
   class flips, etc.). */
.hand-cards .card {
  width: var(--hand-card-w);
  height: var(--hand-card-h);
  z-index: 1;
  transition: transform 220ms cubic-bezier(0.2, 0.9, 0.3, 1.2),
              box-shadow 220ms ease,
              width 220ms cubic-bezier(0.2, 0.9, 0.3, 1.2),
              height 220ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.hand-cards.sizing .card {
  transition: none;
}

/* Shared geometry for hover and selected.
 *
 * We grow the card's *layout box* (width/height) instead of applying a
 * compositor scale(). Reason: scale() bilinearly stretches the already-
 * downscaled raster of the <img>, producing visible blur/aliasing. Growing
 * width/height re-rasters the <img> from the full-resolution source at the
 * new size, so the hovered card is pixel-perfect. Neighbors slide aside via
 * the flex layout, which doubles as the "hand breathing open" effect. */
.hand-cards .card.clickable:hover:not(.suppress-hover),
.hand-cards .card.selected {
  width: calc(var(--hand-card-w) * var(--hover-scale));
  height: calc(var(--hand-card-h) * var(--hover-scale));
  transform: translateY(-18px);
  z-index: 20;
}
/* Hover-only shadow (no ring). */
.hand-cards .card.clickable:hover:not(.suppress-hover) {
  box-shadow: 0 22px 40px rgba(0, 0, 0, 0.7);
}
/* Gold ring marks "pinned". Listed so it wins whether the card is merely
   selected OR selected + hovered — otherwise the hover shadow above would
   clobber the ring while the cursor sits on the card. */
.hand-cards .card.selected,
.hand-cards .card.clickable.selected:hover:not(.suppress-hover) {
  box-shadow: 0 0 0 4px var(--accent), 0 22px 40px rgba(0, 0, 0, 0.6);
}

.sidebar-tabs { display: flex; gap: 6px; }
.sidebar-tabs button {
  flex: 1;
  padding: 6px 10px;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid var(--border);
}
.sidebar-tabs button.active {
  background: rgba(245, 199, 107, 0.12);
  border-color: var(--border-strong);
  color: var(--accent-2);
}

.score-table { width: 100%; border-collapse: separate; border-spacing: 0 4px; }
.score-table th, .score-table td {
  padding: 6px 8px;
  text-align: left;
  border-top: 1px solid transparent;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 13px;
}
.score-table th { color: var(--text-muted); font-weight: 500; }
.score-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.score-table tr.leader td { color: var(--accent-2); font-weight: 600; }
.score-table .player-name {
  color: var(--player-color);
  font-weight: 600;
}
.score-table tbody tr.has-acted td,
.score-table tbody tr.on-clock td {
  background: linear-gradient(90deg, rgba(245,199,107,0.13), rgba(245,199,107,0.045));
  border-top-color: rgba(245,199,107,0.16);
  border-bottom-color: rgba(245,199,107,0.12);
}
.score-table tbody tr.has-acted td:first-child,
.score-table tbody tr.on-clock td:first-child {
  border-left: 1px solid rgba(245,199,107,0.14);
  border-radius: 8px 0 0 8px;
}
.score-table tbody tr.has-acted td:last-child,
.score-table tbody tr.on-clock td:last-child {
  border-right: 1px solid rgba(245,199,107,0.1);
  border-radius: 0 8px 8px 0;
}
.score-table tbody tr.on-clock td {
  border-top-color: rgba(245,199,107,0.58);
  border-bottom-color: rgba(245,199,107,0.48);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), inset 0 -1px 0 rgba(0,0,0,0.18);
}
.score-table tbody tr.on-clock td:first-child {
  border-left-color: var(--accent);
  box-shadow:
    inset 3px 0 0 var(--player-color),
    -5px 0 14px color-mix(in srgb, var(--player-color) 32%, transparent);
}
.score-table tbody tr.on-clock td:last-child {
  border-right-color: rgba(245,199,107,0.58);
}
.score-table tr.offline td { opacity: 0.5; }
.seat-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--player-color);
  margin-right: 8px;
  vertical-align: middle;
  opacity: 0.86;
}

.hand-result {
  min-width: min(420px, 90vw);
  padding: 18px;
  background: linear-gradient(180deg, rgba(10,11,14,0.38), rgba(10,11,14,0.22));
  border: 1px solid var(--accent);
  border-radius: 10px;
  backdrop-filter: var(--frost);
  -webkit-backdrop-filter: var(--frost);
}
.hand-result h3 {
  color: var(--accent);
  margin-bottom: 12px;
  text-align: center;
}
.hand-result-rows {
  display: grid;
  gap: 8px;
}
.hand-result-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 16px;
  align-items: baseline;
  padding: 8px 10px;
  background: rgba(255,255,255,0.035);
  border: 1px solid rgba(255,255,255,0.06);
  border-left: 3px solid var(--player-color);
  border-radius: 8px;
}
.hand-result-row .player-name {
  color: var(--player-color);
  font-weight: 700;
}
.hand-result-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hand-result-delta,
.hand-result-total {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.hand-result-delta {
  color: var(--accent-2);
  font-weight: 700;
}
.hand-result-delta.positive {
  color: var(--ok);
}
.hand-result-delta.negative {
  color: var(--danger);
}
.hand-result-total {
  color: var(--text-dim);
}

.gameover-view {
  max-width: 700px;
  margin: 40px auto;
  text-align: center;
}
.gameover-view h2 {
  font-size: 32px;
  color: var(--accent-2);
  margin-bottom: 20px;
}
.gameover-view .standings { margin: 20px 0; }

/* ---- Toasts ---- */
.toast-root {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  pointer-events: none;
}
.toast {
  background: rgba(10, 11, 14, 0.72);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 10px 14px;
  max-width: 320px;
  box-shadow: var(--shadow);
  animation: toastIn 180ms ease-out;
  backdrop-filter: var(--frost);
  -webkit-backdrop-filter: var(--frost);
}
.toast.error { border-color: var(--danger); background: rgba(54, 22, 42, 0.82); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ---- Help modal ---- */
.help-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.help-modal {
  width: min(720px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: linear-gradient(180deg, rgba(10,11,14,0.9), rgba(10,11,14,0.78));
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.75);
  padding: 18px;
}
.help-modal-header {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
}
.help-modal-header h2 {
  color: var(--accent-2);
  font-size: 22px;
  margin-bottom: 4px;
}
.help-modal-summary {
  color: var(--text-dim);
  font-size: 13px;
}
.help-modal-close { flex: 0 0 auto; }
.help-modal-rules {
  overflow-y: auto;
  min-height: 0;
}

/* ---- Card tooltip (floating-ui) ---- */
.card-tooltip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2000;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
  max-width: 360px;
  background: linear-gradient(180deg, rgba(10,11,14,0.85), rgba(6,7,10,0.82));
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.7);
  padding: 12px;
  backdrop-filter: var(--frost);
  -webkit-backdrop-filter: var(--frost);
}
.card-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}
.card-tip {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.card-tip-img {
  width: 140px;
  height: 240px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.6);
  flex-shrink: 0;
  user-select: none;
}
.card-tip-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 150px;
}
.card-tip.card-tip-compact { padding: 0; }
.card-tip.card-tip-compact .card-tip-body { min-width: 140px; }
.card-tip-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-2);
  font-family: "Cinzel", "Georgia", serif;
  letter-spacing: 0.02em;
}
.card-tip-rank { color: var(--text-dim); font-size: 13px; }
.card-tip-line { color: var(--text); font-size: 13px; margin-top: 4px; }
.card-tip-line.winner { color: var(--accent); font-weight: 600; }
.card-tip-line.dim { color: var(--text-muted); }

/* ---- Responsive ---- */
@media (max-width: 1600px) {
  :root { --card-w: 142px; --card-h: 244px; }
}
@media (max-width: 1200px) {
  :root { --card-w: 118px; --card-h: 203px; }
}
@media (max-width: 980px) {
  .game-view, .lobby-view {
    grid-template-columns: 1fr;
    height: auto;
  }
  .game-main, .game-sidebar { grid-column: 1; }
  .game-main { grid-row: auto; }
  .game-sidebar { grid-row: auto; }
  :root { --card-w: 96px; --card-h: 165px; }
}
