
:root {
  --bg: #0D1018; --bg2: #1A2136; --panel: #161C28;
  --ink: #E8EDF5; --muted: #8A97AC;
  --accent: #7C97FF; --on-accent: #1C2240;
  --add: #4ADE80; --gold: #FFCF4D;
  --num-tile: #222B3D; --num-edge: #38445C;
  --wheel-top: #1C2436; --wheel-bot: #121826;
  --vtx-top: #252C3D; --vtx-bot: #1B2130;
  --hairline: rgba(255,255,255,.08);
  --thread: rgba(232,237,245,.85);
  --op-plus: #5FD68A; --op-minus: #F2736B; --op-times: #FFB020;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {

  background-color: var(--bg);
  background-image: linear-gradient(to bottom, rgba(26,33,54,.6) 0%, rgba(13,16,24,1) 50%);
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI",
               Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none; -webkit-user-select: none;
  overscroll-behavior: none;
}

#app {
  height: 100%; max-width: 460px; margin: 0 auto;
  display: flex; flex-direction: column; align-items: center;
  padding: calc(14px + env(safe-area-inset-top)) 16px calc(14px + env(safe-area-inset-bottom));
  gap: clamp(4px, 1.4vh, 14px);
}

#head { margin-bottom: auto; }
#foot { margin-top: auto; }

#head { width: 100%; display: flex; align-items: center; justify-content: space-between; }

.wordmark { font-size: 17px; font-weight: 500; letter-spacing: -.01em; }
.wordmark b { font-weight: 800; }
.badge {
  font-size: 14px; font-weight: 800; color: var(--add);
  font-variant-numeric: tabular-nums;
}

.targets { display: flex; justify-content: center; gap: 6px; flex-wrap: nowrap; }
.target {
  min-width: 46px; padding: 6px 9px; text-align: center; white-space: nowrap;
  border: 1.5px solid var(--hairline); border-radius: 13px;
  font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums;
  transition: border-color .25s, color .25s, transform .25s;
}
.target.next { border-color: var(--accent); }
.target.found { border-color: var(--add); color: var(--add); }
.target.found::before { content: "✓"; font-size: 12px; margin-right: 3px; vertical-align: 1px; }
.target.just { animation: pop .45s ease-out; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }

@media (max-width: 360px) {
  .targets { gap: 5px; }
  .target { min-width: 40px; padding: 5px 7px; font-size: 16px; }
}

.result { text-align: center; min-height: 72px; }
.expr {
  font-size: 15px; font-weight: 600; color: var(--muted); min-height: 20px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 90vw;
}
.total {
  font-size: 42px; font-weight: 900; line-height: 1.15; color: rgba(138,151,172,.4);
  font-variant-numeric: tabular-nums;
  transition: color .2s ease;
}
.total.live { color: var(--ink); }
.total.match { color: var(--add); }

.wheelbox { flex: 0 1 auto; display: flex; align-items: center; justify-content: center;
            width: 100%; min-height: 0; }
#wheel {
  width: min(92vw, 380px); max-height: 100%; height: auto;
  touch-action: none; display: block;
  overflow: visible;
  animation: rise .55s cubic-bezier(.2,.8,.3,1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.96); } }
#wheel.shake { animation: shake .32s; }
@keyframes shake {
  0%,100% { transform: translateX(0); } 22%,66% { transform: translateX(-9px); }
  44%,88% { transform: translateX(9px); }
}
.vx { transition: opacity .16s ease; }

.ring { animation: ring .55s ease-out forwards; transform-origin: 160px 160px; }
@keyframes ring { from { opacity: .85; transform: scale(.72); } to { opacity: 0; transform: scale(1.28); } }
.ghost { animation: ghost 2.6s ease-in-out; }
@keyframes ghost { 0%,100% { opacity: 0; } 12%,88% { opacity: .85; } }

.hintbar { display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 62px; }
.hintbtn {
  background: none; border: 1px solid rgba(255,207,77,.35); color: var(--gold);
  font: inherit; font-size: 14px; font-weight: 800; border-radius: 999px;
  padding: 9px 22px; cursor: pointer;
  transition: background .18s, opacity .18s;
}
.hintbtn::before { content: "💡"; margin-right: 6px; font-size: 13px; }
.hintbtn:hover { background: rgba(255,207,77,.1); }
.hintbtn:disabled { opacity: .35; cursor: default; }

.hinttext {
  min-height: 19px; font-size: 14px; font-weight: 700; color: var(--gold);
  font-variant-numeric: tabular-nums; text-align: center;
}

#foot { min-height: 20px; display: flex; flex-direction: column; align-items: center; gap: 3px; }

.disclaimer { color: var(--muted); font-size: 12px; opacity: .8;
              text-align: center; text-wrap: balance; }
#foot a { color: var(--muted); font-size: 13px; font-weight: 600; text-decoration: none;
          border-bottom: 1px solid rgba(138,151,172,.3); }
#foot a:hover { color: var(--ink); }

.modal-layer {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 20;
  display: flex; align-items: center; justify-content: center; padding: 22px;
  animation: fade .25s ease both;
}

.modal-layer[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.card {
  background: var(--panel); border: 1px solid var(--hairline); border-radius: 26px;
  padding: 26px 24px; max-width: 340px; width: 100%; text-align: center;
  box-shadow: 0 16px 40px rgba(0,0,0,.45);
  animation: cardin .35s cubic-bezier(.2,.8,.3,1) both;
}
@keyframes cardin { from { opacity: 0; transform: scale(.92) translateY(10px); } }
.card h1 { font-size: 26px; font-weight: 900; margin: 0 0 2px; letter-spacing: -.02em; }

.card .kicker { font-size: 15px; color: var(--muted); margin: 0 0 16px; text-align: center; }
.card p { font-size: 14.5px; line-height: 1.6; color: var(--ink); margin: 0 0 12px; text-align: left; }
.card p.dim { color: var(--muted); }
.card p.note {
  font-size: 13px; line-height: 1.5; color: var(--muted);
  background: var(--bg2); border: 1px solid var(--hairline);
  border-radius: 12px; padding: 10px 12px; margin: 4px 0 0;
}
.eq {
  display: inline-block; background: var(--bg2); border: 1px solid var(--hairline);
  border-radius: 9px; padding: 5px 10px; margin: 2px 0 14px;
  font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.eq b { color: var(--add); }

.card .url {
  font-size: 13px; font-weight: 700; color: var(--ink); text-align: center; word-break: break-all;
  background: var(--bg2); border: 1px solid var(--hairline); border-radius: 10px;
  padding: 9px 11px; margin: 0 0 4px;
  user-select: text; -webkit-user-select: text;
}
.star { font-size: 40px; line-height: 1; margin-bottom: 6px; color: var(--gold); }

.card h1.gold { color: var(--gold); margin-bottom: 14px; }
.btn {
  display: block; width: 100%; border: none; border-radius: 13px; padding: 14px;
  font: inherit; font-size: 15.5px; font-weight: 800; cursor: pointer;
  text-decoration: none; margin-top: 9px;
}
.btn.gold { background: var(--gold); color: var(--on-accent); }
.btn.accent { background: var(--accent); color: var(--on-accent); }
.btn.plain { background: var(--num-tile); color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  #wheel, .card, .modal-layer, .target.just { animation: none; }
  #wheel.shake { animation: none; }

  .ring { animation: ringfade .5s ease-out forwards; transform: scale(1); }

}
@keyframes ringfade { from { opacity: .85; } to { opacity: 0; } }

