*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #1a472a;
  --bg-dark: #0d2818;
  --felt: #1a6b35;
  --felt-light: #228b45;
  --card-bg: #fff;
  --card-shadow: rgba(0,0,0,0.3);
  --text: #f0f0f0;
  --text-muted: #a0b8a8;
  --accent: #ffd700;
  --btn-primary: #2563eb;
  --btn-primary-hover: #1d4ed8;
  --btn-secondary: #475569;
  --btn-secondary-hover: #334155;
  --btn-danger: #dc2626;
  --btn-danger-hover: #b91c1c;
  --red-suit: #dc2626;
  --black-suit: #1a1a1a;
  --spade-color: #1e3a5f;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* Global hidden */
.hidden { display: none !important; }

/* Views */
.view { display: none; height: 100%; width: 100%; position: absolute; top: 0; left: 0; }
.view.active { display: flex !important; }

/* Buttons */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.96); }
.btn-primary { background: var(--btn-primary); color: #fff; }
.btn-primary:hover { background: var(--btn-primary-hover); }
.btn-secondary { background: var(--btn-secondary); color: #fff; }
.btn-secondary:hover { background: var(--btn-secondary-hover); }
.btn-danger { background: var(--btn-danger); color: #fff; }
.btn-danger:hover { background: var(--btn-danger-hover); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-icon {
  background: none; border: none; color: var(--text); font-size: 22px;
  cursor: pointer; padding: 4px 8px; border-radius: 4px;
}
.btn-icon:hover { background: rgba(255,255,255,0.1); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 14px; }
.form-group input, .form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid #334;
  border-radius: 8px;
  background: #1a1a2e;
  color: var(--text);
  font-size: 15px;
}
.form-group input:focus, .form-group select:focus {
  outline: none;
  border-color: var(--btn-primary);
}
/* Toggle button group (game mode selector) */
.toggle-group {
  display: flex;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid #334;
}
.toggle-group input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-btn {
  flex: 1;
  padding: 10px 16px !important;
  text-align: center;
  cursor: pointer;
  background: #1a1a2e;
  color: var(--text-muted);
  font-size: 14px !important;
  font-weight: 600 !important;
  margin: 0 !important;
  transition: background 0.2s, color 0.2s;
  border-right: 1px solid #334;
}
.toggle-btn:last-of-type { border-right: none; }
.toggle-group input[type="radio"]:checked + .toggle-btn {
  background: var(--btn-primary);
  color: #fff;
}

/* Toggle switch (renege checkbox) */
.toggle-switch {
  display: flex !important;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 400 !important;
}
.toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 0 !important;
  height: 0;
}
.toggle-slider {
  width: 40px;
  height: 22px;
  background: #334;
  border-radius: 11px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle-slider::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--btn-primary);
}
.toggle-switch input:checked + .toggle-slider::after {
  transform: translateX(18px);
}
.toggle-text {
  font-size: 14px;
  color: var(--text);
}

/* Name view */
#name-view {
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, var(--felt) 0%, var(--bg-dark) 100%);
}
.center-box {
  background: rgba(0,0,0,0.5);
  padding: 40px;
  border-radius: 16px;
  text-align: center;
  max-width: 400px;
  width: 90%;
}
.game-title {
  font-size: 36px;
  color: var(--accent);
  margin-bottom: 28px;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

/* Lobby */
#lobby-view { flex-direction: column; overflow-y: auto; }
.lobby-container {
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
}
.lobby-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 8px;
}
.lobby-header h2 { color: var(--accent); }
.player-badge {
  background: var(--btn-secondary);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 13px;
}
.lobby-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.lobby-main {
  display: flex;
  gap: 20px;
}
.lobby-main .room-list {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.lobby-chat {
  width: 280px;
  flex-shrink: 0;
}
.lobby-chat h3 { margin-bottom: 12px; color: var(--text-muted); }
.lobby-chat-box {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  height: 300px;
}
.lobby-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  font-size: 13px;
}
.lobby-chat-messages .chat-msg { margin-bottom: 6px; }
.lobby-chat-messages .chat-sender { font-weight: 700; color: var(--accent); }
.lobby-chat-box .chat-input-area {
  border-top: 1px solid rgba(255,255,255,0.1);
}

.room-list h3 { margin-bottom: 12px; color: var(--text-muted); }
#room-list-body {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 12px;
  max-height: 300px;
  overflow-y: auto;
}
.muted { color: var(--text-muted); font-size: 14px; }

.room-card {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background 0.2s;
}
.room-card:hover { background: rgba(255,255,255,0.14); }
.room-card-info {
  min-width: 0;
  flex: 1;
}
.room-card-info h4 {
  font-size: 15px;
  margin-bottom: 4px;
}
.room-card-info span {
  font-size: 13px;
  color: var(--text-muted);
}
.room-card-join { flex-shrink: 0; }

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-content {
  background: #1e293b;
  border-radius: 14px;
  padding: 28px;
  max-width: 420px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-content h3 { margin-bottom: 16px; color: var(--accent); }
.modal-buttons { display: flex; gap: 10px; margin-top: 16px; }

/* Room view */
#room-view { align-items: center; justify-content: center; }
.room-container {
  background: rgba(0,0,0,0.5);
  border-radius: 16px;
  padding: 30px;
  max-width: 500px;
  width: 90%;
  text-align: center;
}
.room-header {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.room-header h2 { color: var(--accent); }
.mode-badge {
  background: var(--btn-primary);
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
.room-info {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 20px;
  font-size: 14px;
  color: var(--text-muted);
}
#room-password-badge { color: var(--accent); }
.renege-badge { color: #fca5a5; }
.team-names-area {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.form-group-inline {
  display: flex;
  align-items: center;
  gap: 6px;
}
.form-group-inline label { font-size: 13px; font-weight: 600; white-space: nowrap; }
.form-group-inline input {
  padding: 6px 10px;
  border: 1px solid #334;
  border-radius: 6px;
  background: #1a1a2e;
  color: var(--text);
  font-size: 13px;
  width: 120px;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 400;
}
.form-hint {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.player-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}
.player-slot {
  background: rgba(255,255,255,0.06);
  border: 2px dashed rgba(255,255,255,0.15);
  border-radius: 10px;
  padding: 14px;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 52px;
}
.player-slot.filled {
  border-style: solid;
  border-color: rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.1);
}
.player-slot.cpu { border-color: var(--accent); color: var(--accent); }
.player-slot .host-icon { color: var(--accent); }
.team-header {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 4px;
}

.room-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.room-share {
  font-size: 13px;
  color: var(--text-muted);
}
.copy-code {
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.2s;
}
.copy-code:hover {
  background: rgba(255,255,255,0.15);
}
.copy-code.copied {
  background: rgba(34,197,94,0.3);
}

/* GAME VIEW */
#game-view { flex-direction: column; }
.game-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: radial-gradient(ellipse at center, var(--felt) 0%, var(--bg-dark) 100%);
  position: relative;
}

/* Score bar */
.score-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: rgba(0,0,0,0.5);
  font-size: 13px;
  z-index: 10;
  flex-shrink: 0;
  gap: 4px;
}
#score-display { display: flex; gap: 16px; flex-wrap: wrap; }
.score-item { display: flex; gap: 4px; }
.score-label { color: var(--text-muted); }
.score-value { font-weight: 700; }
.game-code {
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1px;
}
.game-buttons { display: flex; gap: 6px; flex-shrink: 0; }
.btn-label {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-label:hover { background: rgba(255,255,255,0.22); }
.btn-renege {
  background: rgba(220,38,38,0.3);
  border-color: rgba(220,38,38,0.5);
  color: #fca5a5;
}
.btn-renege:hover { background: rgba(220,38,38,0.5); }
.btn-label.chat-notify {
  background: rgba(220,38,38,0.5);
  border-color: rgba(220,38,38,0.7);
  color: #fff;
  animation: chatPulse 1s ease-in-out infinite;
}
@keyframes chatPulse {
  0%, 100% { background: rgba(220,38,38,0.5); }
  50% { background: rgba(220,38,38,0.8); }
}
.btn-leave-game {
  background: rgba(220,38,38,0.2);
  border-color: rgba(220,38,38,0.4);
  color: #f87171;
}
.btn-leave-game:hover { background: rgba(220,38,38,0.4); color: #fff; }

/* Table area */
.table-area {
  flex: 1;
  position: relative;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Player seats */
.player-seat {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  z-index: 5;
}
.seat-top { top: 8px; left: 50%; transform: translateX(-50%); }
.seat-left { left: 8px; top: 50%; transform: translateY(-50%); }
.seat-right { right: 8px; top: 50%; transform: translateY(-50%); }

.seat-label {
  background: rgba(0,0,0,0.6);
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12px;
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.seat-label .seat-name { font-weight: 700; }
.seat-label .seat-info { font-size: 11px; color: var(--text-muted); }
.seat-label.is-turn {
  background: rgba(37, 99, 235, 0.7);
  box-shadow: 0 0 12px rgba(37,99,235,0.5);
}
.seat-label.disconnected { opacity: 0.5; }
.seat-cards {
  display: flex;
  gap: 2px;
}

/* Mini cards (opponents) */
.mini-card {
  width: 24px;
  height: 34px;
  background: #2d3748;
  border: 1px solid #4a5568;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
}

/* Trick area (center of table) - plus/cross layout */
.trick-area {
  display: grid;
  grid-template-areas:
    ".     top    ."
    "left  center right"
    ".     bottom .";
  grid-template-columns: auto auto auto;
  grid-template-rows: auto auto auto;
  gap: 4px;
  align-items: center;
  justify-items: center;
  z-index: 6;
}
.trick-card-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.trick-card-wrapper.pos-top { grid-area: top; }
.trick-card-wrapper.pos-left { grid-area: left; }
.trick-card-wrapper.pos-right { grid-area: right; }
.trick-card-wrapper.pos-bottom { grid-area: bottom; }
.trick-card-wrapper.pos-center { grid-area: center; }
.trick-card-name {
  font-size: 10px;
  color: var(--text-muted);
  background: rgba(0,0,0,0.5);
  padding: 1px 6px;
  border-radius: 4px;
}
.trick-winner-label {
  grid-area: center;
  font-size: 12px;
  color: #ffd700;
  font-weight: 700;
  text-align: center;
}

/* Cards */
.card {
  width: 60px;
  height: 84px;
  background: var(--card-bg);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  box-shadow: 0 2px 6px var(--card-shadow);
  position: relative;
  cursor: default;
  transition: transform 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
}
.card .card-rank { font-size: 18px; line-height: 1; }
.card .card-suit { font-size: 22px; line-height: 1; }
.card.red { color: var(--red-suit); }
.card.black { color: var(--black-suit); }
.card.spade { color: var(--spade-color); }

.card-corner {
  position: absolute;
  font-size: 10px;
  line-height: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.card-corner.top-left { top: 3px; left: 4px; }
.card-corner.bottom-right { bottom: 3px; right: 4px; transform: rotate(180deg); }

/* Player hand */
.player-hand-area {
  flex-shrink: 0;
  padding: 6px 10px 10px;
  background: rgba(0,0,0,0.4);
  z-index: 10;
  position: relative;
}
.hand-info {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  margin-bottom: 6px;
  color: var(--text-muted);
}
.hand-info span:first-child { font-weight: 700; color: var(--text); }
.sort-select {
  background: rgba(255,255,255,0.1);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  cursor: pointer;
}
.player-hand {
  display: flex;
  justify-content: center;
  gap: 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 4px 0;
  -webkit-overflow-scrolling: touch;
}
.player-hand .card {
  cursor: pointer;
}
.player-hand .card:hover {
  transform: translateY(-8px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}
.player-hand .card.invalid {
  opacity: 0.4;
  cursor: not-allowed;
}
.player-hand .card.invalid:hover {
  transform: none;
  box-shadow: 0 2px 6px var(--card-shadow);
}
.player-hand .card.selected {
  transform: translateY(-12px);
  box-shadow: 0 0 16px rgba(37,99,235,0.6);
  outline: 2px solid var(--btn-primary);
}

/* Bid panel */
.bid-panel {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.85);
  border-radius: 14px;
  padding: 16px 20px;
  z-index: 20;
  text-align: center;
  max-width: 95%;
}
.bid-panel h3 { margin-bottom: 10px; font-size: 16px; }
.bid-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}
.bid-btn {
  width: 42px;
  height: 38px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  background: var(--btn-secondary);
  color: #fff;
  transition: background 0.2s;
  touch-action: manipulation;
}
.bid-btn:hover { background: var(--btn-primary); }
.bid-btn.nil-btn {
  width: auto;
  padding: 0 12px;
  background: #7c3aed;
}
.bid-btn.nil-btn:hover { background: #6d28d9; }

/* Draft panel */
.draft-panel {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.85);
  border-radius: 14px;
  padding: 16px 20px;
  z-index: 20;
  text-align: center;
}
.draft-panel h3 { margin-bottom: 10px; font-size: 16px; }
.draft-cards {
  display: flex;
  gap: 16px;
  justify-content: center;
}
.draft-cards .card {
  cursor: pointer;
  width: 70px;
  height: 98px;
}
.draft-cards .card:hover {
  transform: translateY(-6px) scale(1.05);
  box-shadow: 0 0 16px rgba(37,99,235,0.6);
}

/* Round over / Game over panels */
.round-panel, .gameover-panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.9);
  border-radius: 16px;
  padding: 24px;
  z-index: 30;
  text-align: center;
  max-width: 90%;
  min-width: 280px;
  max-height: 80vh;
  overflow-y: auto;
}
.round-panel h3, .gameover-panel h3 { margin-bottom: 14px; color: var(--accent); }

.score-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 14px;
}
.score-table th, .score-table td {
  padding: 6px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  text-align: center;
}
.score-table th {
  color: var(--accent);
  font-size: 12px;
  text-transform: uppercase;
}

/* Game info overlay - centered in table area */
.game-info-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.7);
  padding: 8px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  z-index: 15;
  text-align: center;
  pointer-events: none;
  white-space: nowrap;
  transition: background 0.3s, border-color 0.3s;
  border: 2px solid transparent;
}
.game-info-overlay.playing-2p {
  top: auto;
  bottom: 8px;
  transform: translateX(-50%);
}
.game-info-overlay.playing-4p {
  top: auto;
  bottom: 8px;
  transform: translateX(-50%);
}
.game-info-overlay.raised {
  z-index: 25;
}
.game-info-overlay.your-turn {
  background: rgba(220,38,38,0.85);
  border-color: rgba(255,100,100,0.6);
  animation: turnPulse 1.5s ease-in-out infinite;
}
.game-info-overlay.playing-2p.your-turn,
.game-info-overlay.playing-4p.your-turn {
  animation: turnPulseBottom 1.5s ease-in-out infinite;
}
.game-info-overlay.still-there {
  background: rgba(220,38,38,0.95);
  border-color: #ff4444;
  font-size: 16px;
  padding: 12px 28px;
  animation: turnPulse 0.8s ease-in-out infinite;
}
.game-info-overlay.playing-2p.still-there,
.game-info-overlay.playing-4p.still-there {
  animation: turnPulseBottom 0.8s ease-in-out infinite;
}
@keyframes turnPulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.05); }
}
@keyframes turnPulseBottom {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.05); }
}

/* Chat */
.chat-panel {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 280px;
  height: 350px;
  background: rgba(0,0,0,0.9);
  border-radius: 14px 0 0 0;
  display: flex;
  flex-direction: column;
  z-index: 50;
}
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  font-weight: 700;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  font-size: 13px;
}
.chat-msg {
  margin-bottom: 6px;
}
.chat-msg .chat-sender { font-weight: 700; color: var(--accent); }
.chat-input-area {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.chat-input-area input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid #334;
  border-radius: 6px;
  background: #1a1a2e;
  color: var(--text);
  font-size: 13px;
}

/* Leaderboard */
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.leaderboard-table th, .leaderboard-table td {
  padding: 6px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  text-align: left;
}
.leaderboard-table th { color: var(--accent); }

/* Toast */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
}
.toast.error { border-left: 3px solid var(--btn-danger); }
.toast.success { border-left: 3px solid #22c55e; }
.toast.turn {
  background: rgba(220,38,38,0.9);
  border-left: 3px solid #ff4444;
  font-weight: 700;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-10px); } }

/* Seat picker */
.seat-pick-option {
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.seat-pick-option:hover {
  background: rgba(255,255,255,0.14);
  border-color: var(--btn-primary);
}
.seat-pick-info { font-size: 14px; }
.seat-pick-info .seat-pick-name { font-weight: 700; }
.seat-pick-info .seat-pick-team { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.room-card-badge {
  display: inline-block;
  background: rgba(37,99,235,0.3);
  color: #93c5fd;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  margin-left: 8px;
}
.room-card-badge.rejoin-badge {
  background: rgba(34,197,94,0.3);
  color: #86efac;
}
.room-card.my-game {
  border: 1px solid rgba(34,197,94,0.5);
  background: rgba(34,197,94,0.08);
}
.room-card.my-game:hover {
  background: rgba(34,197,94,0.15);
}

/* Responsive */
@media (max-width: 600px) {
  .game-title { font-size: 28px; }
  .center-box { padding: 24px; }

  .card {
    width: 46px;
    height: 66px;
  }
  .card .card-rank { font-size: 14px; }
  .card .card-suit { font-size: 17px; }
  .card-corner { font-size: 8px; }

  .player-hand {
    gap: 0;
    overflow: visible;
  }
  .player-hand .card:hover { transform: translateY(-6px); z-index: 10; }
  .player-hand .card:active { transform: translateY(-6px); z-index: 10; }
  .player-hand .card.selected { transform: translateY(-10px); }

  .trick-area { gap: 2px; }
  .trick-card-wrapper { gap: 1px; }
  .trick-area .card { width: 42px; height: 60px; }
  .trick-area .card .card-rank { font-size: 12px; }
  .trick-area .card .card-suit { font-size: 15px; }

  .seat-label { font-size: 11px; padding: 3px 8px; }
  /* Hide mini card backs on mobile to prevent overlap */
  .seat-cards { display: none; }

  .bid-panel { padding: 12px 14px; bottom: 8px; }
  .bid-btn { width: 36px; height: 34px; font-size: 14px; }

  .score-bar { font-size: 10px; padding: 4px 6px; gap: 2px; }
  .game-code { font-size: 9px; }
  #score-display { gap: 8px; }
  .game-buttons { gap: 3px; }
  .btn-label { font-size: 10px; padding: 3px 6px; border-radius: 4px; }

  .chat-panel { width: 100%; height: 250px; border-radius: 14px 14px 0 0; }

  .player-seat.seat-left { left: 4px; }
  .player-seat.seat-right { right: 4px; }

  .mini-card { width: 18px; height: 26px; }

  .draft-cards .card { width: 60px; height: 84px; }
  .draft-panel { bottom: 8px; }

  .lobby-actions { flex-direction: column; }
  .lobby-actions .btn { width: 100%; }

  .lobby-main { flex-direction: column; }
  .lobby-chat { width: 100%; }
  .lobby-chat-box { height: 200px; }
}

@media (min-width: 601px) and (max-width: 900px) {
  .card {
    width: 52px;
    height: 74px;
  }
  .card .card-rank { font-size: 16px; }
  .card .card-suit { font-size: 19px; }
}

@media (min-width: 901px) {
  .table-area { padding: 20px; }
  .player-hand { gap: 6px; }
  .card {
    width: 66px;
    height: 92px;
  }
  .card .card-rank { font-size: 20px; }
  .card .card-suit { font-size: 24px; }
  .trick-area { gap: 12px; }
}

/* ── Dominoes Styles ── */

.domino-board {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 10px;
}

.domino-board-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

/* Cross layout for spinner */
.domino-cross-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.domino-arm {
  display: flex;
  align-items: center;
  gap: 2px;
}

.domino-arm-top,
.domino-arm-bottom {
  flex-direction: column;
  gap: 2px;
}

.domino-arm-middle {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 2px;
}

/* Domino tile */
.domino-tile {
  width: 36px;
  height: 66px;
  background: #f5f0e6;
  border: 2px solid #333;
  border-radius: 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: default;
  transition: transform 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
}

.domino-tile.domino-small {
  width: 28px;
  height: 52px;
}

.domino-tile.domino-horizontal {
  flex-direction: row;
  width: 52px;
  height: 28px;
}

.domino-tile.domino-horizontal .domino-half {
  width: 50%;
  height: 100%;
}

.domino-tile.domino-horizontal .domino-divider {
  width: 1px;
  height: 100%;
}

.domino-half {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: calc(50% - 1px);
  padding: 2px;
}

.domino-divider {
  width: 80%;
  height: 1px;
  background: #666;
}

.domino-spinner {
  border-color: #ffd700;
  box-shadow: 0 0 6px rgba(255, 215, 0, 0.5);
}

/* Pips */
.pip-blank { display: block; width: 4px; height: 4px; }

.pip-group {
  display: grid;
  gap: 1px;
  width: 100%;
  height: 100%;
  padding: 2px;
}

.pip {
  width: 5px;
  height: 5px;
  background: #222;
  border-radius: 50%;
}

.domino-small .pip {
  width: 4px;
  height: 4px;
}

.domino-horizontal .pip {
  width: 4px;
  height: 4px;
}

/* Pip layouts */
.pip-1 { display: flex; align-items: center; justify-content: center; }
.pip-2 { display: flex; justify-content: space-between; align-items: center; }
.pip-3 { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.pip-3 .pip:nth-child(2) { align-self: center; }
.pip-4 { display: grid; grid-template-columns: 1fr 1fr; place-items: center; }
.pip-5 { display: grid; grid-template-columns: 1fr 1fr; place-items: center; }
.pip-5 .pip:last-child { grid-column: 1 / -1; justify-self: center; }
.pip-6 { display: grid; grid-template-columns: 1fr 1fr; place-items: center; gap: 1px; }

/* Hand dominos */
.domino-hand {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 4px 0;
}

.domino-hand .domino-tile {
  width: 40px;
  height: 72px;
  cursor: pointer;
}

.domino-hand .domino-tile.domino-playable {
  cursor: pointer;
  border-color: #2563eb;
}

.domino-hand .domino-tile.domino-playable:hover {
  transform: translateY(-6px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.5);
}

.domino-hand .domino-tile.domino-invalid {
  opacity: 0.4;
  cursor: default;
}

.domino-hand .domino-tile.domino-selected {
  transform: translateY(-8px);
  border-color: #ffd700;
  box-shadow: 0 4px 12px rgba(255, 215, 0, 0.6);
}

/* Position picker */
.domino-position-picker {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.95);
  border: 2px solid var(--accent);
  border-radius: 10px;
  padding: 10px 16px;
  display: flex;
  gap: 8px;
  align-items: center;
  z-index: 30;
  white-space: nowrap;
}

.domino-position-picker span {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

/* Domino actions (draw/pass) */
.domino-actions {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 20;
}

/* Open ends info */
.domino-ends-info {
  margin-top: 8px;
  background: rgba(0, 0, 0, 0.6);
  color: var(--text-muted);
  padding: 4px 12px;
  border-radius: 8px;
  font-size: 12px;
  text-align: center;
}

/* Mobile domino adjustments */
@media (max-width: 600px) {
  .domino-hand .domino-tile {
    width: 34px;
    height: 62px;
  }
  .domino-tile.domino-small {
    width: 22px;
    height: 42px;
  }
  .domino-tile.domino-horizontal.domino-small {
    width: 42px;
    height: 22px;
  }
  .domino-hand .pip { width: 4px; height: 4px; }
  .domino-position-picker {
    font-size: 11px;
    padding: 6px 10px;
    gap: 6px;
  }
}

/* ── Go Fish Styles ── */

.gofish-books-area {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 10;
  pointer-events: none;
  max-width: 90%;
  min-width: 200px;
}

.gofish-player-books {
  background: rgba(0, 0, 0, 0.7);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.gofish-book-label {
  font-weight: 700;
  color: var(--accent);
  margin-right: 2px;
}

.gofish-book-badge {
  background: rgba(34, 197, 94, 0.3);
  border: 1px solid rgba(34, 197, 94, 0.6);
  color: #4ade80;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
}

.gofish-last-action {
  background: rgba(0, 0, 0, 0.7);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  text-align: center;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.gofish-last-action strong {
  color: var(--accent);
}

.gofish-last-action em {
  color: #4ade80;
}

/* Go Fish ask panel */
.gofish-ask-panel {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  border-radius: 14px;
  padding: 12px 16px;
  z-index: 20;
  text-align: center;
  max-width: 95%;
}

.gofish-ask-panel h3 {
  margin-bottom: 8px;
  font-size: 14px;
}

.gofish-ask-step {
  margin-bottom: 8px;
}

.gofish-ask-step label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.gofish-opponents,
.gofish-ranks {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
}

.gofish-opponent-btn,
.gofish-rank-btn {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  background: var(--btn-secondary);
  color: var(--text);
  transition: all 0.15s;
}

.gofish-opponent-btn:hover,
.gofish-rank-btn:hover {
  background: var(--btn-primary);
}

.gofish-opponent-btn.selected,
.gofish-rank-btn.selected {
  background: var(--btn-primary);
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

/* Go Fish hand highlight */
.card.gofish-highlight {
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}

/* Mobile Go Fish adjustments */
@media (max-width: 600px) {
  .gofish-ask-panel { padding: 8px 10px; }
  .gofish-ask-panel h3 { font-size: 12px; }
  .gofish-opponent-btn, .gofish-rank-btn { font-size: 11px; padding: 3px 7px; }
  .gofish-player-books { font-size: 10px; }
}
