:root {
  color-scheme: dark;
  --bg: #140c0e;
  --card: #2a181c;
  --card-2: #341f24;
  --line: #5a3338;
  --yellow: #ffd23f;
  --yellow-2: #ffe7a3;
  --red: #e06b5c;
  --red-2: #f0a097;
  --ink: #fff6ea;
  --muted: #d2b5ab;
  --good: #9dcead;
  --gold: #f0d078;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(120% 42% at 50% -8%, rgba(255, 210, 63, 0.16), transparent 56%),
    radial-gradient(70% 32% at 110% 0%, rgba(224, 107, 92, 0.14), transparent 50%),
    var(--bg);
  color: var(--ink);
  font: 16px/1.45 ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.app {
  width: min(480px, 100%);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
}
.top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 8px;
  position: sticky;
  top: 0;
  z-index: 30;
  background: linear-gradient(var(--bg), rgba(20, 12, 14, 0.92) 70%, transparent);
}
.top-title { flex: 1; font-weight: 700; letter-spacing: -0.02em; }
.top-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(42, 24, 28, 0.9);
  color: var(--yellow-2);
  display: grid;
  place-items: center;
  padding: 0;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.gold { color: var(--gold); border-color: rgba(240, 208, 120, 0.7); }
.screen { padding: 4px 16px calc(92px + env(safe-area-inset-bottom)); }
.lede { color: var(--muted); margin: 4px 0 12px; }
.muted { color: var(--muted); font-size: 13px; }
h1, h2, p { margin-top: 0; }
h2 {
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--yellow);
  margin: 16px 0 8px;
}
.nw { text-align: center; padding: 8px 0 4px; }
.nw .label { color: var(--yellow); font-weight: 650; }
.nw .num {
  font-size: clamp(42px, 12vw, 58px);
  font-weight: 650;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  margin: 4px 0;
}
.chg { font-variant-numeric: tabular-nums; font-size: 15px; }
.chg.up { color: var(--good); }
.chg.dn { color: var(--red-2); }
.chart-wrap { height: 168px; margin: 8px 0 2px; }
.chart-wrap svg { width: 100%; height: 100%; display: block; overflow: visible; }
.halo { transform-box: fill-box; transform-origin: center; animation: halo 2.6s ease-in-out infinite; }
.pulse { transform-box: fill-box; transform-origin: center; animation: pulse 2.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }
@keyframes halo { 0%, 100% { opacity: 0.18; } 50% { opacity: 0.55; } }
.pills { display: flex; justify-content: center; gap: 4px; flex-wrap: wrap; margin: 8px 0 14px; }
.pills button {
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  padding: 8px 11px;
  font-weight: 700;
  font-size: 13px;
}
.pills button.on { background: #3a2226; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.card {
  background: var(--card);
  border: 1px solid #3d2428;
  border-radius: 22px;
  padding: 16px;
  margin: 0 0 12px;
  box-shadow: var(--shadow);
}
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.k, .split .k { color: var(--yellow); font-size: 14px; }
.split .v { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.banner {
  border-radius: 16px;
  padding: 12px 14px;
  margin: 0 0 12px;
  background: #3a2420;
  border: 1px solid #6a4038;
}
.banner.good { background: #243028; border-color: #3d5a48; }
.banner.bad { background: #3a2224; border-color: #7a4540; color: #ffe4de; }
.banner strong { display: block; margin-bottom: 2px; }
.goal { margin: 10px 0; }
.goal .row, .spread { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.track { height: 7px; border-radius: 7px; background: #3a2428; overflow: hidden; margin-top: 5px; }
.track i { display: block; height: 100%; background: linear-gradient(90deg, #c9842a, #ffd23f); border-radius: 7px; }
.mood-chip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid #3d2428;
  border-radius: 18px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.meter { height: 8px; border-radius: 8px; background: linear-gradient(90deg, #e7a398, #ffd23f); position: relative; margin: 8px 0; }
.meter b {
  position: absolute;
  top: -4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid #1a1012;
  transform: translateX(-50%);
}
.dock {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(480px, 100%);
  height: calc(64px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: #1a1012;
  border-top: 1px solid #3d2428;
  z-index: 40;
}
.dock button {
  flex: 1;
  background: none;
  border: 0;
  color: #a88880;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.dock button svg { width: 22px; height: 22px; }
.dock button.on { color: var(--yellow-2); }
.coin-row, .edit-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid #3d2428;
}
.coin-row:first-child, .edit-row:first-child { border-top: 0; }
.coin-row b { font-size: 16px; }
.coin-row .sub, .where { color: var(--muted); font-size: 13px; }
.right { text-align: right; font-variant-numeric: tabular-nums; }
.up { color: var(--good); }
.dn { color: var(--red-2); }
.pie-wrap { display: grid; grid-template-columns: 148px 1fr; gap: 12px; align-items: center; }
.pie-wrap svg { width: 148px; height: 148px; }
.legend-row { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; margin: 4px 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.linkish, .text-btn {
  background: none;
  border: 0;
  color: var(--yellow-2);
  padding: 0;
  font-weight: 700;
}
.primary, .ghost {
  border-radius: 14px;
  padding: 12px 14px;
  font-weight: 750;
  width: 100%;
}
.primary { background: var(--yellow); color: #1a1012; border: 0; }
.ghost { background: transparent; color: var(--yellow-2); border: 1px solid var(--line); }
.stack { display: grid; gap: 8px; }
label.field { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
input, select {
  width: 100%;
  background: #1a1012;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  min-height: 44px;
}
.secret-line { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.steps { margin: 8px 0; padding-left: 18px; }
.steps li { margin: 4px 0; }
.warn {
  background: #3a2422;
  border: 1px solid #8a5048;
  border-radius: 16px;
  padding: 12px;
  color: #ffe8e2;
}
.edit-row { grid-template-columns: 72px 1fr 1fr auto; align-items: center; }
.edit-row.two { grid-template-columns: 80px 1fr auto; }
.x {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #1a1012;
  color: var(--yellow-2);
}
details { margin: 8px 0 16px; }
summary { cursor: pointer; color: var(--yellow-2); font-weight: 700; }
.check { display: flex; gap: 8px; align-items: flex-start; margin: 8px 0 14px; }
.check input { width: auto; min-height: 0; margin-top: 3px; }
.glossary details { background: var(--card); border-radius: 16px; padding: 10px 12px; margin: 8px 0; border: 1px solid #3d2428; }
.glossary summary { color: var(--ink); }
.glossary p { margin: 8px 0 0; color: var(--muted); }
#testResult:empty { display: none; }
.liq-canvas {
  width: 100%;
  height: 440px;
  border-radius: 18px;
  display: block;
  background: #140c0e;
}
.liq-head { display: grid; gap: 4px; }
.legend { color: var(--muted); font-size: 13px; }
.sw { display: inline-block; width: 18px; height: 8px; border-radius: 4px; vertical-align: middle; }
.sw.lo { background: #5c2a24; }
.sw.hi { background: #e06b5c; }
.venue { display: flex; justify-content: space-between; gap: 8px; margin: 6px 0; font-variant-numeric: tabular-nums; }
.spark { height: 64px; }
.spark svg { width: 100%; height: 64px; display: block; }
.ov {
  position: fixed;
  z-index: 60;
  width: 92px;
  height: 142px;
  right: max(12px, calc((100vw - 480px) / 2 + 12px));
  bottom: calc(78px + env(safe-area-inset-bottom));
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(255, 210, 63, 0.55);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  background: #000;
  touch-action: none;
}
.ov video { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; pointer-events: none; }
.ov .x {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: rgba(12, 11, 9, 0.72);
  color: var(--yellow-2);
  line-height: 22px;
  font-size: 14px;
}
.ov .chip, .ov .fallback { display: none; }
.ov.min { width: 46px; height: 46px; border-radius: 50%; }
.ov.min video, .ov.min .x, .ov.min .fallback { display: none; }
.ov.min .chip {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--yellow);
  color: #1a1012;
  font-size: 11px;
  font-weight: 800;
}
.ov.novid video { display: none; }
.ov.novid .fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: #1a1012;
  background: var(--gold);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  padding: 8px;
}
.modal[hidden] { display: none !important; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(8, 4, 6, 0.62);
  display: grid;
  place-items: center;
  padding: 22px;
}
.modal-card {
  position: relative;
  width: min(360px, 100%);
  border-radius: 28px;
  overflow: hidden;
  background: #1c1210;
  border: 1px solid rgba(240, 208, 120, 0.75);
  box-shadow: 0 0 0 1px rgba(255, 210, 63, 0.15), 0 20px 50px rgba(0, 0, 0, 0.45);
  animation: glow 3.8s ease-in-out infinite;
}
@keyframes glow {
  50% { box-shadow: 0 0 28px rgba(240, 208, 120, 0.35), 0 20px 50px rgba(0, 0, 0, 0.45); }
}
#sparkles { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.modal-body { position: relative; padding: 28px 22px 22px; text-align: center; }
.eyebrow { letter-spacing: 0.14em; text-transform: uppercase; font-size: 12px; color: var(--gold); margin-bottom: 10px; }
.glitter-text {
  font-size: clamp(28px, 7vw, 36px);
  line-height: 1.2;
  font-weight: 750;
  letter-spacing: -0.03em;
  margin: 0 0 12px;
  background-image: linear-gradient(105deg, #8a6a22 0%, #fff4c4 18%, #f0d078 38%, #fff 50%, #e2c56a 62%, #fff6d0 80%, #8a6a22 100%);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 4.8s linear infinite;
}
.sign {
  margin: 0 0 18px;
  font-size: 20px;
  background-image: linear-gradient(100deg, #c9a24a, #fff6d0, #f0d078, #fff, #c9a24a);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 5.5s linear infinite;
}
@keyframes shimmer { to { background-position: -220% 0; } }
@media (prefers-reduced-motion: reduce) {
  .glitter-text, .sign { animation: none; background: none; color: var(--gold); }
  .halo, .pulse, .modal-card { animation: none; }
}
@media (max-width: 380px) {
  .pie-wrap { grid-template-columns: 1fr; justify-items: center; }
  .edit-row { grid-template-columns: 64px 1fr auto; }
  .edit-row .where { display: none; }
}
