﻿/* Clean & light theme: white surfaces, soft greys, one calm blue accent. */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --table: #edf1f6;
  --table-line: #dde3ea;
  --border: #e5e7eb;
  --text: #1f2937;
  --muted: #6b7280;
  --faint: #9ca3af;
  --accent: #2f6feb;
  --accent-soft: #e8f0fe;
  --danger: #d64545;
  --danger-soft: #fdecec;
  --success: #1e9e6a;
  --success-soft: #e6f6ef;
  --card-red: #d32f2f;
  --card-black: #1f2937;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08);

  --header-h: 56px;
  --card-w: 78px;
  --card-h: calc(var(--card-w) * 1.4);
  --tcard-w: 62px;
  --tcard-h: calc(var(--tcard-w) * 1.4);
  --avatar: 48px;
}

@media (max-width: 600px) {
  :root {
    --card-w: 58px;
    --tcard-w: 46px;
    --avatar: 40px;
    --header-h: 52px;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, p { margin: 0; }
.muted { color: var(--muted); }
.muted-dark { color: var(--muted); }
.small-text { font-size: 0.8rem; }

/* ---------- Buttons & inputs ---------- */

.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  color: var(--text);
  background: var(--surface);
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: #f3f4f6; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #2560d6; }
.btn.primary:disabled:hover { background: var(--accent); }
.btn.secondary { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.btn.secondary:hover { background: #dbe7fd; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: #f3f4f6; }
.btn.danger { color: var(--danger); }
.btn.big { padding: 13px 20px; font-size: 1rem; width: 100%; }
.btn.small { padding: 6px 12px; font-size: 0.85rem; }

input {
  font: inherit;
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  min-width: 0;
}
input::placeholder { color: var(--faint); }
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Header ---------- */

.topbar {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; }
.logo {
  background: var(--text);
  color: #fff;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 0.85rem;
}
.top-actions { display: flex; align-items: center; gap: 6px; }
.logo-img { width: 30px; height: 30px; border-radius: 8px; display: block; }

.chip {
  font: inherit;
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
}
.chip b { color: var(--text); letter-spacing: 2px; margin-left: 4px; }

@media (max-width: 420px) {
  .topbar { padding: 0 10px; }
  .chip { padding: 5px 8px; }
  .brand span:last-child { display: none; }
}

/* ---------- Screens ---------- */

.screen { min-height: calc(100dvh - var(--header-h)); }

/* Home */
.home {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 24px 16px 40px;
}
.hero { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.hero h1 { font-size: 2.2rem; }
.hero-fan { position: relative; width: 160px; height: 100px; margin-bottom: 6px; }
.hero-fan .card { position: absolute; left: 50%; bottom: 0; transform-origin: 50% 120%; margin-left: calc(var(--card-w) / -2); }
.hero-fan .card:nth-child(1) { transform: rotate(-24deg); }
.hero-fan .card:nth-child(2) { transform: rotate(-8deg); }
.hero-fan .card:nth-child(3) { transform: rotate(8deg); }
.hero-fan .card:nth-child(4) { transform: rotate(24deg); }
.hero-fan .card:nth-child(1), .hero-fan .card:nth-child(3) { color: var(--card-red); }

.panel {
  width: 100%;
  max-width: 380px;
  padding: 24px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.9rem; }
.join-row { display: flex; gap: 8px; }
.join-row input { text-transform: uppercase; letter-spacing: 4px; text-align: center; font-weight: 700; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 0.85rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.error { color: var(--danger); min-height: 1.2em; font-size: 0.9rem; text-align: center; }

/* Lobby */
.lobby {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 16px 28px;
}
.lobby-head { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.eyebrow { text-transform: uppercase; letter-spacing: 2px; font-size: 0.75rem; color: var(--muted); font-weight: 600; }
.room-code { font-size: 2.4rem; font-weight: 800; letter-spacing: 10px; padding-left: 10px; }
.lobby-arena { width: 100%; max-width: 520px; height: 290px; flex: none; }
.lobby-foot { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.hint { color: var(--muted); }
.big-count { font-size: 1.8rem; font-weight: 800; }

/* ---------- Table ---------- */

.game {
  height: calc(100dvh - var(--header-h));
  display: flex;
  flex-direction: column;
}

.arena-wrap {
  position: relative;
  flex: 1;
  min-height: 240px;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

.arena {
  position: absolute;
  inset: calc(var(--avatar) * 0.75 + 12px) calc(var(--avatar) * 0.9 + 8px);
  border-radius: 32px;
  background: var(--table);
  border: 1px solid var(--table-line);
}

.table-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 46%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
  pointer-events: none;
}
/* In a game your own seat isn't drawn on the table, so the bottom edge can sit lower. */
.game .arena { bottom: 16px; }

/* Seats around the table */
.seat {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 92px;
  text-align: center;
  z-index: 2;
}
.avatar {
  position: relative;
  width: var(--avatar);
  height: var(--avatar);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: calc(var(--avatar) * 0.4);
  color: hsl(var(--hue), 45%, 30%);
  background: hsl(var(--hue), 70%, 90%);
  border: 3px solid var(--surface);
  box-shadow: var(--shadow-sm);
}
.seat-name {
  font-weight: 600;
  font-size: 0.85rem;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.seat-status { font-size: 0.72rem; color: var(--muted); white-space: nowrap; }

.seat.turn .avatar { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.seat.turn .seat-status { color: var(--accent); font-weight: 700; }
.seat.safe .avatar, .seat.left .avatar { opacity: 0.5; }
.seat.safe .seat-status { color: var(--success); font-weight: 600; }
.seat.ass .avatar { border-color: var(--danger); }
.seat.ass .seat-status { color: var(--danger); font-weight: 700; }
.seat.offline .avatar { border-color: var(--faint); border-style: dashed; }
.seat.offline .seat-status { color: var(--danger); }
.seat.empty .avatar {
  background: transparent;
  border: 2px dashed #c9d1db;
  box-shadow: none;
  color: var(--faint);
}
.seat.empty .seat-name { color: var(--faint); font-weight: 500; }

.bubble {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #f6caca;
}
.bubble.good { background: var(--accent-soft); color: var(--accent); border-color: #c9dafc; }

/* ---------- Cards ---------- */

.card {
  position: relative;
  flex: none;
  width: var(--card-w);
  height: var(--card-h);
  padding: 0;
  border-radius: 8px;
  background: #fff;
  color: var(--card-black);
  border: 1px solid #d7dce3;
  box-shadow: var(--shadow-sm);
  font-family: inherit;
  font-weight: 700;
}
.card.red { color: var(--card-red); }
.card .corner {
  position: absolute;
  top: 5px;
  left: 6px;
  font-size: calc(var(--card-w) * 0.25);
  line-height: 1;
  text-align: center;
}
.card .pip {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 10%;
  font-size: calc(var(--card-w) * 0.48);
}

/* Cards played on the table */
.tcard {
  position: absolute;
  --card-w: var(--tcard-w);
  --card-h: var(--tcard-h);
  transform: translate(-50%, -50%);
  z-index: 1;
}
.tcard.winner { border: 2px solid var(--accent); }
.tcard.cut { border: 2px solid var(--danger); }

/* ---------- My hand ---------- */

.my-area {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 10px calc(14px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.turn-banner {
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
  background: var(--accent-soft);
  color: var(--accent);
}
.turn-banner.warn { background: var(--danger-soft); color: var(--danger); }
.turn-banner.info { background: var(--bg); color: var(--muted); }
.turn-banner.good { background: var(--success-soft); color: var(--success); }

.hand { width: 100%; max-width: 1160px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.hand-row { display: flex; justify-content: center; padding-top: 8px; }

.hand .card { transition: transform 0.12s, opacity 0.12s; }
.hand.my-turn .card:not(.playable) { opacity: 0.45; }
.hand .card.playable {
  cursor: pointer;
  border: 2px solid var(--accent);
  transform: translateY(-6px);
}
.hand .card.playable:hover,
.hand .card.playable:focus-visible { transform: translateY(-10px); z-index: 1; outline: none; }

/* ---------- Log drawer ---------- */

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(340px, 88vw);
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(16, 24, 40, 0.08);
}
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.drawer-head h2 { font-size: 1rem; }
.drawer-sub { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.log { list-style: none; margin: 0; padding: 8px 16px 16px; overflow-y: auto; font-size: 0.85rem; }
.log li { padding: 7px 0; border-bottom: 1px solid #f0f2f5; }
.log li.important { color: var(--accent); font-weight: 600; }

/* ---------- Dialogs ---------- */

dialog {
  max-width: min(480px, calc(100vw - 32px));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px 24px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-md);
}
dialog::backdrop { background: rgba(17, 24, 39, 0.35); }
dialog h2 { margin-bottom: 10px; }
dialog li { margin-bottom: 8px; line-height: 1.45; }
dialog form { margin-top: 14px; text-align: right; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(17, 24, 39, 0.35);
}
.overlay-card {
  width: 100%;
  max-width: 380px;
  padding: 24px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.over-emoji { font-size: 2.6rem; line-height: 1; }
.ranking { list-style: none; margin: 4px 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ranking li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--bg);
  text-align: left;
}
.ranking .mini-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: hsl(var(--hue), 45%, 30%);
  background: hsl(var(--hue), 70%, 90%);
  flex: none;
}
.ranking .rank-name { flex: 1; font-weight: 600; }
.ranking .rank-tag { font-size: 0.8rem; color: var(--success); font-weight: 600; }
.ranking li.ass { background: var(--danger-soft); }
.ranking li.ass .rank-tag { color: var(--danger); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--text);
  color: #fff;
  box-shadow: var(--shadow-md);
  z-index: 40;
}

/* Short screens (phone turned sideways): smaller everything so the hand stays
   visible. Kept last so it overrides the rules above. */
@media (max-height: 500px) {
  :root {
    --card-w: 52px;
    --tcard-w: 40px;
    --avatar: 32px;
    --header-h: 44px;
  }
  .arena-wrap { min-height: 120px; }
  .my-area { gap: 4px; padding-top: 4px; padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
  .turn-banner { padding: 3px 12px; font-size: 0.8rem; }
  .hand-row { padding-top: 4px; }
  .seat-name { font-size: 0.75rem; }
  .seat-status { font-size: 0.65rem; }
  .btn.small { padding: 4px 10px; }
}

/* ---------- Penalty Aces ---------- */

.seat-aces, .rank-aces, .my-aces .seat-aces { display: inline-flex; gap: 2px; }
.ace {
  display: inline-block;
  padding: 0 3px;
  border-radius: 4px;
  border: 1px solid #d7dce3;
  background: #fff;
  color: var(--card-black);
  font-size: 0.66rem;
  font-weight: 700;
  line-height: 1.35;
}
.ace.red { color: var(--card-red); }
.seat .seat-aces { margin-top: 1px; }

.my-area { position: relative; }
.my-aces {
  position: absolute;
  left: calc(12px + env(safe-area-inset-left));
  top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 3;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
}
body.phone-game .my-aces { top: auto; bottom: calc(100% + 4px); left: calc(12px + var(--edge-left)); }

.over-sub { color: var(--muted); font-weight: 600; margin-top: -4px; }
.overlay.final .over-sub { color: var(--danger); }
.overlay.final .overlay-card { border: 2px solid var(--danger); }
.ranking .rank-aces { flex: none; }

/* ---------- Chat ---------- */

.chat-btn { position: relative; }
.chat-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.drawer.chat { z-index: 35; }
.chat-list {
  flex: 1;
  list-style: none;
  margin: 0;
  padding: 12px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-empty { color: var(--faint); font-size: 0.85rem; text-align: center; margin-top: 24px; }
.chat-msg { max-width: 82%; align-self: flex-start; display: flex; flex-direction: column; gap: 2px; }
.chat-msg.mine { align-self: flex-end; align-items: flex-end; }
.chat-name { font-size: 0.72rem; color: var(--muted); font-weight: 600; padding: 0 4px; }
.chat-text {
  padding: 7px 11px;
  border-radius: 14px;
  background: #f1f3f6;
  font-size: 0.9rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.chat-msg.mine .chat-text { background: var(--accent); color: #fff; }
.chat-msg.system { align-self: center; max-width: 100%; font-size: 0.75rem; color: var(--faint); }

.chat-quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 14px 0; border-top: 1px solid var(--border); }
.chat-quick .chip { color: var(--text); }
.chat-form { display: flex; gap: 8px; padding: 10px 14px calc(14px + env(safe-area-inset-bottom)); }
.chat-form .btn { flex: none; }

/* ---------- Feedback ---------- */

.feedback-dialog { width: min(440px, calc(100vw - 32px)); }
.feedback-dialog[open] { display: flex; flex-direction: column; gap: 10px; }
.feedback-dialog h2 { margin-bottom: 0; }
.feedback-dialog textarea {
  font: inherit;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  resize: vertical;
}
.feedback-dialog textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Donation link, footer, ads ---------- */

a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.btn.donate { font-size: 1rem; padding: 4px 10px; }

.donate-link { color: var(--muted); font-size: 0.85rem; text-decoration: none; }
.donate-link:hover { color: var(--text); text-decoration: underline; }

.site-footer { display: flex; gap: 18px; justify-content: center; font-size: 0.85rem; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--text); text-decoration: underline; }

/* Ad spaces stay collapsed until an ad is actually placed in them */
.ad-slot { width: 100%; max-width: 728px; margin: 0 auto; text-align: center; }
.ad-slot:empty { display: none; }
.overlay-card .ad-slot { max-width: 100%; }

@media (orientation: landscape) and (max-height: 540px) {
  .home { flex-wrap: wrap; }
  .home .ad-slot, .site-footer { flex-basis: 100%; }
}

/* ---------- Phone game mode (touch screen held sideways) ---------- */

.fab { display: none; }

.menu-sheet { width: min(320px, calc(100vw - 32px)); }
.menu-sheet[open] { display: flex; flex-direction: column; gap: 8px; }
.menu-sheet .btn { width: 100%; }
.menu-sheet form { margin: 0; text-align: center; }
.menu-code { font-size: 1.6rem; font-weight: 800; letter-spacing: 6px; text-align: center; margin-bottom: 4px; }
.menu-sheet .eyebrow { text-align: center; }

/* Home and lobby side by side on a sideways phone */
@media (orientation: landscape) and (max-height: 540px) {
  .home { flex-direction: row; gap: 32px; padding: 12px 20px; }
  .hero-fan { display: none; }
  .hero { max-width: 260px; }
  .panel { padding: 16px; gap: 10px; }

  .lobby {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
    grid-template-areas: "head arena" "foot arena";
    align-items: center;
    column-gap: 20px;
    padding: 8px 20px;
  }
  .lobby-head { grid-area: head; }
  .lobby-foot { grid-area: foot; }
  .lobby-arena { grid-area: arena; height: calc(100dvh - var(--header-h) - 16px); max-width: none; }
  .room-code { font-size: 1.8rem; }
}

/* The client sets body.phone-game during a game on a phone, and adds
   body.rotated when the phone is upright: the game is then drawn turned 90°
   so it's played sideways even on iPhones (which can't lock orientation) or
   with rotation lock on. --game-w/--game-h are the game's own width/height. */
body.phone-game {
  --game-w: 100vw;
  --game-h: 100dvh;
  --card-w: clamp(56px, calc(var(--game-h) * 0.2), 92px);
  --card-h: calc(var(--card-w) * 1.4);
  --tcard-w: clamp(42px, calc(var(--game-h) * 0.14), 66px);
  --tcard-h: calc(var(--tcard-w) * 1.4);
  --avatar: clamp(32px, calc(var(--game-h) * 0.1), 44px);
  --edge-left: env(safe-area-inset-left);
  --edge-right: env(safe-area-inset-right);
  --edge-bottom: env(safe-area-inset-bottom);
  overflow: hidden;
}
body.phone-game.rotated {
  --game-w: 100dvh;
  --game-h: 100vw;
  /* After turning, the notch side is the game's left and the home bar its right */
  --edge-left: env(safe-area-inset-top);
  --edge-right: env(safe-area-inset-bottom);
  --edge-bottom: 0px;
}

/* Full-screen table: no website header during a game */
body.phone-game .topbar { display: none; }
body.phone-game .game { height: var(--game-h); min-height: 0; }
body.phone-game.rotated .game {
  position: fixed;
  top: 0;
  left: 100vw;
  width: var(--game-w);
  transform-origin: top left;
  transform: rotate(90deg);
}

body.phone-game .fab {
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 8px;
  left: calc(8px + var(--edge-left));
  z-index: 15;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-size: 1.1rem;
  color: var(--text);
}

body.phone-game .fab-right { left: auto; right: calc(8px + var(--edge-right)); }
/* Upright phone: the game is drawn sideways but chat opens upright, full width */
body.phone-game.rotated .drawer.chat { width: 100vw; }

body.phone-game .game .arena-wrap { max-width: none; min-height: 0; }
body.phone-game .game .arena {
  top: calc(var(--avatar) * 0.75 + 8px);
  left: calc(56px + var(--edge-left));
  right: calc(56px + var(--edge-right));
  bottom: 8px;
}

body.phone-game .my-area {
  position: relative;
  gap: 0;
  padding: 2px calc(8px + var(--edge-right)) calc(4px + var(--edge-bottom)) calc(8px + var(--edge-left));
  border-top: none;
  background: transparent;
}
/* The message floats just above the cards instead of taking a row */
body.phone-game .turn-banner {
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  z-index: 3;
  padding: 4px 12px;
  font-size: 0.8rem;
  box-shadow: var(--shadow-sm);
}
body.phone-game .turn-banner.info { background: var(--surface); }

/* Fanned hand */
body.phone-game .hand.fan .hand-row { padding-top: 16px; align-items: flex-start; }
body.phone-game .hand.fan .card {
  transform-origin: 50% 120%;
  transform: translateY(calc(var(--arc, 0px) + var(--lift, 0px))) rotate(var(--rot, 0deg)) !important;
}
body.phone-game .hand.fan .card.playable { --lift: -14px; }

body.phone-game .seat-name { font-size: 0.75rem; }
body.phone-game .seat-status { font-size: 0.65rem; }

body.phone-game .overlay-card { max-height: calc(var(--game-h) - 32px); overflow-y: auto; }
body.phone-game .drawer { width: min(340px, calc(var(--game-w) * 0.6)); }

/* Menu: two columns of buttons so it fits the short screen */
body.phone-game .menu-sheet {
  width: min(440px, calc(var(--game-w) - 32px));
  max-height: calc(var(--game-h) - 24px);
  overflow-y: auto;
  padding: 14px 18px;
}
body.phone-game .menu-sheet[open] { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
body.phone-game .menu-sheet .eyebrow,
body.phone-game .menu-sheet .menu-code,
body.phone-game .menu-sheet form { grid-column: 1 / -1; }
body.phone-game .menu-sheet .btn { padding: 9px 12px; }
body.phone-game .menu-code { margin-bottom: 0; }

/* Pop-ups live above the page, so turn them to match the rotated game */
/* (Feedback stays upright: typing happens with the phone upright, like chat.) */
body.phone-game.rotated dialog[open]:not(.feedback-dialog) {
  transform: rotate(90deg);
  max-width: calc(var(--game-w) - 32px);
  max-height: calc(var(--game-h) - 24px);
  overflow-y: auto;
}
body.phone-game.rotated .toast {
  left: 44px;
  top: 50%;
  bottom: auto;
  max-width: calc(var(--game-w) - 32px);
  transform: translate(-50%, -50%) rotate(90deg);
}

