body { font-family: 'Quicksand', sans-serif; }
[hidden] { display: none !important; }

.sg {
  --bg0: #060a1d; --bg1: #101a3f; --ink: #e8ecff; --mute: #8e9acb; --acc: #34d399; --acc2: #22d3ee;
  --glass: rgba(14, 20, 52, .78); --line: rgba(148, 163, 255, .22);
  --stagew: 400px;
  font-family: 'Quicksand', sans-serif; color: var(--ink);
  min-height: calc(100vh - 64px); min-height: calc(100dvh - 64px);
  display: flex; justify-content: center; align-items: flex-start;
  padding: 6px 10px calc(10px + env(safe-area-inset-bottom));
  box-sizing: border-box;
  background: radial-gradient(120% 70% at 50% 0%, #162055 0%, #0a0f2c 55%, #050816 100%);
}
.sg *, .sg *::before, .sg *::after { box-sizing: border-box; }
.sg-card { width: 100%; max-width: 640px; display: flex; flex-direction: column; gap: 6px; }

/* HUD */
.sg-hud {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--glass); border: 1px solid var(--line); border-radius: 14px; padding: 6px 12px;
  backdrop-filter: blur(6px);
}
.sg-hl, .sg-hc, .sg-hr { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
.sg-hl { align-items: flex-start; flex: 1; }
.sg-hc { align-items: center; flex: 1; }
.sg-hr { align-items: flex-end; flex: 1; }
.sg-hole { font-weight: 700; font-size: 1rem; letter-spacing: .06em; }
.sg-par { font-weight: 700; font-size: .78rem; color: var(--acc); letter-spacing: .1em; }
.sg-score { font-weight: 700; font-size: 1.7rem; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.sg-score.pop { animation: sgpop .35s ease-out; }
.sg-mult { font-weight: 700; font-size: 1.35rem; color: var(--acc2); }
.sg-mult.hot { color: #fbbf24; text-shadow: 0 0 12px rgba(251, 191, 36, .6); }
.sg-lbl { font-size: .62rem; color: var(--mute); letter-spacing: .16em; font-weight: 600; }
@keyframes sgpop { 0% { transform: scale(1.25); color: #fff; } 100% { transform: scale(1); } }

.sg-sub { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 22px; padding: 0 4px; }
.sg-pips { display: flex; gap: 6px; align-items: center; }
.sg-pip { width: 13px; height: 13px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .35); background: transparent; transition: background .15s, transform .15s; }
.sg-pip.par { border-color: var(--acc); }
.sg-pip.over { border-color: #fbbf24; }
.sg-pip.used { background: #fff; transform: scale(.9); }
.sg-pip.par.used { background: var(--acc); }
.sg-pip.over.used { background: #fbbf24; }
.sg-state { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: .85rem; letter-spacing: .08em; color: var(--ink); min-width: 0; }
.sg-life { width: 14px; height: 14px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, #bae6fd); box-shadow: 0 0 8px rgba(186, 230, 253, .7); }
.sg-life.gone { background: transparent; border: 2px solid rgba(255, 255, 255, .3); box-shadow: none; }
.sg-clock { width: 120px; height: 9px; border-radius: 6px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.sg-clock > i { display: block; height: 100%; background: linear-gradient(90deg, var(--acc), var(--acc2)); border-radius: 6px; transition: width .12s linear; }
.sg-clock.low > i { background: linear-gradient(90deg, #f43f5e, #fb923c); }
.sg-secs { font-variant-numeric: tabular-nums; min-width: 3ch; text-align: right; }

/* Stage */
.sg-stage {
  position: relative; width: 100%; flex: 1 1 0; min-height: 240px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 18px; overflow: hidden;
  background: #070b1f; border: 1px solid var(--line);
  box-shadow: 0 0 0 1px rgba(52, 211, 153, .06), 0 14px 40px rgba(0, 0, 0, .45), inset 0 0 40px rgba(34, 211, 238, .05);
}
#sgCv { display: block; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: crosshair; }

/* Overlays */
.sg-ov {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-start; align-items: center;
  background: rgba(5, 8, 22, .80); backdrop-filter: blur(4px); z-index: 5; overflow-y: auto; padding: 14px;
}
.sg-ov > :first-child { margin-top: auto; }
.sg-ov > :last-child { margin-bottom: auto; }
.sg-ov.sg-opaque { background: #0a1030; backdrop-filter: none; }
.sg-ov.sg-clear { background: transparent; backdrop-filter: none; pointer-events: none; justify-content: center; }
.sg-panel { width: 100%; max-width: 360px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.sg-panel.sg-scroll { align-items: stretch; }
.sg-logo { width: 150px; height: auto; overflow: visible; margin-bottom: -2px; filter: drop-shadow(0 6px 18px rgba(124, 58, 237, .45)); }
.sg-title { margin: 0; font-size: 2rem; letter-spacing: .14em; font-weight: 700; background: linear-gradient(90deg, #86efac, #67e8f9, #c4b5fd); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sg-h2 { margin: 0; font-size: 1.4rem; letter-spacing: .14em; font-weight: 700; }
.sg-tag { margin: 0; color: var(--mute); font-size: .92rem; font-weight: 600; }
.sg-modes { display: flex; gap: 8px; width: 100%; justify-content: center; }
.sg-mode {
  flex: 1 1 0; min-width: 0; padding: 10px 6px; border-radius: 14px; cursor: pointer;
  background: rgba(255, 255, 255, .05); border: 2px solid rgba(255, 255, 255, .14); color: var(--ink);
  font-family: inherit; font-weight: 700; font-size: .85rem; letter-spacing: .08em;
  display: flex; flex-direction: column; align-items: center; gap: 2px; transition: border-color .15s, background .15s, transform .1s;
}
.sg-mode b { font-size: 1.25rem; font-weight: 400; }
.sg-mode:active { transform: scale(.96); }
.sg-mode[aria-checked="true"] { border-color: var(--acc); background: rgba(52, 211, 153, .14); box-shadow: 0 0 18px rgba(52, 211, 153, .25); }
.sg-mode:focus-visible, .sg-btn:focus-visible, .sg-row:focus-visible, .sg-chip:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.sg-mdesc { margin: 0; min-height: 2.6em; color: #c7d0ff; font-size: .9rem; font-weight: 600; line-height: 1.3; }
.sg-mbest { margin: 0; color: var(--acc); font-size: .85rem; font-weight: 700; letter-spacing: .06em; }
.sg-mnote { margin: -4px 0 0; color: var(--mute); font-size: .74rem; font-weight: 600; text-align: center; }
.sg-btn {
  width: 100%; padding: 13px 16px; border-radius: 14px; border: 2px solid rgba(255, 255, 255, .2); cursor: pointer;
  background: rgba(255, 255, 255, .06); color: var(--ink); font-family: inherit; font-weight: 700; font-size: 1rem; letter-spacing: .12em;
}
.sg-btn:active { transform: scale(.98); }
.sg-primary { background: linear-gradient(180deg, #34d399, #10b981); border-color: #6ee7b7; color: #04120c; box-shadow: 0 8px 22px rgba(16, 185, 129, .35); }
.sg-rows { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.sg-row {
  display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 12px 14px; border-radius: 12px; cursor: pointer;
  background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .14); color: var(--ink); font-family: inherit;
  font-weight: 700; font-size: .88rem; letter-spacing: .08em; white-space: nowrap;
}
.sg-row b { color: var(--acc); font-weight: 700; }
#trophy-list { text-align: left; max-height: 260px; overflow-y: auto; border-radius: 12px; background: rgba(255, 255, 255, .04); padding: 6px; }
.sg-count { font-size: 5.5rem; font-weight: 700; color: #fff; text-shadow: 0 0 30px rgba(52, 211, 153, .8); animation: sgpop .5s ease-out; }

/* Bottom bar */
.sg-bar { display: flex; gap: 8px; }
.sg-chip {
  flex: 1; padding: 11px 8px; border-radius: 12px; cursor: pointer; white-space: nowrap;
  background: var(--glass); border: 1px solid var(--line); color: var(--ink); font-family: inherit; font-weight: 700; font-size: .82rem; letter-spacing: .12em;
}
.sg-chip:active { transform: scale(.97); }

.sg-toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: rgba(10, 16, 48, .95); border: 1px solid var(--line); color: var(--ink); padding: 10px 16px; border-radius: 12px;
  font-weight: 700; font-size: .85rem; z-index: 50; max-width: 90vw; text-align: center;
}

/* Hide the floating bug pill (reports live in Options and Pause) */
#beta-report-trigger { display: none !important; }

/* Short or narrow stages */
.sg.tight .sg-logo { display: none; }
.sg.tight .sg-title { font-size: 1.55rem; }
.sg.compact .sg-tag { display: none; }
.sg.compact .sg-panel { gap: 7px; }
.sg.compact .sg-mode { padding: 7px 4px; }
.sg.compact .sg-mode b { font-size: 1.05rem; }
.sg.compact .sg-btn { padding: 10px 14px; }

/* Landscape phones: board left, controls in a right column */
.sg.land .sg-card { max-width: none; display: grid; grid-template-columns: 1fr 190px; grid-template-rows: auto auto 1fr auto; column-gap: 10px; }
.sg.land .sg-stage { grid-column: 1; grid-row: 1 / 5; min-height: 0; }
.sg.land .sg-hud { grid-column: 2; grid-row: 1; flex-direction: column; align-items: stretch; padding: 6px 10px; }
.sg.land .sg-hl, .sg.land .sg-hc, .sg.land .sg-hr { flex-direction: row; align-items: baseline; justify-content: space-between; }
.sg.land .sg-score { font-size: 1.25rem; }
.sg.land .sg-sub { grid-column: 2; grid-row: 2; flex-direction: column; align-items: flex-start; }
.sg.land .sg-bar { grid-column: 2; grid-row: 4; flex-direction: column; }
.sg.land .sg-chip { padding: 8px; }

@media (max-width: 380px) {
  .sg { padding-left: 6px; padding-right: 6px; }
  .sg-score { font-size: 1.45rem; }
  .sg-mode { font-size: .74rem; letter-spacing: .04em; }
  .sg-chip { font-size: .72rem; letter-spacing: .06em; }
  .sg-clock { width: 90px; }
}
@media (prefers-reduced-motion: reduce) {
  .sg-score.pop, .sg-count { animation: none; }
}

/* very short stages (landscape phones): keep PLAY visible */
.sg.compact .sg-logo { display: none; }
.sg.compact .sg-mdesc { min-height: 0; font-size: .8rem; }
.sg.compact .sg-mbest { font-size: .75rem; }
.sg.compact .sg-title { font-size: 1.45rem; }
.sg.compact .sg-ov { padding: 8px; }
.sg.compact .sg-panel { gap: 5px; }
.sg.compact .sg-h2 { font-size: 1.15rem; }

/* keep BACK reachable in the long options list */
#btnOptsBack { position: sticky; bottom: 0; flex: 0 0 auto; margin-top: 4px; box-shadow: 0 -10px 14px #0a1030; }
