/* chinesepoker.css — Chinese Poker layout and mobile lock (theme aligned with game.html / style.css) */
:root {
  --card-bg: #f8f9fa;
  --card-border: #ced4da;
  --red-suit: #b91c1c;
  --black-suit: #1f2937;
  --gold: #f59e0b;
  --text: #343A40;
  --text-muted: #6c757d;
  --panel-bg: #E9ECEF;
  --panel-border: #dee2e6;
  --section-border: #333;
  --accent: #4CB5F5;
  --accent-strong: #2D6A87;
}

/* Keep hand container exactly aligned to board-area width at all breakpoints. */
.board-column > .hand-container {
  width: 100%;
  box-sizing: border-box;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

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

.hidden { display: none !important; }

/* Join / queue: show Privacy & Terms. During play, hide so fixed-height viewports fit controls. */
.cp-footer-legal {
  text-align: center;
  padding: 12px 8px 18px;
  margin: 0;
  flex-shrink: 0;
  font-size: 0.82rem;
}
body:has(#game-content:not(.hidden)) .cp-footer-legal {
  display: none !important;
}

/* During play only: match body edge to game backdrop (join queue unchanged) */
body:has(#game-content:not(.hidden)) {
  background: #1a0f12;
  /* Reduces double-tap zoom on play surface (cards use touch-action: none for drag). */
  touch-action: manipulation;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  height: 100vh;
  max-height: 100dvh;
  padding: 0;
  background: #F8F9FA;
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Join queue: fluid width; game play keeps fixed snap tiers in media queries below. */
body:has(#join-queue-screen:not(.hidden)) {
  width: 100%;
  min-width: 0;
  max-width: none;
  height: auto;
  min-height: 100vh;
  max-height: none;
  align-items: stretch;
  overflow-x: hidden;
  overflow-y: auto;
}

/* Join screen — no horizontal padding so site banner can span full width */
#join-queue-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  align-self: stretch;
  width: 100%;
  max-width: none;
  justify-content: flex-start;
  padding: 0 0 32px;
  text-align: center;
  overflow-y: auto;
  overflow-x: clip;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}
/* Full-width game title strip under the site header */
#join-queue-screen > .join-queue-title-banner {
  align-self: stretch;
  width: 100%;
  max-width: none;
  box-sizing: border-box;
  padding: 18px max(24px, env(safe-area-inset-left, 0px)) 16px max(24px, env(safe-area-inset-right, 0px));
  text-align: center;
  background: transparent;
  flex-shrink: 0;
}
/* Restore side inset for lobby content below the title banner */
#join-queue-screen > .join-queue-top {
  padding-left: 24px;
  padding-right: 24px;
  padding-top: 16px;
  box-sizing: border-box;
}
.join-queue-top {
  width: 100%;
  max-width: 42rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 8px;
}
/* Match Bullpen Bluff join queue title (style.css .join-queue-title) */
#join-queue-screen .join-queue-title {
  font-family: "Aptos", "Aptos (Body)", sans-serif;
  color: #5a5a5a;
  font-size: 3.25rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  margin: 0 0 0.25rem;
  text-align: center;
  width: 100%;
  text-shadow: 0 -2px 0 rgba(255, 255, 255, 0.5), 0 2px 0 rgba(0, 0, 0, 0.35);
  line-height: 1.1;
}
/* Same look as .join-queue-title, two steps smaller (0.5rem per step) */
#join-queue-screen .join-queue-subtitle {
  font-family: "Aptos", "Aptos (Body)", sans-serif;
  color: #5a5a5a;
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  margin: 0.2rem 0 0;
  text-align: center;
  width: 100%;
  text-shadow: 0 -2px 0 rgba(255, 255, 255, 0.5), 0 2px 0 rgba(0, 0, 0, 0.35);
  line-height: 1.1;
}
/* Hero: was 624px max; reduced by 1/3 → 2/3 scale (416px) */
.join-queue-hero {
  max-width: 416px;
  width: 100%;
  height: auto;
  margin-bottom: 1rem;
  display: block;
}
.join-queue-legend-heading {
  font-size: 1.25rem;
  font-weight: 700;
  color: #000000;
  text-align: center;
  width: 100%;
  margin: 1em 0 1rem;
  line-height: 1.3;
}
/* Same font size/family as Bullpen tagline; body weight normal so only <strong> SEO terms read bold */
.join-queue-intro {
  width: 100%;
  text-align: left;
  font-family: "Aptos", "Aptos (Body)", "Calibri (Body)", sans-serif;
  font-size: 0.825rem;
  font-weight: 400;
  line-height: 1.5;
  color: #2d2d2d;
  margin-bottom: 0.5rem;
}
.join-queue-intro p {
  margin: 0 0 1em;
}
.join-queue-intro p:last-child {
  margin-bottom: 0;
}
/* SEO keywords only — contrast vs normal paragraph weight */
.join-queue-intro strong {
  font-weight: 700;
  color: #0a0a0a;
  letter-spacing: 0.01em;
}

/* Join queue actions — match Bullpen Bluff (game.html) join-queue row + sound */
#join-queue-screen .join-queue-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 26rem;
  margin: 0 auto;
  padding: 0 16px;
  box-sizing: border-box;
}
/* Center Game Rules | Turn Sound row above JOIN QUEUE */
#join-queue-screen .waiting-links.join-queue-top-links {
  font-family: "Aptos", "Aptos (Body)", "Calibri (Body)", sans-serif;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin: 1.25rem 0 12px;
  padding: 0;
  text-align: center;
}
#join-queue-screen .join-queue-actions .join-queue-button {
  align-self: center;
}
#join-queue-screen .join-queue-actions #join-error {
  text-align: center;
  width: 100%;
}
#join-queue-screen .join-queue-top-links .waiting-links-sep {
  opacity: 0.6;
  user-select: none;
}
#join-queue-screen .join-queue-top-links .waiting-link strong {
  font-size: inherit;
  font-weight: 600;
}
/* Match Bullpen .waiting-links .waiting-link (style.css) */
#join-queue-screen .waiting-links .waiting-link {
  font-family: inherit;
  color: #3d3d3d;
  text-decoration: underline;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  display: inline-flex;
  align-items: baseline;
}
#join-queue-screen .waiting-links .waiting-link:hover {
  text-decoration: underline;
}
#join-queue-screen .sound-toggle-wrap {
  display: inline-flex;
  align-items: baseline;
  cursor: pointer;
}
#join-queue-screen .sound-toggle-emoji {
  font-family: "Aptos", "Aptos (Body)", "Calibri (Body)", sans-serif;
  background-color: #3d3d3d;
  color: #e8e8e8;
  font-size: 0.9rem;
  margin-left: 4px;
  padding: 2px 4px;
  display: inline-block;
  vertical-align: baseline;
  line-height: 1;
  border-radius: 2px;
}
#join-queue-screen .sound-toggle-emoji.sound-on {
  font-size: 1.125rem;
}

.join-welcome-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.join-avatar-wrap {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.3);
  flex-shrink: 0;
}
.join-avatar-wrap img { width: 100%; height: 100%; object-fit: cover; }
.join-welcome-text { text-align: left; }
.join-welcome-text p { margin: 0 0 8px; font-size: 1rem; color: var(--text); }
/* Match Bullpen Bluff "Play Ball" (style.css .join-queue-button) */
#join-queue-screen .join-queue-button {
  margin-top: 16px;
  padding: 14px 48px;
  font-size: 1.25rem;
  font-weight: bold;
  font-family: "Aptos", "Aptos (Body)", sans-serif;
  background-color: #2d2d2d;
  color: #ffffff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  line-height: 1.15;
}
#join-queue-screen .join-queue-button .join-queue-subtext {
  font-size: 0.75rem;
  font-weight: 400;
}
#join-queue-screen .join-queue-button:hover {
  background-color: #1a1a1a;
}
#join-queue-screen .join-queue-button:active {
  transform: scale(0.98);
}
#join-queue-screen .join-queue-button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}
/* Match Bullpen Bluff join-queue promo (game.html / style.css .join-queue-promo) */
#join-queue-screen .join-queue-promo {
  margin: calc(12px + 1.35em) auto 0;
  padding: 0 16px;
  max-width: 26rem;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 400;
  color: #2d2d2d;
  line-height: 1.45;
}
#join-queue-screen .join-queue-promo strong {
  font-weight: 700;
  color: #0a0a0a;
}
#join-queue-screen .join-queue-promo .waiting-link {
  color: #0b57d0;
  text-decoration: underline;
  font-weight: inherit;
}
#join-queue-screen .join-queue-promo .waiting-link strong {
  font-weight: 700;
  color: #0b57d0;
}
#join-queue-screen .join-queue-promo .waiting-link:hover {
  text-decoration: underline;
}
.btn-primary {
  background: var(--accent-strong);
  color: white;
  border: 2px solid #1a4d66;
  cursor: pointer;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.btn-primary:hover { background: #1f526d; border-color: #164055; }
.btn-manage { display: inline-block; color: var(--accent); text-decoration: none; font-size: 0.9rem; }
.btn-manage:hover { text-decoration: underline; }
#join-error { color: #0b57d0; margin-top: 12px; font-size: 0.9rem; }

/* Manage (Update avatar) page */
#manage-page { max-width: 480px; margin: 0 auto; padding: 24px; }
#manage-page h2 { color: var(--text); margin-bottom: 8px; }
.manage-back { margin-bottom: 24px; }
.manage-back a { color: var(--accent); text-decoration: none; }
.manage-back a:hover { text-decoration: underline; }
.manage-section { margin-bottom: 28px; }
.manage-section h3 { font-size: 1rem; color: var(--text-muted); margin-bottom: 8px; }
.manage-hint { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 12px; }
.identity-pickers, .crew-add { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.identity-pickers select, .crew-add select { padding: 6px 8px; border-radius: 6px; min-width: 4em; }
.crew-add input[type="number"] { width: 64px; padding: 6px 8px; border-radius: 6px; }
.btn-link { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 0.9rem; padding: 0; }
#recover-emojis { margin-top: 8px; font-size: 0.9rem; }
#crew-list { list-style: none; padding: 0; margin: 0; }
#crew-list li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--panel-border); }
.crew-label { flex: 1; }
.crew-tag { font-size: 0.75rem; color: var(--accent); }
.btn-small { padding: 4px 10px; font-size: 0.8rem; }
.crew-delete { background: #b91c1c; color: white; border: none; border-radius: 4px; cursor: pointer; }
.hidden { display: none !important; }

/* Game content only — imperial dragon backdrop (static asset + CSS; join queue unchanged) */
#game-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
  isolation: isolate;
  background-color: #1a0f12;
  background-image: url("images/chinese-poker-imperial-bg.png?v=1");
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center center;
}

/* Header: ~40% avatar+identity, ~30% chips, ~30% timer (one row) */
.cp-header-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  position: relative;
  background: var(--panel-bg);
  border: 2px solid var(--section-border);
  border-bottom: 1px solid var(--section-border);
}
.header-left {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.header-profile {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--panel-border);
  overflow: hidden;
  flex-shrink: 0;
}
.header-profile img { width: 100%; height: 100%; object-fit: cover; }
.header-identity {
  font-size: 0.75rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.header-identity.hidden { display: none !important; }
.header-chips {
  text-align: center;
  color: #00A86B;
  font-weight: bold;
  font-size: 0.85rem;
  min-width: 0;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--panel-bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}
.header-chips-label {
  color: #FFFFFF;
  font-weight: 700;
}
.header-chips-value {
  color: #00A86B;
  font-weight: 700;
}

.cp-sound-toggle {
  flex-shrink: 0;
  width: 36px;
  height: 32px;
  padding: 0;
  margin: 0 auto;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--panel-bg);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cp-sound-toggle:hover { filter: brightness(1.06); }

.cp-multipick-hint {
  display: inline;
  opacity: 0.88;
  font-size: 0.9em;
}

/* Timer: clock-style, countdown, flash when low */
.timer-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--panel-bg);
  padding: 4px 5px;
  border-radius: 12px;
  font-size: 0.85rem;
  color: var(--text);
  border: 1px solid var(--panel-border);
  width: auto;
  min-width: max-content;
}
.timer-wrap.timer-low { animation: cp-timer-flash 1s ease-in-out infinite; }
@keyframes cp-timer-flash {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(45, 106, 135, 0.4); }
  50% { opacity: 0.9; box-shadow: 0 0 12px 4px rgba(45, 106, 135, 0.5); }
}
.timer-wrap .timer-icon { font-size: 1rem; }
#headerTimer { font-variant-numeric: tabular-nums; }

/* Ad banner — same height as profile row */
.cp-ad-banner {
  min-height: 28px;
  background: var(--panel-bg);
  border: 2px solid var(--section-border);
  border-top: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.65rem;
}

/* In-game only: top header + ad strip (not join queue) */
#game-content .cp-header-row {
  background-color: #2C2C2C;
  background: #2C2C2C;
  color: #f1f3f5;
}
#game-content .cp-header-row .header-identity {
  color: #FFFFFF;
}
/* Same bar color as header — chips / sound / timer sit on #2C2C2C, not light panels */
#game-content .cp-header-row .header-chips {
  background-color: #2C2C2C;
  background: #2C2C2C;
  border-color: rgba(255, 255, 255, 0.22);
}
#game-content .cp-header-row .cp-sound-toggle {
  background-color: #2C2C2C;
  background: #2C2C2C;
  border-color: rgba(255, 255, 255, 0.22);
  color: #f1f3f5;
}
#game-content .cp-header-row .timer-wrap {
  background-color: #2C2C2C;
  background: #2C2C2C;
  border-color: rgba(255, 255, 255, 0.22);
  color: #FFFFFF;
}
#game-content .cp-header-row .header-profile {
  border-color: rgba(255, 255, 255, 0.28);
}
#game-content .cp-ad-banner {
  background: #2C2C2C;
  color: #FFFFFF;
}
#game-content .opponents {
  background-color: #2C2C2C;
  background: #2C2C2C;
}
/* White text for requested game/readout labels */
#game-content #headerTimer,
#game-content .readout-panel h3,
#game-content .readout-multiplayer-hint,
#game-content .readout-points,
#game-content .readout-step-label,
#game-content .readout-vs-detail,
#game-content #readoutHint {
  color: #FFFFFF;
}
/* Game page: unify all buttons to parchment tone */
#game-content button {
  background-color: #E6E0AE;
  background: #E6E0AE;
  border: 1px solid #E6E0AE;
  color: #1A1A1A;
}
#game-content button:hover {
  filter: brightness(0.96);
}
#game-content button:active {
  background-color: #F5F0E6;
  background: #F5F0E6;
  border-color: #F5F0E6;
}
#game-content button:disabled {
  opacity: 0.5;
}

/* Opponents */
.opponents {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 6px 8px;
  max-height: 88px;
  overflow: auto;
  background: var(--panel-bg);
  border: 2px solid var(--section-border);
  border-top: none;
  align-items: center;
  justify-content: center;
}
.avatar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  min-width: 44px;
}
.avatar-wrap:hover .avatar { transform: scale(1.1); border-color: var(--accent); }
.avatar-wrap.selected .avatar { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
.avatar-wrap .score-vs {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-strong);
  background: #E6E0AE;
  padding: 2px 6px;
  border-radius: 6px;
  min-width: 28px;
  text-align: center;
  line-height: 1.2;
}
.avatar-wrap .score-vs.positive { color: #00A86B; }
.avatar-wrap .score-vs.negative { color: #C8102E; }
.avatar-wrap .score-vs.locked { color: #1A1A1A; font-size: 9px; }
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--panel-bg);
  border: 2px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.watching { opacity: 0.6; }

.main-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 6px 8px;
  border: 2px solid var(--section-border);
  border-top: none;
}

/* Board column: wraps board + hand controls (mockup layout) */
.board-column {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
}
.board-area {
  border: 2px solid var(--section-border);
  border-radius: 8px;
  padding: 4px;
  margin: 2px 0;
  flex-shrink: 0;
}
.board-row {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 3px;
  padding: 1px 0;
}
.board-row-front .row-left { width: 25%; flex: 0 0 25%; justify-content: flex-end; }
.board-row-front .row-center { width: 50%; flex: 0 0 50%; }
.board-row-front .row-right { width: 25%; flex: 0 0 25%; justify-content: flex-start; }
.board-row-middle .row-left { width: 15%; flex: 0 0 15%; }
.board-row-middle .row-center { width: 70%; flex: 0 0 70%; }
.board-row-middle .row-right { width: 15%; flex: 0 0 15%; }
.board-row-back .row-left { width: 15%; flex: 0 0 15%; justify-content: flex-end; }
.board-row-back .row-center { width: 70%; flex: 0 0 70%; }
.board-row-back .row-right { width: 15%; flex: 0 0 15%; justify-content: flex-start; }
.row-left, .row-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}
.row-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}
.row-label-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  margin-bottom: 2px;
}
.row-center .row-label { margin-bottom: 0; }
.slots-with-stars {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 4px;
  min-height: 0;
}
.slots-with-stars .slots {
  flex: 1 1 auto;
  min-width: 0;
}
.suggest-star,
.suggest-star-side {
  font-size: clamp(16px, 3.2vw, 24px);
  font-weight: 900;
  color: #ea580c;
  text-shadow: 0 0 1px rgba(255, 255, 255, 0.9);
  min-width: 1.1em;
  text-align: center;
  line-height: 1;
  flex-shrink: 0;
  align-self: center;
}
.cp-granny-tooltip {
  position: fixed;
  z-index: 10000;
  max-width: min(280px, 92vw);
  padding: 8px 10px;
  font-size: 0.78rem;
  line-height: 1.35;
  color: #111827;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  pointer-events: none;
}
.cp-granny-tooltip.hidden { display: none !important; }
.readout-multiplayer-hint {
  font-size: 0.78rem;
  color: #495057;
  line-height: 1.35;
  margin: 0 0 10px 0;
  max-width: 42rem;
}
.board-row .btn-granny.btn-icon {
  min-width: 52px;
  min-height: 52px;
  font-size: 2rem;
  padding: 8px 12px;
}
.granny-bubble {
  max-width: 100%;
  background: #f8f9fa;
  color: #1f2937;
  border-radius: 8px;
  padding: 4px 5px;
  font-size: 0.6rem;
  line-height: 1.25;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
  margin-bottom: 1px;
}
.granny-emoji { font-size: 1.5rem; line-height: 1; }
.helper-portrait {
  display: block;
  width: 72px;
  height: 72px;
  max-width: none;
  max-height: none;
  object-fit: cover;
  object-position: center 16%;
  border-radius: 6px;
  user-select: none;
  image-rendering: auto;
  filter: contrast(1.08) saturate(1.08) brightness(1.04);
  border: 1px solid #333333;
}
#askTitoBtn,
#askTitaBtn {
  background-color: #E6E0AE;
  background: #E6E0AE;
  border: 1px solid #E6E0AE;
  color: #1f2937;
  min-width: 46px;
  min-height: 26px;
  font-size: 0.66rem;
  font-weight: 700;
  padding: 3px 7px;
}
.cp-help-btn { margin-top: 12px; }
.btn-help {
  font-size: 0.7rem;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--gold);
  color: #1f2937;
  border: none;
  cursor: pointer;
  font-weight: 600;
}
.hand-controls-top {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin: 2px 0;
  border: 2px solid var(--section-border);
  border-radius: 6px;
}
.hand-controls-sort {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin: 2px 0;
  border: 2px solid var(--section-border);
  border-radius: 6px;
}
.hand-controls-sort .sort-label {
  font-size: 18px;
  font-weight: 600;
  color: #FFFFFF;
  margin-right: 4px;
}
#game-content .hand-container {
  background-color: transparent;
  background: transparent;
}

/* Banter row above board: 40% Tito | 20% spacer | 40% Tita (legacy) */
.banter-row {
  display: grid;
  grid-template-columns: 2fr 1fr 2fr; /* 40% 20% 40% */
  gap: 6px;
  flex-shrink: 0;
  min-height: 2.2em;
  margin-bottom: 2px;
  align-items: center;
}
.banter-cell {
  font-size: 0.65rem;
  line-height: 1.2;
  color: var(--text-muted);
  font-style: italic;
  padding: 2px 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.banter-tito { text-align: left; }
.banter-spacer { min-width: 0; }
.banter-tita { text-align: right; }

.board-wrap { display: flex; flex-shrink: 0; min-height: 0; }

.board {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 8px;
  background: var(--panel-bg);
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  min-height: 0;
  justify-content: space-between;
}
.board .row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 0 0 auto;
}
.row-label { display: none; font-size: 0.7rem; font-weight: 600; color: var(--text-muted); text-align: center; }
.slots {
  display: flex;
  gap: 0;
  justify-content: center;
  min-height: 52px;
  flex-wrap: nowrap;
  border-radius: 6px;
  transition: background 0.15s;
}
.slots.drag-over { background: rgba(76, 181, 245, 0.15); }
.slot.drag-over { border-color: var(--accent); background: rgba(76, 181, 245, 0.15); }
.slot {
  width: 34px;
  height: 50px;
  margin-left: -28px;
  background-color: transparent;
  background-image: url("images/chinese-poker-card-slot-bg-v2.png?v=20260430a");
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
  border: 1px solid #333333;
  border-radius: 4px;
  background-clip: padding-box;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--text-muted);
  box-shadow: 0 1px 2px rgba(0,0,0,0.25);
  transition: border-color 0.2s, background 0.2s;
  flex-shrink: 0;
  position: relative;
  z-index: 0;
}
.slot.filled {
  margin-left: -14px;
  z-index: 1;
  background: var(--card-bg);
  border: 1.5px solid var(--card-border);
  box-shadow: 0 1px 2px rgba(0,0,0,0.25);
  font-size: 13px;
  cursor: grab;
  touch-action: none;
  -webkit-user-drag: element;
}
.slots > .slot:first-child { margin-left: 0; }
/* First empty slot after any filled: gap so blank drop zones sit to the right of placed cards (not filled slots) */
.slot.filled + .slot:not(.filled) { margin-left: 6px; }
.slot .card {
  justify-content: flex-start;
}
.slot .card-face,
#handRows .card-face {
  align-items: flex-start;
  justify-content: flex-start;
  text-align: left;
  padding: 3px 0 0 3px;
}
#handRows .card { justify-content: flex-start; }
.slot .card-rank { font-size: 18px; }
.slot .card-suit { font-size: 22px; }

.hand-container {
  flex-shrink: 0;
  padding: 8px;
  background: transparent;
  border: 2px solid var(--section-border);
  border-radius: 8px;
  margin: 0 6px 8px;
  min-height: max(72px, 12vh);
  position: relative;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.hand-container,
.hand-container .sort-label,
.hand-container .lock-status,
.hand-container .watching-watermark,
.hand-container .btn {
  color: #FFFFFF;
}
.hand-container.watching .hand-controls-top button,
.hand-container.watching .card { pointer-events: none; opacity: 0.6; }
.board-column:has(.hand-container.watching) .hand-controls-sort button { pointer-events: none; opacity: 0.6; }
.watching-watermark {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  pointer-events: none;
}
.hand-container.watching .watching-watermark { display: flex; }

#handRows {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 2px;
  justify-content: center;
  align-content: flex-start;
  min-height: 58px;
  box-sizing: border-box;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* While multi-selecting from the hand, fan cards slightly so neighbors stay tappable (phone). */
#handRows.cp-hand-pick-spread .card.cp-pick-active {
  z-index: 24;
  transform: scale(1.1);
}

@keyframes cp-pick-pulse {
  0%, 100% { transform: scale(1.12) rotate(-1.5deg); box-shadow: 0 0 0 2px rgba(76, 181, 245, 0.65); }
  50% { transform: scale(1.18) rotate(1.5deg); box-shadow: 0 0 12px 3px rgba(76, 181, 245, 0.45); }
}
@-webkit-keyframes cp-pick-pulse {
  0%, 100% { -webkit-transform: scale(1.12) rotate(-1.5deg); transform: scale(1.12) rotate(-1.5deg); box-shadow: 0 0 0 2px rgba(76, 181, 245, 0.65); }
  50% { -webkit-transform: scale(1.18) rotate(1.5deg); transform: scale(1.18) rotate(1.5deg); box-shadow: 0 0 12px 3px rgba(76, 181, 245, 0.45); }
}
@keyframes cp-row-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}
@-webkit-keyframes cp-row-shake {
  0%, 100% { -webkit-transform: translateX(0); transform: translateX(0); }
  25% { -webkit-transform: translateX(-3px); transform: translateX(-3px); }
  75% { -webkit-transform: translateX(3px); transform: translateX(3px); }
}
#handRows.cp-row-hint {
  -webkit-animation: cp-row-shake 0.35s ease-in-out infinite;
  animation: cp-row-shake 0.35s ease-in-out infinite;
  border-radius: 8px;
  outline: 2px dashed rgba(76, 181, 245, 0.5);
  outline-offset: 2px;
}
.board-row.cp-row-hint {
  -webkit-animation: none;
  animation: none;
}
.board-row.cp-row-hint .slots {
  outline: 2px dashed #2E8B57;
  border-radius: 6px;
}
#handRows .card.cp-pick-active,
.slots .slot.filled.cp-pick-active {
  -webkit-animation: none;
  animation: none;
  z-index: 10;
  position: relative;
  transform: scale(1.06);
  outline: 2px solid #00A86B;
  outline-offset: 1px;
  box-shadow: 0 0 0 2px rgba(0, 168, 107, 0.35);
}
@media (prefers-reduced-motion: reduce) {
  #handRows.cp-row-hint,
  .board-row.cp-row-hint {
    -webkit-animation: none;
    animation: none;
  }
  #handRows .card.cp-pick-active,
  .slots .slot.filled.cp-pick-active {
    -webkit-animation: none;
    animation: none;
    transform: scale(1.08);
    box-shadow: 0 0 0 2px rgba(76, 181, 245, 0.85);
  }
  #handRows.cp-hand-pick-spread .card.cp-pick-active {
    transform: scale(1.09);
  }
}

/* Hand controls: icon-only on mobile, compact */
.hand-controls-top, .hand-controls-bottom {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin: 4px 0;
}
.btn {
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
}
.btn-icon {
  padding: 6px 8px;
  min-width: 32px;
  font-size: 1rem;
  border-radius: 6px;
}
.btn-icon:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-sort { background: var(--accent-strong); color: white; }
.btn-sort:hover { background: #1f526d; }
.btn-reset { background: #b91c1c; color: white; padding: 6px 10px; }
.btn-reset:hover { background: #991b1b; }
.btn-granny { background: var(--gold); color: #1f2937; }
.btn-granny:hover { background: #d97706; }
.btn-granny:disabled { background: var(--text-muted); color: #adb5bd; }
.btn-confirm { background: var(--accent-strong); color: white; padding: 6px 12px; }
.btn-confirm:hover { background: #1f526d; }
.btn-confirm.lock-pop { animation: cp-lock-pop 0.6s ease-in-out; }
@keyframes cp-lock-pop {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(45, 106, 135, 0.4); }
  50% { transform: scale(1.08); box-shadow: 0 0 16px 6px rgba(45, 106, 135, 0.6); }
}
.lock-status { font-size: 0.75rem; min-height: 1.2em; margin-top: 2px; }

.hand-container.locked .card,
.hand-container.locked .slot.filled,
.hand-container.locked .combo { cursor: default; pointer-events: none; }
.hand-container.locked .slot:not(.filled) { pointer-events: none; }

.card {
  width: 34px;
  height: 50px;
  background: white;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: grab;
  user-select: none;
  touch-action: none;
  -webkit-user-drag: element;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  overflow: visible;
}
/* Let drag/pointer events hit the card root (not inner face), for trackpad/touch. */
#handRows .card > .card-face,
.slots .slot.filled > .card-face {
  pointer-events: none;
}
.card.red, .card.red .card-rank, .card.red .card-suit { color: var(--red-suit); }
.card.black, .card.black .card-rank, .card.black .card-suit { color: var(--black-suit); }
/* Board area only: make revealed card indices/suits fully saturated (not gray). */
.slots .slot.filled.red .card-face,
.slots .slot.filled.red .card-rank,
.slots .slot.filled.red .card-suit,
.slot.filled.red .card-face,
.slot.filled.red .card-rank,
.slot.filled.red .card-suit { color: #c1121f; }
.slots .slot.filled.black .card-face,
.slots .slot.filled.black .card-rank,
.slots .slot.filled.black .card-suit,
.slot.filled.black .card-face,
.slot.filled.black .card-rank,
.slot.filled.black .card-suit { color: #000000; }
.card:active { cursor: grabbing; }
.card-face { display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; padding: 1px; min-width: 1em; }
.card-rank { font-size: 18px; font-weight: 600; line-height: 1; }
.card-suit { font-size: 22px; line-height: 1; margin-top: 1px; }

.chat-section {
  display: none;
}

/* Readout — leave table (visible only while readout panel is shown) */
.readout-leave-row {
  margin: 1em 0 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  flex-shrink: 0;
}
.btn-leave-table {
  background: #4b5563;
  color: #f9fafb;
  border: 1px solid #374151;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn-leave-table:hover {
  background: #374151;
}
.readout-leave-msg {
  font-size: 0.85rem;
  color: #fca5a5;
  margin: 6px 0 0;
  width: 100%;
}
.readout-leave-msg.hidden {
  display: none !important;
}

/* Readout panel — scroll so footer controls aren’t clipped by #game-content { overflow: hidden } */
.readout-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 10px 8px 12px;
  text-align: center;
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.readout-panel h3 { margin-top: 0; margin-bottom: 8px; color: var(--text); }
/* Same border/radius/spacing as .hand-controls-top (Reset / Confirm row) */
.cp-waiting-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  max-width: 42rem;
  margin: 0 auto;
  padding: 18px 14px;
  box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  text-align: center;
}
.cp-waiting-banner h3 { margin: 0; color: #FFFFFF; }
.cp-waiting-banner p { margin: 0; color: rgba(255, 255, 255, 0.85); font-size: 0.9rem; }
.cp-waiting-banner.hidden { display: none !important; }
.readout-summary-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  max-width: 42rem;
  margin: 0;
  padding: 8px 10px;
  box-sizing: border-box;
  border: 2px solid var(--section-border);
  border-radius: 6px;
}
.readout-summary-box .readout-multiplayer-hint {
  margin: 0;
}
#readoutMultiHint {
  text-align: left;
  width: 100%;
}
.readout-summary-box .readout-points {
  margin: 0;
}
/* Readout on dark bg — summary strip matches hint tone (no solid panel) */
#game-content .readout-summary-box {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
}
#game-content .readout-summary-box h3 {
  color: #FFFFFF;
}
#game-content .readout-summary-box .readout-multiplayer-hint {
  color: rgba(255, 255, 255, 0.88);
}
#game-content .readout-summary-box .readout-points {
  color: #FFFFFF;
}
.readout-points { font-size: 1.25rem; color: #1A1A1A; font-weight: bold; }
.readout-hint { font-size: 0.85rem; color: var(--text-muted); margin: 6px 0 10px; }
.readout-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.readout-step-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  min-width: 8rem;
  text-align: center;
}
.btn-readout-step {
  min-width: 40px;
  padding: 6px 10px;
  font-size: 1rem;
  border-radius: 8px;
}
.readout-compare {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 6px;
  background: transparent;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  max-width: 100%;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  /* Avoid stray horizontal scrollbar under hand controls on narrow layouts */
  overflow-x: hidden;
  overflow-y: visible;
}
.readout-compare.hidden { display: none; }

.readout-vs-detail {
  margin: 0;
  padding: 0 10px 8px;
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--text-muted);
  text-align: center;
  max-width: 100%;
}
.readout-vs-detail.hidden { display: none !important; }

.cp-readout-rules-wrap {
  margin-top: 10px;
  text-align: left;
}
.readout-rules-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #FFFFFF;
  cursor: pointer;
  user-select: none;
}
.readout-rules-toggle-label input { width: 16px; height: 16px; accent-color: #2E8B57; cursor: pointer; }
.readout-rules-glossary-panel {
  margin-top: 10px;
  padding: 10px 12px;
  background: #F8F9FA;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  font-size: 11px;
  line-height: 1.45;
  color: #1A1A1A;
  text-align: left;
}
.readout-rules-glossary-panel p { margin: 0 0 6px; }
.readout-rules-glossary-panel p + ul { margin-top: 4px; }
.readout-rules-glossary-panel a {
  color: #0b57d0;
  font-weight: 600;
  text-decoration: underline;
}
.readout-rules-glossary-panel ul { margin: 0 0 8px 1rem; padding: 0; }
.readout-rules-glossary-panel li { margin: 3px 0; }
.readout-rules-glossary-panel .readout-glossary-dl { margin-top: 10px; padding-top: 10px; border-top: 1px dashed #ced4da; }
.readout-rules-glossary-panel .readout-glossary-dl dt { font-weight: 700; margin-top: 8px; color: #1A1A1A; }
.readout-rules-glossary-panel .readout-glossary-dl dd { margin: 2px 0 0 0.75rem; color: #1A1A1A; font-size: inherit; }

.readout-special-compare {
  width: 100%;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px 10px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #1A1A1A;
  background: #F5F0E6;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 10px;
  box-sizing: border-box;
}
.readout-compare,
.readout-compare .compare-label {
  color: #FFFFFF;
}

.btn-lock-special {
  margin-left: 8px;
  background: linear-gradient(180deg, #fcd34d 0%, #f59e0b 100%);
  color: #1f2937;
  font-weight: 700;
  border: 1px solid #d97706;
}
.btn-lock-special:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.compare-column {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 24px;
  min-width: 0;
  flex: 1 1 0;
  max-width: 50%;
}
.compare-label {
  font-weight: 700;
  color: #1A1A1A;
  font-size: 0.9rem;
  margin-bottom: 0;
}
.compare-rows { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; width: 100%; min-width: 0; }
.compare-row { display: flex; gap: 0; flex-wrap: nowrap; justify-content: flex-start; align-items: center; min-height: 32px; transition: opacity 0.2s ease; }
.compare-row.compare-row-dim {
  opacity: 0.42;
  filter: grayscale(0.35);
}
.compare-row .mini-card {
  width: 34px;
  height: 44px;
  font-size: 10px;
  border-radius: 5px;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  flex-direction: column;
  background: white;
  box-shadow: 0 1px 2px rgba(0,0,0,0.25);
  flex-shrink: 0;
  line-height: 1.1;
  margin-left: -14px;
  padding: 2px 0 0 3px;
  text-align: left;
}
.compare-row .mini-card:first-child { margin-left: 0; }
.compare-row .mini-card .card-rank { font-weight: 700; font-size: 14px; line-height: 1; }
.compare-row .mini-card .card-suit { font-size: 16px; line-height: 1; }
.compare-row .mini-card.red, .compare-row .mini-card.red .card-rank, .compare-row .mini-card.red .card-suit { color: var(--red-suit); }
.compare-row .mini-card.black, .compare-row .mini-card.black .card-rank, .compare-row .mini-card.black .card-suit { color: var(--black-suit); }
.avatar .ai-badge { font-size: 8px; color: var(--accent); margin-top: 1px; }

/* Modals */
#confirmModal, #playerZoomModal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
#playerZoomModal { z-index: 2000; flex-direction: column; gap: 16px; }
#playerZoomModal[style*="flex"] { display: flex !important; }
.player-zoom-avatar { width: 120px; height: 120px; border-radius: 50%; border: 3px solid var(--accent); overflow: hidden; }
.player-zoom-avatar img { width: 100%; height: 100%; object-fit: cover; }
.player-zoom-chips { color: var(--gold); font-size: 1.5rem; font-weight: bold; }
.modal-content {
  background: var(--panel-bg);
  padding: 20px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  max-width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  color: var(--text);
}
.modal-close { float: right; font-size: 1.5rem; cursor: pointer; color: #d1fae5; }
.player-zoom-content { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.btn-back { background: #4b5563; color: #e5e7eb; padding: 8px 16px; border: none; border-radius: 8px; cursor: pointer; font-size: 0.9rem; font-weight: 600; }
.btn-back:hover { background: #374151; }

/* Hide hand cards during fly-in from top-right */
#handRows.cp-fly-in-hide .card { opacity: 0; pointer-events: none; }
/* Hide filled slots during Tito/Tita fly-to-slots */
.board-area.cp-fly-to-slots-hide .slot.filled { visibility: hidden; }

/* ========== 0–480: snap to 320px wide (game play only) ========== */
@media screen and (max-device-width: 480px) and (orientation: portrait),
       screen and (max-width: 480px) {
  body:has(#game-content:not(.hidden)) {
    width: 320px;
    min-width: 320px;
    max-width: 320px;
    height: 640px;
    min-height: 640px;
    max-height: 640px;
    margin: 0 auto;
    overflow: hidden;
  }

  #game-content {
    width: 100%;
    flex: 1;
    min-height: 0;
    max-height: 100%;
  }

  .cp-header-row { padding: 4px 6px; }
  .header-profile { width: 24px; height: 24px; }
  .header-chips { font-size: 0.75rem; }
  .timer-wrap { padding: 2px 3px; font-size: 0.8rem; }

  .cp-ad-banner { min-height: 22px; font-size: 0.6rem; }

  .opponents {
    max-height: 52px;
    padding: 3px 6px;
    gap: 3px 4px;
  }
  .avatar-wrap { min-width: 32px; }
  .avatar { width: 25px; height: 25px; }
  .avatar-wrap .score-vs { font-size: 9px; min-width: 22px; padding: 1px 4px; }

  .main-content { padding: 4px 6px; }
  .board-area { padding: 4px 6px; margin: 1px 0; }
  .board-row { gap: 3px; padding: 1px 0; }
  .helper-portrait {
    display: block;
    width: 50px;
    height: 50px;
  }
  .board-row .btn-granny.btn-icon {
    min-width: 44px;
    min-height: 44px;
    font-size: 1.5rem;
    padding: 4px 8px;
  }
  .slots { min-height: 66px; }
  .slot { width: 50px; height: 66px; margin-left: -43px; }
  .slot.filled { margin-left: -14px; }
  .slot .card { width: 50px; height: 66px; }
  .slot .card-rank { font-size: 24px; }
  .slot .card-suit { font-size: 24px; }
  .slot .card-face,
  #handRows .card-face {
    align-items: flex-start;
    justify-content: flex-start;
    text-align: left;
    padding: 3px 0 0 0;
  }
  /* Hand: narrower than board so 7+ cards fit one row in ~288px (320 − margins/padding) */
  #handRows .card {
    width: 44px;
    height: 66px;
    margin-left: -16px;
  }
  #handRows.cp-hand-pick-spread .card {
    margin-left: -7px;
  }
  #handRows .card:first-child { margin-left: 0; }
  #handRows.cp-hand-pick-spread .card:first-child { margin-left: 0; }
  #handRows .card-rank { font-size: 24px; }
  #handRows .card-suit { font-size: 24px; }
  #handRows .card-face { padding: 2px 0 0 2px; }

  .hand-container {
    padding: 4px 6px;
    margin: 0 6px 4px;
    min-height: 56px;
  }
  .hand-controls-top {
    margin: 2px 0;
    gap: 4px;
    padding: 2px 0;
  }
  .hand-controls-sort {
    margin: 2px 0 0;
    padding: 3px 4px;
    gap: 4px;
    flex-shrink: 0;
  }
  .hand-controls-sort .sort-label {
    font-size: 0.7rem;
    margin-right: 2px;
  }
  .hand-controls-sort .btn-sort {
    min-width: 34px;
    padding: 3px 5px;
    font-size: 0.8rem;
  }
  .hand-controls-bottom { margin: 2px 0; gap: 4px; }
  .btn-icon { min-width: 28px; padding: 4px 6px; font-size: 0.9rem; }
  .btn-reset, .btn-confirm { padding: 4px 8px; font-size: 0.7rem; }
  #handRows { gap: 2px; min-height: 50px; }

  .chat-section { min-height: 22px; padding: 2px 6px; font-size: 0.6rem; }

  .readout-panel { padding: 4px 4px 6px; }
  .readout-panel h3 { margin-bottom: 4px; font-size: 1.05rem; }
  .readout-summary-box {
    margin: 0;
    padding: 6px 8px;
  }
  .readout-leave-row {
    margin: 0;
  }
  .readout-vs-detail {
    margin: 0;
    padding: 0 8px 6px;
  }
  .readout-points { font-size: 1.12rem; }
  .readout-hint { margin: 4px 0 6px; font-size: 0.8rem; }
  .readout-stepper { margin-bottom: 4px; gap: 8px; }
  /* Compare: ~match hand/board card scale; overlap so 5 cards fit ~half of 320px column */
  .readout-compare {
    padding: 8px 4px;
    gap: 4px;
    margin-top: 4px;
    border-radius: 8px;
    overflow-x: hidden;
  }
  .compare-column { gap: 8px; }
  .compare-label { font-size: 0.88rem; }
  .compare-rows { gap: 5px; width: 100%; }
  .compare-row {
    min-height: 60px;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }
  .compare-row .mini-card {
    width: 35px;
    height: 60px;
    margin-left: -6px;
    padding: 4px 0 0 4px;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.22);
  }
  .compare-row .mini-card:first-child { margin-left: 0; }
  .compare-row .mini-card .card-rank { font-size: 21px; }
  .compare-row .mini-card .card-suit { font-size: 22px; }
}

/* ========== 481–1040: snap to 480px wide × 900px high (game play only) ========== */
@media (min-width: 481px) and (max-width: 1040px) {
  body:has(#game-content:not(.hidden)) {
    justify-content: flex-start;
    align-items: center;
    overflow-y: auto;
    overflow-x: hidden;
    zoom: calc(100vw / 480);
  }
  body:has(#join-queue-screen:not(.hidden)) {
    zoom: 1;
    justify-content: flex-start;
    align-items: stretch;
  }
  #game-content {
    width: 480px;
    min-height: 900px;
    height: 900px;
    max-height: 900px;
    margin: 0 auto;
    flex: 0 0 auto;
    box-shadow: 0 0 0 3px var(--section-border);
  }
  .cp-header-row { padding: 6px 10px; gap: 6px; }
  .header-profile { width: 32px; height: 32px; }
  .header-identity { font-size: 0.85rem; }
  .header-chips { font-size: 0.9rem; }
  .timer-wrap { padding: 5px 5px; font-size: 0.9rem; border-radius: 10px; }
  .timer-wrap .timer-icon { font-size: 1rem; }
  .cp-ad-banner { min-height: 32px; font-size: 0.75rem; }
  .opponents {
    padding: 6px 8px;
    gap: 5px 8px;
    max-height: 100px;
  }
  .avatar-wrap { min-width: 44px; }
  .avatar { width: 40px; height: 40px; border-width: 2px; }
  .main-content { padding: 6px 8px; }
  .board-area { padding: 5px; margin: 4px 0; border-radius: 8px; }
  .board-row { gap: 4px; padding: 2px 0; }
  .slots { min-height: 75px; gap: 0; }
  .slot { width: 55px; height: 73px; margin-left: -46px; border-width: 2px; }
  .slot.filled { margin-left: -15px; }
  .slots > .slot:first-child { margin-left: 0; }
  .slot .card { width: 55px; height: 73px; border-radius: 4px; padding: 4px 0 0 4px; }
  .slot .card-rank { font-size: 22px; }
  .slot .card-suit { font-size: 26px; }
  .hand-controls-top,
  .hand-controls-sort {
    padding: 6px; margin: 4px 0; border-radius: 8px;
  }
  .hand-controls-top .btn,
  .hand-controls-sort .btn {
    font-size: 0.95rem;
    min-width: 88px;
    min-height: 40px;
    padding: 6px 12px;
    border-radius: 8px;
  }
  .hand-controls-top { gap: 8px; }
  .hand-controls-sort { gap: 8px; }
  .hand-controls-sort .sort-label { font-size: 0.95rem; margin-right: 5px; }
  .hand-container { padding: 8px; margin: 0 6px 8px; border-radius: 8px; }
  #handRows .card {
    width: 55px;
    height: 73px;
    margin-left: -15px;
    border-width: 2px;
    border-radius: 4px;
  }
  #handRows.cp-hand-pick-spread .card {
    margin-left: -7px;
  }
  #handRows .card:first-child { margin-left: 0; }
  #handRows.cp-hand-pick-spread .card:first-child { margin-left: 0; }
  #handRows .card-rank { font-size: 22px; }
  #handRows .card-suit { font-size: 26px; }
  #handRows .card-face { padding: 4px 0 0 4px; }

  /* Readout hand comparison — scale with mid layout (board/hand use ~55×73 cards) */
  .readout-panel { padding: 10px 8px 12px; }
  .readout-panel h3 { font-size: 1.05rem; margin-bottom: 6px; }
  .readout-points { font-size: 1.1rem; }
  .readout-hint { font-size: 0.8rem; margin: 6px 0 8px; }
  .readout-stepper { margin-bottom: 6px; }
  .readout-compare {
    padding: 8px 8px;
    gap: 10px;
    margin-top: 8px;
  }
  .compare-column { gap: 8px; min-width: 0; }
  .compare-label { font-size: 0.95rem; }
  .compare-rows { gap: 4px; }
  .compare-row { min-height: 38px; }
  .compare-row .mini-card {
    width: 46px;
    height: 60px;
    margin-left: -20px;
    padding: 4px 0 0 4px;
    border-radius: 6px;
  }
  .compare-row .mini-card .card-rank { font-size: 18px; }
  .compare-row .mini-card .card-suit { font-size: 22px; }
  /* Tito/Tita suggestion bubbles — larger on mid tier (smallest tier keeps base 0.6rem) */
  .granny-bubble {
    font-size: 0.85rem;
    line-height: 1.35;
    padding: 6px 8px;
  }
  .granny-emoji { font-size: 1.65rem; }
}

/* ========== 1041px+: autoscale (fluid), +30% font ========== */
@media (min-width: 1041px) {
  body:has(#game-content:not(.hidden)) {
    justify-content: flex-start;
    align-items: center;
    overflow-y: auto;
  }
  body:has(#join-queue-screen:not(.hidden)) {
    align-items: stretch;
  }
  #join-queue-screen:not(.hidden) {
    width: 100%;
    max-width: none;
    align-self: stretch;
  }
  #join-queue-screen:not(.hidden) > .site-banner {
    align-self: stretch;
    width: 100%;
    max-width: none;
  }
  #game-content {
    width: min(96%, 1200px);
    max-width: 1200px;
    min-height: 90vh;
    margin: 0 auto;
    flex: 0 0 auto;
  }
  .cp-header-row {
    padding: clamp(6px, 1vw, 12px) clamp(10px, 1.6vw, 20px);
    gap: clamp(5px, 0.8vw, 10px);
  }
  .header-profile {
    width: clamp(32px, 4vw, 56px);
    height: clamp(32px, 4vw, 56px);
  }
  .header-identity { font-size: clamp(1.1rem, 1.43vw, 1.43rem); }
  .header-chips { font-size: clamp(1.17rem, 1.56vw, 1.63rem); }
  .timer-wrap {
    padding: clamp(5px, 0.7vw, 10px) clamp(4px, 0.6vw, 7px);
    font-size: clamp(1.1rem, 1.43vw, 1.56rem);
  }
  .cp-ad-banner {
    min-height: clamp(28px, 3.5vh, 50px);
    font-size: clamp(0.91rem, 1.17vw, 1.24rem);
  }
  #opponentsRow {
    padding: clamp(6px, 0.8vw, 10px) clamp(8px, 1.2vw, 16px);
    gap: clamp(5px, 0.8vw, 10px);
    max-height: clamp(80px, 12vh, 180px);
  }
  .avatar-wrap { min-width: clamp(40px, 5vw, 64px); }
  .avatar {
    width: clamp(40px, 5vw, 64px);
    height: clamp(40px, 5vw, 64px);
  }
  .main-content { padding: clamp(6px, 1vw, 12px); }
  .board-area {
    padding: clamp(5px, 1vw, 12px);
    margin: clamp(3px, 0.6vw, 8px) 0;
    border-radius: clamp(8px, 1vw, 14px);
  }
  .board-row {
    gap: clamp(3px, 0.5vw, 8px);
    padding: clamp(1px, 0.3vw, 4px) 0;
  }
  .slots { min-height: clamp(70px, 8.8vh, 132px); gap: 0; }
  .slot {
    width: clamp(57px, 7.2vw, 106px);
    height: clamp(77px, 9.4vw, 141px);
    margin-left: clamp(-50px, -6vw, -85px);
  }
  .slot.filled { margin-left: clamp(-20px, -2.4vw, -35px); }
  .slots > .slot:first-child { margin-left: 0; }
  .slot .card {
    width: clamp(57px, 7.2vw, 106px);
    height: clamp(77px, 9.4vw, 141px);
    border-radius: 6px;
  }
  .slot .card-rank { font-size: clamp(26px, 3.1vw, 52px); }
  .slot .card-suit { font-size: clamp(31px, 3.9vw, 62px); }
  .slot .card-face { padding: clamp(3px, 0.5vw, 8px) 0 0 clamp(3px, 0.5vw, 8px); }
  .banter-cell { font-size: clamp(0.91rem, 1.1vw, 1.3rem); }
  .hand-controls-top,
  .hand-controls-sort {
    padding: clamp(6px, 0.8vw, 10px);
    margin: clamp(4px, 0.6vw, 8px) 0;
    border-radius: clamp(6px, 0.8vw, 12px);
  }
  .hand-controls-top .btn,
  .hand-controls-sort .btn {
    font-size: clamp(1.3rem, 1.56vw, 1.82rem);
    min-width: clamp(100px, 12vw, 180px);
    min-height: clamp(44px, 5vw, 72px);
    padding: clamp(6px, 0.8vw, 12px) clamp(12px, 1.6vw, 28px);
  }
  .hand-controls-top { gap: clamp(6px, 1vw, 16px); }
  .hand-controls-sort { gap: clamp(6px, 1vw, 16px); }
  .hand-controls-sort .sort-label {
    font-size: clamp(1.3rem, 1.56vw, 1.82rem);
    margin-right: clamp(3px, 0.5vw, 10px);
  }
  .hand-container {
    padding: clamp(8px, 1vw, 14px);
    margin: 0 clamp(6px, 0.8vw, 12px) clamp(8px, 1vw, 16px);
    border-radius: clamp(8px, 1vw, 12px);
  }
  #handRows .card {
    width: clamp(57px, 7.2vw, 106px);
    height: clamp(77px, 9.4vw, 141px);
    margin-left: clamp(-20px, -2.4vw, -35px);
    border-radius: 6px;
  }
  #handRows.cp-hand-pick-spread .card {
    margin-left: clamp(-10px, -1.2vw, -7px);
  }
  #handRows .card:first-child { margin-left: 0; }
  #handRows.cp-hand-pick-spread .card:first-child { margin-left: 0; }
  #handRows .card-rank { font-size: clamp(26px, 3.1vw, 52px); }
  #handRows .card-suit { font-size: clamp(31px, 3.9vw, 62px); }
  #handRows .card-face { padding: clamp(3px, 0.5vw, 8px) 0 0 clamp(3px, 0.5vw, 8px); }
  .lock-status { font-size: clamp(0.98rem, 1.2vw, 1.3rem); }
  .chat-section { font-size: clamp(0.91rem, 1.17vw, 1.24rem); }

  /* Readout compare — scale with large layout (same spirit as board / hand cards) */
  .readout-panel {
    padding: clamp(8px, 1vw, 20px) clamp(8px, 1vw, 18px) clamp(10px, 1.2vw, 22px);
  }
  .readout-panel h3 {
    font-size: clamp(1.05rem, 1.3vw, 1.5rem);
    margin-bottom: clamp(6px, 0.7vw, 12px);
  }
  .readout-points {
    font-size: clamp(1.15rem, 1.5vw, 1.75rem);
  }
  .readout-hint {
    font-size: clamp(0.85rem, 1.05vw, 1.1rem);
    margin: clamp(4px, 0.5vw, 10px) 0 clamp(6px, 0.8vw, 14px);
  }
  .readout-stepper {
    margin-bottom: clamp(4px, 0.6vw, 12px);
  }
  .readout-compare {
    padding: clamp(6px, 0.8vw, 14px) clamp(6px, 0.9vw, 16px);
    gap: clamp(8px, 1.2vw, 24px);
    margin-top: clamp(6px, 0.8vw, 16px);
    border-radius: clamp(10px, 1vw, 16px);
  }
  .compare-column {
    gap: clamp(8px, 1vw, 14px);
    min-width: 0;
    max-width: 50%;
  }
  .compare-label {
    font-size: clamp(0.9rem, 1.1vw, 1.25rem);
  }
  .compare-rows {
    gap: clamp(3px, 0.5vw, 8px);
  }
  .compare-row {
    min-height: clamp(34px, 4vw, 56px);
  }
  .compare-row .mini-card {
    width: clamp(42px, 5.2vw, 84px);
    height: clamp(54px, 6.6vw, 108px);
    margin-left: clamp(-18px, -2.2vw, -36px);
    padding: clamp(3px, 0.45vw, 8px) 0 0 clamp(4px, 0.55vw, 10px);
    border-radius: clamp(5px, 0.55vw, 10px);
  }
  .compare-row .mini-card .card-rank {
    font-size: clamp(16px, 2vw, 38px);
  }
  .compare-row .mini-card .card-suit {
    font-size: clamp(20px, 2.45vw, 46px);
  }
  .granny-emoji {
    font-size: clamp(1.5rem, 2.2vw, 2.75rem);
  }
  /* Tito/Tita suggestion bubbles — scale with large layout */
  .granny-bubble {
    font-size: clamp(0.85rem, 1.12vw, 1.25rem);
    line-height: 1.35;
    padding: clamp(6px, 0.75vw, 10px) clamp(8px, 1vw, 14px);
  }
}
