/* ==========================================================================
   Snooker Break — Responsive Desktop & Full-Viewport Mobile Stylesheet
   ========================================================================== */

:root {
  --bg-page: #0c0f12;
  --bg-surface: #14191e;
  --bg-elevated: #1c232b;
  --bg-hover: #252e38;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);

  --text-primary: #f1f4f7;
  --text-secondary: #9aa5b1;
  --text-muted: #687482;

  --accent-emerald: #1f9d68;
  --accent-emerald-soft: rgba(31, 157, 104, 0.18);
  --accent-gold: #d4a64a;
  --accent-danger: #d94c4c;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  font-family: inherit;
  color: inherit;
  cursor: pointer;
}

/* Main Shell */
.sg-shell {
  height: 100dvh;
  max-width: 1340px;
  margin: 0 auto;
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

/* Header */
.sg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}

.sg-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.sg-back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  text-decoration: none;
  flex-shrink: 0;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.sg-back-link:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.sg-brand-mark {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 32%, #e84848, #8e1414);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.sg-brand-text h1 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.1;
  white-space: nowrap;
}

.sg-brand-sub {
  display: block;
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
}

/* Mode Segmented Switcher */
.sg-modes {
  display: inline-flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
}

.sg-mode-btn {
  background: transparent;
  border: none;
  border-radius: 7px;
  padding: 5px 11px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: background 0.14s ease, color 0.14s ease;
}

.sg-mode-btn:hover {
  color: var(--text-primary);
}

.sg-mode-btn.is-active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

/* Header Right Actions */
.sg-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.sg-chip-btn {
  height: 30px;
  padding: 0 9px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-gold);
  transition: background 0.14s ease, border-color 0.14s ease;
}

.sg-chip-btn:hover {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
}

.sg-chip-btn[hidden] {
  display: none;
}

.sg-icon-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.sg-icon-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

#btn-sound[aria-pressed="true"] .icon-sound-off { display: none; }
#btn-sound[aria-pressed="false"] .icon-sound-on { display: none; }

/* Scoreboard HUD Strip */
.sg-hud {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  flex-shrink: 0;
}

/* vs CPU Match HUD */
.sg-match-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sg-match-hud[hidden],
.sg-solo-hud[hidden] {
  display: none;
}

.sg-player-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.sg-player-box.is-active {
  background: var(--accent-emerald-soft);
  border-color: rgba(31, 157, 104, 0.5);
}

.sg-player-cpu.is-active {
  background: rgba(212, 166, 74, 0.14);
  border-color: rgba(212, 166, 74, 0.5);
}

.sg-turn-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: transparent;
  flex-shrink: 0;
}

.sg-player-box.is-active .sg-turn-dot {
  background: var(--accent-emerald);
  box-shadow: 0 0 8px rgba(31, 157, 104, 0.8);
}

.sg-player-cpu.is-active .sg-turn-dot {
  background: var(--accent-gold);
  box-shadow: 0 0 8px rgba(212, 166, 74, 0.8);
}

.sg-player-name {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.sg-player-box.is-active .sg-player-name {
  color: var(--text-primary);
}

.sg-player-score {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
  min-width: 24px;
  text-align: center;
}

.sg-match-center {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sg-frames-pill {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-gold);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.sg-target-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.sg-match-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.74rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.sg-match-meta strong {
  font-family: var(--font-mono);
  color: var(--text-primary);
  margin-left: 2px;
}

/* Solo Break HUD */
.sg-solo-hud {
  display: flex;
  align-items: center;
  gap: 14px;
}

.sg-stat {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.sg-stat-primary {
  padding-right: 12px;
  border-right: 1px solid var(--border-subtle);
}

.sg-stat-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sg-stat-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-primary);
}

.sg-stat-primary .sg-stat-value {
  font-size: 1.3rem;
}

.sg-stat-accent {
  color: var(--accent-gold);
}

.sg-target-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sg-ball-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #c82323;
  box-shadow: inset -1.5px -1.5px 2.5px rgba(0, 0, 0, 0.45), inset 1.5px 1.5px 2px rgba(255, 255, 255, 0.35);
  flex-shrink: 0;
}

.sg-target-text {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.sg-pot-history {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow: hidden;
  max-width: 320px;
}

.sg-pot-pip {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: inset -1.5px -1.5px 2px rgba(0, 0, 0, 0.45), inset 1.5px 1.5px 2px rgba(255, 255, 255, 0.35);
}

/* Main Play Workspace — Desktop Landscape */
.sg-workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 224px;
  gap: 12px;
  align-items: center;
}

.sg-table-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  min-width: 0;
}

#snooker-canvas {
  display: block;
  border-radius: 10px;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.6);
  touch-action: none;
  cursor: crosshair;
}

/* Non-blocking Toast & Hints */
.sg-toast {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: rgba(12, 15, 18, 0.95);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  white-space: nowrap;
  z-index: 6;
}

.sg-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.sg-toast.is-foul {
  border-color: rgba(217, 76, 76, 0.65);
  color: #f8b4b4;
}

.sg-toast.is-good {
  border-color: rgba(31, 157, 104, 0.65);
  color: #a7f3d0;
}

.sg-toast.is-cpu {
  border-color: rgba(212, 166, 74, 0.65);
  color: #f3d999;
}

.sg-hint {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(12, 15, 18, 0.82);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.7rem;
  pointer-events: none;
  white-space: nowrap;
  z-index: 4;
  transition: opacity 0.18s ease;
}

.sg-hint.is-hidden {
  opacity: 0;
}

/* Non-blocking End-of-Frame Banner (only when frame/table finishes) */
.sg-frame-banner {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(18, 23, 28, 0.96);
  border: 1px solid var(--border-strong);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.65);
  z-index: 8;
  white-space: nowrap;
}

.sg-frame-banner[hidden] {
  display: none;
}

.sg-frame-banner-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sg-frame-banner-text strong {
  font-size: 0.9rem;
  color: var(--text-primary);
}

.sg-frame-banner-text span {
  font-size: 0.74rem;
  color: var(--text-secondary);
}

.sg-btn {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.sg-btn-primary {
  background: var(--accent-emerald);
  color: #ffffff;
}

.sg-btn-primary:hover {
  background: #24b477;
}

.sg-btn-sm {
  padding: 7px 12px;
  font-size: 0.78rem;
}

/* Controls Dock — Desktop */
.sg-dock {
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: center;
  height: 100%;
  max-height: 540px;
}

.sg-dock.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.sg-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 11px;
}

.sg-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.sg-panel-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.sg-power-readout {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--accent-emerald);
}

.sg-power-track {
  position: relative;
  width: 100%;
  height: 168px;
  background: #0b0e12;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  touch-action: none;
  cursor: ns-resize;
}

.sg-power-fill {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 0%;
  background: linear-gradient(180deg, rgba(31, 157, 104, 0.25) 0%, rgba(212, 166, 74, 0.38) 65%, rgba(217, 76, 76, 0.55) 100%);
  pointer-events: none;
}

.sg-power-ticks {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  pointer-events: none;
}

.sg-power-ticks span {
  display: block;
  width: 100%;
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
}

.sg-power-handle {
  position: absolute;
  left: 6px;
  right: 6px;
  top: 6px;
  height: 28px;
  border-radius: 5px;
  background: linear-gradient(180deg, #343f4b, #232a33);
  border: 1px solid rgba(255, 255, 255, 0.24);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.sg-cue-grip {
  width: 28px;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, #a67c52, #e2c191, #a67c52);
}

.sg-power-hint {
  margin-top: 7px;
  font-size: 0.68rem;
  color: var(--text-muted);
  text-align: center;
}

/* Mobile-only rail buttons hidden on desktop */
.sg-rail-tools {
  display: none;
}

.sg-spin-close {
  display: none;
}

.sg-spin-head-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sg-text-btn {
  background: transparent;
  border: none;
  padding: 2px 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: 4px;
}

.sg-text-btn:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.sg-spin-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
}

.sg-spin-pad {
  position: relative;
  width: 102px;
  height: 102px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #ffffff 0%, #eae7de 55%, #b8b3a6 100%);
  box-shadow: inset -6px -6px 14px rgba(0, 0, 0, 0.35), 0 6px 16px rgba(0, 0, 0, 0.45);
  touch-action: none;
  cursor: pointer;
  flex-shrink: 0;
}

.sg-spin-crosshair::before,
.sg-spin-crosshair::after {
  content: "";
  position: absolute;
  background: rgba(15, 18, 21, 0.16);
  pointer-events: none;
}

.sg-spin-crosshair::before {
  left: 50%;
  top: 12%;
  bottom: 12%;
  width: 1px;
  transform: translateX(-50%);
}

.sg-spin-crosshair::after {
  top: 50%;
  left: 12%;
  right: 12%;
  height: 1px;
  transform: translateY(-50%);
}

.sg-spin-safe-ring {
  position: absolute;
  inset: 14%;
  border-radius: 50%;
  border: 1px dashed rgba(15, 18, 21, 0.22);
  pointer-events: none;
}

.sg-spin-dot {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: #c82323;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.sg-spin-meta {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sg-spin-readout {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-align: center;
  min-height: 16px;
}

.sg-toggle-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.sg-toggle-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.sg-toggle-btn[aria-pressed="true"] {
  background: var(--accent-emerald-soft);
  border-color: rgba(31, 157, 104, 0.55);
  color: #9bf0c9;
}

/* Spin Backdrop */
.sg-spin-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 9, 11, 0.55);
  z-index: 30;
}

.sg-spin-backdrop[hidden] {
  display: none;
}

/* Help Modal */
.sg-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.sg-modal[hidden] {
  display: none;
}

.sg-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 9, 11, 0.78);
  backdrop-filter: blur(4px);
}

.sg-modal-card {
  position: relative;
  width: 100%;
  max-width: 460px;
  max-height: 86dvh;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 18px 20px 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
}

.sg-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.sg-modal-head h2 {
  margin: 0;
  font-size: 1.02rem;
}

.sg-help-group + .sg-help-group {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.sg-help-group h3 {
  margin: 0 0 8px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.sg-help-group ul {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.83rem;
  line-height: 1.45;
  color: var(--text-secondary);
}

.sg-help-group strong {
  color: var(--text-primary);
}

.sg-help-group code {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--text-primary);
}

/* ==========================================================================
   MOBILE PORTRAIT FULL-SCREEN SIDE-RAIL LAYOUT
   Maximizes table size (~2.2x larger than stacked layout) with zero overflow
   ========================================================================== */
@media (max-width: 860px) {
  .sg-shell {
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    gap: 5px;
  }

  .sg-header {
    flex-wrap: wrap;
    gap: 5px 6px;
  }

  .sg-brand-text h1 {
    font-size: 0.82rem;
  }

  .sg-brand-sub {
    display: none;
  }

  .sg-modes {
    order: 3;
    width: 100%;
    justify-content: space-between;
    padding: 2px;
  }

  .sg-mode-btn {
    flex: 1;
    padding: 4px 4px;
    font-size: 0.72rem;
    text-align: center;
  }

  .sg-chip-btn {
    height: 26px;
    padding: 0 7px;
    font-size: 0.68rem;
  }

  .sg-icon-btn {
    width: 26px;
    height: 26px;
  }

  /* Slim single-row HUD */
  .sg-hud {
    padding: 5px 8px;
    border-radius: 8px;
  }

  .sg-match-hud {
    gap: 4px;
  }

  .sg-player-box {
    padding: 3px 7px;
    gap: 5px;
  }

  .sg-player-name {
    font-size: 0.65rem;
  }

  .sg-player-score {
    font-size: 1.05rem;
    min-width: 18px;
  }

  .sg-match-center {
    gap: 6px;
  }

  .sg-frames-pill {
    font-size: 0.7rem;
    padding: 2px 7px;
  }

  .sg-target-inline {
    font-size: 0.72rem;
    gap: 4px;
  }

  .sg-match-meta {
    display: none;
  }

  .sg-solo-hud {
    gap: 10px;
    justify-content: space-between;
  }

  .sg-stat-primary {
    padding-right: 8px;
  }

  .sg-stat-label {
    font-size: 0.6rem;
  }

  .sg-stat-value {
    font-size: 0.98rem;
  }

  .sg-stat-primary .sg-stat-value {
    font-size: 1.08rem;
  }

  .sg-target-text {
    font-size: 0.74rem;
  }

  .sg-pot-history {
    display: none;
  }

  /* Side-by-side workspace: Large vertical table + sleek 60px right control rail */
  .sg-workspace {
    grid-template-columns: minmax(0, 1fr) 60px;
    gap: 6px;
    align-items: stretch;
  }

  #snooker-canvas {
    border-radius: 8px;
  }

  .sg-dock {
    height: 100%;
    max-height: none;
    justify-content: space-between;
    gap: 6px;
  }

  .sg-power-panel {
    flex: 1;
    min-height: 0;
    padding: 6px 5px;
    display: flex;
    flex-direction: column;
    gap: 5px;
  }

  .sg-power-panel .sg-panel-head {
    flex-direction: column;
    gap: 2px;
    margin-bottom: 0;
  }

  .sg-power-panel .sg-panel-label {
    font-size: 0.56rem;
    letter-spacing: 0.06em;
  }

  .sg-power-readout {
    font-size: 0.68rem;
  }

  .sg-power-track {
    flex: 1;
    height: auto;
    min-height: 110px;
  }

  .sg-power-handle {
    left: 4px;
    right: 4px;
    height: 26px;
  }

  .sg-cue-grip {
    width: 20px;
  }

  .sg-power-hint {
    display: none;
  }

  /* Compact vertical tool buttons beneath Power rail */
  .sg-rail-tools {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex-shrink: 0;
  }

  .sg-rail-btn {
    width: 100%;
    padding: 6px 2px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-secondary);
    transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
  }

  .sg-rail-btn[aria-pressed="true"] {
    background: var(--accent-emerald-soft);
    border-color: rgba(31, 157, 104, 0.55);
    color: #9bf0c9;
  }

  .sg-rail-label {
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .sg-mini-ball {
    position: relative;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #ffffff 0%, #eae7de 60%, #b3aea1 100%);
    box-shadow: inset -2px -2px 4px rgba(0, 0, 0, 0.35);
    display: block;
  }

  .sg-mini-dot {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #c82323;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
  }

  /* Spin panel becomes a crisp floating popover on mobile */
  .sg-spin-panel {
    display: none;
    position: fixed;
    right: 70px;
    bottom: calc(20px + env(safe-area-inset-bottom));
    width: 184px;
    z-index: 40;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.75);
    border-color: var(--border-strong);
  }

  .sg-spin-panel.is-open {
    display: block;
  }

  .sg-spin-close {
    display: inline-block;
    color: var(--accent-emerald);
  }

  .sg-desktop-only {
    display: none;
  }

  .sg-spin-pad {
    width: 122px;
    height: 122px;
  }

  .sg-hint {
    font-size: 0.65rem;
    padding: 4px 10px;
    bottom: 8px;
  }

  .sg-frame-banner {
    gap: 10px;
    padding: 8px 10px;
    bottom: 10px;
  }

  .sg-frame-banner-text strong {
    font-size: 0.82rem;
  }

  .sg-frame-banner-text span {
    font-size: 0.68rem;
  }
}
/* ==========================================================================
   1v1 Room Chip & Multiplayer Lobby Styles
   ========================================================================== */
.sg-room-chip {
  color: #9bf0c9;
  border-color: rgba(31, 157, 104, 0.45);
  background: var(--accent-emerald-soft);
}

.sg-room-chip:hover {
  background: rgba(31, 157, 104, 0.28);
  border-color: rgba(31, 157, 104, 0.7);
}

.sg-btn-full {
  width: 100%;
}

.sg-btn-ghost {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
}

.sg-btn-ghost:hover {
  background: var(--bg-hover);
}

.sg-btn-danger {
  background: rgba(217, 76, 76, 0.14);
  border: 1px solid rgba(217, 76, 76, 0.45);
  color: #f8b4b4;
}

.sg-btn-danger:hover {
  background: rgba(217, 76, 76, 0.24);
}

.sg-pvp-card {
  max-width: 400px;
}

.sg-pvp-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 3px;
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}

.sg-pvp-tab {
  border: none;
  background: transparent;
  padding: 7px 8px;
  border-radius: 5px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: background 0.14s ease, color 0.14s ease;
}

.sg-pvp-tab.is-active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

.sg-pvp-pane[hidden] {
  display: none;
}

.sg-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}

.sg-field label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.sg-field input {
  width: 100%;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}

.sg-field input:focus,
.sg-code-input:focus {
  border-color: var(--accent-emerald);
}

/* Foul Decision Bar, Shot Clock, Concede Chip & Leaderboard Modal */
.sg-concede-chip {
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.35);
}

.sg-clock-pill {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.16);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #a7f3d0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.sg-clock-pill.is-low {
  background: rgba(239, 68, 68, 0.22);
  border-color: rgba(248, 113, 113, 0.65);
  color: #fecaca;
}

.sg-foul-bar {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 16;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 8px 12px;
  background: rgba(11, 16, 23, 0.94);
  border: 1px solid rgba(212, 175, 55, 0.48);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
  max-width: calc(100% - 24px);
}

.sg-foul-bar[hidden] {
  display: none;
}

.sg-foul-bar-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: #fde68a;
  white-space: nowrap;
}

.sg-foul-bar-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.sg-btn-gold {
  background: #d4af37;
  color: #0b1017;
  border: 1px solid #eab308;
}

.sg-btn-gold:hover {
  background: #c49f28;
}

.sg-lb-card {
  max-width: 520px;
}

.sg-lb-user-bar {
  font-size: 0.78rem;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sg-lb-user-bar a {
  color: var(--accent-gold);
  font-weight: 700;
  text-decoration: none;
}

.sg-lb-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}

.sg-lb-tab {
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
}

.sg-lb-tab.is-active {
  background: var(--bg-elevated);
  color: var(--accent-gold);
  border-color: rgba(212, 175, 55, 0.5);
}

.sg-lb-body {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-page);
}

.sg-lb-empty {
  padding: 24px 14px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.sg-lb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.sg-lb-table th,
.sg-lb-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.sg-lb-table th {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.02);
}

.sg-lb-table tr.is-me {
  background: rgba(16, 185, 129, 0.12);
}

.sg-lb-score {
  text-align: right !important;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-gold);
}

.sg-lb-cleared {
  display: inline-block;
  margin-left: 5px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
  font-size: 0.66rem;
  font-weight: 700;
}

.sg-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.sg-pvp-box {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 11px;
}

.sg-pvp-box-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.sg-pvp-box-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
}

.sg-rack-toggle {
  display: inline-flex;
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.sg-rack-opt {
  background: transparent;
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.sg-rack-opt.is-active {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.sg-pvp-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sg-pvp-divider::before,
.sg-pvp-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

.sg-join-row {
  display: flex;
  gap: 8px;
}

.sg-code-input {
  flex: 1;
  min-width: 0;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-align: center;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}

.sg-pvp-error {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(217, 76, 76, 0.14);
  border: 1px solid rgba(217, 76, 76, 0.45);
  color: #f8b4b4;
  font-size: 0.78rem;
  text-align: center;
}

.sg-pvp-error[hidden] {
  display: none;
}

.sg-room-code-card {
  text-align: center;
  background: var(--bg-page);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 16px 12px;
  margin-bottom: 12px;
}

.sg-room-code-label {
  display: block;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sg-room-code-value {
  font-family: var(--font-mono);
  font-size: 2.15rem;
  font-weight: 700;
  letter-spacing: 0.24em;
  color: var(--accent-gold);
  margin: 6px 0 8px;
  padding-left: 0.24em;
  user-select: text;
  -webkit-user-select: text;
}

.sg-room-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.sg-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 0 0 rgba(31, 157, 104, 0.65);
  animation: sg-pulse 1.5s infinite;
}

@keyframes sg-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(31, 157, 104, 0.65); }
  70%  { box-shadow: 0 0 0 7px rgba(31, 157, 104, 0); }
  100% { box-shadow: 0 0 0 0 rgba(31, 157, 104, 0); }
}

.sg-room-share-actions {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.sg-room-footer-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.sg-room-footer-actions .sg-btn {
  flex: 1;
}

@media (max-width: 860px) {
  .sg-mode-btn {
    padding: 4px 2px;
    font-size: 0.68rem;
  }

  .sg-player-name {
    max-width: 68px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
