@font-face {
  font-family:Apercu;
  src:url('./assets/ApercuMonoProBold.ttf') format('truetype');
  font-weight:700;
  font-display:swap;
}

@font-face {
  font-family:Chancery;
  src:url('./assets/AppleChancery.ttf') format('truetype');
  font-display:swap;
}

:root {
  --header-height:132px;
  --page-gutter:28px;
  font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
  color:#fff;
  color-scheme:dark;
  --line:rgba(255,255,255,.24);
  --panel:rgba(10,15,26,.36);
  --accent:#ffe475;
  --wheel-gradient:conic-gradient(from 90deg,#cc3d3d,#c5943d,#9ac43d,#3cc577,#3dc3c3,#3d64c5,#923dc5,#cc3d3d);
}

* {
  box-sizing:border-box;
}

body {
  margin:0;
  min-width:300px;
  min-height:100vh;
  min-height:100dvh;
  --page-shade:rgba(0,0,0,.22);
  --page-gradient:conic-gradient(from 90deg at 50% 50%,#ff3b30 0deg,#ff3b30 36deg,#ff9500 72deg,#ffcc00 108deg,#34c759 144deg,#34c759 180deg,#30b0c7 216deg,#007aff 252deg,#5856d6 288deg,#af52de 324deg,#ff3b30 360deg);
  /* The body's background propagates to the document canvas, including the
     iOS standalone safe area. A fixed child cannot paint that canvas. */
  background-image:linear-gradient(var(--page-shade),var(--page-shade)),var(--page-gradient);
  background-size:100% 100lvh;
  background-attachment:fixed;
}

button,input,select {
  font:inherit;
}

button,a,input,select {
  -webkit-tap-highlight-color:transparent;
}

button {
  color:inherit;
  cursor:pointer;
}

button:disabled {
  cursor:default;
  opacity:.45;
}

button:focus-visible,input:focus-visible,select:focus-visible,[tabindex]:focus-visible {
  outline:3px solid #ffe475;
  outline-offset:4px;
}

button {
  border:0;
  background:none;
}

button svg {
  width:22px;
  height:22px;
  flex-shrink:0;
}

input {
  min-width:0;
  color:white;
  background:rgba(255,255,255,.09);
  border:1px solid var(--line);
  border-radius:9px;
  padding:13px 14px;
}

input::placeholder {
  color:rgba(255,255,255,.55);
}

[hidden] {
  display:none!important;
}

svg {
  display:block;
}

.background {
  /* Keep a decorative layer for browsers that make the page canvas
     transparent. The body also paints the same gradient for iOS safe areas. */
  position:fixed;
  inset:0;
  min-height:100lvh;
  z-index:-1;
  pointer-events:none;
  background-image:linear-gradient(var(--page-shade),var(--page-shade)),var(--page-gradient);
  background-size:100% 100lvh;
}

body[data-background=green] {
  --page-gradient:conic-gradient(from 90deg,#134c3a,#71b26c,#134c3a);
}

body[data-background=blue] {
  --page-gradient:conic-gradient(from 90deg,#134e5e,#61c0db,#134e5e);
}

body[data-background=pink] {
  --page-gradient:conic-gradient(from 90deg,#e95b7c,#ffc0cb,#e95b7c);
}

body[data-page=questions],body[data-page=settings] {
  --page-shade:rgba(0,0,0,.48);
}

#app {
  max-width:1360px;
  min-height:100svh;
  margin:0 auto;
  padding:0 max(var(--page-gutter),env(safe-area-inset-right)) env(safe-area-inset-bottom) max(var(--page-gutter),env(safe-area-inset-left));
}

.topbar {
  height:calc(var(--header-height) + env(safe-area-inset-top));
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding-top:env(safe-area-inset-top);
}

.brand {
  font:clamp(42px,4.5vw,66px)/1.12 Chancery,Georgia,serif;
  white-space:nowrap;
  text-shadow:0 0 3px #ffffff80,0 0 20px #ffffff99,0 0 48px #ffffff52;
  padding:10px 0;
}

.toolbar {
  display:flex;
  align-items:center;
  gap:9px;
  flex-shrink:0;
}

.icon-button {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:44px;
  height:44px;
  border-radius:50%;
  transition:background .15s;
}

.icon-button:hover {
  background:rgba(255,255,255,.15);
}

.icon-button[aria-current=page] {
  background:rgba(255,255,255,.19);
}

.text-button {
  display:inline-flex;
  align-items:center;
  gap:6px;
  min-height:44px;
  border-radius:10px;
  padding:8px 12px;
}

.text-button:hover {
  background:rgba(255,255,255,.12);
}

.text-button.accent {
  color:var(--accent);
  font-weight:600;
}

.back {
  margin-left:-12px;
}

.back svg {
  width:16px;
}

.wheel-page {
  min-height:calc(100svh - var(--header-height) - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  display:grid;
  grid-template-columns:minmax(210px,.9fr) minmax(0,1.7fr);
  align-items:center;
  gap:30px;
  padding-bottom:20px;
}

.question-area {
  display:flex;
  flex-direction:column;
  align-items:center;
  text-align:center;
  gap:20px;
  max-width:380px;
  justify-self:center;
  width:100%;
}


.question-button {
  font-size:clamp(22px,2.5vw,34px);
  line-height:1.25;
  font-weight:650;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:12px;
  padding:6px 4px;
  overflow-wrap:anywhere;
}

.question-button span {
  min-width:0;
}

.question-button svg {
  width:16px;
  opacity:.6;
}


.result {
  font-size:clamp(24px,2.8vw,38px);
  font-weight:650;
  line-height:1.25;
  min-height:66px;
  display:flex;
  align-items:center;
  justify-content:center;
  width:100%;
  padding:8px 12px;
  overflow-wrap:anywhere;
  text-shadow:0 0 14px #ffffffb3;
}

.result.revealed {
  text-shadow:0 0 6px #ffffffe6,0 0 22px #ffffffb3,0 0 48px #ffffff66;
  animation:reveal 1.0s cubic-bezier(.2,.7,.2,1) both;
}

.result .waiting {
  font-size:15px;
  font-weight:400;
  opacity:.7;
  text-shadow:none;
}


.wheel-area {
  width:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  flex-direction:column;
  gap:26px;
}

.wheel-stage {
  position:relative;
  width:min(100%,calc(100svh - var(--header-height) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 44px));
  min-width:0;
  max-width:880px;
  aspect-ratio:1;
  touch-action:none;
  user-select:none;
  -webkit-user-select:none;
  border-radius:50%;
  cursor:grab;
  isolation:isolate;
}

/* The rim radiates independently of the rotating face. Box shadows do not
   enlarge the scrollable area, even when the halo extends beyond the wheel. */
.wheel-stage::before {
  content:'';
  position:absolute;
  inset:1.6%;
  border-radius:50%;
  pointer-events:none;
  box-shadow:0 0 12px 4px #ffffffd9,
             0 0 38px 14px #ffffff94,
             0 0 85px 30px #ffffff57,
             0 0 145px 52px #ffffff30,
             0 8px 14px #00000030;
}

/* Clip the rotating square's invisible corners at a stationary circle.
   Otherwise its 45-degree bounding box makes scrollbars appear mid-spin. */
.wheel-rotor {
  position:absolute;
  inset:0;
  border-radius:50%;
  overflow:hidden;
}

.wheel-stage:active {
  cursor:grabbing;
}

.wheel-face {
  position:absolute;
  inset:1%;
  border-radius:50%;
  background:var(--wheel-gradient);
  will-change:transform;
}

.wheel-face svg {
  width:100%;
  height:100%;
  overflow:visible;
}

.segments {
  stroke:#fff;
  stroke-width:2.4;
  stroke-linejoin:round;
  filter:drop-shadow(0 0 3px #ffffffb3);
}

.wheel-hub {
  position:absolute;
  z-index:2;
  left:43%;
  top:43%;
  width:14%;
  height:14%;
  border:2.5px solid #fff;
  border-radius:50%;
  background:var(--wheel-gradient);
  box-shadow:0 0 5px #fffc,0 0 11px #ffffff73,0 3px 8px #0005;
  pointer-events:none;
}

.wheel-pointer {
  position:absolute;
  z-index:1;
  left:45.6%;
  top:37.2%;
  width:8.8%;
  height:10.4%;
  overflow:visible;
  filter:drop-shadow(0 0 2.5px #ffffffb3) drop-shadow(0 2px 2px #0004);
  pointer-events:none;
}

.wheel-pointer path {
  fill:var(--pointer,#ff3b30);
  stroke:#fff;
  stroke-width:1.8;
  stroke-linejoin:round;
}


.page-footer {
  height:42px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  font-size:11px;
  opacity:.65;
  gap:15px;
}

.footer-note {
  display:flex;
  align-items:center;
  gap:7px;
}

.status-dot {
  width:5px;
  height:5px;
  flex-shrink:0;
  border-radius:50%;
  background:#c8f0cb;
}

.install-button {
  font-size:12px;
  padding:8px 0;
  text-decoration:underline;
  text-underline-offset:3px;
}

.sheet {
  width:min(100%,720px);
  margin:24px auto 60px;
}

.sheet-heading {
  font-size:29px;
  font-weight:650;
  letter-spacing:-.02em;
  margin:0 0 30px;
}

.section-label {
  font-size:12px;
  color:#ffffffa6;
  margin:25px 4px 10px;
  font-weight:600;
}

.group {
  background:var(--panel);
  border:1px solid #ffffff17;
  border-radius:15px;
  overflow:hidden;
  backdrop-filter:blur(18px);
}

.setting-row {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:20px;
  padding:19px 20px;
}

.setting-row+.setting-row {
  border-top:1px solid #ffffff15;
}

.setting-title {
  font-size:15px;
  font-weight:600;
  display:block;
}

.setting-description {
  display:block;
  font-size:12px;
  line-height:1.5;
  opacity:.6;
  margin-top:5px;
}

.palette-row {
  padding:18px 20px 20px;
}

.palettes {
  display:grid;
  grid-template-columns:repeat(5,1fr);
  gap:10px;
}

.palettes.backgrounds {
  grid-template-columns:repeat(4,1fr);
}

.palette-button {
  border:1px solid transparent;
  border-radius:11px;
  padding:10px 4px;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:9px;
  font-size:11px;
}

.palette-button:hover {
  background:#ffffff0a;
}

.palette-button[aria-pressed=true] {
  border-color:#ffffffb3;
  background:#ffffff14;
}

.swatch {
  width:43px;
  height:43px;
  border:1.5px solid #ffffffb3;
  border-radius:50%;
  display:block;
  box-shadow:0 0 6px #ffffff30;
}

.rainbow-swatch {
  background:conic-gradient(#f55,#fb5,#dd4,#5b8,#5cc,#67f,#c6d,#f55);
}

.flat-swatch {
  background:conic-gradient(#cc3d3d 0deg 72deg,#c59c3d 72deg 144deg,#93c53d 144deg 216deg,#3dc56c 216deg 288deg,#3dc5c5 288deg);
}

.green-swatch {
  background:conic-gradient(#134c3a,#71b26c,#134c3a);
}

.blue-swatch {
  background:conic-gradient(#134e5e,#61c0db,#134e5e);
}

.pink-swatch {
  background:conic-gradient(#e95b7c,#ffc0cb,#e95b7c);
}

.switch {
  position:relative;
  width:46px;
  height:44px;
  display:flex;
  align-items:center;
  flex-shrink:0;
}

.switch input {
  position:absolute;
  inset:0;
  opacity:0;
  cursor:pointer;
  margin:0;
  width:100%;
  height:100%;
  z-index:1;
}

.switch span {
  position:relative;
  display:block;
  width:100%;
  height:28px;
  border-radius:20px;
  background:#ffffff30;
  transition:background .2s;
}

.switch span::after {
  content:'';
  position:absolute;
  top:3px;
  left:3px;
  width:22px;
  height:22px;
  border-radius:50%;
  background:#fff;
  box-shadow:0 1px 4px #0004;
  transition:transform .2s;
}

.switch input:checked+span {
  background:#34c759;
}

.switch input:checked+span::after {
  transform:translateX(18px);
}

.switch input:focus-visible+span {
  outline:3px solid var(--accent);
  outline-offset:4px;
}

.segmented {
  display:flex;
  padding:3px;
  border-radius:9px;
  background:#0003;
  gap:3px;
  min-width:175px;
}

.segmented button {
  flex:1;
  border-radius:6px;
  padding:7px 12px;
  min-height:44px;
  font-size:13px;
}

.segmented button[aria-pressed=true] {
  background:#ffffff30;
  box-shadow:0 1px 4px #0002;
}

.segmented button:disabled {
  opacity:.35;
}

.settings-about {
  font-size:13px;
  line-height:1.8;
  text-align:center;
  opacity:.67;
  margin:35px auto;
  max-width:430px;
}

.about-brand {
  font:26px Chancery,Georgia,serif;
  margin-bottom:8px;
  display:block;
}

.question-picker-row {
  display:flex;
  gap:10px;
  margin-bottom:26px;
}

.question-picker-row select {
  width:100%;
  border:1px solid var(--line);
  border-radius:10px;
  padding:12px;
  background:#172c39;
  color:#fff;
}

.question-title-label {
  display:block;
  font-size:12px;
  opacity:.65;
  margin:0 0 9px 4px;
}

.title-input {
  width:100%;
  font-size:21px;
  font-weight:600;
  padding:17px 16px;
  margin-bottom:9px;
}

.editor-meta {
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:10px;
}

.options-list {
  list-style:none;
  padding:0;
  margin:0;
}

.option-row {
  display:flex;
  align-items:center;
  gap:8px;
  padding:5px 12px;
  border-bottom:1px solid #ffffff17;
  min-height:60px;
}

.option-row:last-child {
  border-bottom:0;
}

.option-row.drag-over {
  background:#ffffff30;
}

.option-row input {
  flex:1;
  width:100%;
  border:0;
  background:transparent;
  padding:13px 3px;
  font-size:16px;
}

.drag-handle {
  cursor:grab;
  opacity:.4;
  flex-shrink:0;
  padding:6px;
}

.drag-handle svg {
  width:14px;
  height:20px;
}

.row-buttons {
  display:flex;
  gap:0;
}

.row-buttons button {
  width:30px;
  height:36px;
  opacity:.65;
}

.row-buttons button svg {
  width:16px;
}

.row-buttons button:hover {
  opacity:1;
}

.row-buttons button:disabled {
  opacity:.2;
}

.add-option {
  display:flex;
  align-items:center;
  gap:12px;
  margin-top:12px;
}

.add-option input {
  flex:1;
  width:100%;
}

.add-option button {
  color:var(--accent);
  background:#ffffff12;
}

.editor-actions {
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-top:26px;
  gap:20px;
}

.danger {
  color:#ffd1d1;
}

.empty-options {
  padding:24px;
  text-align:center;
  opacity:.65;
  font-size:14px;
}

.validation-hint {
  font-size:12px;
  line-height:1.5;
  margin:14px 3px;
  color:#ffe99a;
}

.loading {
  min-height:85svh;
  display:flex;
  align-items:center;
  justify-content:center;
  flex-direction:column;
  gap:18px;
  text-align:center;
}

.loading img {
  border-radius:24px;
  box-shadow:0 0 30px #fff5;
}

.loading h1 {
  font:44px Chancery,Georgia,serif;
  margin:0;
}

.loading p {
  font-size:14px;
  opacity:.8;
}

.loading button {
  padding:10px 18px;
  border:1px solid white;
  border-radius:12px;
}

#notice {
  position:fixed;
  z-index:20;
  left:50%;
  bottom:30px;
  transform:translate(-50%,20px);
  max-width:min(90%,600px);
  background:#122430ed;
  color:#fff;
  backdrop-filter:blur(20px);
  padding:14px 22px;
  border:1px solid #ffffff30;
  border-radius:12px;
  box-shadow:0 5px 25px #0003;
  opacity:0;
  pointer-events:none;
  transition:opacity .2s,transform .2s;
  font-size:14px;
  text-align:center;
}

#notice.visible {
  opacity:1;
  transform:translate(-50%,0);
}

dialog {
  width:min(92vw,440px);
  max-height:80svh;
  overflow:auto;
  padding:26px;
  background:#1b2835f5;
  border:1px solid #ffffff30;
  border-radius:20px;
  color:white;
  box-shadow:0 20px 90px #0007;
  backdrop-filter:blur(25px);
}

dialog::backdrop {
  background:#0006;
  backdrop-filter:blur(5px);
}

dialog h2 {
  font-size:21px;
  margin:0 0 18px;
  overflow-wrap:anywhere;
}

dialog p {
  font-size:14px;
  line-height:1.65;
  opacity:.8;
}

.dialog-actions {
  display:flex;
  justify-content:flex-end;
  gap:10px;
  margin-top:22px;
  flex-wrap:wrap;
}

.dialog-question {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:15px;
  width:100%;
  text-align:left;
  padding:15px 5px;
  border-bottom:1px solid #ffffff20;
  overflow-wrap:anywhere;
}

.dialog-question svg {
  width:18px;
  height:18px;
  color:var(--accent);
  flex-shrink:0;
}

.dialog-question:hover {
  background:#ffffff0a;
}

.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;
}

@keyframes reveal {
  from {
    opacity:.24;
    transform:translateY(3px);
    filter:blur(1px);
  }
  to {
    opacity:1;
    transform:translateY(0);
    filter:blur(0);
  }
}

/* Stack the wheel on narrow windows and tablets in portrait. Size the wheel
   from BOTH viewport dimensions; no fixed minimum may force it off-screen. */
@media(max-width:760px),(orientation:portrait) {
  :root {
    --header-height:104px;
    --page-gutter:18px;
  }
  .brand {
    font-size:clamp(30px,6.1vw,54px);
    white-space:normal;
    max-width:calc(100% - 104px);
  }
  .wheel-page {
    display:flex;
    flex-direction:column;
    gap:clamp(12px,2svh,24px);
    justify-content:center;
    padding:12px 0 24px;
  }
  .question-area {
    max-width:680px;
    gap:6px;
  }
  .question-button {
    font-size:clamp(20px,3vw,28px);
    max-width:100%;
    line-height:1.3;
  }
  .result {
    min-height:46px;
    font-size:clamp(26px,4vw,36px);
    padding:4px 8px;
  }
  .result .waiting {
    font-size:14px;
  }
  .wheel-area {
    gap:0;
    margin-top:0;
  }
  .wheel-stage {
    width:min(100%,calc(100svh - var(--header-height) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 184px));
    min-width:0;
    max-width:840px;
  }
  .sheet {
    margin-top:16px;
  }
  .sheet-heading {
    font-size:28px;
    margin-bottom:24px;
  }
  .setting-row {
    padding:18px 16px;
    gap:14px;
  }
  .setting-title {
    font-size:15px;
  }
  .palette-row {
    padding:12px;
  }
  .palette-button {
    font-size:12px;
    overflow-wrap:anywhere;
  }
  .segmented {
    min-width:150px;
  }
  .segmented button {
    padding:7px 10px;
  }
}

@media(min-width:700px) and (orientation:portrait) {
  :root {
    --header-height:116px;
    --page-gutter:28px;
  }
}

/* Phone landscape returns to two columns, including narrow phones which also
   match the stacked layout above. Preserve space for browser bars and notches. */
@media(max-height:600px) and (orientation:landscape) {
  :root {
    --header-height:68px;
    --page-gutter:18px;
  }
  .brand {
    font-size:clamp(28px,4.4vw,40px);
    white-space:nowrap;
    max-width:none;
    padding:4px 0;
  }
  .wheel-page {
    display:grid;
    grid-template-columns:minmax(170px,.85fr) minmax(0,1.25fr);
    align-items:center;
    gap:18px;
    padding:8px 0 16px;
  }
  .wheel-stage {
    width:min(100%,calc(100svh - var(--header-height) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 32px));
  }
  .question-area {
    gap:8px;
  }
  .question-button {
    font-size:clamp(18px,2.6vw,24px);
  }
  .result {
    min-height:40px;
    font-size:26px;
  }
  .wheel-area {
    margin-top:0;
  }
}

@media(max-width:600px) {
  :root { --page-gutter:16px; }
  input,select,.option-row input { font-size:16px; }
  .palettes { grid-template-columns:repeat(3,minmax(0,1fr)); gap:6px; }
  .palettes.backgrounds { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .swatch { width:40px; height:40px; }
  .option-row {
    display:grid;
    grid-template-columns:24px minmax(0,1fr);
    gap:4px;
    padding:10px 10px 6px;
  }
  .drag-handle { grid-row:1 / 3; align-self:center; padding:4px; }
  .option-row input { grid-column:2; padding:9px 4px; }
  .row-buttons { grid-column:2; justify-content:flex-end; }
  .row-buttons button { width:44px; height:44px; }
  .setting-row { flex-wrap:wrap; }
  .setting-row > label:not(.switch) { flex:1; min-width:140px; }
  .setting-row > .segmented { margin-left:auto; }
  .editor-actions { gap:10px; }
  .editor-actions .text-button { font-size:14px; }
  .page-footer { height:auto; min-height:48px; flex-wrap:wrap; padding-block:10px; }
}

@media(pointer:coarse) {
  .row-buttons button { width:44px; height:44px; }
}

@media(prefers-reduced-motion:reduce) {
  *,*::before,*::after {
    animation:none!important;
    transition:none!important;
  }
}

/* Update notice remains available while editing; idle wheels update themselves. */
#update-banner {
  position: fixed;
  z-index: 30;
  bottom: max(20px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 18px;
  border: 1px solid #ffffff30;
  border-radius: 18px;
  background: #173b4df5;
  color: #fff;
  box-shadow: 0 8px 35px #0005;
}

.sound-setting {
  margin-top:24px;
}
