/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --felt: #1a5c32;
  --felt-dark: #134424;
  --felt-light: #1e6b3a;
  --card-w: 62px;
  --card-h: 90px;
  --card-r: 6px;
  --gold: #d4a843;
  --red: #c0392b;
  --text: #f0ece0;
  --shadow: rgba(0,0,0,.45);
  --modal-bg: rgba(0,0,0,.72);
  --card-back-from: #1a3a8c;
  --card-back-to: #0d2361;
}

html, body {
  height: 100%;
  font-family: 'Georgia', serif;
  background: var(--felt-dark);
  color: var(--text);
  overflow: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* ── Screens ── */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
.screen.hidden { display: none; }
.screen.active { display: flex; }

/* ── Lobby ── */
.lobby-box {
  background: linear-gradient(160deg, var(--felt-light) 0%, var(--felt-dark) 100%);
  border: 2px solid var(--gold);
  border-radius: 16px;
  padding: 32px 28px;
  width: min(480px, 96vw);
  max-height: 96vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
}

.logo {
  font-size: clamp(2rem, 8vw, 3rem);
  text-align: center;
  color: var(--gold);
  letter-spacing: .05em;
  margin-bottom: 28px;
  text-shadow: 0 2px 8px rgba(0,0,0,.5);
}

input[type=text], input[type=number], select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1.5px solid rgba(255,255,255,.2);
  background: rgba(0,0,0,.3);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  margin-bottom: 12px;
  outline: none;
  transition: border-color .2s;
}
input:focus, select:focus { border-color: var(--gold); }
input::placeholder { color: rgba(240,236,224,.45); }

.btn {
  display: block;
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  font-weight: bold;
  cursor: pointer;
  transition: transform .1s, opacity .2s;
  letter-spacing: .03em;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--gold); color: #1a1a1a; }
.btn-primary:hover { opacity: .9; }
.btn-secondary { background: rgba(255,255,255,.12); color: var(--text); border: 1.5px solid rgba(255,255,255,.25); }
.btn-secondary:hover { background: rgba(255,255,255,.2); }

.divider {
  text-align: center;
  color: rgba(240,236,224,.45);
  margin: 14px 0;
  font-size: .9rem;
  position: relative;
}
.divider::before, .divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 42%;
  height: 1px;
  background: rgba(255,255,255,.15);
}
.divider::before { left: 0; }
.divider::after { right: 0; }

.join-row { display: flex; gap: 8px; }
.join-row input { margin-bottom: 0; flex: 1; }
.join-row .btn { width: auto; padding: 12px 18px; white-space: nowrap; }

/* Settings gear on home screen */
.btn-settings-gear {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 9px;
  background: none;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 8px;
  color: rgba(240,236,224,.5);
  font-size: .85rem;
  font-family: inherit;
  cursor: pointer;
  transition: color .2s, border-color .2s;
}
.btn-settings-gear:hover { color: var(--gold); border-color: var(--gold); }

/* Room lobby */
.room-code-display {
  text-align: center;
  font-size: 1.3rem;
  margin-bottom: 20px;
  letter-spacing: .05em;
}
.room-code-display strong { color: var(--gold); font-size: 1.6rem; letter-spacing: .15em; }
.btn-copy {
  background: none; border: none; color: var(--gold); font-size: 1.2rem;
  cursor: pointer; padding: 2px 6px; vertical-align: middle;
}

/* Seat grid */
.seat-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}
.seat-cell { width: 100%; display: flex; justify-content: center; }
.seat-middle { display: flex; align-items: center; gap: 8px; width: 100%; }
.team-badge {
  flex: 1;
  text-align: center;
  font-size: .75rem;
  color: rgba(240,236,224,.5);
  white-space: nowrap;
}
.seat-card {
  background: rgba(0,0,0,.3);
  border: 1.5px solid rgba(255,255,255,.15);
  border-radius: 10px;
  padding: 10px 14px;
  min-width: 110px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.seat-card:hover { border-color: var(--gold); background: rgba(212,168,67,.1); }
.seat-card.mine { border-color: var(--gold); background: rgba(212,168,67,.15); }
.seat-label { font-size: .72rem; color: rgba(240,236,224,.5); text-transform: uppercase; letter-spacing: .08em; }
.seat-player { font-size: .95rem; font-weight: bold; margin-top: 3px; }
.btn-take-seat {
  margin-top: 6px; padding: 4px 10px; font-size: .75rem;
  background: var(--gold); color: #1a1a1a; border: none; border-radius: 5px;
  cursor: pointer; font-weight: bold;
}

/* Settings */
.settings-panel { margin-bottom: 18px; }
.settings-panel h3 { font-size: .85rem; color: rgba(240,236,224,.5); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 10px; }
.settings-panel label { display: flex; justify-content: space-between; align-items: center; font-size: .9rem; margin-bottom: 8px; gap: 12px; }
.settings-panel select, .settings-panel input[type=text] { width: 120px; margin: 0; padding: 7px 10px; font-size: .85rem; }

.btn-start { margin-bottom: 8px; }
.lobby-status { text-align: center; font-size: .85rem; color: rgba(240,236,224,.5); }
.error-msg { background: rgba(192,57,43,.25); border: 1px solid var(--red); border-radius: 6px; padding: 10px; text-align: center; font-size: .9rem; color: #f8b4aa; margin-top: 12px; }
.hidden { display: none !important; }

/* ── Game Screen ── */
#screen-game {
  display: flex;
  flex-direction: column;
  background: var(--felt-dark);
  padding: 0;
  align-items: stretch;
  justify-content: flex-start;
}

/* Score bar */
.btn-menu {
  background: none;
  border: 1px solid rgba(255,255,255,.2);
  color: var(--text);
  font-size: 1.1rem;
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  flex-shrink: 0;
}
.btn-menu:hover { background: rgba(255,255,255,.1); }

.score-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0,0,0,.4);
  padding: 6px 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
  min-height: 48px;
}
.score-team { display: flex; flex-direction: column; align-items: center; min-width: 70px; }
.team-label { font-size: .7rem; color: rgba(240,236,224,.5); text-transform: uppercase; letter-spacing: .1em; }
.team-score { font-size: 1.4rem; font-weight: bold; color: var(--gold); line-height: 1; }
.team-bags { font-size: .7rem; color: rgba(240,236,224,.45); }
.team-hand-tricks { font-size: .65rem; color: rgba(240,236,224,.55); margin-top: 1px; }
.game-info-center { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.badge {
  font-size: .7rem; padding: 2px 8px;
  background: rgba(212,168,67,.2); border: 1px solid var(--gold);
  border-radius: 20px; color: var(--gold);
}
.hand-num { font-size: .72rem; color: rgba(240,236,224,.4); }

/* Table */
.table-wrap {
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.felt-table {
  width: 100%;
  height: 100%;
  max-width: 700px;
  max-height: 620px;
  background: radial-gradient(ellipse at center, var(--felt-light) 0%, var(--felt) 55%, var(--felt-dark) 100%);
  border-radius: 50% / 8%;
  border: 3px solid rgba(212,168,67,.35);
  box-shadow: inset 0 0 40px rgba(0,0,0,.3), 0 4px 30px rgba(0,0,0,.5);
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    ". north ."
    "west center east"
    ". south .";
  padding: 8px;
  gap: 4px;
}

/* Player areas */
.player-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.player-north { grid-area: north; }
.player-south { grid-area: south; }
.player-west  { grid-area: west; flex-direction: row; }
.player-east  { grid-area: east; flex-direction: row; }

.player-info {
  display: flex;
  align-items: center;
  gap: 6px;
}
.player-info.vertical { flex-direction: column; gap: 2px; }

.player-name { font-size: clamp(.65rem, 2vw, .85rem); color: rgba(240,236,224,.75); white-space: nowrap; }
.bid-badge {
  background: var(--gold);
  color: #1a1a1a;
  font-size: .7rem;
  font-weight: bold;
  padding: 1px 7px;
  border-radius: 10px;
  white-space: nowrap;
}
.bid-badge.made { background: #27ae60; color: white; }
.bid-badge.set  { background: var(--red); color: white; }
@keyframes bidPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .45; }
}
.bid-badge.bid-pending {
  background: rgba(212,168,67,.25);
  border: 1.5px solid var(--gold);
  color: var(--gold);
  animation: bidPulse 1s ease-in-out infinite;
}

/* Trick area */
.trick-area {
  grid-area: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.trick-row { display: flex; align-items: center; gap: 4px; }
.trick-slot { width: var(--card-w); height: var(--card-h); position: relative; }
.trick-center-info {
  width: 44px;
  text-align: center;
  font-size: .72rem;
  color: rgba(240,236,224,.5);
}

/* ── Cards ── */
.card {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: var(--card-r);
  background: white;
  border: 1px solid #ccc;
  position: relative;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 3px 4px;
  cursor: pointer;
  user-select: none;
  transition: box-shadow .15s ease, filter .2s;
  box-shadow: 1px 2px 6px var(--shadow);
  font-family: 'Georgia', serif;
  font-weight: bold;
  will-change: box-shadow;
  z-index: 1;
}

/* Highlight playable cards in-place — outline draws inside the card boundary,
   no z-index change, so overlapping neighbors are never blocked */
.your-hand .card:not(.illegal):hover {
  outline: 3px solid var(--gold);
  outline-offset: -3px;
}

.card.illegal {
  filter: brightness(0.6) saturate(0.5);
  cursor: not-allowed;
  pointer-events: none;
}
.card.winning-card {
  box-shadow: 0 0 0 3px #f9c744, 0 0 18px rgba(249,199,68,.7);
  z-index: 10;
}
.card-rank { font-size: clamp(.7rem, 2.5vw, .9rem); line-height: 1; }
.card-suit { font-size: clamp(.75rem, 2.8vw, .95rem); line-height: 1; }
.card-center { font-size: clamp(1rem, 4vw, 1.4rem); text-align: center; }
.card-rank-bot { font-size: clamp(.7rem, 2.5vw, .9rem); line-height: 1; transform: rotate(180deg); }
.card-suit-bot { font-size: clamp(.75rem, 2.8vw, .95rem); line-height: 1; transform: rotate(180deg); }
.card.red .card-rank, .card.red .card-rank-bot,
.card.red .card-suit, .card.red .card-suit-bot,
.card.red .card-center { color: var(--red); }
.card.black .card-rank, .card.black .card-rank-bot,
.card.black .card-suit, .card.black .card-suit-bot,
.card.black .card-center { color: #1a1a1a; }

/* Joker cards */
.card.joker-big {
  background: linear-gradient(160deg, #fff8ee 0%, #fff 60%);
  border: 2px solid #c0392b;
}
.card.joker-little {
  background: white;
  border: 2px solid #444;
}
.joker-corner {
  font-size: .58rem;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: .02em;
}
.joker-label { font-size: .48rem; letter-spacing: .08em; display: block; }
.joker-corner-bot { transform: rotate(180deg); }
.joker-body {
  font-size: 2rem;
  text-align: center;
  line-height: 1;
}
.joker-big .joker-corner,
.joker-big .joker-body { color: #c0392b; }
.joker-little .joker-corner,
.joker-little .joker-body { color: #333; }

/* Card back — uses theme CSS vars */
.card-back {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: var(--card-r);
  background: linear-gradient(135deg, var(--card-back-from) 0%, var(--card-back-to) 100%);
  border: 2px solid rgba(255,255,255,.15);
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 1px 2px 5px var(--shadow);
}
.card-back::after {
  content: '♠';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: rgba(255,255,255,.15);
}

/* Hand displays */
.hand-display {
  display: flex;
  align-items: flex-end;
  position: relative;
  overflow: visible;
  height: calc(var(--card-h) + 12px);
}

/* Your hand (south) — overlapping fan */
.your-hand {
  justify-content: center;
  align-items: flex-end;
  padding-bottom: 4px;
}
.your-hand .card + .card { margin-left: clamp(-40px, -5.5vw, -28px); }

/* Opponent (north) backs — horizontal overlap */
.player-north .hand-display .card-back + .card-back { margin-left: -46px; }

/* Side player hands (east/west) — vertical stack of backs */
.player-west .hand-display,
.player-east .hand-display {
  flex-direction: column;
  height: auto;
  max-height: 160px;
  overflow: visible;
  align-items: center;
}
.player-west .hand-display .card-back + .card-back,
.player-east .hand-display .card-back + .card-back { margin-top: -70px; }

/* Played card animations — directional slide from each player */
@keyframes cardFromSouth {
  from { transform: scale(0.7) translateY(50px); opacity: 0; }
  to   { transform: scale(1) translateY(0);      opacity: 1; }
}
@keyframes cardFromNorth {
  from { transform: scale(0.7) translateY(-50px); opacity: 0; }
  to   { transform: scale(1) translateY(0);       opacity: 1; }
}
@keyframes cardFromWest {
  from { transform: scale(0.7) translateX(-50px); opacity: 0; }
  to   { transform: scale(1) translateX(0);       opacity: 1; }
}
@keyframes cardFromEast {
  from { transform: scale(0.7) translateX(50px); opacity: 0; }
  to   { transform: scale(1) translateX(0);      opacity: 1; }
}

.trick-slot .card { position: relative; }
.trick-south .card { animation: cardFromSouth .38s cubic-bezier(0.25, 0.46, 0.45, 0.94) both; }
.trick-north .card { animation: cardFromNorth .38s cubic-bezier(0.25, 0.46, 0.45, 0.94) both; }
.trick-west  .card { animation: cardFromWest  .38s cubic-bezier(0.25, 0.46, 0.45, 0.94) both; }
.trick-east  .card { animation: cardFromEast  .38s cubic-bezier(0.25, 0.46, 0.45, 0.94) both; }

/* Cards fly to winner's corner after trick */
@keyframes flyToNorth { to { transform: translateY(-220px) scale(0.15); opacity: 0; } }
@keyframes flyToSouth { to { transform: translateY(220px)  scale(0.15); opacity: 0; } }
@keyframes flyToWest  { to { transform: translateX(-220px) scale(0.15); opacity: 0; } }
@keyframes flyToEast  { to { transform: translateX(220px)  scale(0.15); opacity: 0; } }
.fly-north .card { animation: flyToNorth 0.45s cubic-bezier(0.4,0,1,1) forwards !important; }
.fly-south .card { animation: flyToSouth 0.45s cubic-bezier(0.4,0,1,1) forwards !important; }
.fly-west  .card { animation: flyToWest  0.45s cubic-bezier(0.4,0,1,1) forwards !important; }
.fly-east  .card { animation: flyToEast  0.45s cubic-bezier(0.4,0,1,1) forwards !important; }

/* Tricks bar */
.tricks-bar {
  display: flex;
  justify-content: space-around;
  background: rgba(0,0,0,.35);
  padding: 5px 12px;
  font-size: .8rem;
  border-top: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.tricks-team strong { color: var(--gold); }

/* ── Modals ── */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  pointer-events: none;
}
/* Modals that need a dark backdrop */
#modal-game-over,
#modal-hand-over,
#modal-settings {
  background: var(--modal-bg);
  pointer-events: auto;
}
.modal-box {
  background: linear-gradient(160deg, var(--felt-light) 0%, var(--felt-dark) 100%);
  border: 2px solid var(--gold);
  border-radius: 14px;
  padding: 28px 24px;
  width: min(400px, 96vw);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 12px 48px rgba(0,0,0,.85), 0 0 0 1px rgba(212,168,67,.2);
  pointer-events: auto;
}
.modal-box h2 { text-align: center; color: var(--gold); margin-bottom: 14px; font-size: 1.5rem; }

/* Bid modal — other players' bids bar */
.bid-others-bar {
  display: flex;
  justify-content: space-around;
  gap: 6px;
  background: rgba(0,0,0,.25);
  border-radius: 8px;
  padding: 6px 8px;
  margin-bottom: 12px;
}
.bid-others-entry {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  opacity: 0.6;
  font-size: .72rem;
}
.bid-others-entry.bid-others-done { opacity: 1; }
.bid-others-name { color: rgba(240,236,224,.7); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 70px; }
.bid-others-val { color: var(--gold); font-weight: bold; font-size: .95rem; }

/* Bid modal */
.bid-hint { text-align: center; font-size: .9rem; color: rgba(240,236,224,.6); margin-bottom: 14px; }
.bid-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}
.bid-btn {
  aspect-ratio: 1;
  border: 1.5px solid rgba(255,255,255,.2);
  background: rgba(0,0,0,.3);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.bid-btn:hover { background: rgba(212,168,67,.25); border-color: var(--gold); }
.bid-btn.bid-selected {
  background: var(--gold);
  color: #1a1a1a;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(212,168,67,.5);
}
.btn-nil {
  width: 100%;
  margin-top: 4px;
  margin-bottom: 8px;
  padding: 11px;
  background: rgba(255,255,255,.08);
  border: 1.5px solid rgba(255,255,255,.2);
  border-radius: 8px;
  color: var(--text);
  font-size: .95rem;
  font-weight: bold;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn-nil:hover { background: rgba(192,57,43,.3); border-color: var(--red); }
.btn-nil.bid-selected { background: rgba(192,57,43,.4); border-color: var(--red); }
.btn-bid-confirm { margin-top: 4px; }

/* Hand over */
#hand-over-content { font-size: .95rem; line-height: 1.8; margin-bottom: 16px; }
.ho-row { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,.08); }
.ho-label { color: rgba(240,236,224,.6); }
.ho-val { font-weight: bold; }
.ho-val.pos { color: #2ecc71; }
.ho-val.neg { color: var(--red); }

.hand-over-ready-status {
  text-align: center;
  font-size: .85rem;
  color: rgba(240,236,224,.6);
  margin-bottom: 12px;
  min-height: 1.2em;
}

/* Trick result overlay */
.trick-result {
  position: fixed;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,.82);
  border: 2px solid var(--gold);
  border-radius: 12px;
  padding: 14px 28px;
  font-size: 1.25rem;
  font-weight: bold;
  color: var(--gold);
  z-index: 50;
  pointer-events: none;
  text-align: center;
  letter-spacing: .03em;
  text-shadow: 0 1px 4px rgba(0,0,0,.6);
}
@keyframes fadeInOut {
  0%   { opacity: 0; transform: translate(-50%, -62%) scale(.85); }
  12%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  70%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -40%) scale(.95); }
}
.trick-result.show { animation: fadeInOut 2.2s ease forwards; }

/* ── Color Palette Picker ── */
.palette-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}
.palette-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px 10px;
  border-radius: 10px;
  border: 2px solid transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: .82rem;
  font-weight: bold;
  transition: border-color .15s, transform .1s;
  color: inherit;
}
.palette-swatch:hover { transform: scale(1.04); }
.palette-swatch.swatch-active { border-color: white; box-shadow: 0 0 0 3px rgba(255,255,255,.3); }
.palette-swatch .swatch-spade { font-size: 1.5rem; }
.palette-swatch .swatch-name { font-size: .75rem; opacity: .85; text-align: center; }

/* Chat */
.chat-fab {
  position: fixed;
  bottom: 20px;
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--gold);
  color: #1a1a1a;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(0,0,0,.5);
  z-index: 60;
  display: none;
}
.chat-panel {
  position: fixed;
  bottom: 72px;
  right: 10px;
  width: min(320px, 94vw);
  max-height: 260px;
  background: rgba(15,40,20,.95);
  border: 1.5px solid rgba(212,168,67,.4);
  border-radius: 12px;
  z-index: 61;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#chat-messages { flex: 1; overflow-y: auto; padding: 10px; font-size: .82rem; line-height: 1.5; }
.chat-msg { margin-bottom: 4px; }
.chat-msg .chat-name { color: var(--gold); font-weight: bold; }
.chat-input-row { display: flex; border-top: 1px solid rgba(255,255,255,.1); }
#chat-input { flex: 1; background: transparent; border: none; color: var(--text); padding: 8px 10px; font-size: .85rem; outline: none; }
#btn-chat-send { background: var(--gold); border: none; color: #1a1a1a; padding: 8px 12px; font-weight: bold; cursor: pointer; font-size: .85rem; }

/* ── Responsive: mobile (portrait phones) ── */
@media (max-width: 540px) {
  :root { --card-w: 56px; --card-h: 82px; --card-r: 5px; }

  .card-rank, .card-rank-bot { font-size: .72rem; }
  .card-suit, .card-suit-bot { font-size: .78rem; }
  .card-center { font-size: 1.1rem; }

  /* Restructure grid so N/S span full width — eliminates E/W column width constraints */
  .felt-table {
    grid-template-areas:
      "north north north"
      "west  center east"
      "south south south";
    grid-template-columns: 38px 1fr 38px;
    padding: 4px 2px;
    gap: 2px;
  }

  /* E/W: hide hand display, show only a compact vertical label */
  .player-west .hand-display,
  .player-east .hand-display { display: none; }

  .player-west,
  .player-east {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    overflow: hidden;
    width: 38px;
  }

  .player-west .player-info,
  .player-east .player-info {
    flex-direction: column;
    align-items: center;
    gap: 3px;
  }

  /* Vertical player name */
  .player-west .player-name,
  .player-east .player-name {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: .55rem;
    max-height: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: rgba(240,236,224,.7);
  }

  /* Keep bid badge horizontal and compact */
  .player-west .bid-badge,
  .player-east .bid-badge {
    writing-mode: horizontal-tb;
    transform: none;
    font-size: .55rem;
    padding: 1px 4px;
    max-width: 36px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
  }

  /* South hand spans full width — use moderate overlap so cards are easier to tap */
  .your-hand .card + .card { margin-left: -32px; }
  .player-north .hand-display .card-back + .card-back { margin-left: -50px; }

  /* Trick area more compact */
  .trick-center-info { width: 32px; font-size: .6rem; }
}

@media (max-width: 360px) {
  :root { --card-w: 48px; --card-h: 70px; }
  .felt-table { grid-template-columns: 32px 1fr 32px; }
  .player-west, .player-east { width: 32px; }
  .player-west .bid-badge, .player-east .bid-badge { max-width: 30px; font-size: .5rem; }
  .your-hand .card + .card { margin-left: -26px; }
  .joker-body { font-size: 1.7rem; }
}

@media (max-height: 600px) {
  .felt-table { border-radius: 20px; }
}

/* Card leaving hand */
@keyframes cardLeave {
  from { transform: translateY(0) scale(1); opacity: 1; }
  to   { transform: translateY(-30px) scale(0.8); opacity: 0; }
}
.card.playing { animation: cardLeave .22s ease-in forwards; pointer-events: none; }

/* Turn highlight pulse */
@keyframes turnPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212,168,67,.4); }
  50%       { box-shadow: 0 0 0 8px rgba(212,168,67,0); }
}
.your-turn .your-hand .card:not(.illegal) {
  animation: turnPulse 1.6s ease-in-out infinite;
}
