/*! Copyright (c) 2026 BamByte (bambyte.net). All rights reserved.
 * Proprietary code: no copying, redistribution, or use to train or prompt
 * AI / machine-learning systems without written permission from BamByte. */
/* Solitaire -- game page (game.html).
   The table on the left, the site's sidebar on the right: HUD panel with the
   round controls on top (js/sidebarLayout.js), the same shell, frame and
   sizes Blockz and Brick Blast use, so every game reads the same. Single
   player only, so none of the online chat / lobby chrome is here.

   Reskin points: --felt-* (the table, drawn here, not on the canvas) and
   --game-accent (keep in step with ACCENT in js/render.js and --sol-accent in
   menu.css). Card art and sounds are set in js/config.js. */

:root {
  --game-accent: #ffd23f;
  --game-accent-rgb: 255, 210, 63;
  --felt-light: #1f7a4d;
  --felt-dark: #0b3a24;
  --panel: #0f2a1d;
  --text: #f4f7fb;
  --muted: #b4c7bc;
  --sol-sidebar-w: clamp(220px, 24vw, 340px);
  /* The table canvas' logical size for the layout in use, set by js/main.js
     (wide 852 x 820; the phone portrait table is 742 wide and as tall as the
     screen's shape); these are the wide defaults. */
  --sol-vw: 852;
  --sol-vh: 820;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background:
    radial-gradient(ellipse at 50% 40%, #12442c, #06170f 85%),
    #06170f;
  overflow: hidden;
}

/* Full-height flex + dvh, same as the rest of the site. */
.sol-shell {
  display: flex;
  gap: 16px;
  height: var(--bb-vh, 100vh);
  height: var(--bb-vh, 100dvh);
  padding: 16px;
}

/* The stage takes the slack; the board (one canvas of VIEW_W x VIEW_H =
   --sol-vw x --sol-vh, js/config.js) is the biggest that fits in it
   (container query units, so no resize JS). */
.sol-stage {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: size;
  order: 2;
}

.sol-board {
  position: relative;
  width: min(100cqw, 100cqh * var(--sol-vw) / var(--sol-vh));
  height: min(100cqh, 100cqw * var(--sol-vh) / var(--sol-vw));
  border-radius: 18px;
  /* The felt: the table picked in the HUD (TABLES in js/config.js; main.js
     paintTable() sets these), over its colours while the picture loads. */
  background:
    var(--felt-image, none) center / cover no-repeat,
    radial-gradient(ellipse at 50% 35%, var(--felt-light), var(--felt-dark) 95%);
  border: 3px solid rgba(var(--game-accent-rgb), 0.55);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55), inset 0 0 60px rgba(0, 0, 0, 0.35);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#screen {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline: none;
}
/* ---- sidebar folded away (net/sidebar_collapse.js, keys 1 / 2) -------------------
   The table fills the window edge to edge like Microsoft's: no page padding,
   no frame. js/render.js widens the table to the new shape, so the cards grow.
   The fold arrow floats over the table's edge instead of taking a strip. */
.sol-shell { position: relative; }
body.sol-sidebar-folded .sol-shell { padding: 0; gap: 0; }
body.sol-sidebar-folded .sol-board,
body.sol-sidebar-folded .sol-pause { border: 0; border-radius: 0; box-shadow: none; }
body.sol-sidebar-folded .sol-shell > .bb-sidebar-collapse-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 2px;
}
/* On the edge the sidebar went to (data-side is set by the module). */
body.sol-sidebar-folded .sol-shell > .bb-sidebar-collapse-btn[data-side="right"] {
  left: auto;
  right: 2px;
}

/* The deal buttons laid over the middle of the status strip while folded
   (js/render.js puts the strip's height / bottom in --sol-strip-*). */
.sol-foldbar { display: none; }
body.sol-sidebar-folded .sol-foldbar {
  position: absolute;
  left: 50%;
  bottom: var(--sol-strip-b, 6px);
  height: var(--sol-strip-h, 34px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 4;
}
body.sol-sidebar-folded .sol-foldbar .sol-btn {
  height: 78%;
  padding: 0 1.4em;
  font-size: calc(var(--sol-strip-h, 34px) * 0.38);
}
.sol-foldbar .sol-btn[hidden] { display: none; }

/* Pause cover. */
.sol-pause {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  /* Paused hides the board: no planning the next move with the clock stopped. */
  background: rgba(4, 20, 12, 0.6);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  cursor: pointer;
  z-index: 5;
}
.sol-pause[hidden] { display: none; }
.sol-pause__card {
  padding: 18px 34px;
  border-radius: 16px;
  background: rgba(12, 36, 24, 0.94);
  border: 2px solid rgba(var(--game-accent-rgb), 0.8);
  box-shadow: 0 0 18px rgba(var(--game-accent-rgb), 0.45), 0 14px 34px rgba(0, 0, 0, 0.6);
  text-align: center;
}
.sol-pause__card h2 {
  margin: 0 0 4px;
  font: 900 clamp(22px, 5cqw, 40px)/1.1 system-ui, -apple-system, "Segoe UI", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow: 0 0 14px rgba(var(--game-accent-rgb), 0.9);
}
.sol-pause__card p { margin: 0; color: var(--muted); font-weight: 600; font-size: clamp(12px, 2cqw, 15px); }

/* ---- Round controls (moved into the sidebar HUD by sidebarLayout.js) ------ */
.sol-side { display: none; }
.bb-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  /* One row whatever the sidebar width: the buttons shrink (to 26px) instead. */
  flex-wrap: nowrap;
  gap: 8px;
  margin: 0 0 8px;
  padding: 6px 10px;
  border-radius: 16px;
  background: #4a4a4a;
  border: 2px solid #6d6d6d;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 2px 6px rgba(0, 0, 0, 0.45);
}
.bb-icon-btn {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}
/* Up to 40px, shrinking together on a narrow sidebar. Also sizes the shared
   HUD menu button (/net/offline_hud_menu.js) appended to this row. */
.bb-toolbar .bb-icon-btn,
.bb-toolbar .bb-offline-hud-menu-btn {
  flex: 0 1 40px;
  width: auto;
  height: auto;
  min-width: 26px;
  aspect-ratio: 1;
}
.bb-icon-btn img { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.bb-icon-btn:hover { transform: translateY(-1px) scale(1.08); filter: brightness(1.15); }
.bb-icon-btn:active { transform: scale(0.94); }
.bb-icon-btn:focus-visible { outline: 2px solid var(--game-accent); outline-offset: 2px; }
.bb-icon-btn--gear { color: #111; background: #d9d9d9; width: 32px; height: 32px; padding: 5px; }
.bb-icon-btn--gear svg { width: 100%; height: 100%; display: block; }
/* The shared HUD menu's Settings item clicks this hidden gear; it only shows
   when that menu could not load (this folder served without the site root). */
#btn-settings { display: none; }
body.sol-no-hud-menu #btn-settings { display: grid; }

/* ---- Sidebar -------------------------------------------------------------- */
#rightPanel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 0 0 var(--sol-sidebar-w);
  width: var(--sol-sidebar-w);
  max-height: 100%;
  min-width: 0;
  padding: 8px;
  overflow: hidden;
  position: relative;
  order: 4;
}
/* No room, no chat: the chat mount stays hidden in single player. */
#sb-content { display: none; }

body.sol-dock-left #rightPanel { order: 1; }
body.sol-dock-left .sol-resize-handle { order: 2; }
body.sol-dock-left .sol-stage { order: 3; }

/* The grab strip between the board and the sidebar: the 10px strip is the
   hit area, the 2px line down its middle is what you see. */
.sol-resize-handle {
  display: block;
  position: relative;
  flex: 0 0 10px;
  align-self: stretch;
  cursor: col-resize;
  background: transparent;
  order: 3;
}
.sol-resize-handle::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: var(--game-accent);
  opacity: 0.35;
  border-radius: 2px;
  transition: opacity 0.18s ease, width 0.18s ease;
}
.sol-resize-handle:hover::before,
.sol-resize-handle.sol-resizing::before { opacity: 1; width: 4px; }
body.sol-resizing-cursor { cursor: col-resize; user-select: none; }

/* ---- HUD panel -------------------------------------------------------------- */
.hud-panel { display: none; }
#rightPanel > .hud-panel {
  display: flex;
  flex-direction: column;
  position: relative;          /* the settings popover is placed against it */
  width: 100%;
  flex: 0 1 auto;
  min-height: 0;
  overflow: hidden;            /* the body below scrolls; controls + logo stay put */
  border: 3px solid var(--game-accent);
  border-radius: 8px;
  background-color: rgba(12, 16, 24, 0.4);
  padding: 8px;
}
.hud-panel[hidden] { display: none !important; }

.hud-panel__title {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.hud-panel__logo-card { width: 100%; padding: 4px 6px; }
.hud-panel__logo {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.45));
}
.hud-panel__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 4px 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--game-accent-rgb), 0.6) transparent;
}

/* "Hide HUD": just the control strip stays. */
#rightPanel .hud-collapsed > *:not(.bb-toolbar) { display: none; }
#rightPanel .hud-collapsed {
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
}

/* Logo: the art is 4:3, so cap its height to leave the stats room. */
.hud-panel__logo { max-height: 150px; object-fit: contain; border-radius: 12px; }

/* HUD Table row: the same picker as Jump Kings' Board row / Pocket Kings'
   Table row (js/previewSelect.js); styles ported from BB_JumpKings/styles.css. */
.sol-hud-row { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; }
.sol-hud-row > label { flex: 0 0 auto; font-weight: 700; letter-spacing: .8px; font-size: 13px; color: #e9ecf6; }
.sol-hud-row > div { flex: 1 1 auto; min-width: 0; }

.sol-preview-select {
  flex: 1 1 auto;
  min-width: 0;
}

.sol-preview-select-btn {
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  font: inherit;
  font-size: 13px;
  padding: 6px 8px;
  color: #e6e6e6;
  background: #4a4a4a;
  border: 2px solid rgba(var(--game-accent-rgb), .55);
  border-radius: 999px;
  cursor: pointer;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.sol-preview-select-btn:hover {
  background: #5c5c5c;
  border-color: var(--game-accent);
}
/* Lit while the list is open or the control holds focus -- BAMO is a native
   <select>, which a plain click focuses; a <button> like this one is not. */
.sol-preview-select-btn:focus-visible,
.sol-preview-select-btn[aria-expanded="true"] {
  outline: none;
  border-color: var(--game-accent);
  box-shadow: 0 0 10px rgba(var(--game-accent-rgb), .45);
}

.sol-preview-select-btn::after {
  content: '';
  float: right;
  margin-top: 5px;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid #e6e6e6;
}

.sol-preview-select-list {
  position: fixed;
  z-index: 1000;
  background: #2a2a2a;
  border: 2px solid rgba(var(--game-accent-rgb), .55);
  border-radius: 14px;
  padding: 4px;
  max-height: 260px;
  overflow-y: auto;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5), 0 0 10px rgba(var(--game-accent-rgb), .25);
}

.sol-preview-select-list[hidden] { display: none; }

.sol-preview-select-option {
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  color: #e6e6e6;
  cursor: pointer;
  white-space: nowrap;
}

.sol-preview-select-option:hover,
.sol-preview-select-option.selected {
  background: #4a4a4a;
}

/* Host-locked (online mode) -- see session.js's window.__dmSetMapSelectLocked
   wiring. Same dim/disabled treatment as BB_PocketKings' own locked pickers. */
.sol-preview-select-btn:disabled,
.sol-preview-select-btn.is-locked {
  background: #3a3a3a;
  border-color: #1a1a1a;
  /* A field you cannot change should not look lit up. */
  box-shadow: none;
  color: #8f8f8f;
  font-style: italic;
  cursor: not-allowed;
}

.sol-preview-select-btn:disabled:hover,
.sol-preview-select-btn.is-locked:hover {
  background: #3a3a3a;
}

.sol-preview-select-btn:disabled::after,
.sol-preview-select-btn.is-locked::after {
  display: none;
}

/* Score / time / moves / cards home (also in the strip under the table). */
.sol-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.sol-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  min-width: 0;
}
.sol-stat:first-child { grid-column: 1 / -1; }
.sol-stat__label {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--game-accent);
  white-space: nowrap;
}
.sol-stat__value {
  font-size: 18px;
  font-weight: 900;
  color: #fff;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sol-deal { margin: 8px 0 0; font-size: 12px; font-weight: 700; color: var(--muted); text-align: center; }

/* Undo / Hint / Finish. */
.sol-actions { display: flex; gap: 6px; margin-top: 10px; }
.sol-actions .sol-btn { flex: 1 1 0; padding: 10px 8px; font-size: 13.5px; }
.sol-actions .sol-btn[hidden] { display: none; }
.sol-btn:disabled { opacity: 0.45; cursor: default; filter: none; transform: none; }

/* Controls cheat sheet. */
.sol-keys { margin: 12px 0 0; display: grid; gap: 4px; }
.sol-keys div { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; }
.sol-keys dt {
  margin: 0;
  padding: 1px 7px;
  border-radius: 6px;
  background: rgba(var(--game-accent-rgb), 0.16);
  border: 1px solid rgba(var(--game-accent-rgb), 0.45);
  color: #fff;
  font-weight: 800;
  white-space: nowrap;
}
.sol-keys dd { margin: 0; color: var(--muted); font-weight: 600; text-align: right; }

.sol-hint { margin: 10px 0 0; font-size: 12px; line-height: 1.45; color: var(--muted); text-align: center; }
.sol-hint b { color: #fff; }

/* ---- Settings popover ----------------------------------------------------------- */
.settings-menu {
  position: absolute;
  right: 8px;
  top: 64px;
  z-index: 40;
  width: min(280px, calc(100% - 16px));
  max-height: calc(var(--bb-vh, 100dvh) - 120px);
  overflow-y: auto;
  padding: 12px;
  border-radius: 14px;
  background: #2b2a2a;
  border: 2px solid rgba(var(--game-accent-rgb), 0.55);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5);
}
.settings-menu[hidden] { display: none; }
/* In the sidebar it opens like BAMO's / Boom Boats': a full-width panel inside
   the side panel. Solitaire's HUD box runs the whole height of the sidebar
   (there's no chat under it), so instead of hanging below it, the panel fills
   the HUD box from just under the control bar and its Game Settings button
   down to the bottom, and scrolls. The small-screen rule further down still
   floats it centred instead. */
#hud-panel > #settings-menu {
  top: 132px;
  bottom: 10px;
  left: 10px;
  right: 10px;
  width: auto;
  max-height: none;
  padding: 14px 16px 12px;
  background: rgba(22, 22, 22, 0.97);
  border: 2px solid var(--game-accent);
  border-radius: 12px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55), 0 0 18px rgba(var(--game-accent-rgb), 0.22);
  text-align: left;
}
.settings-note { margin: 6px 0 0; font-size: 11.5px; color: var(--muted); }
.settings-group { margin-top: 12px; border-top: 1px solid rgba(255, 255, 255, 0.12); padding-top: 10px; }
.settings-title { margin: 0 0 8px; font-size: 13px; color: var(--game-accent); }

.sol-set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  margin: 6px 0;
}
.sol-set-row input[type="range"] { flex: 1 1 auto; max-width: 140px; accent-color: var(--game-accent); }
.sol-toggle-row input { width: 18px; height: 18px; accent-color: var(--game-accent); }
.sol-select {
  padding: 5px 8px;
  border-radius: 8px;
  border: 1px solid rgba(var(--game-accent-rgb), 0.6);
  background: var(--panel);
  color: #fff;
  font: inherit;
}
.sol-set-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.sol-set-buttons .sol-btn--go:first-child:nth-last-child(odd) { grid-column: 1 / -1; }
.sol-set-buttons--three { grid-template-columns: 1fr 1fr 1fr; }

/* Statistics dialog. */
.sol-statlist { margin: 0; display: grid; gap: 6px; }
.sol-statlist div { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; padding: 4px 2px; border-top: 1px solid rgba(255, 255, 255, 0.07); }
.sol-statlist dt { color: var(--muted); font-weight: 700; }
.sol-statlist dd { margin: 0; color: #fff; font-weight: 900; font-variant-numeric: tabular-nums; }

.sol-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  border: 0;
  border-radius: 999px;
  font: 800 12.5px/1.1 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #fff;
  text-decoration: none;
  text-align: center;
  background: #3a3a3a;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.16);
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.15s ease;
}
.sol-btn:hover, .sol-btn:focus-visible { filter: brightness(1.18); transform: translateY(-1px); }
.sol-btn--go {
  background: #1f7a3d;
  box-shadow: 0 0 0 2px rgba(70, 220, 120, 0.75), 0 0 10px 2px rgba(70, 220, 120, 0.45);
}

.rules { margin: 0; }
.rules dt { margin-top: 8px; font-weight: 800; font-size: 12.5px; color: var(--game-accent); }
.rules dd { margin: 2px 0 6px; font-size: 12px; line-height: 1.45; color: #fff; }

/* ---- Dialogs (high scores, name entry) ---------------------------------------- */
.sol-modal {
  position: fixed;
  inset: 0;
  z-index: 4100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(0, 0, 0, 0.6);
}
.sol-modal__card {
  width: min(360px, 92vw);
  max-height: calc(var(--bb-vh, 100dvh) - 24px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px 22px;
  border-radius: 20px;
  background: #1c1c1c;
  border: 2px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.6);
}
.sol-modal__title {
  margin: 0;
  text-align: center;
  font: 900 clamp(18px, 4vw, 24px)/1.1 system-ui, -apple-system, "Segoe UI", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #fff;
}
.sol-modal__score {
  margin: 0;
  text-align: center;
  font-size: 34px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 14px rgba(var(--game-accent-rgb), 0.8);
}
.sol-modal__label { font-size: 13px; font-weight: 700; color: var(--muted); text-align: center; }
/* The signed-in name the high score is saved under (no name box to fill in). */
.sol-modal__name {
  margin: -6px 0 0;
  text-align: center;
  font-size: 20px;
  font-weight: 900;
  color: #fff;
  overflow-wrap: anywhere;
  text-shadow: 0 0 10px rgba(var(--game-accent-rgb), 0.6);
}
.sol-input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 2px solid rgba(var(--game-accent-rgb), 0.7);
  background: #0e1220;
  color: #fff;
  font: 700 16px system-ui, sans-serif;
  text-align: center;
}
.sol-modal .sol-btn { padding: 12px 0; font-size: 14px; text-transform: uppercase; }

.sol-scores-wrap { overflow-y: auto; min-height: 0; }
.sol-scores { width: 100%; border-collapse: collapse; font-size: 14px; }
.sol-scores th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--game-accent);
  padding: 4px 8px;
}
.sol-scores td { padding: 6px 8px; border-top: 1px solid rgba(255, 255, 255, 0.07); color: #fff; }
.sol-scores td:first-child { width: 2.5em; color: var(--muted); }
.sol-scores td:last-child, .sol-scores th:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.sol-scores tr.is-me td { background: rgba(var(--game-accent-rgb), 0.22); font-weight: 800; }
.sol-empty { text-align: center; color: var(--muted) !important; }

/* ==== Phones and tablets ====================================================
   Desktop is untouched: everything below is gated on a portrait viewport no
   wider than 1024px (stacked) or a landscape one no taller than 500px. */

/* Portrait: board on top at full width, sidebar under it. */
@media (orientation: portrait) and (max-width: 1024px) {
  /* The sidebar fold (net/sidebar_collapse.js) is desktop / landscape only. */
  .sol-shell > .bb-sidebar-collapse-btn { display: none; }
  html, body { height: auto; min-height: 100%; }
  body { overflow-x: hidden; overflow-y: auto; }

  .sol-shell {
    flex-direction: column;
    height: auto;
    min-height: var(--bb-vh, 100dvh);
    padding: 8px;
    gap: 8px;
  }
  .sol-stage,
  body.sol-dock-left .sol-stage {
    order: 1;
    flex: 0 0 auto;
    width: 100%;
    /* The tall portrait table (js/render.js 'portrait', sized by main.js to
       the screen's shape): as wide as the screen, and short enough that the
       sidebar's control bar (Restart / Pause / Stop / Home / Sound / Menu)
       always shows under it. The table takes every touch (card drags), so
       swiping that bar is how the page scrolls down to the rest of the
       sidebar. Keep the 16px / 90px in step with PORTRAIT_INSET /
       PORTRAIT_INSET_H in js/main.js. */
    height: min(calc((100vw - 16px) * var(--sol-vh) / var(--sol-vw)), calc(var(--bb-vh, 100dvh) - 90px));
  }
  #rightPanel,
  body.sol-dock-left #rightPanel {
    order: 2;
    flex: 0 0 auto;
    width: 100%;
    max-height: none;
    padding: 0;
    overflow: visible;
  }
  #rightPanel > .hud-panel,
  .hud-panel__body { overflow: visible; }
  .sol-resize-handle { display: none; }
  .hud-panel__logo { max-width: 320px; margin: 0 auto; }
}

/* Phones on their side: keep side by side, narrower sidebar. */
@media (orientation: landscape) and (max-height: 500px) {
  :root { --sol-phone-side-w: clamp(180px, 26vw, 240px); }
  .sol-shell { padding: 6px; gap: 6px; }
  #rightPanel {
    flex: 0 0 var(--sol-phone-side-w);
    width: var(--sol-phone-side-w);
    padding: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .sol-resize-handle { display: none; }
  /* Tighter control row in the narrow sidebar (the buttons shrink to fit). */
  .bb-toolbar { gap: 5px; padding: 4px 6px; }
  .hud-panel__logo { max-height: 48px; width: auto; margin: 0 auto; }
  .hud-panel__title { padding: 4px 6px; }
  #rightPanel > .hud-panel { padding: 6px; }
  .sol-stat { padding: 5px 8px; }
  .sol-stat--score .sol-stat__value { font-size: 22px; }
  .sol-keys { display: none; }
  .sol-hint { display: none; }
}

/* Settings popover on small screens: floats over the viewport, centred. */
@media (orientation: portrait) and (max-width: 1024px), (orientation: landscape) and (max-height: 500px) {
  #rightPanel #settings-menu {
    position: fixed;
    top: 50%;
    left: 50%;
    right: auto;
    transform: translate(-50%, -50%);
    bottom: auto;
    width: min(320px, calc(100vw - 24px));
    max-height: calc(var(--bb-vh, 100dvh) - 24px);
    z-index: 900;
  }
}

/* The first settings group sits right at the top: no divider above it. */
.settings-group--first { margin-top: 0; border-top: 0; padding-top: 0; }
.rules dd b { color: var(--game-accent); }
p.sol-modal__label { margin: 0; }
