:root {
  --felt: #12805a;
  --felt-mid: #0c6647;
  --felt-dark: #063f2c;
  --gold: #e8c565;
  --gold-soft: #f6e0a0;
  --ink: #1b1b1b;
  --paper: #faf7f0;
  --red: #e23b3b;
  --black: #1b1b1b;
  --panel-bg: #ffffff;
  --shadow: 0 8px 24px rgba(0,0,0,0.35);
  --rail: #3a2417;
  --rail-hi: #6b4327;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(ellipse 120% 90% at 50% 0%, rgba(255,255,255,0.06), transparent 60%),
    radial-gradient(ellipse at center, #0f7a54 0%, #06382a 75%, #04241a 100%);
  color: var(--paper);
  overflow-x: hidden;
}
/* When the game screen is active, lock the whole page — no scrolling. */
body.in-game { overflow: hidden; height: 100dvh; }

.screen {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
/* The game screen fills the viewport exactly and never scrolls. */
#screen-game.active { display: flex; padding: 0; height: 100dvh; overflow: hidden; }
.screen.active { display: flex; }
.muted { color: #999; font-weight: 500; font-size: 0.85em; }

/* ---------- Panels / landing / lobby ---------- */
.card-panel {
  background: var(--panel-bg);
  color: var(--ink);
  border-radius: 16px;
  padding: 28px 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
  text-align: center;
}

h1 { margin: 0 0 4px; font-size: 2rem; }
.thulla-tag {
  font-size: 0.85rem;
  vertical-align: middle;
  background: var(--gold);
  color: var(--ink);
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 700;
}
.subtitle { color: #555; margin-bottom: 20px; font-size: 0.95rem; }

.field { display: block; text-align: left; margin-bottom: 12px; }
.field span { display: block; font-size: 0.8rem; font-weight: 600; color: #444; margin-bottom: 4px; }
.field input {
  width: 100%; padding: 12px 14px; border-radius: 10px;
  border: 2px solid #ddd; font-size: 1rem; outline: none;
}
.field input:focus { border-color: var(--felt); }

.btn {
  display: block; width: 100%; padding: 13px 16px;
  border-radius: 10px; border: none; font-size: 1rem; font-weight: 700;
  cursor: pointer; margin-top: 6px;
  transition: transform 0.08s ease, opacity 0.15s ease, background 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--felt); color: white; }
.btn-primary:hover:not(:disabled) { background: #0c6b44; }
.btn-secondary { background: var(--gold); color: var(--ink); }
.btn-small { width: auto; display: inline-block; padding: 8px 14px; font-size: 0.85rem; background: #eee; color: var(--ink); }
.btn-link { background: none; color: #666; font-weight: 600; font-size: 0.85rem; text-decoration: underline; }
.btn-link:hover { color: var(--ink); }
.btn-icon { width: auto; background: rgba(0,0,0,0.25); color: #fff; padding: 6px 10px; margin: 0; font-size: 1rem; }

.divider { display: flex; align-items: center; text-align: center; color: #999; font-size: 0.8rem; margin: 18px 0 12px; }
.divider::before, .divider::after { content: ""; flex: 1; border-bottom: 1px solid #ddd; }
.divider span { padding: 0 10px; }

.error-text { color: var(--red); font-size: 0.85rem; margin-top: 10px; min-height: 1em; }
.hint-text { color: #666; font-size: 0.85rem; margin-top: 10px; }

.rules-box { text-align: left; background: #f6f4ee; border-radius: 10px; padding: 10px 14px 10px 26px; margin-top: 10px; font-size: 0.82rem; color: #444; }
.rules-box ol { margin: 4px 0; padding-left: 8px; }
.rules-box li { margin-bottom: 6px; }

/* Lobby */
.room-code-display {
  font-size: 2.2rem; font-weight: 800; letter-spacing: 6px;
  background: var(--felt); color: white; border-radius: 10px; padding: 14px; margin: 10px 0 14px;
}
.lobby-players-title { text-align: left; margin: 20px 0 8px; font-size: 1rem; }
.player-list { list-style: none; padding: 0; margin: 0 0 16px; text-align: left; }
.player-list li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-radius: 8px; background: #f4f2ec; margin-bottom: 6px; font-weight: 600;
}
.player-list li .badge {
  font-size: 0.7rem; font-weight: 700; color: var(--felt);
  background: #e3f1e9; padding: 2px 8px; border-radius: 999px; margin-left: 6px;
}
.player-list li .dot { width: 8px; height: 8px; border-radius: 50%; background: #4caf50; display: inline-block; margin-right: 8px; }
.player-list li.disconnected .dot { background: #bbb; }
.player-list li.disconnected { opacity: 0.55; }

/* ---------- Game screen ---------- */
/* screen-game is a flex ROW: play column on the left, chat column on the right. */
#screen-game.active { flex-direction: row; align-items: stretch; }
.play-column {
  flex: 1 1 auto; min-width: 0; height: 100dvh; position: relative;
  display: flex; flex-direction: column;
}
.game-wrap {
  flex: 1 1 auto; min-height: 0; width: 100%; max-width: 980px; margin: 0 auto;
  display: flex; flex-direction: column; padding: 8px; position: relative; overflow: hidden;
}
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.topbar-tools { display: flex; gap: 6px; }
.room-badge { font-size: 0.8rem; background: rgba(0,0,0,0.28); padding: 6px 12px; border-radius: 999px; white-space: nowrap; letter-spacing: 0.5px; }
.turn-banner {
  flex: 1; text-align: center; font-weight: 800; padding: 9px 14px; border-radius: 999px;
  background: linear-gradient(180deg, var(--gold-soft), var(--gold)); color: #4a350a; font-size: 0.85rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.turn-banner.waiting { background: rgba(255,255,255,0.14); color: #eee; box-shadow: none; }
.turn-banner.mine { animation: pulse-gold 1.2s ease-in-out infinite; }
@keyframes pulse-gold { 0%,100% { box-shadow: 0 0 0 0 rgba(232,197,101,0.7);} 50% { box-shadow: 0 0 0 10px rgba(232,197,101,0);} }

/* Prominent whole-screen glow when it's my turn */
.game-wrap.my-turn::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 5;
  box-shadow: inset 0 0 0 3px rgba(232,197,101,0.55), inset 0 0 60px rgba(232,197,101,0.25);
  animation: turn-flash 1.3s ease-in-out infinite;
}
@keyframes turn-flash { 0%,100% { opacity: 0.35; } 50% { opacity: 0.9; } }

/* ---------- Flat 2D felt table ---------- */
.table-area {
  flex: 1 1 auto; min-height: 0; position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  padding: 44px 12px 10px; /* top padding = headroom for the top-arc seats */
  background:
    radial-gradient(ellipse 80% 60% at 50% 30%, rgba(255,224,150,0.10), transparent 65%);
}
/* The oval table; sized to fit the available box on BOTH axes so it never
   gets cut off. --tw/--th are its width/height. */
.table {
  position: relative;
  width: min(94%, 720px);
  height: min(100%, calc((94vw) / 1.55));
  max-height: 100%;
  aspect-ratio: 1.55 / 1;
  border-radius: 50%;
  border: 14px solid var(--rail);
  background:
    radial-gradient(ellipse 60% 55% at 50% 42%, rgba(255,255,255,0.10), transparent 66%),
    radial-gradient(ellipse at center, var(--felt) 0%, var(--felt-mid) 62%, var(--felt-dark) 100%);
  box-shadow:
    inset 0 0 0 6px rgba(0,0,0,0.28),
    inset 0 0 70px rgba(0,0,0,0.5),
    0 22px 44px rgba(0,0,0,0.55);
}
.table-felt {
  position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  box-shadow: inset 0 0 60px rgba(0,0,0,0.45);
}
/* felt stitching ring */
.table::after {
  content: ""; position: absolute; inset: 12px; border-radius: 50%;
  border: 2px dashed rgba(255,255,255,0.12); pointer-events: none;
}
/* wooden rail sheen */
.table::before {
  content: ""; position: absolute; inset: -14px; border-radius: 50%; pointer-events: none;
  background: linear-gradient(160deg, rgba(255,235,200,0.26), transparent 26%, transparent 72%, rgba(0,0,0,0.38));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 14px), #000 calc(100% - 14px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 14px), #000 calc(100% - 14px));
}

/* ---------- Seats (players around the rim) ---------- */
.seat {
  position: absolute; transform: translate(-50%, -50%);
  width: 92px; text-align: center; transition: transform 0.2s; z-index: 3;
}
.seat .seat-inner {
  background: linear-gradient(180deg, rgba(255,255,255,0.12), rgba(0,0,0,0.42));
  border: 1.5px solid rgba(255,255,255,0.18);
  border-radius: 14px; padding: 6px 6px 7px;
  box-shadow: 0 8px 18px rgba(0,0,0,0.45);
}
.seat.active .seat-inner { border-color: var(--gold); box-shadow: 0 0 22px rgba(232,197,101,0.85); background: linear-gradient(180deg, rgba(232,197,101,0.26), rgba(0,0,0,0.42)); }
.seat.finished .seat-inner { opacity: 0.5; }
.seat.me .seat-inner { border-color: #6fd08c; }

/* A little "person": head + shoulders silhouette */
.seat .avatar {
  position: relative; width: 40px; height: 38px; margin: 0 auto 3px;
  display: flex; align-items: flex-start; justify-content: center;
}
.seat .avatar .head {
  position: relative; width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(150deg, var(--av1, #6aa9ff), var(--av2, #2f6fd6));
  border: 2px solid rgba(255,255,255,0.35);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 6px rgba(0,0,0,0.4); z-index: 1;
}
.seat .avatar .head span { font-size: 0.6rem; font-weight: 800; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.4); }
.seat .avatar::after {
  content: ""; position: absolute; bottom: -1px; left: 50%; transform: translateX(-50%);
  width: 38px; height: 18px; border-radius: 20px 20px 7px 7px;
  background: linear-gradient(150deg, var(--av1, #6aa9ff), var(--av2, #2f6fd6));
  opacity: 0.85; box-shadow: 0 4px 8px rgba(0,0,0,0.4); z-index: 0;
}
.seat.active .avatar .head { border-color: var(--gold); box-shadow: 0 0 12px rgba(232,197,101,0.9); }
.seat.finished .avatar .head { filter: grayscale(0.6); }
.seat .seat-name { font-weight: 700; font-size: 0.72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat .seat-cards { font-size: 0.72rem; color: var(--gold-soft); font-weight: 700; margin-top: 1px; }
.seat .seat-cards.safe { color: #6fd08c; }
.seat .mini-cards { display: flex; justify-content: center; gap: 1px; margin-top: 3px; height: 14px; }
.seat .mini-card { width: 8px; height: 12px; background: linear-gradient(135deg,#c33,#900); border-radius: 2px; border: 1px solid rgba(255,255,255,0.3); }
.seat .disc-dot { width: 7px; height: 7px; border-radius: 50%; background: #e74c3c; display: inline-block; margin-left: 3px; }
.seat .turn-ring { display: none; }

/* seat timer bar */
.seat .timer-bar { height: 3px; background: rgba(255,255,255,0.15); border-radius: 3px; margin-top: 4px; overflow: hidden; display: none; }
.seat.active .timer-bar { display: block; }
.seat .timer-fill { height: 100%; width: 100%; background: var(--gold); transform-origin: left; }

/* ---------- Discard pile — tucked to the lower-left of the felt ---------- */
.discard {
  position: absolute; left: 12%; bottom: 14%; width: 54px; height: 74px;
  display: flex; align-items: center; justify-content: center; z-index: 2;
}
.discard-fan { position: absolute; inset: 0; }
.discard-fan .pcard { position: absolute; top: 0; left: 0; width: 42px; height: 60px; opacity: 0.92; }
.discard-label {
  position: absolute; bottom: -16px; left: 50%; transform: translateX(-50%);
  font-size: 0.66rem; color: rgba(255,255,255,0.72); white-space: nowrap; font-weight: 700;
}
.discard-empty { width: 42px; height: 60px; border: 2px dashed rgba(255,255,255,0.2); border-radius: 8px; }

/* ---------- Current trick (face-up, dead center) ---------- */
.table-center {
  position: absolute; top: 46%; left: 50%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 4px; z-index: 4;
  width: min(80%, 340px);
}
.trick { position: relative; height: 88px; width: 100%; display: flex; align-items: center; justify-content: center; }
.trick .pcard { position: absolute; box-shadow: 0 4px 10px rgba(0,0,0,0.5); }
.trick .pcard .thrower {
  position: absolute; top: -17px; left: 50%; transform: translateX(-50%);
  font-size: 0.62rem; color: #fff; background: rgba(0,0,0,0.62); padding: 1px 7px; border-radius: 999px;
  white-space: nowrap; font-weight: 700; max-width: 70px; overflow: hidden; text-overflow: ellipsis;
}
.trick .pcard .thrower.below { top: auto; bottom: -17px; }
.trick .pcard.winning { box-shadow: 0 0 0 3px var(--gold), 0 8px 16px rgba(0,0,0,0.6); z-index: 20 !important; }
.trick .pcard.winning .thrower { background: var(--gold); color: #4a350a; }

.lead-suit-tag {
  font-size: 0.78rem; font-weight: 700; color: var(--gold-soft); min-height: 1em;
  background: rgba(0,0,0,0.35); padding: 2px 10px; border-radius: 999px;
}
.lead-suit-tag:empty { display: none; }

/* ---------- Player's hand ---------- */
.my-area {
  flex: 0 0 auto; background: linear-gradient(180deg, rgba(0,0,0,0.15), rgba(0,0,0,0.45));
  border-radius: 18px 18px 0 0; padding: 8px 8px 12px; margin-top: 6px;
  box-shadow: 0 -8px 24px rgba(0,0,0,0.4);
}
.my-header { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 4px; }
.my-name { font-weight: 700; font-size: 0.9rem; }
.turn-timer { font-weight: 800; font-size: 0.85rem; color: var(--gold); background: rgba(0,0,0,0.3); padding: 2px 10px; border-radius: 999px; }
.turn-timer.low { color: #ff6b6b; }
.my-hand {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; padding: 4px 0;
  max-height: 26dvh; overflow-y: auto; overflow-x: hidden;
  scrollbar-width: thin;
}
.my-hand::-webkit-scrollbar { height: 6px; width: 6px; }
.my-hand::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }
.my-hint { text-align: center; font-size: 0.78rem; color: rgba(255,255,255,0.6); min-height: 1em; margin-top: 2px; }

/* Playing card */
.pcard {
  width: 54px; height: 76px;
  background: linear-gradient(160deg, #ffffff 0%, #f3f0e8 100%);
  border-radius: 9px; border: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 3px 7px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.9);
  display: flex; flex-direction: column;
  justify-content: space-between; padding: 5px; font-weight: 800; font-size: 0.95rem;
  color: var(--black); user-select: none;
  transition: transform 0.14s ease, box-shadow 0.14s ease, opacity 0.14s;
}
.pcard.red { color: var(--red); }
.pcard .rank-top { line-height: 1; }
.pcard .suit-big { align-self: center; font-size: 1.3rem; }
.pcard .rank-bottom { align-self: flex-end; transform: rotate(180deg); line-height: 1; }

.my-hand .pcard { cursor: pointer; }
.my-hand .pcard.playable:hover { transform: translateY(-10px); box-shadow: 0 12px 18px rgba(0,0,0,0.5); }
.my-hand .pcard.playable { outline: 2px solid rgba(111,208,140,0.0); }
.my-hand .pcard.not-playable { opacity: 0.4; cursor: not-allowed; filter: grayscale(0.4); }

/* card entrance / motion */
@keyframes deal-in { from { opacity: 0; transform: translateY(30px) scale(0.8);} to { opacity:1; transform: translateY(0) scale(1);} }
.pcard.dealt { animation: deal-in 0.28s ease both; }
@keyframes throw-in { from { opacity: 0; transform: translateY(60px) scale(0.7) rotate(-8deg);} to { opacity:1; } }
.trick .pcard { animation: throw-in 0.22s ease both; }

/* fly-out to discard */
@keyframes fly-discard { to { transform: translate(var(--dx), var(--dy)) scale(0.7) rotate(20deg); opacity: 0; } }
.flying-discard { animation: fly-discard 0.5s ease forwards; }
/* fly to a seat (pickup) */
@keyframes fly-pickup { to { transform: translate(var(--dx), var(--dy)) scale(0.5); opacity: 0; } }
.flying-pickup { animation: fly-pickup 0.55s ease forwards; }

.fly-layer { position: fixed; inset: 0; pointer-events: none; z-index: 900; }
.fly-layer .pcard { position: absolute; }

/* ---------- Center banner (round result) ---------- */
.banner-overlay {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  z-index: 950; pointer-events: none;
}
.banner-overlay.show { display: flex; }
.banner-text {
  background: rgba(0,0,0,0.82); color: #fff; font-weight: 800; font-size: 1.3rem;
  padding: 18px 30px; border-radius: 16px; border: 2px solid var(--gold);
  box-shadow: 0 10px 40px rgba(0,0,0,0.6); text-align: center; max-width: 88vw;
  animation: banner-pop 0.3s ease both;
}
.banner-text.thulla { border-color: var(--red); }
@keyframes banner-pop { from { transform: scale(0.7); opacity: 0;} to { transform: scale(1); opacity: 1; } }

/* ---------- Log panel ---------- */
.log-panel {
  position: absolute; top: 44px; right: 8px; width: 240px; max-height: 55vh; overflow-y: auto;
  background: rgba(0,0,0,0.82); border: 1px solid rgba(255,255,255,0.15); border-radius: 12px; padding: 10px 12px; z-index: 20;
}
.log-title { font-weight: 800; font-size: 0.8rem; margin-bottom: 6px; color: var(--gold-soft); }
.log-panel ul { list-style: none; margin: 0; padding: 0; }
.log-panel li { font-size: 0.76rem; color: #ddd; padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,0.07); line-height: 1.3; }

/* ---------- Toasts ---------- */
#toast-container {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 999;
  display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none;
}
.toast {
  background: var(--gold); color: var(--ink); font-weight: 800; padding: 10px 20px;
  border-radius: 999px; box-shadow: var(--shadow);
  animation: toast-in 0.2s ease, toast-out 0.3s ease 2.6s forwards;
}
.toast.bad { background: #e74c3c; color: #fff; }
@keyframes toast-in { from { opacity:0; transform: translateY(-10px);} to {opacity:1; transform:translateY(0);} }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px);} }

/* Standings */
.standings-list { list-style: none; padding: 0; text-align: left; margin: 16px 0; }
.standings-list li {
  padding: 12px 14px; border-radius: 8px; background: #f4f2ec; margin-bottom: 6px;
  font-weight: 700; display: flex; align-items: center; gap: 10px;
}
.standings-list li.loser { background: #fbe4e4; color: var(--red); }
.standings-list li.winner { background: #e3f1e9; }
.standings-list .rank-num { font-size: 1.1rem; }

/* ---------- Turn clock (above the trick, in the table center) ---------- */
.turn-clock {
  position: relative; width: 46px; height: 46px; margin-bottom: 2px;
  display: flex; align-items: center; justify-content: center;
  filter: drop-shadow(0 3px 8px rgba(0,0,0,0.6));
}
.turn-clock[hidden] { display: none; }
.turn-clock .clock-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.turn-clock .clock-track { fill: rgba(0,0,0,0.6); stroke: rgba(255,255,255,0.15); stroke-width: 4; }
.turn-clock .clock-progress {
  fill: none; stroke: var(--gold); stroke-width: 4; stroke-linecap: round;
  transition: stroke-dashoffset 0.2s linear, stroke 0.3s;
}
.turn-clock .clock-num { position: relative; font-weight: 800; font-size: 1.05rem; color: #fff; }
.turn-clock.mine { animation: clock-pop 1.1s ease-in-out infinite; }
.turn-clock.mine .clock-progress { stroke: var(--gold-soft); }
.turn-clock.low .clock-progress { stroke: #ff6b6b; }
.turn-clock.low .clock-num { color: #ff9d9d; }
@keyframes clock-pop { 0%,100% { transform: scale(1);} 50% { transform: scale(1.1);} }

/* ---------- Chat panel ---------- */
.chat-unread {
  position: absolute; top: -5px; right: -5px; background: var(--red); color: #fff;
  font-size: 0.6rem; font-weight: 800; min-width: 15px; height: 15px; padding: 0 3px;
  border-radius: 999px; display: flex; align-items: center; justify-content: center;
}
.btn-icon { position: relative; }
/* Chat = dedicated right-hand column; part of the flex row, so it never
   overlaps the table/cards on desktop. */
.chat-panel {
  flex: 0 0 320px; width: 320px; height: 100dvh; z-index: 40;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, rgba(14,30,23,0.98), rgba(8,20,15,0.98));
  border-left: 1px solid rgba(255,255,255,0.12);
  box-shadow: -12px 0 40px rgba(0,0,0,0.5); overflow: hidden;
}
.chat-panel[hidden] { display: none; }
.chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; font-weight: 800; font-size: 0.85rem; color: var(--gold-soft);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.chat-close { background: none; border: none; color: #aaa; font-size: 1rem; cursor: pointer; padding: 2px 6px; }
.chat-close:hover { color: #fff; }
.chat-messages { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.chat-msg { max-width: 85%; align-self: flex-start; }
.chat-msg.mine { align-self: flex-end; text-align: right; }
.chat-meta { font-size: 0.65rem; color: #9fb0a6; display: flex; gap: 6px; margin-bottom: 2px; }
.chat-msg.mine .chat-meta { justify-content: flex-end; }
.chat-name { font-weight: 800; color: var(--gold-soft); }
.chat-body {
  display: inline-block; background: rgba(255,255,255,0.1); color: #f2f2f2;
  padding: 7px 11px; border-radius: 12px; font-size: 0.85rem; line-height: 1.35;
  word-break: break-word; text-align: left;
}
.chat-msg.mine .chat-body { background: linear-gradient(180deg,#1f9c6e,#137a52); color: #fff; }
.chat-form { display: flex; gap: 6px; padding: 8px; border-top: 1px solid rgba(255,255,255,0.1); }
.chat-input {
  flex: 1; padding: 9px 12px; border-radius: 999px; border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08); color: #fff; font-size: 0.85rem; outline: none;
}
.chat-input:focus { border-color: var(--gold); }
.chat-input::placeholder { color: #8aa; }
.chat-send {
  background: var(--gold); color: #4a350a; border: none; border-radius: 999px;
  padding: 0 16px; font-weight: 800; font-size: 0.82rem; cursor: pointer;
}

/* ---------- Responsive ---------- */
/* On narrow screens the chat can't be a side column (would crush the table),
   so it slides in as a full-height overlay from the right instead. */
@media (max-width: 720px) {
  .chat-panel {
    position: fixed; top: 0; right: 0; bottom: 0; height: 100dvh;
    flex-basis: auto; width: min(88vw, 360px); z-index: 60;
    animation: chat-slide 0.22s ease both;
  }
  @keyframes chat-slide { from { transform: translateX(100%);} to { transform: translateX(0);} }
}
@media (max-width: 560px) {
  .table { border-width: 12px; }
  .seat { width: 78px; }
  .pcard { width: 46px; height: 66px; font-size: 0.82rem; }
  .trick { width: 180px; }
  h1 { font-size: 1.6rem; }
  .log-panel { width: 200px; }
  .stage { width: min(98vw, 58vh * 1.5); }
}
@media (max-width: 380px) {
  .seat { width: 64px; }
  .seat .seat-name { font-size: 0.64rem; }
  .seat .avatar { width: 34px; height: 34px; }
  .seat .avatar .head { width: 22px; height: 22px; }
  .my-hand .pcard { width: 42px; height: 60px; }
}
/* Very short viewports (landscape phones): shrink hand cards so nothing scrolls */
@media (max-height: 560px) {
  .my-hand .pcard { width: 40px; height: 58px; }
  .my-area { padding: 5px 8px 8px; }
  .stage { width: min(90vw, 50vh * 1.5); }
}
