:root {
  --felt: #1a5c38;
  --felt-dark: #124327;
  --bg: #0d2318;
  --card-w: 63px;
  --card-h: 88px;
  --gold: #ffcb3d;
  --red: #d64545;
  --ink: #1c2430;
  --panel: #16302257;
}

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

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: radial-gradient(ellipse at 50% 30%, var(--felt) 0%, var(--bg) 90%);
  color: #eef3ee;
  overflow: hidden;
}

.hidden { display: none !important; }

.view { height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; }

/* ------------------------------ home / lobby ------------------------------ */

.home-card {
  background: rgba(10, 26, 18, 0.75);
  border: 1px solid rgba(232, 195, 74, 0.25);
  border-radius: 16px;
  padding: 40px 48px;
  display: flex; flex-direction: column; gap: 14px;
  align-items: center; min-width: 340px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}

.logo {
  font-family: Georgia, serif; font-size: 2.4rem; letter-spacing: 2px; font-weight: 800; color: #fff;
}
.logo span { color: var(--gold); }
.logo.small { font-size: 1.15rem; z-index: 6; position: relative; }

.tagline { color: #9fbfae; font-size: .9rem; }

input {
  background: #0b1f14; color: #fff; border: 1px solid #2e5941;
  border-radius: 8px; padding: 12px 14px; font-size: 1rem; width: 100%;
  text-align: center; outline: none;
}
input:focus { border-color: var(--gold); }
#code-input { text-transform: uppercase; letter-spacing: 6px; font-weight: 700; }

.join-row { display: flex; gap: 8px; width: 100%; }

.btn {
  background: #274c38; color: #fff; border: 1px solid #3c7154;
  padding: 12px 22px; border-radius: 8px; font-size: 1rem; cursor: pointer;
  width: 100%; transition: transform .08s, background .15s;
}
.btn:hover:not(:disabled) { background: #336249; transform: translateY(-1px); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--gold); border-color: #b8952c; color: #241d05; font-weight: 700; }
.btn.primary:hover:not(:disabled) { background: #f2d269; }
.btn.subtle { background: transparent; border-color: #33503f; color: #8fae9c; }
.btn.tiny { width: auto; padding: 5px 14px; font-size: .8rem; }
.btn.danger { background: #6b2a2a; border-color: #a04545; }
.btn.danger:hover:not(:disabled) { background: #8a3535; }

.status { color: #9fbfae; font-size: .85rem; min-height: 1.2em; }

.room-code {
  background: #0b1f14; border: 1px dashed var(--gold); color: var(--gold);
  padding: 4px 14px; border-radius: 8px; letter-spacing: 6px; font-weight: 800;
}
.room-code.small { font-size: .8rem; padding: 2px 10px; letter-spacing: 3px; }

.menu-link { color: #8fae9c; font-size: .8rem; text-decoration: none; margin-top: 4px; }
.menu-link:hover { color: var(--gold); }

.lobby-list { list-style: none; width: 100%; }
.lobby-list li {
  padding: 9px 14px; border-bottom: 1px solid #234534;
  display: flex; justify-content: space-between; font-size: 1rem;
}
.lobby-list .host-tag { color: var(--gold); font-size: .8rem; }

/* ------------------------------ game layout ------------------------------ */

/* The game screen fits the viewport at ANY resolution and never scrolls
   (the only scrollable thing in-game is the chat panel). It's a fixed-height
   flex column with overflow hidden; a JS auto-fit (fitGame in client.js)
   shrinks the card size + compacts the opponent tiles until everything fits,
   so content is scaled down rather than clipped or scrolled. 100dvh (dynamic
   viewport height) accounts for mobile browser chrome. */
#view-game {
  justify-content: space-between; position: relative; z-index: 0;
  height: 100dvh; overflow: hidden; gap: 4px;
  /* The felt panel is inset 20px; keep all the in-flow chrome (top bar,
     Play/Pass) inside it with a little breathing room, and clear of notches
     on phones. */
  padding: max(30px, env(safe-area-inset-top)) max(30px, env(safe-area-inset-right))
           max(28px, env(safe-area-inset-bottom)) max(30px, env(safe-area-inset-left));
}

/* Felt table panel behind the whole game screen — matches the design
   handoff's "Playing state" look. z-index:-1 keeps it behind the (static,
   in-flow) UI children while still painting above the page background. */
.felt-panel {
  position: absolute; inset: 20px; border-radius: 32px; z-index: -1;
  background: radial-gradient(ellipse at 50% 40%, #0f8a5a 0%, #0c7048 50%, #0a5c3b 100%);
  box-shadow: inset 0 0 0 2px rgba(255,203,61,.25);
  overflow: hidden;
}
.felt-shimmer {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(115deg, rgba(255,255,255,0.04) 0px, rgba(255,255,255,0.04) 2px, transparent 2px, transparent 6px);
  animation: feltShimmer 5s ease-in-out infinite;
}
@keyframes feltShimmer { 0%, 100% { opacity: 0.3; } 50% { opacity: 0.55; } }

.top-bar {
  width: 100%; display: flex; justify-content: flex-end; align-items: center;
  color: #9fbfae; font-size: .9rem; flex-shrink: 0;
}
.top-right { display: flex; gap: 8px; align-items: center; }

#round-label {
  position: absolute; left: 50%; top: 30px; transform: translateX(-50%);
  background: rgba(10,25,20,.85); border: 1px solid rgba(255,203,61,.5);
  color: #fffdf6; font-size: 13px; padding: 8px 18px; border-radius: 10px;
  white-space: nowrap; z-index: 10;
}

.opponents {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
  margin-top: 4px; padding: 2px; flex-shrink: 0;
  /* Scales to any player count (2–16) purely via wrapping — never
     hardcoded to a specific row/column count. Never scrolls: the JS
     auto-fit (fitGame) shrinks the whole board to fit the viewport, and
     adds .compact here to slim the tiles when many players are seated. */
}

.opp {
  background: var(--panel); border: 2px solid transparent; border-radius: 12px;
  padding: 6px 10px; text-align: center; min-width: 92px; position: relative;
  transition: border-color .2s, box-shadow .2s;
}
/* Compact opponent tiles — applied by fitGame when the board is crowded. */
.opponents.compact { gap: 6px; }
.opponents.compact .opp { min-width: auto; padding: 4px 7px; }
.opponents.compact .opp-fan { display: none; }
.opponents.compact .opp-name { font-size: .78rem; max-width: 90px; }
.opponents.compact .opp-cards { font-size: .74rem; }
.opp.turn {
  border-color: var(--gold);
  box-shadow: 0 0 18px rgba(232,195,74,.45);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0%,100% { box-shadow: 0 0 10px rgba(232,195,74,.35); }
  50% { box-shadow: 0 0 22px rgba(232,195,74,.65); }
}
.opp.me { outline: 1px dashed rgba(232,195,74,.4); }
.opp .opp-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px; }
.opp .opp-cards { font-size: .85rem; color: #bcd8c8; }
.opp .opp-role {
  font-size: .68rem; padding: 1px 8px; border-radius: 10px; margin-top: 3px;
  display: inline-block; background: #2c5340; color: #cfe8da;
}
.opp .opp-role.president { background: var(--gold); color: #241d05; font-weight: 700; }
.opp .opp-role.slave { background: #5a2b2b; color: #f0c9c9; }
.opp .tag {
  position: absolute; top: -9px; right: -6px; font-size: .65rem;
  padding: 2px 8px; border-radius: 10px; font-weight: 700;
}
.opp .tag.passed { background: #444; color: #ccc; }
.opp .tag.finished { background: var(--gold); color: #241d05; }
.opp .tag.offline { background: var(--red); color: #fff; }
.opp .tag.two-out { background: #3a1010; color: #ff9c9c; border: 1px solid #a04545; }
.opp.gone { opacity: .35; filter: grayscale(1); }
.kick-btn {
  position: absolute; top: -9px; left: -6px; width: 20px; height: 20px;
  border-radius: 50%; border: 1px solid #a04545; background: #5a2626;
  color: #ffb0b0; font-size: .7rem; line-height: 1; cursor: pointer; padding: 0;
}
.kick-btn:hover { background: #8a3535; color: #fff; }
.spectator-line {
  text-align: center; font-size: .8rem; color: #8fae9c; margin-top: 2px;
}

.opp.skip-flash { animation: skipflash .8s; }
@keyframes skipflash {
  0%, 100% { background: var(--panel); }
  30% { background: #7a2e2e; }
}

/* ------------------------------ table ------------------------------ */

.table-zone {
  flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 10px;
}
.table-label {
  color: #bcd6c8; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; opacity: .8;
}
.table-cards { display: flex; gap: 8px; min-height: var(--card-h); }
.table-info { color: #cfe8da; font-size: 1rem; text-align: center; }
.table-info .hint { color: #8fae9c; font-size: .85rem; display: block; margin-top: 2px; }

.table-zone.reset-flash { animation: resetflash .7s; }
@keyframes resetflash {
  0% { filter: brightness(2.2); }
  100% { filter: brightness(1); }
}

/* The 6-7 ritual. */
.six-seven {
  position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; gap: 6px; pointer-events: none; z-index: 40;
  font-size: 5.5rem; font-weight: 900;
  text-shadow: 0 0 24px rgba(232, 195, 74, .9), 0 4px 12px rgba(0,0,0,.6);
}
.six-seven .ss-six {
  color: var(--gold);
  animation: ss-slam .9s cubic-bezier(.2, 2.2, .4, 1) both,
             ss-fade 1.8s linear both;
}
.six-seven .ss-seven {
  color: #ff9c4a;
  animation: ss-slam .9s .15s cubic-bezier(.2, 2.2, .4, 1) both,
             ss-tilt .5s .5s ease-in-out 2 alternate,
             ss-fade 1.8s linear both;
}
@keyframes ss-slam {
  0% { transform: scale(4) rotate(-20deg); opacity: 0; }
  60% { transform: scale(.9) rotate(6deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes ss-tilt {
  from { transform: rotate(-8deg) translateY(-6px); }
  to { transform: rotate(8deg) translateY(6px); }
}
@keyframes ss-fade {
  0%, 70% { opacity: 1; }
  100% { opacity: 0; }
}
.table-zone { position: relative; }

.turn-banner {
  text-align: center; font-size: 1.05rem; font-weight: 700; min-height: 1.5em;
  color: var(--gold);
}
.turn-banner.waiting { color: #9fbfae; font-weight: 400; }

/* Big centered combo/skip callouts (NOICE!, SKIPPED!) — the design's
   "banner pop" moment, distinct from the small toast pills. */
#banner-wrap {
  position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%);
  z-index: 120; pointer-events: none; text-align: center;
}
.banner-pop {
  font-family: Georgia, serif; font-weight: 800;
  text-shadow: 0 4px 18px rgba(0,0,0,.5); letter-spacing: .04em;
  animation: bannerPop 1.6s ease both;
}
@keyframes bannerPop {
  0% { opacity: 0; transform: scale(0.7); }
  15% { opacity: 1; transform: scale(1.08); }
  25% { transform: scale(1); }
  85% { opacity: 1; }
  100% { opacity: 0; transform: scale(1); }
}

/* ------------------------------ cards ------------------------------ */

.card {
  width: var(--card-w); height: var(--card-h);
  background: #fdfdf5; border-radius: 8px; border: 1px solid #b9b9a8;
  color: var(--ink); position: relative; flex-shrink: 0;
  box-shadow: 0 3px 8px rgba(0,0,0,.4);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 800; user-select: none;
}
.card .rank { font-size: 1.25rem; line-height: 1; }
.card .suit { font-size: 1.15rem; line-height: 1.2; }
.card .corner {
  position: absolute; top: 4px; left: 6px; font-size: .7rem; line-height: 1;
  text-align: center;
}
.card.red { color: var(--red); }
.card.joker { background: linear-gradient(150deg, #fdf3d0, #e9d3f7); color: #7a3fa0; }
.card.joker .rank { font-size: 1.5rem; }

.hand .card { cursor: pointer; transition: transform .12s, box-shadow .12s; }
.hand .card:hover { transform: translateY(-8px); }
.hand .card.selected {
  transform: translateY(-16px);
  box-shadow: 0 0 0 3px var(--gold), 0 10px 18px rgba(0,0,0,.5);
}
.hand .card.disabled-card { opacity: .55; cursor: default; }
.hand .card.disabled-card:hover { transform: none; }
.hand .card.playable-hint { box-shadow: 0 0 0 2px rgba(232,195,74,.65), 0 6px 12px rgba(0,0,0,.4); }
.hand .card.unplayable-hint { opacity: .5; filter: saturate(.6); }
.hand .card.unplayable-hint:hover { transform: translateY(-4px); }

/* ------------------------------ hand zone ------------------------------ */

.hand-zone { width: 100%; display: flex; flex-direction: column; gap: 8px; align-items: center; padding-bottom: 4px; flex-shrink: 0; }

.hand {
  display: flex; flex-wrap: wrap; justify-content: center; align-content: flex-end;
  gap: 6px; padding: 14px 10px 4px; max-width: 100%;
}

.actions { display: flex; gap: 14px; }
.actions .btn {
  width: 150px; font-family: Georgia, serif; font-weight: 700; font-size: 1rem; border-radius: 10px;
}

/* ------------------------------ overlays ------------------------------ */

.overlay {
  position: fixed; inset: 0; background: rgba(4, 12, 8, 0.82);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.panel {
  background: #12271b; border: 1px solid rgba(232,195,74,.3); border-radius: 16px;
  padding: 30px 36px; display: flex; flex-direction: column; gap: 14px;
  align-items: center; max-width: 92vw; max-height: 88vh; overflow-y: auto;
}
.trade-hand { flex-wrap: wrap; max-width: 720px; row-gap: 10px; }

/* Blind-trade deck picker: all 54 cards in a compact grid. */
.deck-grid {
  display: grid !important;
  grid-template-columns: repeat(9, auto);
  gap: 6px; justify-content: center; padding: 4px;
}
.deck-grid .card { margin-left: 0 !important; }
.card.mini { width: 44px; height: 62px; border-radius: 6px; }
.card.mini .rank { font-size: .95rem; }
.card.mini .suit { font-size: .85rem; }
.card.mini .corner { display: none; }

/* Card backs (deal animation + opponent fans). */
.card.back {
  background: repeating-linear-gradient(45deg, #7a2030, #7a2030 6px, #8d2b3c 6px, #8d2b3c 12px);
  border: 2px solid #d9c58a;
}
.deal-fly {
  position: fixed; width: 44px; height: 62px; z-index: 80; pointer-events: none;
  transition: left .55s ease-in, top .55s ease-in, transform .55s ease-in, opacity .55s ease-in;
}
.opp-fan { display: flex; justify-content: center; height: 26px; margin: 3px 0 1px; }
.mini-back {
  width: 15px; height: 22px; border-radius: 3px; margin: 0 -4px; display: inline-block;
  background: repeating-linear-gradient(45deg, #7a2030, #7a2030 3px, #8d2b3c 3px, #8d2b3c 6px);
  border: 1px solid #d9c58a; box-shadow: 0 1px 3px rgba(0,0,0,.4);
}

/* Discard pile — everything thrown this round, stacked top-right. */
.discard {
  position: fixed; right: 34px; top: 130px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  z-index: 30; pointer-events: none;
}
.discard-label {
  color: #bcd6c8; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; opacity: .85;
}
.discard-cards { position: relative; width: 60px; height: 80px; }
.discard-card {
  position: absolute; left: 0; top: 0;
}
.discard-card:nth-child(1) { transform: rotate(-9deg) translate(-4px, 3px); }
.discard-card:nth-child(2) { transform: rotate(5deg) translate(3px, -2px); }
.discard-card:nth-child(3) { transform: rotate(-3deg) translate(-1px, 1px); }
.discard-card:nth-child(4) { transform: rotate(8deg) translate(4px, 2px); }
.discard-card:nth-child(5) { transform: rotate(-6deg) translate(-3px, -1px); }
.discard-card:nth-child(6) { transform: rotate(2deg); }
.discard-count { font-size: .72rem; color: #9fbfae; }

/* Turn countdown */
.turn-timer { text-align: center; font-size: .95rem; color: #9fbfae; min-height: 1.3em; }
.turn-timer.urgent { color: var(--red); font-weight: 800; animation: pulse 1s infinite; }

/* Table shake on a skip */
.table-zone.table-shake { animation: tableshake .5s; }
@keyframes tableshake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-8px, 2px) rotate(-1deg); }
  40% { transform: translate(7px, -3px) rotate(1deg); }
  60% { transform: translate(-5px, 1px); }
  80% { transform: translate(4px, -1px); }
}

/* The tea. */
.tea {
  position: fixed; right: 30px; bottom: 28px; font-size: 2rem; cursor: pointer;
  z-index: 95; user-select: none; transition: transform .15s;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,.5));
}

/* ------------------------------ rulebook ------------------------------ */

.rules-btn {
  position: fixed; top: 30px; left: 30px; z-index: 96;
  background: #16302298; border: 1px solid #3c7154; color: #cfe8da;
  padding: 7px 14px; border-radius: 20px; font-size: .85rem; cursor: pointer;
  backdrop-filter: blur(4px);
}
.rules-btn:hover { background: #234534; }
.rules-panel { max-width: 560px; text-align: left; }
.rules-panel h2 { text-align: center; }
.rules-body { max-height: 50vh; overflow-y: auto; font-size: .92rem; line-height: 1.6; color: #dfeee6; }
.rules-body ul { list-style: disc; padding-left: 1.3em; display: flex; flex-direction: column; gap: 8px; }
.rules-body strong { color: var(--gold); }

/* ------------------------------ chat widget ------------------------------ */

.chat-widget { position: fixed; right: 30px; top: 66px; z-index: 96; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.chat-toggle {
  background: #16302298; border: 1px solid #3c7154; color: #cfe8da;
  padding: 7px 14px; border-radius: 20px; font-size: .85rem; cursor: pointer;
  display: flex; align-items: center; gap: 6px; backdrop-filter: blur(4px);
}
.chat-toggle:hover { background: #234534; }
.chat-unread {
  background: var(--red); color: #fff; border-radius: 999px; font-size: .68rem;
  padding: 1px 6px; font-weight: 700; min-width: 16px; text-align: center;
}
.chat-panel {
  width: 260px; max-height: 320px; display: flex; flex-direction: column;
  background: #0f2116e8; border: 1px solid #3c7154; border-radius: 10px;
  overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.chat-messages { flex: 1; overflow-y: auto; padding: 8px 10px; display: flex; flex-direction: column; gap: 5px; min-height: 120px; max-height: 260px; }
.chat-msg { font-size: .78rem; line-height: 1.3; word-break: break-word; }
.chat-msg .who { color: var(--gold); font-weight: 700; }
.chat-msg .when { color: #6f8f7c; font-size: .68rem; margin-left: 4px; }
.chat-msg .txt { color: #e6f2ea; }
.chat-msg.system { color: #8fae9c; font-style: italic; }
.chat-form { display: flex; gap: 6px; padding: 8px; border-top: 1px solid #234534; }
.chat-form input {
  flex: 1; background: #0b1f14; border: 1px solid #2e5941; border-radius: 6px;
  padding: 7px 9px; font-size: .8rem; color: #fff; text-align: left; width: auto;
}
.chat-form .btn { width: auto; padding: 7px 12px; font-size: .8rem; }

@media (max-width: 640px) {
  .chat-widget { top: auto; bottom: 62px; right: 20px; }
  .chat-panel { width: 220px; }
}
.tea:hover { transform: scale(1.15); }
.tea.sipping { animation: sip 1s ease-in-out; }
@keyframes sip {
  0% { transform: scale(1) rotate(0); }
  30% { transform: scale(1.3) rotate(-25deg) translateY(-10px); }
  60% { transform: scale(1.3) rotate(-35deg) translateY(-12px); }
  100% { transform: scale(1) rotate(0); }
}

/* Lobby deck picker */
.deck-row {
  display: flex; gap: 8px; align-items: center; font-size: .9rem; color: #9fbfae;
}
.deck-row select {
  background: #0b1f14; color: #fff; border: 1px solid #2e5941;
  border-radius: 6px; padding: 6px 8px;
}
.card.mini:hover { transform: translateY(-4px); }
.card.miss { opacity: .22; cursor: default !important; }
.card.miss:hover { transform: none; }
.card.taken {
  box-shadow: 0 0 0 3px var(--gold);
  opacity: .85; cursor: default !important;
}

/* Vote-kick panel */
.vote-panel {
  position: fixed; top: 16px; right: 16px; z-index: 90;
  background: #1c1010f0; border: 1px solid #a04545; border-radius: 12px;
  padding: 14px 18px; display: flex; flex-direction: column; gap: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,.6); min-width: 200px;
}
#vote-title { font-weight: 700; }
.vote-count { font-size: .85rem; color: #d8b0b0; }
.vote-buttons { display: flex; gap: 8px; }

.rankings { list-style: none; width: 100%; min-width: 280px; }
.rankings li {
  display: flex; justify-content: space-between; gap: 20px;
  padding: 8px 12px; border-bottom: 1px solid #234534; font-size: 1.05rem;
}
.rankings .role-label { color: var(--gold); font-weight: 700; }
.rankings li:first-child { background: rgba(232,195,74,.12); border-radius: 8px; }

/* ------------------------------ log & toast ------------------------------ */

/* The play-by-play log is hidden — the toasts, banners, and the discard
   pile already surface what's happening, and the bottom-left log box both
   cluttered the felt and was an extra scrollbar. Kept in the DOM (renderLog
   still writes to it) in case it's ever wanted back. */
.log { display: none; }

#toast-holder {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 100; align-items: center;
}
.toast {
  background: #26483573; backdrop-filter: blur(6px);
  border: 1px solid #3c7154; color: #fff;
  padding: 10px 22px; border-radius: 24px; font-size: .95rem;
  animation: toastin .25s ease-out;
  box-shadow: 0 6px 20px rgba(0,0,0,.45);
}
.toast.error { background: #5a2626d9; border-color: #a04545; }
.toast.big { font-size: 1.05rem; font-weight: 700; }
@keyframes toastin {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Touch devices: the hand-card hover lift sticks after a tap, and tap
   already selects (which lifts via .selected), so drop hover transforms. */
@media (hover: none) {
  .hand .card:hover,
  .hand .card.unplayable-hint:hover,
  .card.mini:hover,
  .tea:hover { transform: none; }
}

@media (max-width: 640px) {
  /* Card size is driven by fitGame (JS) in-game, so no fixed override here. */
  .home-card { padding: 28px 20px; min-width: 0; width: min(360px, calc(100vw - 24px)); }
  .opp { min-width: 78px; padding: 5px 7px; }

  /* Top bar on phones: drop the centered round label and slim the controls
     so the fixed top-left Rules button and the right-hand menu/code/mute
     cluster stop overlapping. */
  #round-label { display: none; }
  .rules-btn { top: max(22px, env(safe-area-inset-top)); left: max(22px, env(safe-area-inset-left)); padding: 6px 11px; font-size: .78rem; }
  .top-bar { font-size: .8rem; }
  .top-right { gap: 5px; }
  .top-right .menu-link.tiny { font-size: 0; }
  .top-right .menu-link.tiny::after { content: '←'; font-size: 1.1rem; line-height: 1; }
  .room-code.small { letter-spacing: 2px; padding: 2px 7px; }
  .btn.tiny { padding: 4px 9px; }

  /* Tea is a decorative easter egg — hide it on phones so it can't sit on
     top of the Play/Pass buttons in the tight bottom-right corner. */
  .tea { display: none; }

  /* Chat lives bottom-right, above the action buttons. */
  .chat-widget { top: auto; bottom: 62px; right: 20px; }
  .chat-panel { width: min(80vw, 250px); }

  /* Action buttons stretch to fill the width for big tap targets. */
  .actions { width: 100%; padding: 0 10px; gap: 10px; }
  .actions .btn { width: auto; flex: 1; }

  /* Overlays (rules, trade, round-end): keep a small margin off the screen
     edges and tighten padding so they never touch the sides on a phone. */
  .panel, .rules-panel { max-width: calc(100vw - 20px); padding: 22px 18px; }
  .rules-body { max-height: 56vh; }
}
