/* ── Variables ────────────────────────────────────────────────────── */
:root {
  --bg:           #0b0c18;
  --surface:      #131425;
  --surface2:     #1a1b30;
  --border:       #252640;
  --border2:      #2e2f52;
  --red:          #e63950;
  --red-glow:     rgba(230, 57, 80, 0.45);
  --yellow:       #f5c518;
  --yellow-glow:  rgba(245, 197, 24, 0.45);
  --purple:       #7c3aed;
  --purple2:      #a855f7;
  --text:         #e8e9f5;
  --muted:        #7778a0;
  --cell-empty:   #0e0f1f;
  --board-bg:     #0d1340;
  --board-border: #1a2a80;
  --radius:       14px;
}

/* ── Light theme ──────────────────────────────────────────────────── */
body.light {
  --bg:           #eef0f7;
  --surface:      #ffffff;
  --surface2:     #f4f5fb;
  --border:       #dde0ef;
  --border2:      #c8cce0;
  --red:          #d42e45;
  --red-glow:     rgba(212, 46, 69, 0.35);
  --yellow:       #c8900a;
  --yellow-glow:  rgba(200, 144, 10, 0.35);
  --purple:       #6d28d9;
  --purple2:      #7c3aed;
  --text:         #1a1b2e;
  --muted:        #6b6d8e;
  --cell-empty:   #dde0ef;
  --board-bg:     #1e2d6b;
  --board-border: #2a4099;
}

body.light {
  background-image:
    radial-gradient(circle at 20% 20%, rgba(109,40,217,0.06) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(212,46,69,0.04) 0%, transparent 50%);
}

/* ── Theme toggle button — lobby only ────────────────────────────── */
/* Hide when any non-lobby screen is active (CSS general sibling) */
#screen-waiting.active ~ #theme-toggle,
#screen-join.active    ~ #theme-toggle,
#screen-game.active    ~ #theme-toggle { display: none !important; }

#theme-toggle {
  position: fixed;
  top: 0.9rem;
  right: 0.9rem;
  z-index: 500;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border2);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
#theme-toggle:hover { background: var(--border); transform: scale(1.1); }

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

/* Lock the root so the iOS address bar can never toggle and shift the
   viewport — the primary cause of the zoom-in/zoom-out on mobile. */
html {
  height: 100%;
  overflow: hidden;
  position: fixed;
  width: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  width: 100%;
  height: 100%;
  overflow: hidden;
  /* subtle grid pattern */
  background-image:
    radial-gradient(circle at 20% 20%, rgba(124,58,237,0.06) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(230,57,80,0.05) 0%, transparent 50%);
}

.hidden { display: none !important; }

/* ── Screens ──────────────────────────────────────────────────────── */
/* Each screen is its own scroll container so content can still scroll
   on small viewports without the document-level scroll triggering
   address-bar toggling. */
.screen {
  display: none;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.screen.active { display: flex; }

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.4rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.975rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
  width: 100%;
  text-decoration: none;
}
.btn:active { transform: scale(0.97) !important; }

.btn.primary {
  background: linear-gradient(135deg, var(--purple), var(--purple2));
  color: #fff;
  box-shadow: 0 4px 20px rgba(124,58,237,0.3);
}
.btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(124,58,237,0.45);
}

.btn.secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border2);
}
.btn.secondary:hover {
  background: var(--border);
  border-color: var(--purple2);
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn.ghost:hover { color: var(--text); border-color: var(--border2); }

.btn.danger {
  background: rgba(230,57,80,0.12);
  color: var(--red);
  border: 1px solid rgba(230,57,80,0.3);
}
.btn.danger:hover { background: rgba(230,57,80,0.22); }

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

/* ── Inputs ───────────────────────────────────────────────────────── */
input[type="text"] {
  width: 100%;
  padding: 0.85rem 1.1rem;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input[type="text"]:focus {
  border-color: var(--purple2);
  box-shadow: 0 0 0 3px rgba(168,85,247,0.15);
}
input[type="text"]::placeholder { color: var(--muted); }

/* ─────────────────────────────────────────────────────────────────── */
/*  LOBBY                                                              */
/* ─────────────────────────────────────────────────────────────────── */
.lobby-card {
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 0.4rem;
}
.logo h1 {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.logo-disc {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
}
.logo-disc.red    { background: var(--red);    box-shadow: 0 0 18px var(--red-glow); }
.logo-disc.yellow { background: var(--yellow); box-shadow: 0 0 18px var(--yellow-glow); }

.tagline {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 2.2rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.field { margin-bottom: 1.5rem; }

.time-config {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
  text-align: left;
}
.time-config-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 0.6rem;
}
.time-opts {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.time-opt {
  flex: 1;
  min-width: 60px;
  padding: 0.45rem 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.time-opt:hover { color: var(--text); border-color: var(--purple2); }
.time-opt.active {
  background: rgba(124,58,237,0.2);
  border-color: var(--purple2);
  color: var(--purple2);
}

.history-link {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  justify-content: center;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
  transition: color 0.15s;
}
.history-link:hover { color: var(--text); }

.lobby-actions { display: flex; flex-direction: column; gap: 0.75rem; }

.bot-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.btn.bot-btn {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
  font-size: 0.9rem;
}
.btn.bot-btn:hover {
  background: rgba(16, 185, 129, 0.22);
  border-color: #10b981;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(16,185,129,0.2);
}

.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.8rem;
  margin: 0.1rem 0;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ─────────────────────────────────────────────────────────────────── */
/*  WAITING                                                            */
/* ─────────────────────────────────────────────────────────────────── */
.waiting-card {
  text-align: center;
  max-width: 380px;
  width: 100%;
}

.spinner-ring {
  width: 60px;
  height: 60px;
  border: 4px solid var(--border2);
  border-top-color: var(--purple2);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  margin: 0 auto 1.75rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

.waiting-card h2 { margin-bottom: 0.45rem; font-size: 1.4rem; }
.waiting-card p  { color: var(--muted); margin-bottom: 1.75rem; }

.room-code-box {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 1.2rem;
  margin-bottom: 1.5rem;
}
.room-code-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.code-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}
#room-code-value {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: 0.35em;
  color: var(--purple2);
  font-family: 'Courier New', monospace;
}
.btn-copy {
  background: var(--purple);
  color: #fff;
  border: none;
  padding: 0.4rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: background 0.15s;
  flex-shrink: 0;
}
.btn-copy:hover { background: var(--purple2); }

/* ─────────────────────────────────────────────────────────────────── */
/*  JOIN                                                               */
/* ─────────────────────────────────────────────────────────────────── */
.join-card {
  text-align: center;
  max-width: 360px;
  width: 100%;
}
.join-card h2 { margin-bottom: 0.4rem; }
.join-sub { color: var(--muted); font-size: 0.875rem; margin-bottom: 1.5rem; }

#input-code {
  text-align: center;
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  font-family: 'Courier New', monospace;
  margin-bottom: 0.75rem;
  padding: 1rem;
}

.error-msg { color: var(--red); font-size: 0.875rem; margin-bottom: 0.75rem; min-height: 1.2em; }

.join-buttons { display: flex; flex-direction: column; gap: 0.65rem; }

/* ─────────────────────────────────────────────────────────────────── */
/*  GAME                                                               */
/* ─────────────────────────────────────────────────────────────────── */
.game-layout {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  max-width: 920px;
  width: 100%;
}

.game-main { flex: 1; min-width: 0; }

/* Score bar */
.scorebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 1.25rem;
  margin-bottom: 1rem;
}
.player-tag {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  font-weight: 600;
  font-size: 0.95rem;
}
.ptag-inner {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.player-tag.right .ptag-inner { flex-direction: row-reverse; }

.turn-arrow {
  font-size: 0.6rem;
  line-height: 1;
  height: 10px;
  visibility: hidden;
  animation: arrow-bob 0.9s ease-in-out infinite;
}
.turn-arrow.red    { color: var(--red); }
.turn-arrow.yellow { color: var(--yellow); }
.player-tag.active-turn .turn-arrow { visibility: visible; }
@keyframes arrow-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(3px); }
}

.ptag-disc {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: transform 0.3s, box-shadow 0.3s;
}
.ptag-disc.red    { background: var(--red); }
.ptag-disc.yellow { background: var(--yellow); }

.player-tag.active-turn .ptag-disc.red {
  box-shadow: 0 0 10px var(--red-glow);
  animation: pulse-disc 1.2s ease-in-out infinite;
}
.player-tag.active-turn .ptag-disc.yellow {
  box-shadow: 0 0 10px var(--yellow-glow);
  animation: pulse-disc 1.2s ease-in-out infinite;
}
@keyframes pulse-disc {
  0%,100% { transform: scale(1); }
  50%      { transform: scale(1.35); }
}

.score-badge {
  font-size: 0.8rem;
  font-weight: 800;
  min-width: 24px;
  height: 24px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  transition: transform 0.25s, box-shadow 0.25s;
}
.score-badge.red {
  background: rgba(230, 57, 80, 0.15);
  color: var(--red);
  border: 1px solid rgba(230, 57, 80, 0.3);
}
.score-badge.yellow {
  background: rgba(245, 197, 24, 0.12);
  color: var(--yellow);
  border: 1px solid rgba(245, 197, 24, 0.3);
}
.score-badge.bump {
  animation: score-bump 0.4s cubic-bezier(.175,.885,.32,1.275);
}
@keyframes score-bump {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.5); }
  100% { transform: scale(1); }
}

/* Resign button */
.btn-resign {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--muted);
  border-radius: 8px;
  padding: 0.25rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  white-space: nowrap;
}
.btn-resign:hover {
  color: var(--red);
  border-color: rgba(230,57,80,0.5);
  background: rgba(230,57,80,0.07);
}

/* Last-played cell ring */
.cell.last-played {
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.5),
              0 0 0 3px rgba(255,255,255,0.75);
}

/* Timer bar */
.timer-bar {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.65rem;
  gap: 0.5rem;
}
.ptimer {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 1rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  transition: all 0.25s;
  background: var(--surface);
  color: var(--muted);
}
.ptimer.red    { --timer-color: var(--red);    --timer-glow: var(--red-glow); }
.ptimer.yellow { --timer-color: var(--yellow); --timer-glow: var(--yellow-glow); }

.ptimer.active {
  color: var(--timer-color);
  border-color: var(--timer-color);
  background: rgba(var(--timer-color), 0.08);
  box-shadow: 0 0 10px var(--timer-glow);
}
.ptimer.low {
  animation: timer-warn 0.7s ease-in-out infinite alternate;
}
@keyframes timer-warn {
  from { opacity: 1; }
  to   { opacity: 0.55; }
}
.ptimer.out {
  color: var(--red);
  border-color: var(--red);
}

/* Board shell */
.board-shell {
  background: var(--board-bg);
  border: 3px solid var(--board-border);
  border-radius: 18px;
  padding: 14px 14px 10px;
  box-shadow: 0 20px 60px rgba(0,0,10,0.6), inset 0 1px 0 rgba(255,255,255,0.04);
}

.board {
  display: flex;
  gap: 8px;
}

.board-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-radius: 10px;
  padding: 4px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s;
  flex: 1;
}
.board-col:hover { background: rgba(255,255,255,0.04); }

/* Drop hint arrow */
.col-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 18px;
  opacity: 0;
  transition: opacity 0.12s;
}
.board-col:hover .col-hint { opacity: 1; }
.col-hint-arrow {
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 9px solid var(--muted);
  transition: border-top-color 0.1s;
}
.board-col.my-turn:hover .col-hint-arrow.is-red    { border-top-color: var(--red); }
.board-col.my-turn:hover .col-hint-arrow.is-yellow { border-top-color: var(--yellow); }

/* Cells */
.cell {
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--cell-empty);
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.5);
  transition: background 0.08s;
  position: relative;
}

.cell.p1 {
  background: radial-gradient(circle at 35% 30%, #ff6b7d, var(--red) 55%, #a0001a);
  box-shadow: 0 0 14px var(--red-glow), inset 0 2px 4px rgba(255,255,255,0.2);
  animation: pop-in 0.22s cubic-bezier(.175,.885,.32,1.275) both;
}
.cell.p2 {
  background: radial-gradient(circle at 35% 30%, #ffe566, var(--yellow) 55%, #9a7800);
  box-shadow: 0 0 14px var(--yellow-glow), inset 0 2px 4px rgba(255,255,255,0.25);
  animation: pop-in 0.22s cubic-bezier(.175,.885,.32,1.275) both;
}

@keyframes pop-in {
  from { transform: scale(0.35); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.cell.winning {
  animation: win-pulse 0.55s ease-in-out infinite alternate !important;
}
.cell.p1.winning { box-shadow: 0 0 22px var(--red),    0 0 44px var(--red-glow) !important; }
.cell.p2.winning { box-shadow: 0 0 22px var(--yellow), 0 0 44px var(--yellow-glow) !important; }

@keyframes win-pulse {
  from { transform: scale(0.93); }
  to   { transform: scale(1.07); }
}

/* ─────────────────────────────────────────────────────────────────── */
/*  CHAT                                                               */
/* ─────────────────────────────────────────────────────────────────── */
.chat-panel {
  width: 240px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  height: 490px;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

.chat-msg { font-size: 0.85rem; line-height: 1.45; word-break: break-word; }
.chat-msg .sender { font-weight: 700; margin-right: 0.3rem; }
.chat-msg.p1 .sender { color: var(--red); }
.chat-msg.p2 .sender { color: var(--yellow); }
.chat-msg.system { color: var(--muted); font-style: italic; font-size: 0.78rem; text-align: center; }

.chat-input-row {
  display: flex;
  gap: 0.5rem;
  padding: 0.65rem;
  border-top: 1px solid var(--border);
}
.chat-input-row input {
  padding: 0.5rem 0.75rem;
  font-size: 1rem; /* ≥16px prevents iOS auto-zoom on focus */
  border-radius: 10px;
}
.chat-input-row button {
  background: var(--purple);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.chat-input-row button:hover { background: var(--purple2); }

/* ─────────────────────────────────────────────────────────────────── */
/*  RESULT BAR                                                         */
/* ─────────────────────────────────────────────────────────────────── */
.result-bar {
  display: none;
  align-items: center;
  gap: 0.9rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  margin-top: 0.6rem;
}
.result-bar.show {
  display: flex;
  animation: result-in 0.45s cubic-bezier(.175,.885,.32,1.275) both;
}
@keyframes result-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.rb-icon { font-size: 1.55rem; flex-shrink: 0; line-height: 1; }
.rb-text { flex: 1; min-width: 0; }
.rb-text strong { font-size: 0.95rem; font-weight: 800; display: block; }
.rb-text span   { font-size: 0.78rem; color: var(--muted); display: block; margin-top: 0.1rem; }
.rb-btns { display: flex; gap: 0.4rem; flex-shrink: 0; }
.rb-btns .btn { padding: 0.42rem 0.85rem; font-size: 0.82rem; }
.rb-waiting { font-size: 0.78rem; color: var(--purple2); white-space: nowrap; flex-shrink: 0; }

/* ─────────────────────────────────────────────────────────────────── */
/*  TOAST                                                              */
/* ─────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 0.7rem 1.4rem;
  font-size: 0.875rem;
  white-space: nowrap;
  z-index: 300;
  animation: toast-in 0.25s ease;
}
@keyframes toast-in {
  from { transform: translateX(-50%) translateY(12px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0);   opacity: 1; }
}

/* ─────────────────────────────────────────────────────────────────── */
/*  RESPONSIVE                                                         */
/* ─────────────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  /* Game screen: remove centering, allow natural scroll */
  #screen-game {
    padding: 0;
    align-items: stretch;
    justify-content: flex-start;
  }

  /* Game layout: column, stretch children to full width,
     safe-area padding so nothing hides under notch/home bar */
  .game-layout {
    flex-direction: column;
    align-items: stretch;   /* fix: desktop sets flex-start, children must stretch */
    padding: 8px;
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));
    gap: 6px;
  }

  /* board-shell: natural height (sized by board content) */
  .board-shell { padding: 8px 8px 6px; }

  .board     { gap: 4px; }
  .board-col { gap: 4px; padding: 2px; }

  .scorebar  { padding: 0.5rem 0.75rem; }

  /* Hide chat on mobile */
  .chat-panel { display: none; }
}

/* ─────────────────────────────────────────────────────────────────── */
/*  MOBILE LANDSCAPE                                                   */
/*  Targets phones in landscape (tall screens are tablets, excluded)  */
/* ─────────────────────────────────────────────────────────────────── */
@media (orientation: landscape) and (max-height: 550px) {
  .chat-panel { display: none !important; }

  /* Fit everything in one screen, no scrolling */
  #screen-game {
    padding: 0;
    align-items: stretch;
    justify-content: flex-start;
    overflow: hidden;
  }

  .game-layout {
    flex-direction: column;
    align-items: stretch;
    height: 100dvh;
    max-width: none;
    overflow: hidden;
    padding: 4px;
    padding-left:  max(4px, env(safe-area-inset-left));
    padding-right: max(4px, env(safe-area-inset-right));
    padding-top:   max(4px, env(safe-area-inset-top));
    padding-bottom:max(4px, env(safe-area-inset-bottom));
    gap: 4px;
  }

  .game-main {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
  }

  /* Compact scorebar */
  .scorebar {
    flex-shrink: 0;
    padding: 0.25rem 0.6rem;
    margin-bottom: 0;
  }
  .ptag-disc { width: 14px; height: 14px; }
  .score-badge { min-width: 20px; height: 20px; font-size: 0.7rem; }

  /* Compact timer */
  .timer-bar { flex-shrink: 0; margin-bottom: 0; }
  .ptimer { padding: 0.2rem 0.5rem; font-size: 0.8rem; }

  /* Board shell: height from flex:1, width set by JS (fitBoardShellLandscape).
     Plain block container so the board fills it naturally. */
  .board-shell {
    flex: 1;
    min-height: 0;
    padding: 0;
    align-self: center;
  }

  /* Board fills shell width as a block; cell aspect-ratio drives height */
  .col-hint { display: none; }
  .board     { gap: 3px; }
  .board-col { gap: 3px; padding: 0; }
  /* Cell width = column width (stretch default); height = width via aspect-ratio */
  .cell { aspect-ratio: 1; }

  .result-bar { flex-shrink: 0; margin-top: 0; }
}
