/**
 * Spades Card Game — Styles
 * @author Keith Adler
 * @copyright 2026 Keith Adler. MIT License.
 */
/* Design tokens */
:root {
  --accent: #ff1919;
  --accent-strong: #ff4d3d;
  --accent-deep: #a00c0c;
  --on-accent: #14171f;
  --on-accent: #14171f;
  --good: #4aaf6c;
  --bad: #e04a3a;
  --surface-1: rgba(255,255,255,0.04);
  --surface-2: rgba(255,255,255,0.07);
  --hairline: rgba(255,255,255,0.09);
  --hairline-strong: rgba(255,255,255,0.16);
  --panel: linear-gradient(165deg, #262b38 0%, #14171f 100%);
  --shadow-panel: 0 24px 64px rgba(0,0,0,0.55), 0 2px 8px rgba(0,0,0,0.35);
  --ring: 0 0 0 2px rgba(10,20,40,0.9), 0 0 0 4px var(--accent);
  --r-sm: 10px; --r-md: 14px; --r-lg: 20px; --r-xl: 26px;
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --gold: #ff1919;
  --gold-deep: #a00c0c;
  --team-us: #3fc1a0;
  --team-them: #e5534b;
  --felt: #1f7a44;
  --felt-dark: #0b3a20;
  --wood: #6b3d1c;
  --wood-dark: #3a1f0c;
}
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, 'Segoe UI Variable', 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  background: #14171f; color: #fff; height: 100vh; height: 100dvh;
  overflow: hidden; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}

/* Modern focus + scrollbars */
:focus { outline: none; }
:focus-visible { box-shadow: var(--ring); border-radius: var(--r-sm); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.22); }
body::before {
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(ellipse 90% 70% at 50% 40%, #1e2230 0%, #14171f 55%, #0c0e13 100%);
}
body::after {
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg width='80' height='80' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='6' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='80' height='80' filter='url(%23n)'/%3E%3C/svg%3E");
}
.screen { display: none; width: 100%; height: 100vh; height: 100dvh; position: relative; z-index: 1; opacity: 0; transition: opacity 0.3s ease; }
.screen.active { display: flex; opacity: 1; }

.menu-container {
  margin: auto; text-align: center; position: relative;
  background: linear-gradient(170deg, rgba(26,30,40,0.9), rgba(20,23,31,0.94));
  padding: 34px 50px 40px; border-radius: var(--r-xl); backdrop-filter: blur(24px) saturate(1.3);
  border: 1px solid rgba(255,25,25,0.25);
  box-shadow: 0 30px 80px rgba(0,0,0,0.7), inset 0 1px 0 rgba(235,229,206,0.08), 0 0 0 6px rgba(0,0,0,0.25);
  max-height: 95vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
#menu-screen, #gameover-screen { background: radial-gradient(ellipse 60% 50% at 50% 35%, rgba(31,122,68,0.35), transparent 70%); }
.menu-hero { position: relative; height: 128px; margin: 0 auto 6px; width: 240px; }
.menu-hero .hero-card { position: absolute; left: 50%; bottom: 0; width: 76px; height: 106px; margin-left: -38px; transform-origin: 50% 130%; transform: rotate(calc((var(--i) - 1.5) * 17deg)); filter: drop-shadow(0 8px 12px rgba(0,0,0,0.55)); animation: heroIn 0.7s var(--ease-spring) backwards; animation-delay: calc(var(--i) * 0.08s); }
.menu-hero .hero-card:hover { transform: rotate(calc((var(--i) - 1.5) * 17deg)) translateY(-8px); transition: transform 0.2s; }
@media (min-width: 960px) {
  #menu-screen .menu-container { display: grid; grid-template-columns: 330px 440px; column-gap: 56px; align-items: center; align-content: center; padding: 40px 56px; }
  #menu-screen .menu-container > * { grid-column: 1; }
  #menu-screen .menu-container > .menu-options { grid-column: 2; grid-row: 1 / span 6; }
  .menu-hero { height: 170px; width: 300px; }
  .menu-hero .hero-card { width: 100px; height: 140px; margin-left: -50px; }
  .menu-options .btn-start { width: 100%; }
  .game-title { font-size: 3.1rem; }
}
@keyframes heroIn { from { transform: rotate(0deg) translateY(30px); opacity: 0; } }
.title-wrap { display: flex; align-items: center; justify-content: center; gap: 20px; margin-bottom: 8px; }
.title-spade { display: none; }
.game-title {
  white-space: nowrap;
  font-family: Georgia, 'Times New Roman', serif; font-size: 3.6rem; letter-spacing: 6px; margin-bottom: 2px; font-weight: 900;
  background: linear-gradient(180deg, #f4f0e2 0%, #ff4d3d 35%, #d01010 62%, #7a0a0a 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; line-height: 1.1;
  filter: drop-shadow(0 3px 0 rgba(90,8,8,0.9)) drop-shadow(0 10px 24px rgba(0,0,0,0.6));
}
.subtitle { font-size: 0.8rem; color: rgba(235,229,206,0.55); margin-bottom: 28px; letter-spacing: 10px; text-transform: uppercase; font-weight: 700; }
.option-group { margin-bottom: 20px; text-align: left; }
.option-group label { display: block; margin-bottom: 8px; font-size: 0.8rem; opacity: 0.4; text-transform: uppercase; letter-spacing: 2px; font-weight: 600; }
/* Segmented controls */
.btn-group { display: flex; gap: 4px; flex-wrap: wrap; padding: 4px; border-radius: var(--r-md); background: var(--surface-1); border: 1px solid var(--hairline); }
.btn-option {
  flex: 1; padding: 11px 14px; border: 1px solid transparent;
  background: transparent; color: rgba(255,255,255,0.65); border-radius: var(--r-sm);
  cursor: pointer; font-size: 0.92rem; font-weight: 600; white-space: nowrap;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}
.btn-option:hover { background: var(--surface-2); color: rgba(255,255,255,0.9); }
.btn-option.active {
  background: linear-gradient(180deg, #ff4d3d, var(--accent-deep)); border-color: transparent;
  color: var(--on-accent); font-weight: 800;
  box-shadow: 0 2px 12px rgba(255,25,25,0.35), inset 0 1px 0 rgba(255,255,255,0.2);
}
.btn-start {
  margin-top: 28px; padding: 17px 56px;
  background: linear-gradient(180deg, #ff5a4a 0%, #e81414 48%, #a00c0c 100%); color: var(--on-accent);
  border: none; border-radius: var(--r-md); font-size: 1.1rem; font-weight: 900; text-transform: uppercase;
  cursor: pointer; letter-spacing: 2px; position: relative; text-shadow: 0 1px 0 rgba(235,229,206,0.5);
  box-shadow: 0 5px 0 #6a0808, 0 12px 28px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.5);
  transition: transform 0.18s var(--ease-spring), box-shadow 0.18s;
}
.btn-start:hover { transform: translateY(-2px); box-shadow: 0 7px 0 #6a0808, 0 16px 34px rgba(0,0,0,0.5), 0 0 30px rgba(255,25,25,0.35), inset 0 1px 0 rgba(255,255,255,0.5); }
.btn-start:active { transform: translateY(4px); box-shadow: 0 1px 0 #6a0808, 0 6px 14px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.5); }

.btn-start.btn-secondary { background: rgba(0,0,0,0.3); color: var(--gold); border: 1.5px solid rgba(255,25,25,0.55); text-shadow: none; box-shadow: 0 10px 24px rgba(0,0,0,0.35); }
.btn-start.btn-secondary:hover { background: rgba(255,25,25,0.12); box-shadow: 0 12px 28px rgba(0,0,0,0.4), 0 0 20px rgba(255,25,25,0.2); }

/* House rule toggles */
.rule-toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.rule-toggle { flex: 1 1 auto; padding: 9px 12px; border-radius: 999px; cursor: pointer; font-size: 0.82rem; font-weight: 700; white-space: nowrap; color: rgba(255,245,225,0.55); background: rgba(255,255,255,0.03); border: 1px solid var(--hairline); transition: background 0.2s, color 0.2s, border-color 0.2s; }
.rule-toggle::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: rgba(255,255,255,0.18); vertical-align: 1px; transition: background 0.2s, box-shadow 0.2s; }
.rule-toggle:hover { color: #f4f0e2; border-color: var(--hairline-strong); }
.rule-toggle.on { color: #ebe5ce; border-color: rgba(255,25,25,0.55); background: rgba(255,25,25,0.1); }
.rule-toggle.on::before { background: var(--gold); box-shadow: 0 0 8px rgba(255,25,25,0.8); }
body[data-theme="light"] .rule-toggle { color: #7a6a52; background: rgba(255,255,255,0.5); border-color: rgba(90,64,20,0.14); }
body[data-theme="light"] .rule-toggle.on { color: #2b2116; border-color: rgba(154,110,30,0.55); background: rgba(255,25,25,0.25); }
.bid-btn:disabled { opacity: 0.25; cursor: not-allowed; transform: none; box-shadow: none; }
.bid-btn:disabled:hover { background: radial-gradient(circle at 50% 35%, #2e3442, #1a1e28 70%); color: #ebe5ce; }

/* Roster: the four seats, as compact tiles */
#player-roster { margin: 4px 0 18px; text-align: left; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.roster-title { grid-column: 1 / -1; font-size: 0.62rem; color: rgba(235,229,206,0.5); text-transform: uppercase; letter-spacing: 2.5px; text-align: center; font-weight: 800; }
.roster-card { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px; background: rgba(255,255,255,0.035); border: 1px solid rgba(255,255,255,0.06); position: relative; min-width: 0; transition: background 0.2s, border-color 0.2s; }
.roster-card:hover { background: rgba(255,255,255,0.06); }
.roster-card.human { border-color: rgba(255,25,25,0.45); background: rgba(255,25,25,0.07); }
.roster-card .roster-avatar { width: 46px; height: 46px; object-fit: cover; object-position: 50% 35%; border-radius: 50%; border: 2px solid rgba(235,229,206,0.25); background: rgba(255,255,255,0.08); flex-shrink: 0; }
.roster-card .roster-info { flex: 1; min-width: 0; }
.roster-card .roster-name { font-weight: 800; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #f4f0e2; }
.roster-card .roster-rank { font-size: 0.66rem; color: rgba(235,229,206,0.55); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.roster-card .roster-record { font-size: 0.6rem; opacity: 0.35; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.roster-card .roster-avatar.pickable { cursor: pointer; transition: transform 0.2s var(--ease-spring), box-shadow 0.2s; }
.roster-card .roster-avatar.pickable:hover { transform: scale(1.12); box-shadow: 0 0 0 2px var(--gold), 0 0 14px rgba(255,25,25,0.5); }
.roster-role { display: inline-block; margin: 1px 0 2px; padding: 1px 7px; border-radius: 999px; font-size: 0.55rem; font-weight: 900; letter-spacing: 1px; text-transform: uppercase; color: #fff; }
.roster-role.partner { background: color-mix(in srgb, var(--team-us) 70%, #000); }
.roster-role.opp { background: color-mix(in srgb, var(--team-them) 75%, #000); }
.roster-role.rival { background: #5a5a66; }
.roster-card.role-partner .roster-avatar { border-color: var(--team-us); }
.roster-card.role-opp .roster-avatar { border-color: var(--team-them); }
.roster-card.human .roster-avatar { border-color: var(--gold); }
.roster-reroll { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.1); color: #fff; width: 24px; height: 24px; border-radius: 50%; cursor: pointer; font-size: 0.7rem; display: flex; align-items: center; justify-content: center; transition: all 0.25s; }
.roster-reroll:hover { background: rgba(255,25,25,0.25); transform: rotate(180deg) scale(1.1); }

/* Game Screen — a felt card table in a dark room */
#game-screen { flex-direction: column; position: relative; --cw: clamp(58px, 6.6vw, 104px); --ch: calc(var(--cw) * 1.4); }
#score-bar { display: flex; align-items: center; justify-content: center; padding: 10px 70px 6px; flex-shrink: 0; z-index: 4; }
#score-bar-content { display: flex; align-items: stretch; gap: 0; justify-content: center; border-radius: 16px; background: linear-gradient(180deg, rgba(20,23,31,0.92), rgba(20,23,31,0.92)); border: 1px solid rgba(255,25,25,0.28); box-shadow: 0 10px 30px rgba(0,0,0,0.55), inset 0 1px 0 rgba(235,229,206,0.08); overflow: hidden; }
.sb-round { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 6px 16px; background: linear-gradient(180deg, #ff1919, #a00c0c); color: #14171f; font-weight: 900; line-height: 1; }
.sb-round small { font-size: 0.55rem; letter-spacing: 2px; font-weight: 800; opacity: 0.75; }
.sb-round b { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.sb-team, .sb-player-score { display: flex; align-items: center; gap: 12px; padding: 8px 20px; position: relative; }
.sb-team + .sb-vs + .sb-team, .sb-player-score + .sb-player-score { border-left: 1px solid rgba(255,255,255,0.06); }
.sb-team::before, .sb-player-score::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--team-c, #888); }
.sb-team.us, .sb-player-score.us { --team-c: var(--team-us); }
.sb-team.them { --team-c: var(--team-them); }
.sb-player-score.current { background: rgba(255,25,25,0.08); }
.sb-names { display: flex; flex-direction: column; line-height: 1.15; }
.sb-team-name, .sb-ps-name { font-weight: 700; font-size: 0.78rem; color: rgba(255,245,225,0.85); max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-bags { font-size: 0.66rem; color: rgba(255,245,225,0.45); font-weight: 600; font-variant-numeric: tabular-nums; }
.sb-team-score { font-weight: 900; font-size: 1.6rem; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; color: #f4f0e2; min-width: 2ch; text-align: right; }
.sb-team.leading .sb-team-score, .sb-player-score.leading .sb-team-score { color: var(--gold); text-shadow: 0 0 14px rgba(255,25,25,0.35); }
.sb-vs { display: flex; align-items: center; padding: 0 4px; color: rgba(255,25,25,0.5); font-weight: 900; font-size: 0.7rem; letter-spacing: 1px; }
.sb-target { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 6px 14px; border-left: 1px solid rgba(255,255,255,0.06); color: rgba(255,245,225,0.5); font-size: 0.55rem; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; line-height: 1.2; }
.sb-target b { font-size: 1rem; color: rgba(255,245,225,0.85); letter-spacing: 0; }
.tdot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; margin-right: 4px; box-shadow: 0 0 0 2px rgba(0,0,0,0.25); }
.tdot.us { background: var(--team-us); } .tdot.them { background: var(--team-them); }

/* Game layout: the felt table sits behind the seats */
#game-layout { flex: 1; display: flex; flex-direction: column; position: relative; min-height: 0; padding-bottom: calc(var(--ch) * 0.85 + 26px); }
#game-layout::before {
  content: ''; position: absolute; z-index: 0; pointer-events: none;
  top: 46px; bottom: calc(var(--ch) * 0.5); left: max(56px, 6%); right: max(56px, 6%);
  border-radius: 999px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .35 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E"),
    radial-gradient(ellipse 70% 60% at 50% 45%, rgba(255,255,255,0.13), transparent 70%),
    radial-gradient(ellipse at center, var(--felt) 0%, var(--felt-dark) 100%);
  box-shadow:
    inset 0 0 0 2px rgba(0,0,0,0.35), inset 0 10px 40px rgba(0,0,0,0.55), inset 0 -6px 30px rgba(0,0,0,0.35),
    0 0 0 3px #1c0f06, 0 0 0 14px var(--wood), 0 0 0 16px var(--wood-dark), 0 0 0 17px rgba(255,210,150,0.18),
    0 30px 60px rgba(0,0,0,0.7), 0 0 120px rgba(0,0,0,0.6);
}
#game-layout::after {
  /* inner betting line, as printed on real felt */
  content: ''; position: absolute; z-index: 0; pointer-events: none;
  top: calc(46px + 26px); bottom: calc(var(--ch) * 0.5 + 26px); left: calc(max(56px, 6%) + 26px); right: calc(max(56px, 6%) + 26px);
  border-radius: 999px; border: 1.5px solid rgba(235,229,206,0.13);
}
#game-middle { flex: 1; display: flex; min-height: 0; position: relative; z-index: 1; }
#center-area { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#board-area { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; }
#trick-area { position: relative; width: calc(var(--cw) * 3.9); height: calc(var(--ch) * 2.15); max-height: 100%; }
#trick-area::before {
  content: ''; position: absolute; left: 50%; top: 50%; width: calc(var(--cw) * 1.5); height: calc(var(--cw) * 1.5); transform: translate(-50%, -50%);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath fill='%23fff' d='M50 2c9 18 47 36 47 60 0 15-11 24-23 24-9 0-16-4-20-10 1 11 6 17 14 22H32c8-5 13-11 14-22-4 6-11 10-20 10C14 86 3 77 3 62 3 38 41 20 50 2z'/%3E%3C/svg%3E") center / contain no-repeat;
  opacity: 0.06; pointer-events: none;
}
#trick-info { position: absolute; bottom: calc(var(--ch) * 0.5 + 34px); left: 50%; transform: translateX(-50%); font-size: 0.68rem; letter-spacing: 3px; text-transform: uppercase; color: rgba(235,229,206,0.45); font-weight: 800; z-index: 1; white-space: nowrap; }

/* Dealer button on the seat */
.dealer-chip { position: absolute; right: -4px; bottom: -4px; width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.62rem; font-weight: 900; color: #14171f; background: radial-gradient(circle at 40% 35%, #f4f0e2, #e81414 70%); border: 1.5px solid #6a0808; box-shadow: 0 2px 5px rgba(0,0,0,0.5); }

/* Last-trick review */
.table-btn { position: absolute; z-index: 5; padding: 6px 14px; border-radius: 999px; cursor: pointer; font-size: 0.68rem; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase; color: var(--gold); background: rgba(20,23,31,0.7); border: 1px solid rgba(255,25,25,0.35); transition: background 0.2s; }
.table-btn:hover { background: rgba(255,25,25,0.18); }
.table-btn[hidden], #last-trick-pop[hidden] { display: none; }
#last-trick-btn { left: max(96px, 9%); top: 18px; }
#last-trick-pop { position: absolute; z-index: 9; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 14px 16px 12px; border-radius: 18px; background: linear-gradient(180deg, rgba(26,30,40,0.97), rgba(20,23,31,0.97)); border: 1px solid rgba(255,25,25,0.4); box-shadow: 0 20px 50px rgba(0,0,0,0.6); cursor: pointer; animation: msgEntrance 0.2s ease-out; }
.lt-title { text-align: center; font-size: 0.6rem; font-weight: 900; letter-spacing: 2px; text-transform: uppercase; color: var(--gold); margin-bottom: 8px; }
.lt-grid { display: grid; grid-template-columns: repeat(3, auto); grid-template-areas: ". top ." "left . right" ". bottom ."; gap: 2px 10px; align-items: center; justify-items: center; }
.lt-top { grid-area: top; } .lt-left { grid-area: left; } .lt-right { grid-area: right; } .lt-bottom { grid-area: bottom; }
.lt-card { width: calc(var(--cw) * 0.7); height: calc(var(--ch) * 0.7); filter: drop-shadow(0 3px 6px rgba(0,0,0,0.5)); }
.lt-play.won .lt-card { filter: drop-shadow(0 0 10px rgba(255,77,61,0.9)); }
.lt-name { font-size: 0.66rem; font-weight: 700; color: rgba(255,247,230,0.75); margin-top: 3px; max-width: 90px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lt-play.won .lt-name { color: var(--gold); }
@media (max-width: 700px) { #last-trick-btn { left: 16px; top: 8px; } }

/* ===== Card impacts: slams, drops, trick sweeps ===== */
.fly-card { will-change: transform, filter; }
.impact-ring { position: fixed; z-index: 4; pointer-events: none; border-radius: 50%; transform: translate(-50%, -50%) scale(0.3);
  border: 3px solid rgba(235,229,206,0.8); box-shadow: 0 0 18px rgba(235,229,206,0.45), inset 0 0 14px rgba(235,229,206,0.35);
  animation: ringOut 0.62s cubic-bezier(.1,.7,.3,1) forwards; }
.impact-ring.thin { border-width: 1.5px; opacity: 0.6; animation-duration: 0.8s; }
@keyframes ringOut { from { opacity: 1; transform: translate(-50%, -50%) scale(0.3); } to { opacity: 0; transform: translate(-50%, -50%) scale(var(--ring-scale, 3)); } }
.impact-flash { position: fixed; z-index: 3; pointer-events: none; transform: translate(-50%, -50%); border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(235,229,206,0.55), rgba(255,220,150,0.18) 35%, transparent 65%);
  mix-blend-mode: screen; animation: flashOut 0.45s ease-out forwards; }
@keyframes flashOut { from { opacity: 1; } to { opacity: 0; } }
.impact-dust { position: fixed; z-index: 4; pointer-events: none; width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; border-radius: 50%;
  background: radial-gradient(circle, #f7f4ea 0%, rgba(235,229,206,0.9) 45%, rgba(235,229,206,0) 75%); box-shadow: 0 0 8px rgba(235,229,206,0.7); }
.impact-label { position: fixed; z-index: 58; pointer-events: none; transform: translate(-50%, -100%); white-space: nowrap;
  font-family: Georgia, 'Times New Roman', serif; font-size: 1.9rem; font-weight: 900; letter-spacing: 2px; text-transform: uppercase;
  background: linear-gradient(180deg, #f4f0e2 0%, #ff4d3d 40%, #d01010 70%, #7a0a0a 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  filter: drop-shadow(0 3px 0 rgba(60,6,6,0.95)) drop-shadow(0 8px 16px rgba(0,0,0,0.7));
  animation: stampIn 0.35s cubic-bezier(.2,1.8,.4,1) backwards, stampOut 0.4s ease-in 1s forwards; }
@keyframes stampIn { from { opacity: 0; transform: translate(-50%, -100%) scale(2.4) rotate(-10deg); } to { opacity: 1; transform: translate(-50%, -100%) scale(1) rotate(-4deg); } }
@keyframes stampOut { to { opacity: 0; transform: translate(-50%, -140%) scale(0.95) rotate(-4deg); } }
#game-layout.table-slam { animation: tableSlam 0.5s cubic-bezier(.3,.6,.4,1); }
#game-layout.table-bump { animation: tableBump 0.34s ease-out; }
@keyframes tableSlam {
  0% { transform: translate(0, 0) scale(1); } 12% { transform: translate(0, 7px) scale(0.992); } 28% { transform: translate(-5px, -3px); }
  44% { transform: translate(4px, 2px); } 62% { transform: translate(-2px, -1px); } 80% { transform: translate(1px, 0); } 100% { transform: none; } }
@keyframes tableBump { 0% { transform: none; } 25% { transform: translateY(3px) scale(0.997); } 60% { transform: translateY(-1px); } 100% { transform: none; } }
.seat-plate.took-trick { animation: tookTrick 0.9s ease-out; }
@keyframes tookTrick { 0% { box-shadow: 0 0 0 0 rgba(255,25,25,0.9), 0 8px 22px rgba(0,0,0,0.55); } 100% { box-shadow: 0 0 0 16px rgba(255,25,25,0), 0 8px 22px rgba(0,0,0,0.55); } }
@media (prefers-reduced-motion: reduce) { .impact-ring, .impact-flash, .impact-dust { display: none; } }

/* Cards: the SVG is the card */
.card-svg { display: block; width: 100%; height: 100%; overflow: visible; }
.cf-bg { fill: var(--card-face, #fdfcf7); }
.cf-edge { fill: none; stroke: rgba(0,0,0,0.28); stroke-width: 1.5; }
.cf-sheen { pointer-events: none; opacity: 0.6; }
.cf-red { fill: var(--card-red, #c42a2a); }
.cf-black { fill: var(--card-black, #15151f); }
body.colorblind .cf-diamonds { fill: #1f63c4; }
body.colorblind .cf-clubs { fill: #1e7d32; }
.cf-index { font: 800 40px/1 Georgia, 'Times New Roman', serif; letter-spacing: -2px; }
.cf-court-letter { font: 700 58px/1 Georgia, 'Times New Roman', serif; }
.cf-court-frame { fill: none; stroke-width: 3; stroke: currentColor; }
.cf-red.cf-court-frame { stroke: var(--card-red, #c42a2a); } .cf-black.cf-court-frame { stroke: var(--card-black, #15151f); }
.cf-court-tint { opacity: 0.1; } .cf-court-tint.red { fill: var(--card-red, #c42a2a); } .cf-court-tint.black { fill: #2d3b8a; }
.cf-court-tint.alt { opacity: 0.16; }
.cf-court-divider { stroke: rgba(0,0,0,0.3); stroke-width: 1.5; stroke-dasharray: 4 4; }
.cf-ace-ring { fill: none; stroke: var(--card-black, #15151f); stroke-width: 2.5; opacity: 0.8; }
.cf-ace-ring.thin { stroke-width: 1; opacity: 0.5; }
.cf-ace-mark { font: 800 11px/1 system-ui, sans-serif; letter-spacing: 3px; fill: var(--card-black, #15151f); opacity: 0.55; }
.cf-trump-badge { fill: url(#cf-gold); stroke: #4a0606; stroke-width: 2; }
.cf-trump-badge-suit { fill: #14171f; }
.cf-joker-big { fill: #c42a2a; stroke: #c42a2a; }
.cf-joker-little { fill: #15151f; stroke: #15151f; }
.cf-joker-frame { fill: none; stroke-width: 3; }
.cf-joker-frame.cf-joker-big { fill: rgba(196,42,42,0.08); }
.cf-joker-frame.cf-joker-little { fill: rgba(21,21,31,0.06); }
.cf-joker-hat { stroke: #4a0606; stroke-width: 2; stroke-linejoin: round; }
.cf-joker-hat.alt.cf-joker-big { fill: #2d4fa0; } .cf-joker-hat.alt.cf-joker-little { fill: #8a8f9c; }
.cf-joker-index { font: 800 22px/1 Georgia, 'Times New Roman', serif; stroke: none; }
.cf-joker-label { font: 900 18px/1 system-ui, sans-serif; letter-spacing: 4px; stroke: none; }
.cb-border { fill: var(--card-face, #fdfcf7); stroke: rgba(0,0,0,0.35); stroke-width: 1.5; }
.cb-fill { fill: var(--card-back, #7a1622); }
.cb-line { stroke: rgba(255,255,255,0.14); }
.cb-dot { fill: rgba(255,255,255,0.2); }
.cb-frame { fill: none; stroke: var(--card-back-dark, #4a0a12); stroke-width: 3; }
.cb-medal { fill: var(--card-back-dark, #4a0a12); stroke: rgba(235,229,206,0.7); stroke-width: 2.5; }
.cb-medal-suit { fill: rgba(235,229,206,0.85); }

.hand-card, .trick-card, .mini-card, .fly-card { border-radius: 7% / 5%; }
.trick-card {
  position: absolute; width: calc(var(--cw) * 1.02); height: calc(var(--ch) * 1.02);
  filter: drop-shadow(0 3px 4px rgba(0,0,0,0.55));
}
.trick-card.incoming { visibility: hidden; }
.trick-card.from-bottom { left: 50%; bottom: 0; transform: translateX(-50%) rotate(var(--tilt, 0deg)); }
.trick-card.from-top { left: 50%; top: 0; transform: translateX(-50%) rotate(var(--tilt, 0deg)); }
.trick-card.from-left { left: 0; top: 50%; transform: translateY(-50%) rotate(var(--tilt, 0deg)); }
.trick-card.from-right { right: 0; top: 50%; transform: translateY(-50%) rotate(var(--tilt, 0deg)); }
.trick-card.winning { filter: drop-shadow(0 0 0 transparent) drop-shadow(0 0 14px rgba(255,77,61,0.9)) drop-shadow(0 6px 10px rgba(0,0,0,0.45)); }
@keyframes cardLand { from { opacity: 0.4; scale: 1.25; } to { opacity: 1; scale: 1; } }

/* Seats: avatar plate + fanned card backs */
.opponent-hand { display: flex; align-items: center; justify-content: center; flex-shrink: 0; position: relative; z-index: 2; }
.opponent-hand.top { min-height: 104px; padding: 0 16px; }
.opponent-hand.left, .opponent-hand.right { width: max(150px, 12%); }
.seat { display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; z-index: 0; }
.opponent-hand.top .seat { flex-direction: column-reverse; }
.seat-fan { position: relative; width: 150px; height: 64px; }
.opponent-hand.top .seat-fan { transform: rotate(180deg); height: 50px; margin-top: -8px; z-index: -1; }
.opponent-hand.left .seat-fan, .opponent-hand.right .seat-fan { width: 110px; height: 58px; margin-bottom: -14px; z-index: -1; }
.mini-card { position: absolute; left: 50%; bottom: 0; width: 36px; height: 50px; margin-left: -18px; transform-origin: 50% 140%; transform: rotate(calc((var(--i) - (var(--n) - 1) / 2) * 5.5deg)); filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4)); }
.seat-plate { display: flex; align-items: center; gap: 10px; padding: 6px 14px 6px 6px; border-radius: 999px; background: linear-gradient(180deg, rgba(26,22,16,0.94), rgba(20,23,31,0.94)); border: 1px solid rgba(255,25,25,0.22); box-shadow: 0 8px 22px rgba(0,0,0,0.55); transition: box-shadow 0.3s, border-color 0.3s; position: relative; }
.opponent-hand.left .seat-plate, .opponent-hand.right .seat-plate { flex-direction: column; padding: 8px 12px; border-radius: 18px; gap: 6px; }
.seat.active .seat-plate { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 26px rgba(255,25,25,0.45), 0 8px 22px rgba(0,0,0,0.55); }
.seat-avatar { position: relative; width: 58px; height: 58px; border-radius: 50%; padding: 3px; background: conic-gradient(var(--team-c), color-mix(in srgb, var(--team-c) 50%, #000), var(--team-c)); flex-shrink: 0; }
.seat-avatar img { width: 100%; height: 100%; border-radius: 50%; background: #262b38; display: block; object-fit: cover; object-position: 50% 35%; }
.seat.partner, .seat.us { --team-c: var(--team-us); } .seat.opp { --team-c: var(--team-them); } .seat.ffa { --team-c: #8a8f9c; }
.seat.active .seat-avatar::after { content: ''; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid var(--gold); animation: seatPulse 1.4s ease-in-out infinite; }
@keyframes seatPulse { 0%,100% { opacity: 0.9; transform: scale(1); } 50% { opacity: 0.3; transform: scale(1.08); } }
.seat-meta { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.opponent-hand.left .seat-meta, .opponent-hand.right .seat-meta { align-items: center; text-align: center; }
.seat-name { font-weight: 800; font-size: 0.86rem; color: #f4f0e2; white-space: nowrap; max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
.seat-sub { font-size: 0.62rem; color: rgba(255,245,225,0.45); font-weight: 600; letter-spacing: 0.3px; }
.seat-bid { display: flex; align-items: baseline; gap: 2px; padding: 4px 10px; border-radius: 10px; background: rgba(0,0,0,0.45); border: 1px solid rgba(255,255,255,0.08); font-variant-numeric: tabular-nums; color: #f4f0e2; white-space: nowrap; }
.seat-bid b { font-size: 1.05rem; font-weight: 900; }
.seat-bid span { font-size: 0.7rem; opacity: 0.55; font-weight: 700; }
.seat-bid small { font-size: 0.5rem; letter-spacing: 1px; opacity: 0.5; margin-left: 4px; text-transform: uppercase; font-weight: 800; }
.seat-bid.made { border-color: rgba(120,210,140,0.5); } .seat-bid.made b { color: #8fe0a0; }
.seat-bid.nil { background: rgba(120,60,200,0.35); border-color: rgba(190,140,255,0.5); }
.seat-bid.busted { background: rgba(160,30,20,0.5); border-color: rgba(255,120,100,0.6); }
.seat-bid.pending { opacity: 0.5; }

/* The human's hand: a fanned arc of full-size cards */
#bottom-bar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; pointer-events: none; }
#bottom-bar > * { pointer-events: auto; }
#player-hand { display: flex; justify-content: center; align-items: flex-end; height: calc(var(--ch) + 56px); padding: 0 16px 36px; position: relative; z-index: 6; pointer-events: none; width: 100%; }
.hand-card {
  pointer-events: auto; touch-action: manipulation; flex-shrink: 0; position: relative;
  width: var(--cw); height: var(--ch); cursor: default;
  transform: translateY(var(--lift, 0px)) rotate(var(--rot, 0deg)); transform-origin: 50% 120%;
  transition: transform 0.22s var(--ease-spring), filter 0.2s, margin 0.25s;
  filter: drop-shadow(-2px 4px 6px rgba(0,0,0,0.45));
}
.hand-card.dealt-in { animation: handIn 0.35s ease-out backwards; }
.hand-card + .hand-card { margin-left: var(--overlap, -40px); }
@keyframes handIn { from { opacity: 0; translate: 0 40px; } }
.hand-card.playable { cursor: pointer; transform: translateY(calc(var(--lift, 0px) - 10px)) rotate(var(--rot, 0deg)); }
.hand-card.playable:hover, .hand-card.playable:focus-visible { transform: translateY(calc(var(--lift, 0px) - 34px)) rotate(var(--rot, 0deg)) scale(1.06); z-index: 5; filter: drop-shadow(0 0 10px rgba(255,77,61,0.75)) drop-shadow(0 10px 14px rgba(0,0,0,0.5)); box-shadow: none; }
.hand-card.playable.selected { transform: translateY(calc(var(--lift, 0px) - 40px)) rotate(var(--rot, 0deg)) scale(1.08); z-index: 6; filter: drop-shadow(0 0 0 2px var(--gold)) drop-shadow(0 0 12px rgba(255,77,61,0.9)) drop-shadow(0 10px 14px rgba(0,0,0,0.5)); }
.hand-card.not-playable { cursor: not-allowed; filter: brightness(0.55) saturate(0.6) drop-shadow(-2px 4px 6px rgba(0,0,0,0.45)); transform: translateY(calc(var(--lift, 0px) + 10px)) rotate(var(--rot, 0deg)); }
#player-hand.my-turn::before { content: attr(data-turn); position: absolute; left: 50%; top: -6px; transform: translateX(-50%); padding: 5px 16px; border-radius: 999px; background: linear-gradient(180deg, #ff4d3d, #d01010); color: #14171f; font-size: 0.7rem; font-weight: 900; letter-spacing: 2px; text-transform: uppercase; box-shadow: 0 6px 18px rgba(0,0,0,0.5), 0 0 20px rgba(255,25,25,0.4); animation: turnPill 1.6s ease-in-out infinite; white-space: nowrap; }
@keyframes turnPill { 0%,100% { translate: 0 0; } 50% { translate: 0 -3px; } }

/* Human seat plate, bottom-left */
#human-info { position: fixed; left: 16px; bottom: 16px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; z-index: 7; }
#human-info .seat-plate { padding-right: 16px; }
#human-info.my-turn .seat-plate { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 26px rgba(255,25,25,0.45), 0 8px 22px rgba(0,0,0,0.55); }
#floating-arrow { display: none !important; }

/* Overlays */
.btn-menu { position: fixed; top: 10px; left: 10px; background: rgba(10,14,26,0.55); border: 1px solid var(--hairline); color: #fff; font-size: 1.3rem; width: 44px; height: 44px; border-radius: var(--r-sm); cursor: pointer; z-index: 12; display: flex; align-items: center; justify-content: center; transition: background 0.2s, border-color 0.2s, transform 0.15s; backdrop-filter: blur(12px); }
.btn-menu:hover { background: rgba(20,28,48,0.75); border-color: var(--hairline-strong); transform: scale(1.05); }
#game-dropdown { position: fixed; top: 62px; left: 10px; z-index: 12; background: linear-gradient(165deg, rgba(24,29,44,0.92), rgba(13,17,30,0.97)); backdrop-filter: blur(20px) saturate(1.5); border: 1px solid var(--hairline); border-radius: var(--r-md); padding: 6px; box-shadow: var(--shadow-panel); min-width: 220px; animation: ddIn 0.2s ease-out; }
#game-dropdown.hidden { display: none; }
@keyframes ddIn { from { opacity: 0; transform: translateY(-8px) scale(0.95); } }
.dd-item { display: block; width: 100%; padding: 12px 16px; background: none; border: none; color: rgba(255,255,255,0.85); font-size: 0.95rem; font-weight: 500; text-align: left; cursor: pointer; border-radius: var(--r-sm); transition: background 0.15s, color 0.15s; }
.dd-item:hover { background: rgba(255,255,255,0.08); }
a.dd-item { text-decoration: none; box-sizing: border-box; }
.dd-danger { color: #ff5a4a; }
.dd-danger:hover { background: rgba(255,80,60,0.12); }

#message-overlay, #bid-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.75); display: flex; align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(8px); }
#message-overlay.hidden, #bid-overlay.hidden { display: none; }
.message-box { background: var(--panel); padding: 40px 48px; border-radius: var(--r-lg); text-align: center; max-width: 440px; border: 1px solid var(--hairline); box-shadow: var(--shadow-panel), inset 0 1px 0 rgba(255,255,255,0.05); animation: msgEntrance 0.3s ease-out; }
@keyframes msgEntrance { from { opacity: 0; transform: scale(0.9) translateY(20px); } }
.message-box p { margin-bottom: 24px; font-size: 1.1rem; line-height: 1.7; opacity: 0.9; }

#rules-overlay, #stats-overlay, #prefs-overlay, #shortcuts-overlay, #log-overlay, #ragequit-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.8); display: flex; align-items: center; justify-content: center; z-index: 200; backdrop-filter: blur(10px); }
#rules-overlay.hidden, #stats-overlay.hidden, #prefs-overlay.hidden, #shortcuts-overlay.hidden, #log-overlay.hidden, #ragequit-overlay.hidden { display: none; }
.rules-panel, .stats-panel, .shortcuts-panel, .log-panel { background: var(--panel); padding: 32px 40px; border-radius: var(--r-lg); max-width: 520px; width: 90%; max-height: 85vh; overflow-y: auto; border: 1px solid var(--hairline); box-shadow: var(--shadow-panel), inset 0 1px 0 rgba(255,255,255,0.05); animation: msgEntrance 0.3s ease-out; }
.rules-panel h2, .stats-panel h2, .shortcuts-panel h2, .log-panel h2 { font-size: 1.4rem; margin-bottom: 20px; text-align: center; letter-spacing: 2px; background: linear-gradient(180deg, #fff 20%, #ff1919); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.rules-content { text-align: left; line-height: 1.8; }
.rules-content h3 { color: #ff1919; font-size: 0.95rem; margin-top: 20px; margin-bottom: 8px; }
.rules-content p { font-size: 0.9rem; opacity: 0.8; margin-bottom: 10px; }
.rules-content strong { color: #ff1919; }
.gm-btn { display: block; width: 100%; padding: 16px 28px; margin: 12px 0; background: var(--surface-2); border: 1px solid var(--hairline); color: #fff; border-radius: var(--r-md); font-size: 1.05rem; font-weight: 600; cursor: pointer; transition: background 0.2s, border-color 0.2s, transform 0.15s; }
.gm-btn:hover { background: rgba(255,255,255,0.12); border-color: var(--hairline-strong); }
.gm-btn:active { transform: scale(0.99); }

/* Countdown before the first deal */
.countdown-num {
  font-family: Georgia, 'Times New Roman', serif; font-size: 11rem; font-weight: 900; line-height: 1;
  background: linear-gradient(180deg, #f4f0e2 0%, #ff4d3d 38%, #d01010 65%, #7a0a0a 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  filter: drop-shadow(0 4px 0 rgba(90,8,8,0.9)) drop-shadow(0 0 40px rgba(255,25,25,0.45));
  animation: countPop 0.8s ease-out forwards;
}
.countdown-num.go { font-size: 5rem; letter-spacing: 10px; }

/* Round results */
.results-box { max-width: 620px; width: 94%; padding: 26px 26px 24px; border-color: rgba(255,25,25,0.3); max-height: 94vh; overflow-y: auto; }
.rr-eyebrow { font-size: 0.66rem; font-weight: 800; letter-spacing: 3px; text-transform: uppercase; color: rgba(235,229,206,0.5); }
.rr-title { font-family: Georgia, 'Times New Roman', serif; font-size: 1.8rem; margin: 2px 0 16px; background: linear-gradient(180deg, #f4f0e2 10%, #ff1919 60%, #a00c0c); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.rr-teams { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; text-align: left; }
.rr-team { border-radius: 16px; padding: 14px; background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.07); border-top: 3px solid var(--team-c); display: flex; flex-direction: column; gap: 10px; }
.rr-team.us { --team-c: var(--team-us); } .rr-team.them { --team-c: var(--team-them); }
.rr-team-head { display: flex; align-items: center; gap: 10px; }
.rr-avatars { display: flex; } .rr-avatars img { width: 32px; height: 32px; object-fit: cover; border-radius: 50%; border: 2px solid var(--team-c); background: #262b38; }
.rr-avatars img + img { margin-left: -10px; }
.rr-team-name { flex: 1; font-weight: 800; font-size: 0.85rem; color: #f4f0e2; }
.rr-delta { font-size: 1.6rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.rr-team.made .rr-delta, .rr-delta-sm.good { color: #8fe0a0; } .rr-team.set .rr-delta, .rr-delta-sm.bad { color: #ff8a7a; }
.rr-grid { display: grid; grid-template-columns: 1fr auto auto; gap: 4px 14px; align-items: center; font-size: 0.85rem; }
.rr-h { font-size: 0.55rem; letter-spacing: 1.5px; text-transform: uppercase; color: rgba(235,229,206,0.4); font-weight: 800; text-align: center; }
.rr-name { font-weight: 700; color: rgba(255,247,230,0.9); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 8px; min-width: 0; }
.rr-name img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
.rr-bid { text-align: center; font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; font-size: 0.8rem; }
.rr-tricks { text-align: center; font-weight: 900; font-variant-numeric: tabular-nums; color: rgba(255,255,255,0.6); }
.rr-tricks.good { color: #8fe0a0; } .rr-tricks.bad { color: #ff8a7a; }
.rr-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; }
.rr-badge { padding: 4px 12px; border-radius: 999px; font-size: 0.72rem; font-weight: 900; letter-spacing: 1.5px; text-transform: uppercase; }
.rr-team.made .rr-badge { background: rgba(80,190,110,0.18); color: #8fe0a0; border: 1px solid rgba(120,210,140,0.4); }
.rr-team.set .rr-badge { background: rgba(220,70,55,0.2); color: #ff9a8a; border: 1px solid rgba(255,120,100,0.45); }
.rr-detail { font-size: 0.72rem; color: rgba(235,229,206,0.55); font-variant-numeric: tabular-nums; }
.rr-detail b { color: #ff8a7a; }
.rr-quote { display: flex; align-items: center; gap: 8px; font-size: 0.78rem; font-style: italic; color: rgba(255,247,230,0.65); padding-top: 8px; border-top: 1px solid rgba(255,255,255,0.06); }
.rr-quote img { width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0; }
.rr-race { margin-top: 16px; display: flex; flex-direction: column; gap: 6px; }
.rr-lane { display: grid; grid-template-columns: 110px 1fr 48px; align-items: center; gap: 10px; font-size: 0.75rem; }
.rr-lane.us { --team-c: var(--team-us); } .rr-lane.them { --team-c: var(--team-them); }
.rr-lane-label { text-align: left; color: rgba(255,247,230,0.7); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rr-lane b { text-align: right; font-variant-numeric: tabular-nums; color: #f4f0e2; }
.rr-bar { height: 8px; border-radius: 99px; background: rgba(255,255,255,0.07); overflow: hidden; }
.rr-bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, color-mix(in srgb, var(--team-c) 60%, #000), var(--team-c)); transition: width 0.8s ease-out; }
.rr-target { font-size: 0.6rem; letter-spacing: 1.5px; text-transform: uppercase; color: rgba(235,229,206,0.4); font-weight: 700; margin-top: 2px; }
.rr-standings { display: grid; grid-template-columns: auto 1fr auto auto auto auto; gap: 8px 14px; align-items: center; text-align: left; font-size: 0.9rem; }
.rr-rank { font-weight: 900; color: rgba(235,229,206,0.45); font-variant-numeric: tabular-nums; }
.rr-delta-sm { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; font-size: 0.8rem; }
.rr-score { text-align: right; font-weight: 900; color: #f4f0e2; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .rr-teams { grid-template-columns: 1fr; } .rr-lane { grid-template-columns: 80px 1fr 40px; } }

/* Thinking */
#thinking-overlay { position: fixed; z-index: 12; pointer-events: none; }
#thinking-overlay.hidden { display: none; }
.think-card { display: flex; align-items: center; gap: 12px; padding: 10px 24px; border-radius: 14px; background: linear-gradient(180deg, rgba(26,30,40,0.94), rgba(20,23,31,0.94)); backdrop-filter: blur(12px); border: 1px solid rgba(255,25,25,0.3); box-shadow: 0 10px 30px rgba(0,0,0,0.55); animation: thinkCardIn 0.3s ease-out; }
@keyframes thinkCardIn { from { opacity: 0; transform: scale(0.9) translateY(10px); } }
.think-name { font-weight: 800; font-size: 0.9rem; color: #ff1919; }
.think-label { display: flex; align-items: center; gap: 5px; font-size: 0.8rem; opacity: 0.7; }
.thinking-dots-lg { display: inline-flex; gap: 6px; }
.thinking-dots-lg span { width: 10px; height: 10px; border-radius: 50%; background: #ff1919; animation: thinkBlink 1.4s ease-in-out infinite; }
.thinking-dots-lg span:nth-child(2) { animation-delay: 0.25s; }
.thinking-dots-lg span:nth-child(3) { animation-delay: 0.5s; }
@keyframes thinkBlink { 0%,100% { opacity: 0.15; transform: scale(0.7); } 50% { opacity: 1; transform: scale(1.3); } }

/* Speech bubble */
.speech-bubble { position: fixed; z-index: 20; pointer-events: none; max-width: 240px; padding: 14px 20px; background: linear-gradient(180deg, rgba(26,30,40,0.96), rgba(20,23,31,0.96)); backdrop-filter: blur(8px); border: 1px solid rgba(255,25,25,0.35); border-radius: 16px; color: #fff; font-size: 1.05rem; font-weight: 700; text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,0.5); animation: bubbleIn 0.3s ease-out, bubbleOut 0.5s ease-in 3.5s forwards; }
@keyframes bubbleIn { from { opacity: 0; transform: scale(0.7) translateY(8px); } }
@keyframes bubbleOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-10px); } }

/* Bid overlay: sits on the felt; your real hand stays visible below it */
body.bidding #bid-overlay { background: radial-gradient(ellipse at 50% 40%, rgba(0,0,0,0.15), rgba(0,0,0,0.55)); backdrop-filter: none; align-items: center; padding: 130px 0 calc(var(--ch, 130px) + 90px); }
body.bidding #bottom-bar { z-index: 101; }
body.bidding .bid-hand-preview { display: none; }
.bid-panel { background: var(--panel); padding: 28px 28px 24px; border-radius: var(--r-lg); max-width: 560px; width: 94%; max-height: 92vh; overflow-y: auto; text-align: center; border: 1px solid var(--hairline); box-shadow: var(--shadow-panel), inset 0 1px 0 rgba(255,255,255,0.05); animation: msgEntrance 0.3s ease-out; }
.bid-panel { border-color: rgba(255,25,25,0.3); max-width: 520px; }
.bid-panel h2 { font-family: Georgia, 'Times New Roman', serif; font-size: 1.7rem; letter-spacing: 1px; margin-bottom: 12px; background: linear-gradient(180deg, #f4f0e2 10%, #ff1919 60%, #a00c0c); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

/* Compact score strip */
.bid-score-strip { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px 14px; margin: 0 0 10px; padding: 9px 14px; border-radius: 10px; background: rgba(255,255,255,0.05); border: 1px solid var(--hairline); font-size: 0.78rem; }
.bid-score-strip .bss-side { display: inline-flex; align-items: center; gap: 5px; opacity: 0.85; white-space: nowrap; }
.bid-score-strip b { font-weight: 900; font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.bss-green { color: #4aaf6c; } .bss-red { color: #e0645a; } .bss-blue { color: #ff4d3d; }
.bid-score-strip .bss-vs { opacity: 0.3; font-weight: 800; font-size: 0.65rem; letter-spacing: 1px; }
.bid-score-strip .bss-target { opacity: 0.4; font-size: 0.65rem; white-space: nowrap; }

/* Bids so far, as chips */
.bids-so-far { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.bsf-label { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 1.5px; opacity: 0.4; margin-right: 2px; }
.bsf-chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,0.06); border: 1px solid var(--hairline); font-size: 0.75rem; white-space: nowrap; }
.bsf-chip b { color: #ff4d3d; font-weight: 800; font-variant-numeric: tabular-nums; }

/* Hand preview, grouped by suit */
.bid-hand-preview { display: flex; flex-direction: column; gap: 5px; margin: 12px auto 4px; max-width: 420px; }
.bid-suit-row { display: flex; align-items: center; gap: 10px; padding: 5px 10px; border-radius: 10px; background: rgba(255,255,255,0.04); }
.bid-suit-icon { width: 22px; font-size: 1.15rem; line-height: 1; flex-shrink: 0; text-align: center; }
.bid-suit-icon[data-suit="spades"], .bid-suit-icon[data-suit="clubs"] { color: rgba(255,255,255,0.85); }
.bid-suit-icon[data-suit="hearts"], .bid-suit-icon[data-suit="diamonds"] { color: #e0645a; }
body.colorblind .bid-suit-icon[data-suit="diamonds"] { color: #5a9ae0; }
body.colorblind .bid-suit-icon[data-suit="clubs"] { color: #58b56a; }
.bid-suit-cards { display: flex; flex-wrap: wrap; gap: 4px; }
.bid-card { min-width: 26px; padding: 4px 6px; border-radius: 6px; background: linear-gradient(160deg, #fff, #f0f0ea); border: 1px solid rgba(0,0,0,0.12); box-shadow: 0 1px 3px rgba(0,0,0,0.3); font-weight: 800; font-size: 0.82rem; line-height: 1; text-align: center; }
.bid-void { opacity: 0.25; font-weight: 700; padding: 4px 2px; }

/* Bid buttons: fixed 7-column grid (Nil + 1-6 / 7-13) */
.bid-buttons { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin-top: 14px; }
.bid-btn {
  width: 100%; aspect-ratio: 1; max-width: 58px; justify-self: center; border-radius: 50%; cursor: pointer;
  border: 2px dashed rgba(255,25,25,0.45); outline: 3px solid #1a1e28; outline-offset: -6px;
  background: radial-gradient(circle at 50% 35%, #2e3442, #1a1e28 70%); color: #ebe5ce;
  font-size: 1.1rem; font-weight: 900; font-variant-numeric: tabular-nums;
  box-shadow: 0 4px 0 #0c0e13, 0 8px 16px rgba(0,0,0,0.45);
  transition: transform 0.15s var(--ease-spring), box-shadow 0.15s, background 0.15s, color 0.15s;
}
.bid-suggest { margin-top: 10px; font-size: 0.72rem; color: rgba(235,229,206,0.6); letter-spacing: 0.5px; }
.bid-suggest b { color: var(--gold); font-size: 0.9rem; }
.bid-btn.suggested { border-style: solid; border-color: var(--gold); box-shadow: 0 4px 0 #0c0e13, 0 0 0 2px rgba(255,25,25,0.35), 0 0 16px rgba(255,25,25,0.35); }
.bid-btn:hover { background: radial-gradient(circle at 50% 35%, #ff5a4a, #d01010 70%); color: var(--on-accent); border-color: rgba(120,10,10,0.6); transform: translateY(-3px); box-shadow: 0 7px 0 #6a4812, 0 12px 22px rgba(0,0,0,0.5), 0 0 18px rgba(255,25,25,0.45); }
.bid-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #0c0e13, 0 4px 8px rgba(0,0,0,0.45); }
.bid-nil { background: radial-gradient(circle at 50% 35%, #6a2a8a, #2c0f3e 70%); border-color: rgba(210,160,255,0.6); color: #f0dcff; font-size: 0.8rem; letter-spacing: 1px; }
.bid-nil:hover { background: radial-gradient(circle at 50% 35%, #b88ae0, #6a2a8a 70%); color: #fff; }
.bid-blind-nil { background: rgba(168,85,247,0.15); border-color: rgba(168,85,247,0.3); color: #a855f7; font-size: 0.75rem; width: auto; padding: 0 12px; }
.bid-blind-nil:hover { background: rgba(168,85,247,0.3); border-color: #a855f7; }

/* Particles */
.particle {
  position: fixed; pointer-events: none; z-index: 55; border-radius: 50%;
  will-change: left, top, opacity, transform;
}
.particle-gold {
  background: radial-gradient(circle, #ff4d3d, #ff1919);
  box-shadow: 0 0 6px rgba(255,25,25,0.8), 0 0 12px rgba(255,25,25,0.4);
}

/* Spades broken banner */
.spades-broken-banner {
  position: fixed; top: 27%; left: 50%; z-index: 55; pointer-events: none; display: flex; align-items: center; gap: 12px;
  padding: 10px 26px 10px 14px; border-radius: 999px; white-space: nowrap;
  font-family: Georgia, 'Times New Roman', serif; font-size: 1.35rem; font-weight: 900; letter-spacing: 3px; text-transform: uppercase; color: #14171f;
  background: linear-gradient(180deg, #ebe5ce 0%, #ff1919 45%, #a00c0c 100%); border: 2px solid #6a0808;
  box-shadow: 0 6px 0 #4a0606, 0 16px 40px rgba(0,0,0,0.6), 0 0 40px rgba(255,25,25,0.45);
  transform: translate(-50%, -50%); animation: sbbIn 0.45s cubic-bezier(.2,1.6,.4,1) backwards, sbbOut 0.45s ease-in forwards;
}
.sbb-suit { display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 50%; background: #1a1e28; color: var(--gold); font-size: 1.4rem; font-family: system-ui, sans-serif; box-shadow: inset 0 0 0 2px rgba(255,25,25,0.5); }
@keyframes sbbIn { from { opacity: 0; transform: translate(-50%, -50%) scale(2.2) rotate(-6deg); } to { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0deg); } }
@keyframes sbbOut { to { opacity: 0; transform: translate(-50%, -80%) scale(0.9); } }
@keyframes spadesBrokenIn { from { opacity: 0; transform: translate(-50%, -50%) scale(0.5); } }
@keyframes spadesBrokenOut { to { opacity: 0; } }

/* Trick winner popup */
.trick-winner-popup { position: fixed; top: 40%; left: 50%; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 12px; padding: 14px 28px; background: linear-gradient(145deg, rgba(20,20,30,0.95), rgba(10,10,20,0.98)); backdrop-filter: blur(12px); border: 1px solid rgba(255,25,25,0.3); border-radius: 14px; z-index: 50; pointer-events: none; box-shadow: 0 8px 30px rgba(0,0,0,0.5); font-weight: 700; animation: trickWinIn 0.3s ease-out; }
@keyframes trickWinIn { from { opacity: 0; transform: translate(-50%, -50%) scale(0.8); } }

/* Achievement popup */
.achievement-popup { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 14px 24px; background: linear-gradient(145deg, rgba(20,20,30,0.95), rgba(10,10,20,0.98)); backdrop-filter: blur(12px); border: 1px solid rgba(255,25,25,0.3); border-radius: 14px; z-index: 60; pointer-events: none; box-shadow: 0 8px 30px rgba(0,0,0,0.5); animation: achIn 0.4s ease-out, achOut 0.5s ease-in 3s forwards; }
.ach-icon { font-size: 2rem; }
.ach-text { font-weight: 700; color: #ff1919; }
.ach-label { font-size: 0.7rem; opacity: 0.5; text-transform: uppercase; letter-spacing: 1px; }
@keyframes achIn { from { opacity: 0; transform: translateX(-50%) translateY(20px); } }
@keyframes achOut { to { opacity: 0; transform: translateX(-50%) translateY(20px); } }

/* Stats */
.stat-section { margin-top: 16px; }
.stat-section-title { font-size: 0.7rem; opacity: 0.35; text-transform: uppercase; letter-spacing: 2px; margin-bottom: 8px; }
.stat-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.04); font-size: 0.9rem; }
.stat-label { opacity: 0.6; }
.stat-value { font-weight: 800; color: #ff1919; }
.achievement-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.03); }
.achievement-icon { font-size: 1.5rem; width: 36px; text-align: center; }
.achievement-info { flex: 1; }
.achievement-name { font-weight: 700; font-size: 0.9rem; }
.achievement-desc { font-size: 0.75rem; opacity: 0.4; }
.achievement-row.locked { opacity: 0.3; filter: grayscale(1); }
.achievement-row.unlocked .achievement-name { color: #ff1919; }

/* Prefs */
.pref-group { margin-bottom: 22px; }
.pref-label { font-size: 0.7rem; opacity: 0.4; text-transform: uppercase; letter-spacing: 2px; margin-bottom: 10px; border-bottom: 1px solid rgba(255,255,255,0.05); padding-bottom: 6px; }
.skin-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.skin-option { padding: 12px 8px; border-radius: 10px; cursor: pointer; border: 2px solid rgba(255,255,255,0.08); transition: all 0.2s; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 600; gap: 8px; background: rgba(255,255,255,0.03); }
.skin-option:hover { border-color: rgba(255,255,255,0.2); }
.skin-option.active { border-color: #ff1919; box-shadow: 0 0 16px rgba(255,25,25,0.25); background: rgba(255,25,25,0.08); }
.skin-preview { width: 48px; height: 24px; border-radius: 4px; border: 1.5px solid rgba(0,0,0,0.2); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; }
.toggle-row span { font-size: 0.95rem; font-weight: 600; }
.toggle-switch { position: relative; width: 48px; height: 26px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; cursor: pointer; background: rgba(255,255,255,0.12); border-radius: 26px; transition: all 0.3s; }
.toggle-slider::before { content: ''; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: all 0.3s; box-shadow: 0 2px 4px rgba(0,0,0,0.3); }
.toggle-switch input:checked + .toggle-slider { background: linear-gradient(145deg, #ff1919, #a00c0c); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(22px); }
.name-edit { background: var(--surface-2); border: 1px solid var(--hairline-strong); color: #fff; padding: 8px 12px; border-radius: var(--r-sm); font-size: 1rem; font-weight: 600; font-family: inherit; width: 140px; text-align: center; outline: none; transition: border-color 0.2s, box-shadow 0.2s; }
.name-edit:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,25,25,0.25); }

/* XP */
#xp-bar-wrap { display: flex; align-items: center; gap: 8px; }
.xp-level { font-size: 0.7rem; font-weight: 900; min-width: 56px; padding: 3px 10px; border-radius: 6px; text-align: center; background: linear-gradient(145deg, #ff1919, #a00c0c); color: #fff; box-shadow: 0 2px 6px rgba(255,25,25,0.3); }
.xp-bar { width: 80px; height: 8px; background: rgba(255,255,255,0.08); border-radius: 4px; overflow: hidden; }
.xp-fill { height: 100%; background: linear-gradient(90deg, #ff1919, #a00c0c, #ff1919); border-radius: 4px; transition: width 0.5s ease; background-size: 200% 100%; animation: xpShimmer 2s linear infinite; }
@keyframes xpShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Log */
.log-entry { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.03); font-size: 0.85rem; margin-bottom: 4px; }
.log-num { font-size: 0.7rem; opacity: 0.3; font-weight: 700; min-width: 50px; }
#log-entries { flex: 1; overflow-y: auto; margin-bottom: 16px; }

/* Shortcuts */
.shortcut-grid { display: flex; flex-direction: column; gap: 6px; }
.sc-row { display: flex; align-items: center; gap: 12px; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.04); font-size: 0.9rem; }
.sc-row kbd { display: inline-block; min-width: 28px; padding: 3px 8px; text-align: center; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15); border-radius: 6px; font-family: monospace; font-weight: 700; font-size: 0.8rem; color: #ff1919; }
.sc-row span { opacity: 0.7; }

/* Game over */
#gameover-screen { align-items: center; justify-content: center; }
#final-scores { margin: 24px 0; text-align: left; }
.final-score-row { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding: 16px 24px; margin: 8px 0; background: rgba(255,255,255,0.04); border-radius: 14px; min-width: 360px; border: 1px solid rgba(255,255,255,0.06); font-size: 1.05rem; font-weight: 700; color: #f4f0e2; }
.final-score-row span:last-child { font-size: 1.4rem; font-weight: 900; font-variant-numeric: tabular-nums; }
#gameover-screen .menu-container { min-width: min(460px, 94vw); padding: 36px 44px 40px; }
#gameover-screen .go-eyebrow { margin-top: 18px; font-size: 0.7rem; letter-spacing: 4px; font-weight: 800; color: rgba(235,229,206,0.5); text-transform: uppercase; }
#gameover-screen .game-title { font-size: 3rem; margin: 4px 0 20px; }
#gameover-screen.lost .game-title { background: linear-gradient(180deg, #f2f2f2 0%, #b8b8b8 50%, #6a6a6a 100%); -webkit-background-clip: text; background-clip: text; }
#gameover-screen .menu-hero { height: 130px; }
#gameover-screen.lost .menu-hero { filter: grayscale(0.8) brightness(0.7); }
.final-score-row.winner { background: linear-gradient(145deg, rgba(255,25,25,0.2), rgba(255,25,25,0.08)); border: 2px solid rgba(255,25,25,0.4); box-shadow: 0 0 30px rgba(255,25,25,0.15); }

/* Responsive */
@media (max-width: 600px) {
  .menu-container { padding: 24px 20px; }
  .game-title { font-size: 2.2rem; letter-spacing: 5px; }
  .title-spade { font-size: 2rem; }
  .subtitle { letter-spacing: 8px; font-size: 1rem; }
  .btn-menu { width: 36px; height: 36px; font-size: 1rem; }
  .bid-panel { padding: 18px 14px 16px; }
  .bid-panel h2 { font-size: 1.25rem; margin-bottom: 10px; }
  .bid-buttons { gap: 6px; }
  .bid-btn { font-size: 0.95rem; }
  .bid-score-strip { font-size: 0.72rem; gap: 4px 10px; padding: 8px 10px; }
  .bid-card { min-width: 23px; padding: 4px 5px; font-size: 0.78rem; }
  .bid-suit-row { padding: 4px 8px; gap: 8px; }
  .bsf-chip { font-size: 0.7rem; padding: 3px 8px; }
  .final-score-row { min-width: auto; padding: 10px 14px; font-size: 0.9rem; }
}
@media (max-width: 400px) {
  .game-title { font-size: 1.6rem; }
}

/* Phone table: smaller cards, compact seats, human plate folds into the top bar area */
@media (max-width: 700px) {
  #game-screen { --cw: 56px; }
  #score-bar { padding: 8px 8px 4px 54px; }
  .sb-team, .sb-player-score { padding: 6px 10px; gap: 8px; }
  .sb-team-name, .sb-ps-name { font-size: 0.66rem; max-width: 70px; }
  .sb-team-score { font-size: 1.15rem; }
  .sb-round { padding: 4px 9px; } .sb-round b { font-size: 1rem; }
  .sb-target { display: none; }
  .opponent-hand.left, .opponent-hand.right { width: 76px; }
  .opponent-hand.top { min-height: 78px; }
  .seat-fan { width: 90px; height: 40px; }
  .mini-card { width: 22px; height: 31px; margin-left: -11px; }
  .opponent-hand.left .seat-fan, .opponent-hand.right .seat-fan { width: 80px; height: 40px; margin-bottom: -10px; }
  .seat-avatar { width: 38px; height: 38px; }
  .seat-plate { gap: 6px; padding: 4px 10px 4px 4px; }
  .opponent-hand.left .seat-plate, .opponent-hand.right .seat-plate { padding: 6px; }
  .seat-name { font-size: 0.7rem; max-width: 64px; }
  .seat-sub { display: none; }
  .seat-bid { padding: 2px 7px; } .seat-bid b { font-size: 0.85rem; } .seat-bid small { display: none; }
  #game-layout::before { left: 10px; right: 10px; top: 40px; }
  #game-layout::after { left: 30px; right: 30px; top: 60px; }
  #trick-area { width: calc(var(--cw) * 3.4); height: calc(var(--ch) * 2.2); }
  #human-info { left: 10px; bottom: calc(var(--ch) + 96px); }
  #trick-info { display: none; }
  #human-info #xp-bar-wrap { display: none; }
  #human-info .seat-avatar { width: 30px; height: 30px; padding: 2px; }
  #human-info .seat-sub { display: none; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* Safe areas */
@supports (padding: env(safe-area-inset-top)) {
  #score-bar { padding-top: max(8px, env(safe-area-inset-top)); }
  #bottom-bar { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .btn-menu { top: max(10px, env(safe-area-inset-top)); }
}


/* ===== Enhanced Visual Effects ===== */

/* Score popup blast */
@keyframes scoreBlast {
  0% { opacity:0; transform:translate(-50%,-50%) scale(0.2) rotate(-8deg); }
  12% { opacity:1; transform:translate(-50%,-50%) scale(1.5) rotate(3deg); }
  22% { transform:translate(-50%,-50%) scale(0.95) rotate(-1deg); }
  30% { transform:translate(-50%,-50%) scale(1.05) rotate(0); }
  75% { opacity:1; transform:translate(-50%,-50%) scale(1) translateY(-20px); }
  100% { opacity:0; transform:translate(-50%,-50%) scale(1.3) translateY(-90px); }
}
.score-popup { position:fixed; pointer-events:none; z-index:50; }

/* Score vignette flash */
@keyframes vignetteFlash { 0% { opacity:1; } 100% { opacity:0; } }

/* Screen shake */
@keyframes boardShake {
  0%,100% { transform:translate(0,0); }
  10% { transform:translate(-4px,2px); }
  20% { transform:translate(4px,-2px); }
  30% { transform:translate(-3px,-3px); }
  40% { transform:translate(3px,3px); }
  50% { transform:translate(-2px,1px); }
  60% { transform:translate(2px,-1px); }
  70% { transform:translate(-1px,2px); }
  80% { transform:translate(1px,-1px); }
}
.board-shake { animation:boardShake 0.5s ease-out; }

@keyframes boardShakeHeavy {
  0%,100% { transform:translate(0,0) rotate(0); }
  8% { transform:translate(-6px,3px) rotate(-0.5deg); }
  16% { transform:translate(6px,-4px) rotate(0.5deg); }
  24% { transform:translate(-5px,-3px) rotate(-0.3deg); }
  32% { transform:translate(4px,4px) rotate(0.3deg); }
  40% { transform:translate(-3px,2px) rotate(-0.2deg); }
  50% { transform:translate(3px,-2px) rotate(0.1deg); }
  60% { transform:translate(-2px,1px); }
  70% { transform:translate(1px,-1px); }
}
.board-shake-heavy { animation:boardShakeHeavy 0.6s ease-out; }

/* Combo popup */
.combo-popup, .first-blood-banner {
  position: fixed; left: 50%; z-index: 80; pointer-events: none; white-space: nowrap; opacity: 0;
  font-family: Georgia, 'Times New Roman', serif; font-weight: 900; text-transform: uppercase;
  background: linear-gradient(180deg, #f4f0e2 0%, #ff4d3d 40%, #d01010 70%, #7a0a0a 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  filter: drop-shadow(0 3px 0 rgba(60,6,6,0.95)) drop-shadow(0 8px 16px rgba(0,0,0,0.7));
}
.combo-popup { top: 38%; font-size: 2.6rem; letter-spacing: 4px; animation: comboIn 1s ease-out forwards; }
.first-blood-banner { top: 30%; font-size: 1.7rem; letter-spacing: 5px; animation: firstBloodIn 1.5s ease-out forwards; }
@keyframes comboIn {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(2) rotate(-6deg); }
  25% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-3deg); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -80%) scale(1) rotate(-3deg); }
}
@keyframes firstBloodIn {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(1.8); letter-spacing: 14px; }
  25% { opacity: 1; transform: translate(-50%, -50%) scale(1); letter-spacing: 5px; }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -70%) scale(1); }
}

/* Round announcement animations */
@keyframes announceIn { 0% { opacity:0; transform:scale(0.8); } 100% { opacity:1; transform:scale(1); } }
@keyframes raSlideDown { 0% { opacity:0; transform:translateY(-20px); } 100% { opacity:1; transform:translateY(0); } }
@keyframes raNumberPop { 0% { opacity:0; transform:scale(0.3); } 70% { opacity:1; transform:scale(1.1); } 100% { opacity:1; transform:scale(1); } }
@keyframes raSlideUp { 0% { opacity:0; transform:translateY(30px); } 100% { opacity:1; transform:translateY(0); } }
@keyframes raFadeIn { 0% { opacity:0; } 100% { opacity:1; } }

/* Countdown pop */
@keyframes countPop {
  0% { opacity:0; transform:scale(2.5); }
  30% { opacity:1; transform:scale(0.9); }
  50% { transform:scale(1.05); }
  100% { opacity:0; transform:scale(0.8); }
}

/* Ambient dust motes */
#dust-canvas { position:fixed; inset:0; pointer-events:none; z-index:1; opacity:0.3; }

/* Time-of-day ambient lighting */
#time-fx { position:fixed; inset:0; pointer-events:none; z-index:0; transition:background 60s linear; }

/* Card play hover glow on trick area */

/* Active turn indicator pulse on human info */


/* Dropdown shortcut key badges */
.dd-key {
  float:right; display:inline-block; min-width:22px; padding:2px 6px;
  text-align:center; background:rgba(255,255,255,0.08); border:1px solid rgba(255,255,255,0.12);
  border-radius:4px; font-family:monospace; font-size:0.7rem; font-weight:700;
  color:rgba(255,255,255,0.4); margin-left:12px; line-height:1.3;
}


/* Floating turn arrow */
#floating-arrow {
  position:fixed; z-index:8; pointer-events:none; width:40px; height:40px; opacity:0.5;
  transition:top 0.5s cubic-bezier(0.34,1.56,0.64,1), left 0.5s cubic-bezier(0.34,1.56,0.64,1);
  filter:drop-shadow(0 0 8px rgba(255,25,25,0.5));
}
#floating-arrow::after {
  content:''; display:block; width:0; height:0;
  border-left:20px solid transparent; border-right:20px solid transparent; border-top:34px solid #ff1919;
  animation:arrowBob 0.8s ease-in-out infinite;
}
@keyframes arrowBob { 0%,100% { transform:translateY(0); } 50% { transform:translateY(8px); } }
#floating-arrow.point-up::after { border-top:none; border-bottom:34px solid #ff1919; animation:arrowBobUp 0.8s ease-in-out infinite; }
@keyframes arrowBobUp { 0%,100% { transform:translateY(0); } 50% { transform:translateY(-8px); } }
#floating-arrow.point-left::after { border-left:none; border-right:none; border-top:20px solid transparent; border-bottom:20px solid transparent; border-right:34px solid #ff1919; animation:arrowBobLeft 0.8s ease-in-out infinite; }
@keyframes arrowBobLeft { 0%,100% { transform:translateX(0); } 50% { transform:translateX(-8px); } }
#floating-arrow.point-right::after { border-left:none; border-right:none; border-top:20px solid transparent; border-bottom:20px solid transparent; border-left:34px solid #ff1919; animation:arrowBobRight 0.8s ease-in-out infinite; }
@keyframes arrowBobRight { 0%,100% { transform:translateX(0); } 50% { transform:translateX(8px); } }
@media (max-width:480px) { #floating-arrow { display:none; } }


/* Bid tracker on table */
#bid-tracker {
  position: absolute; top: 14px; right: max(96px, 9%); z-index: 5;
  padding: 10px 14px 8px; border-radius: 14px; min-width: 150px;
  background: linear-gradient(180deg, rgba(20,23,31,0.88), rgba(20,23,31,0.88));
  border: 1px solid rgba(255,25,25,0.25); font-size: 0.75rem; color: #f4f0e2;
  box-shadow: 0 10px 26px rgba(0,0,0,0.5);
}
#bid-tracker:empty { display: none; }
.bt-title { font-size: 0.56rem; color: var(--gold); text-transform: uppercase; letter-spacing: 2px; margin-bottom: 6px; text-align: center; font-weight: 800; }
.bt-row { display: flex; justify-content: space-between; align-items: center; padding: 3px 0; gap: 10px; }
.bt-row.current .bt-name { color: var(--gold); }
.bt-name { opacity: 0.85; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 84px; }
.bt-bid { font-weight: 800; color: rgba(255,245,225,0.6); min-width: 22px; text-align: center; font-variant-numeric: tabular-nums; }
.bt-tricks { font-weight: 900; min-width: 20px; text-align: center; font-variant-numeric: tabular-nums; }
.bt-tricks.made { color: #8fe0a0; }
.bt-tricks.over { color: #ff8a7a; }
.bt-tricks.under { color: rgba(255,255,255,0.55); }
.bt-divider { height: 1px; background: rgba(255,25,25,0.18); margin: 5px 0; }
.bt-team-row { display: flex; justify-content: space-between; font-weight: 800; font-size: 0.72rem; padding: 1px 0; font-variant-numeric: tabular-nums; }
@media (max-width: 700px) { #bid-tracker { display: none; } }

/* ===== Light Theme: ivory daylight room; the table, seats and chips stay the same ===== */
body[data-theme="light"] { background: #e9dfca; color: #2b2116; --lt-panel: linear-gradient(170deg, #fdfaf2 0%, #f1e8d6 100%); --lt-ink: #2b2116; --lt-muted: #7a6a52; --lt-gold: #9a6e1e; --lt-line: rgba(90,64,20,0.14); }
body[data-theme="light"]::before { background: radial-gradient(ellipse 90% 70% at 50% 40%, #f6efe0 0%, #e4d6b8 60%, #c9b58c 100%); }
body[data-theme="light"]::after { opacity: 0.04; }
body[data-theme="light"] #menu-screen, body[data-theme="light"] #gameover-screen { background: radial-gradient(ellipse 60% 50% at 50% 35%, rgba(31,122,68,0.12), transparent 70%); }

/* Panels */
body[data-theme="light"] .menu-container,
body[data-theme="light"] .message-box, body[data-theme="light"] .bid-panel,
body[data-theme="light"] .rules-panel, body[data-theme="light"] .log-panel,
body[data-theme="light"] .shortcuts-panel, body[data-theme="light"] .stats-panel,
body[data-theme="light"] .tutorial-panel, body[data-theme="light"] #game-dropdown {
  background: var(--lt-panel); color: var(--lt-ink); border-color: rgba(154,110,30,0.35);
  box-shadow: 0 30px 70px rgba(120,10,10,0.28), inset 0 1px 0 #fff;
}
body[data-theme="light"] .game-title { filter: drop-shadow(0 2px 0 rgba(120,80,20,0.35)) drop-shadow(0 8px 18px rgba(120,10,10,0.25)); }
body[data-theme="light"] .subtitle, body[data-theme="light"] .option-group label, body[data-theme="light"] .roster-title,
body[data-theme="light"] .rr-eyebrow, body[data-theme="light"] .go-eyebrow, body[data-theme="light"] .pref-label,
body[data-theme="light"] .rr-h, body[data-theme="light"] .rr-target, body[data-theme="light"] .bsf-label { color: var(--lt-muted); opacity: 1; }
body[data-theme="light"] .message-box p, body[data-theme="light"] .rules-content p { color: #4a3d2a; }
body[data-theme="light"] .rules-content h3, body[data-theme="light"] .rules-content strong { color: var(--lt-gold); }

/* Controls */
body[data-theme="light"] .btn-group { background: rgba(90,64,20,0.06); border-color: var(--lt-line); }
body[data-theme="light"] .btn-option { color: #5a4a32; }
body[data-theme="light"] .btn-option:hover { background: rgba(90,64,20,0.08); color: var(--lt-ink); }
body[data-theme="light"] .btn-start.btn-secondary { background: rgba(255,255,255,0.6); color: var(--lt-gold); border-color: rgba(154,110,30,0.55); }
body[data-theme="light"] .gm-btn, body[data-theme="light"] .name-edit { background: rgba(90,64,20,0.06); border-color: var(--lt-line); color: var(--lt-ink); }
body[data-theme="light"] .gm-btn:hover { background: rgba(90,64,20,0.12); }
body[data-theme="light"] .btn-menu { background: rgba(253,250,242,0.9); border-color: rgba(154,110,30,0.35); color: var(--lt-ink); }
body[data-theme="light"] .dd-item { color: var(--lt-ink); }
body[data-theme="light"] .dd-item:hover { background: rgba(90,64,20,0.08); }
body[data-theme="light"] .dd-key { background: rgba(90,64,20,0.08); border-color: var(--lt-line); color: var(--lt-muted); }
body[data-theme="light"] .toggle-row span, body[data-theme="light"] .stat-row, body[data-theme="light"] .sc-row,
body[data-theme="light"] .achievement-row, body[data-theme="light"] .log-entry { color: var(--lt-ink); border-color: var(--lt-line); }
body[data-theme="light"] .stat-label, body[data-theme="light"] .sc-row span, body[data-theme="light"] .achievement-desc { color: var(--lt-muted); }
body[data-theme="light"] .sc-row kbd { background: rgba(90,64,20,0.08); border-color: var(--lt-line); }
body[data-theme="light"] .log-entry { background: rgba(90,64,20,0.04); }
body[data-theme="light"] .skin-option { background: rgba(90,64,20,0.04); border-color: var(--lt-line); color: var(--lt-ink); }
body[data-theme="light"] .skin-option:hover { background: rgba(90,64,20,0.08); }
body[data-theme="light"] .toggle-slider { background: rgba(90,64,20,0.2); }

/* Roster */
body[data-theme="light"] .roster-card { background: rgba(255,255,255,0.55); border-color: var(--lt-line); }
body[data-theme="light"] .roster-card:hover { background: rgba(255,255,255,0.85); }
body[data-theme="light"] .roster-card.human { background: rgba(255,25,25,0.18); border-color: rgba(154,110,30,0.45); }
body[data-theme="light"] .roster-card .roster-name { color: var(--lt-ink); }
body[data-theme="light"] .roster-card .roster-rank { color: var(--lt-gold); }
body[data-theme="light"] .roster-card .roster-record { color: var(--lt-muted); opacity: 1; }
body[data-theme="light"] .roster-reroll { background: rgba(255,255,255,0.7); border-color: var(--lt-line); color: var(--lt-ink); }

/* Bidding and results */
body[data-theme="light"] .bid-suggest { color: var(--lt-muted); }
body[data-theme="light"] .bid-suggest b { color: var(--lt-gold); }
body[data-theme="light"] .bid-score-strip, body[data-theme="light"] .bsf-chip { background: rgba(90,64,20,0.06); border-color: var(--lt-line); color: var(--lt-ink); }
body[data-theme="light"] .bss-blue, body[data-theme="light"] .bsf-chip b { color: var(--lt-gold); }
body[data-theme="light"] .rr-team { background: rgba(255,255,255,0.6); border-color: var(--lt-line); }
body[data-theme="light"] .rr-team-name, body[data-theme="light"] .rr-name, body[data-theme="light"] .rr-lane b,
body[data-theme="light"] .rr-score, body[data-theme="light"] .rr-lane-label { color: var(--lt-ink); }
body[data-theme="light"] .rr-bid { color: var(--lt-gold); }
body[data-theme="light"] .rr-tricks { color: #6a5a42; }
body[data-theme="light"] .rr-tricks.good, body[data-theme="light"] .rr-team.made .rr-delta, body[data-theme="light"] .rr-delta-sm.good { color: #1f8a4a; }
body[data-theme="light"] .rr-tricks.bad, body[data-theme="light"] .rr-team.set .rr-delta, body[data-theme="light"] .rr-delta-sm.bad { color: #c0392b; }
body[data-theme="light"] .rr-team.made .rr-badge { color: #17703b; background: rgba(40,160,90,0.14); border-color: rgba(30,130,70,0.4); }
body[data-theme="light"] .rr-team.set .rr-badge { color: #a8281a; background: rgba(200,60,40,0.12); border-color: rgba(170,50,30,0.4); }
body[data-theme="light"] .rr-detail, body[data-theme="light"] .rr-quote { color: var(--lt-muted); border-color: var(--lt-line); }
body[data-theme="light"] .rr-bar { background: rgba(90,64,20,0.1); }
body[data-theme="light"] .final-score-row { background: rgba(255,255,255,0.6); border-color: var(--lt-line); color: var(--lt-ink); }
body[data-theme="light"] .final-score-row.winner { background: linear-gradient(145deg, rgba(255,25,25,0.35), rgba(255,25,25,0.15)); border-color: rgba(154,110,30,0.5); }
body[data-theme="light"] .trick-winner-popup { background: var(--lt-panel); border-color: rgba(154,110,30,0.35); color: var(--lt-ink); }


/* Bid announcement bubble — larger and bolder than regular speech */
.speech-bubble.bid-bubble {
  font-size: 1.4rem; padding: 16px 28px; min-width: 100px;
  background: linear-gradient(145deg, rgba(255,25,25,0.25), rgba(20,20,30,0.95));
  border: 2px solid rgba(255,25,25,0.4);
  box-shadow: 0 8px 30px rgba(0,0,0,0.5), 0 0 20px rgba(255,25,25,0.15);
  animation: bubbleIn 0.3s ease-out, bubbleOut 0.5s ease-in 2.5s forwards;
}

body[data-theme="light"] .speech-bubble.bid-bubble {
  background: linear-gradient(145deg, rgba(255,25,25,0.15), rgba(255,255,255,0.95));
  border-color: rgba(255,25,25,0.4); color: #1a2e3e;
}


/* Tutorial */
#tutorial-overlay { position:fixed; inset:0; background:rgba(0,0,0,0.85); display:flex; align-items:center; justify-content:center; z-index:250; backdrop-filter:blur(12px); }
#tutorial-overlay.hidden { display:none; }
.tutorial-panel { background:var(--panel); padding:36px 44px; border-radius:var(--r-lg); max-width:520px; width:92%; border:1px solid var(--hairline); box-shadow:var(--shadow-panel), inset 0 1px 0 rgba(255,255,255,0.05); animation:msgEntrance 0.3s ease-out; position:relative; }
.tutorial-panel strong { color:#ff1919; }
.tutorial-nav { display:flex; align-items:center; justify-content:space-between; margin-top:20px; padding-top:16px; border-top:1px solid rgba(255,255,255,0.05); }
.tut-btn-prev, .tut-btn-next { padding:10px 24px; border:none; border-radius:10px; font-weight:700; font-size:0.9rem; cursor:pointer; transition:all 0.2s; }
.tut-btn-next { background:linear-gradient(145deg,#ff1919,#a00c0c); color:#fff; box-shadow:0 4px 12px rgba(255,25,25,0.3); }
.tut-btn-next:hover { transform:translateY(-1px); }
.tut-btn-prev { background:rgba(255,255,255,0.08); color:#fff; border:1px solid rgba(255,255,255,0.1); }
.tut-btn-prev:disabled { opacity:0.3; cursor:not-allowed; }
.tut-dots { display:flex; gap:6px; }


/* Avatar fallback */
.opp-avatar, .human-avatar, .roster-avatar, .think-avatar {
  object-fit: cover;
}
