/* =========================================================================
   SpinSlots — premium dark design system
   ========================================================================= */
:root {
  --bg: #0B0E1A; --bg2: #11152A;
  --surface: rgba(255,255,255,0.045); --surface-2: rgba(255,255,255,0.07);
  --stroke: rgba(255,255,255,0.08); --stroke-2: rgba(255,255,255,0.14);
  --violet: #8D68F7; --violet-d: #6E4BE0; --green: #34D399; --amber: #F5B544; --rose: #FB7185;
  --text: #F4F5FB; --muted: #9AA0B8; --muted-2: #6E7591;
  --radius: 24px; --radius-sm: 16px; --shadow: 0 18px 40px rgba(0,0,0,0.45);
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1100px 700px at 50% -10%, rgba(141,104,247,0.22), transparent 60%),
    radial-gradient(900px 600px at 90% 110%, rgba(52,211,153,0.12), transparent 55%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%);
  background-attachment: fixed; -webkit-font-smoothing: antialiased;
  overflow: hidden; user-select: none; -webkit-user-select: none;
}
#app { position: relative; height: 100%; max-width: 520px; margin: 0 auto; overflow: hidden; }

.view {
  position: absolute; inset: 0; display: none; flex-direction: column;
  padding: calc(var(--safe-top) + 14px) 20px calc(var(--safe-bottom) + 18px);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  animation: viewIn 0.34s cubic-bezier(0.22, 1, 0.36, 1);
}
.view.is-active { display: flex; }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px) scale(0.99); } to { opacity: 1; transform: none; } }
.hidden { display: none !important; }

.btn {
  appearance: none; border: none; border-radius: var(--radius-sm); font: inherit;
  font-weight: 650; font-size: 17px; color: var(--text); padding: 16px 20px; width: 100%;
  cursor: pointer; transition: transform 0.12s ease, filter 0.2s ease, opacity 0.2s ease;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
}
.btn:active { transform: scale(0.97); }
.btn-sm { padding: 12px 16px; font-size: 15px; width: auto; }
.btn-primary { background: linear-gradient(135deg, var(--violet), var(--violet-d)); box-shadow: 0 12px 26px rgba(141,104,247,0.42); color: #fff; }
.btn-primary:active { filter: brightness(1.05); }
.btn:disabled, .wheel-hub:disabled { opacity: 0.45; cursor: default; box-shadow: none; filter: grayscale(0.15); }
.btn-spin:disabled::after { opacity: 0; }
.btn:focus-visible, .icon-btn:focus-visible, .mini-btn:focus-visible,
.chip-row button:focus-visible, .seg button:focus-visible, .wheel-hub:focus-visible, .field-input:focus-visible {
  outline: 2px solid var(--violet); outline-offset: 2px;
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.btn-soft { background: var(--surface-2); border: 1px solid var(--stroke); }
.btn-ghost { background: transparent; border: 1px solid var(--stroke-2); color: var(--text); }
.btn-text { background: transparent; color: var(--muted); font-weight: 600; font-size: 15px; }
.btn-danger { color: var(--rose); }
.stack { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.row { display: flex; gap: 12px; } .row .btn { flex: 1; }

.onboard { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 28px; padding: 12px 4px; }
.onboard-track { position: relative; overflow: hidden; }
.onboard-slide { display: none; text-align: center; padding: 8px; animation: viewIn 0.4s cubic-bezier(0.22,1,0.36,1); }
.onboard-slide.is-active { display: block; }
.onboard-art {
  font-size: 76px; line-height: 1; width: 132px; height: 132px; margin: 0 auto 26px;
  display: flex; align-items: center; justify-content: center; border-radius: 36px;
  background: linear-gradient(160deg, rgba(141,104,247,0.28), rgba(52,211,153,0.12));
  border: 1px solid var(--stroke-2); box-shadow: var(--shadow);
}
.onboard h1 { font-size: 28px; font-weight: 800; margin: 0 0 12px; letter-spacing: -0.4px; }
.onboard p { font-size: 17px; color: var(--muted); margin: 0 auto; max-width: 320px; line-height: 1.5; }
.onboard-dots { display: flex; gap: 8px; justify-content: center; }
.onboard-dots .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--stroke-2); transition: all 0.3s ease; }
.onboard-dots .dot.is-on { width: 22px; border-radius: 4px; background: var(--violet); }
.onboard-actions { display: flex; flex-direction: column; gap: 10px; }

.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 44px; margin-bottom: 4px; }
.topbar-title { font-size: 18px; font-weight: 700; }
.wordmark { display: flex; align-items: center; gap: 9px; font-size: 20px; font-weight: 800; letter-spacing: -0.3px; }
.wordmark-dot { width: 14px; height: 14px; border-radius: 50%;
  background: conic-gradient(from 0deg, var(--violet), var(--green), var(--amber), var(--rose), var(--violet));
  box-shadow: 0 0 14px rgba(141,104,247,0.6); }
.icon-btn { appearance: none; background: var(--surface); color: var(--text); width: 44px; height: 44px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; cursor: pointer; border: 1px solid var(--stroke); }
.icon-btn:active { transform: scale(0.94); }
.home-sub { display: flex; align-items: center; justify-content: space-between; margin: 6px 2px 10px; }
.wheel-name { font-size: 15px; color: var(--muted); font-weight: 600; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--stroke); font-size: 13px; font-weight: 650; color: var(--text); }
.chip-streak b { color: var(--amber); }

.wheel-stage { position: relative; display: flex; align-items: center; justify-content: center; margin: 4px auto 18px; width: 100%; max-width: 340px; aspect-ratio: 1; }
.wheel-wrap { position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
#wheel { width: 100%; height: 100%; filter: drop-shadow(0 16px 30px rgba(0,0,0,0.5)); transform: rotate(0deg); will-change: transform; }
.wheel-pointer { position: absolute; top: -2px; left: 50%; transform: translateX(-50%); width: 0; height: 0;
  border-left: 15px solid transparent; border-right: 15px solid transparent; border-top: 26px solid #F4F5FB; z-index: 3;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.5)); }
.wheel-hub { position: absolute; width: 30%; height: 30%; border-radius: 50%; border: none; cursor: pointer;
  background: radial-gradient(circle at 50% 35%, #1a1f3a, #0d1022); color: var(--text); font-weight: 800; font-size: 17px; letter-spacing: 0.3px;
  box-shadow: inset 0 0 0 4px rgba(141,104,247,0.85), 0 6px 16px rgba(0,0,0,0.5); z-index: 2; transition: transform 0.12s ease; }
.wheel-hub:active { transform: scale(0.92); }
.wheel-hub.is-spinning { color: var(--muted-2); }
.wheel-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; background: rgba(11,14,26,0.72); border-radius: 50%; }
.wheel-empty p { color: var(--muted); margin: 0; font-weight: 600; }
.btn-spin { font-size: 19px; font-weight: 800; letter-spacing: 0.3px; margin-top: 2px; position: relative; overflow: hidden; }
.btn-spin::after { content: ""; position: absolute; inset: 0; background: radial-gradient(120px 60px at 50% 0%, rgba(255,255,255,0.35), transparent 70%); opacity: 0.5; }

.home-stats { display: flex; gap: 10px; margin: 16px 0; }
.stat-card { flex: 1; background: var(--surface); border: 1px solid var(--stroke); border-radius: var(--radius-sm); padding: 14px 10px; text-align: center; }
.stat-value { font-size: 26px; font-weight: 800; letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--violet), var(--green)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; font-weight: 600; }

.centered { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; text-align: center; }
.centered .stack { max-width: 360px; }
.result-card { background: var(--surface); border: 1px solid var(--stroke); border-radius: 28px; padding: 34px 28px; width: 100%; max-width: 360px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.result-emoji { font-size: 72px; line-height: 1; }
.result-card h2 { font-size: 30px; font-weight: 800; margin: 4px 0 0; letter-spacing: -0.5px; }
.result-duration { font-size: 18px; color: var(--muted); } .result-duration b { color: var(--text); font-size: 22px; }

.timer-head { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.timer-emoji { font-size: 46px; } .timer-head h2 { font-size: 24px; font-weight: 800; margin: 0; }
.timer-ring-wrap { position: relative; width: 260px; height: 260px; }
.ring-track { fill: none; stroke: var(--surface-2); stroke-width: 14; }
.ring-progress { fill: none; stroke: url(#ringGrad); stroke-width: 14; stroke-linecap: round; transition: stroke-dashoffset 0.4s linear; }
.timer-readout { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.timer-time { font-size: 56px; font-weight: 800; letter-spacing: 1px; font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.timer-state { font-size: 14px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: 1px; }

.celebrate { width: 110px; height: 110px; border-radius: 50%; background: linear-gradient(135deg, var(--violet), var(--green));
  display: flex; align-items: center; justify-content: center; box-shadow: 0 16px 40px rgba(52,211,153,0.4); animation: pop 0.5s cubic-bezier(0.2, 1.4, 0.4, 1); }
.celebrate-check { font-size: 58px; color: #fff; font-weight: 800; }
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }
.done-title { font-size: 30px; font-weight: 800; margin: 6px 0 0; } .done-sub { color: var(--muted); margin: 0; }
.done-slot { font-size: 22px; font-weight: 700; } .done-stats { max-width: 360px; }

.editor-list { display: flex; flex-direction: column; gap: 10px; padding-bottom: 10px; }
.slot-row { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--stroke); border-radius: var(--radius-sm); padding: 12px 14px; }
.slot-row.is-disabled { opacity: 0.5; }
.slot-emoji { width: 46px; height: 46px; border-radius: 13px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 24px; background: var(--surface-2); }
.slot-info { flex: 1; min-width: 0; }
.slot-title { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.slot-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.mini-btn { appearance: none; border: 1px solid var(--stroke); background: var(--surface-2); color: var(--muted); width: 32px; height: 32px; border-radius: 9px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.mini-btn:active { transform: scale(0.9); } .mini-btn:disabled { opacity: 0.3; }
.toggle { position: relative; width: 48px; height: 30px; flex-shrink: 0; cursor: pointer; }
.toggle input { display: none; }
.toggle .track { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--stroke); transition: background 0.2s ease; }
.toggle .knob { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform 0.2s ease; }
.toggle input:checked + .track { background: linear-gradient(135deg, var(--violet), var(--green)); border-color: transparent; }
.toggle input:checked + .track + .knob { transform: translateX(18px); }
.editor-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; color: var(--muted); }
.editor-empty-art { font-size: 64px; }

.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,0.55); display: flex; align-items: flex-end; justify-content: center; animation: fade 0.25s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet { width: 100%; max-width: 520px; background: linear-gradient(180deg, #161A2E, #0F1322);
  border-top-left-radius: 28px; border-top-right-radius: 28px; border-top: 1px solid var(--stroke-2);
  padding: 12px 20px calc(var(--safe-bottom) + 22px); max-height: 90%; overflow-y: auto; animation: sheetUp 0.32s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
.sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: var(--stroke-2); margin: 4px auto 14px; }
.sheet h3 { margin: 0 0 16px; font-size: 22px; font-weight: 800; }
.field-label { display: flex; justify-content: space-between; align-items: center; font-size: 14px; font-weight: 650; color: var(--muted); margin: 16px 2px 8px; }
.field-value { color: var(--text); }
.field-input { width: 100%; appearance: none; border: 1px solid var(--stroke); background: var(--surface); color: var(--text); border-radius: 14px; padding: 14px 16px; font: inherit; font-size: 17px; outline: none; }
.field-input:focus { border-color: var(--violet); }
.field-range { width: 100%; accent-color: var(--violet); height: 28px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-row button { appearance: none; border: 1px solid var(--stroke); background: var(--surface); color: var(--text); padding: 9px 14px; border-radius: 999px; cursor: pointer; font: inherit; font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.chip-row button.is-on { border-color: transparent; background: linear-gradient(135deg, var(--violet), var(--violet-d)); color: #fff; }
.chip-row button.emoji-chip { font-size: 22px; padding: 6px 10px; }
.seg { display: flex; background: var(--surface); border: 1px solid var(--stroke); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { flex: 1; appearance: none; border: none; background: transparent; color: var(--muted); padding: 10px; border-radius: 10px; cursor: pointer; font: inherit; font-size: 14px; font-weight: 650; }
.seg button.is-on { background: var(--surface-2); color: var(--text); }
.sheet-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
a.btn { text-decoration: none; }
.settings-about { color: var(--muted); font-size: 14px; margin: -2px 2px 6px; }

.toast { position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 26px); transform: translateX(-50%); z-index: 60;
  background: rgba(20,24,42,0.96); border: 1px solid var(--stroke-2); color: var(--text); padding: 12px 18px; border-radius: 14px; font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow); max-width: 90%; animation: toastIn 0.25s ease; }
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.05ms !important; }
  .view { animation: none; }
}
@media (min-height: 760px) { .wheel-stage { max-width: 360px; } }
@media (max-height: 700px) {
  .centered { gap: 18px; } .wheel-stage { max-width: 290px; } .home-stats { margin: 12px 0; }
  .timer-ring-wrap { width: 216px; height: 216px; } .timer-time { font-size: 44px; } .timer-emoji { font-size: 38px; }
  .result-emoji { font-size: 60px; } .celebrate { width: 92px; height: 92px; } .celebrate-check { font-size: 48px; }
}
