/* Ultra Beam Blasters — settings sheet + parent corner. Layout approved on #25 / #167; Temple look to
   match Home v2 and the online screens (dark plum panel, gold rims, gold title, card-G rival cards).
   Colors and sizes come from theme.css / kit.css tokens. Animates transform and opacity only.
   Every pressable thing is >= var(--tap). */

#settings-root {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  --st-lock-hole: var(--table);
}
#settings-root[hidden] { display: none !important; }
.st-scrim { position: absolute; inset: 0; background: var(--scrim); animation: st-fade var(--dur-med) var(--ease-out) both; }

/* ---------- Sheet: dark plum panel, gold rim (the online code plaque recipe) ---------- */
.st-sheet {
  position: relative; display: flex; flex-direction: column;
  width: min(780px, 100%); max-height: 100%;
  background: linear-gradient(180deg, var(--table-2), var(--table-3));
  color: var(--hud-ink);
  border: var(--stroke) solid var(--ink);
  border-radius: 30px;
  box-shadow: inset 0 0 0 5px var(--gold), 0 0 0 3px var(--gold-lip), var(--shadow-lg);
  overflow: hidden;
  animation: st-rise var(--dur-slow) var(--ease-pop) both;
}
.st-head {
  position: relative; flex: none; display: flex; align-items: center; justify-content: center;
  min-height: 92px; padding: 8px 76px;
}
.st-title {
  display: flex; align-items: center; gap: 14px; margin: 0;
  font: var(--fw-display) 3rem / 1 var(--font-display); color: var(--gold-hi);
  -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; text-shadow: 0 3px 0 var(--ink);
}
.st-title::before, .st-title::after { content: ''; width: clamp(20px, 5vw, 70px); height: 4px; border-radius: 2px; background: linear-gradient(90deg, transparent, var(--gold)); }
.st-title::after { transform: scaleX(-1); }
.st-sheet[data-view='kid'] .st-title--parent, .st-sheet[data-view='parent'] .st-title--kid { display: none; }
.st-sheet[data-view='kid'] .st-back { display: none; }

/* round plum buttons with a gold rim (same as the online back button) */
.st-round {
  -webkit-appearance: none; appearance: none; cursor: pointer;
  position: absolute; top: 50%; width: 60px; height: 60px; margin-top: -30px; padding: 0;
  display: grid; place-items: center; font-size: 28px;
  border: var(--stroke) solid var(--ink); border-radius: 50%;
  background: var(--table-2); color: var(--surface);
  box-shadow: inset 0 0 0 4px var(--gold), var(--shadow-md);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: transform var(--dur-fast) var(--ease-out);
}
.st-round:active { transform: scale(0.92); }
.st-close { right: 16px; }
.st-back { left: 16px; }
.st-round:focus-visible, .st-switch:focus-visible, .st-face:focus-visible, .st-seg:focus-visible, .st-lock:focus-visible, .st-input:focus-visible { outline: 4px solid var(--focus); outline-offset: 3px; }

.st-view { display: none; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.st-sheet[data-view='kid'] .st-view--kid, .st-sheet[data-view='parent'] .st-view--parent { display: block; animation: st-fade var(--dur-med) var(--ease-out) both; }

/* ---------- Kid view ---------- */
.st-body { display: grid; gap: 12px; padding: 4px 24px 22px; }
.st-row {
  display: flex; align-items: center; gap: 16px; min-height: 76px; padding: 8px 20px;
  background: var(--arena-3); border-radius: var(--radius-lg);
  box-shadow: inset 0 0 0 2px var(--table-line), inset 0 6px 0 rgba(0, 0, 0, 0.25);
}
.st-ico { position: relative; flex: none; display: grid; place-items: center; width: 52px; height: 52px; font-size: 44px; color: var(--gold-hi); }
.st-ico .st-svg { width: 1em; height: 1em; }
.st-row[data-off] .st-ico { color: var(--hud-soft); }
.st-row[data-off] .st-ico::after { /* slash: off is never color alone */
  content: ''; position: absolute; left: 4px; right: 4px; top: 50%; height: 6px; margin-top: -3px;
  background: var(--bad); border: 2px solid var(--arena-3); border-radius: 4px; transform: rotate(-42deg);
}
.st-label { flex: 1; font: var(--fw-display) var(--fs-xl) / 1 var(--font-display); color: var(--hud-ink); }

.st-switch {
  -webkit-appearance: none; appearance: none; cursor: pointer; flex: none; position: relative;
  width: 108px; min-height: 60px; height: 60px; padding: 0;
  border: var(--stroke) solid var(--ink); border-radius: var(--radius-pill);
  background: var(--table-2);
  box-shadow: inset 0 0 0 2px var(--table-line), inset 0 4px 0 rgba(0, 0, 0, 0.3);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: background-color var(--dur-fast) linear;
}
.st-switch[aria-checked='true'] { background: var(--cel-gold); box-shadow: inset 0 0 0 2px var(--gold-lip), var(--glow-gold); }
.st-knob {
  position: absolute; left: 4px; top: 50%; width: 44px; height: 44px; margin-top: -22px;
  border: var(--stroke) solid var(--ink); border-radius: 50%;
  background: var(--surface); box-shadow: 0 3px 0 rgba(42, 30, 46, 0.35);
  transition: transform var(--dur-med) var(--ease-pop);
}
.st-switch[aria-checked='true'] .st-knob { transform: translateX(48px); }

/* rival divider: gold rules around the robot icon */
.st-divider { display: flex; align-items: center; gap: 14px; margin: 4px 0 -2px; color: var(--gold-hi); }
.st-divider::before, .st-divider::after { content: ''; flex: 1; height: 4px; border-radius: 2px; background: linear-gradient(90deg, transparent, var(--gold)); }
.st-divider::after { transform: scaleX(-1); }
.st-divider span { display: grid; place-items: center; font-size: 34px; }

/* rival: three card-G hero cards (Narwhee: sleepy / happy / fierce), lit pips = strength */
.st-faces { display: flex; justify-content: center; align-items: flex-end; gap: clamp(16px, 4vw, 40px); padding: 14px 0 6px; }
.st-face {
  -webkit-appearance: none; appearance: none; cursor: pointer; font: inherit; color: inherit;
  position: relative; display: block; padding: 0; border: 0; background: none; min-width: var(--tap);
  --card-w: clamp(84px, 18dvh, 132px);
  border-radius: calc(var(--card-w) * var(--card-corner));
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.st-face .uc { display: block; --w: var(--card-w); }
.st-face .uc-art.is-crop { transform: scale(1.32); transform-origin: 50% 44%; } /* old round crops: zoom past the baked ring */
.st-face .uc-pip.is-on { background: var(--gold); }
.st-face .uc-pip.is-on .ui-icon { color: var(--gold-ink); }
.st-face:active .uc { --zoom: 0.95; }
.st-face[aria-checked='true'] .uc {
  --lift: -0.5em; --zoom: 1.08;
  box-shadow: 0 0 0 var(--card-keyline) var(--edge), 0 0 0 0.28em var(--gold), var(--glow-gold), var(--card-drop);
}
.st-face[aria-checked='true'] .uc::after { box-shadow: inset 0 0 0 calc(var(--w) * 0.03) var(--gold); }

.st-actions { display: flex; align-items: center; gap: 16px; margin-top: 6px; }
.st-actions .st-act { flex: 1; min-width: 0; min-height: 68px; padding: 0 18px; font-size: var(--fs-xl); white-space: nowrap; }
.st-actions .ui-btn--gold { background: var(--cel-gold); }
.st-actions .st-act .st-svg { width: 1.1em; height: 1.1em; flex: none; }
#settings-root[data-ctx='home'] .st-only-game, #settings-root[data-ctx='game'] .st-only-home { display: none; }

/* lock: hold to open the parent corner */
.st-lock {
  -webkit-appearance: none; appearance: none; cursor: pointer; flex: none; position: relative;
  width: 100px; height: 100px; margin: 0 0 4px; padding: 0; border: 0; border-radius: 50%;
  background: var(--table-2); color: var(--surface);
  box-shadow: 0 0 0 3px var(--ink), 0 5px 0 3px var(--ink);
  display: grid; place-items: center; align-content: center; gap: 0;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent; touch-action: none;
}
.st-lock__ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); pointer-events: none; }
.st-lock__track, .st-lock__arc { fill: none; stroke-width: 5; }
.st-lock__track { stroke: var(--gold-lip); }
.st-lock__arc { stroke: var(--gold-hi); stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 100; }
.st-lock.is-holding .st-lock__arc { animation: st-hold 1500ms linear forwards; }
.st-lock.is-holding { transform: scale(0.95); }
.st-lock__ico { font-size: 34px; line-height: 0; display: grid; margin-top: -4px; }
.st-lock__ico .st-svg { width: 1em; height: 1em; }
.st-lock__txt { margin-top: 4px; max-width: 72px; font: var(--fw-bold) 16px / 1.05 var(--font-display); text-align: center; color: var(--hud-soft); } /* >= 16 px (a11y #984) */
.st-lock.is-nudge { animation: st-nudge 420ms var(--ease-out); }

/* ---------- Parent view (grown-ups: words are fine here) ---------- */
.st-pbody { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 20px; padding: 4px 24px 24px; align-items: start; }
.st-pcol { display: grid; gap: 14px; align-content: start; min-width: 0; }
.st-pcol--right { gap: 14px; }
/* Play on another tablet: QR on a cream card (dark modules need a light field to scan) */
.st-share { display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: var(--radius-md); background: var(--arena-3); box-shadow: inset 0 0 0 2px var(--gold); }
.st-share[hidden] { display: none; }
.st-share__qr { flex: none; width: clamp(112px, 20dvh, 150px); aspect-ratio: 1; padding: 4px; border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); }
.st-share__qr svg { display: block; width: 100%; height: 100%; }
.st-share__txt { display: grid; gap: 6px; min-width: 0; }
.st-share__url { font: var(--fw-bold) var(--fs-sm) / 1.25 var(--font-body); color: var(--hud-ink); overflow-wrap: anywhere; user-select: all; -webkit-user-select: all; }
.st-pcol--log { background: var(--arena-3); border-radius: var(--radius-md); padding: 12px 14px; box-shadow: inset 0 0 0 2px var(--table-line); }
.st-field { display: grid; gap: 6px; }
.st-field__lbl { margin: 0; font: var(--fw-display) var(--fs-md) / 1 var(--font-display); color: var(--gold-hi); }
.st-field__lbl small { font: var(--fw-body) var(--fs-xs) var(--font-body); color: var(--hud-soft); }
.st-hint { color: var(--hud-soft); font-size: var(--fs-xs); }
.st-input {
  font: var(--fw-bold) var(--fs-md) var(--font-body); color: var(--ink); background: var(--surface); min-height: var(--tap);
  border: var(--stroke) solid var(--ink); border-radius: var(--radius-md); padding: 6px 14px; width: 100%;
}
.st-segs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.st-seg {
  -webkit-appearance: none; appearance: none; cursor: pointer; min-height: var(--tap); padding: 0 6px;
  font: var(--fw-display) var(--fs-sm) / 1 var(--font-display); color: var(--hud-ink);
  background: var(--table-2); border: var(--stroke) solid var(--ink); border-radius: var(--radius-md);
  box-shadow: inset 0 0 0 2px var(--table-line);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.st-seg[aria-checked='true'] { background: var(--cel-gold); color: var(--gold-ink); box-shadow: inset 0 0 0 2px var(--gold-lip); }
.st-pbody .st-row { min-height: 60px; padding: 4px 14px; }
.st-pbody .st-label { font-size: var(--fs-md); }
.st-pbody .st-switch { width: 92px; height: 52px; min-height: 52px; }
.st-pbody .st-knob { width: 36px; height: 36px; margin-top: -18px; }
.st-pbody .st-switch[aria-checked='true'] .st-knob { transform: translateX(40px); }
.st-info { margin: 0; color: var(--hud-soft); font-size: var(--fs-sm); }
.st-info code { color: var(--hud-ink); font-weight: var(--fw-bold); }
.st-log { max-height: min(46vh, 340px); min-height: 120px; overflow: auto; margin: 0; padding: 0 4px 0 28px; font-size: var(--fs-sm); color: var(--hud-ink); overscroll-behavior: contain; }
.st-log li { margin: 3px 0; }
.st-log li .small { color: var(--hud-soft); font-size: var(--fs-xs); }
.st-log li.turn-line { margin-top: 10px; padding-top: 6px; border-top: 1px dashed var(--table-line); font-weight: var(--fw-bold); }
.st-log li.end-line { font-weight: 800; color: var(--gold-hi); }

/* ---------- Motion ---------- */
@keyframes st-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes st-rise { from { opacity: 0; transform: translateY(40px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes st-hold { to { stroke-dashoffset: 0; } }
@keyframes st-nudge { 0%, 100% { transform: none; } 25% { transform: translateX(-6px) rotate(-6deg); } 60% { transform: translateX(5px) rotate(5deg); } }
@media (prefers-reduced-motion: reduce) {
  .st-sheet, .st-scrim, .st-view, .st-lock.is-nudge { animation: none !important; }
  .st-knob { transition: none; }
}

/* short landscape screens: tighter rows so the sheet still fits */
@media (max-height: 620px) {
  .st-head { min-height: 64px; }
  .st-title { font-size: var(--fs-xl); }
  .st-round { width: 52px; height: 52px; margin-top: -26px; }
  .st-body { gap: 8px; padding: 2px 16px 14px; }
  .st-row { min-height: 60px; }
  .st-label { font-size: var(--fs-lg); }
  .st-actions .st-act { min-height: 56px; font-size: var(--fs-lg); }
  .st-lock { width: 76px; height: 76px; }
}

/* the tutorial hand (web/onboarding.js .ob-layer) never shows over the sheet (a11y #976) */
body:has(#settings-root:not([hidden])) .ob-layer { visibility: hidden; }
