:root {
  --bg: #0b1020;
  --panel: #121a30;
  --panel-2: #182240;
  --ink: #e8ecf6;
  --ink-dim: #8fa0c2;
  --up: #2fbf9b;
  --down: #ef5350;
  --amber: #f5b942;
  --line: #223052;
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

header { border-bottom: 1px solid var(--line); }
.head-inner {
  max-width: 560px; margin: 0 auto; padding: 10px 14px;
  display: flex; align-items: center; justify-content: space-between;
}
h1 { font-size: 20px; letter-spacing: 3px; font-weight: 800; }
h1 span { color: var(--amber); }
.head-right { display: flex; gap: 8px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line);
  font-size: 16px; cursor: pointer;
}
.icon-btn:active { transform: scale(.95); }

main { flex: 1; width: 100%; max-width: 560px; margin: 0 auto; padding: 12px 14px 28px; }

.puzzle-meta {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--ink-dim); margin-bottom: 8px;
}
#puzzle-num { font-weight: 700; color: var(--ink); }
.chip {
  margin-left: auto; background: var(--panel); border: 1px solid var(--line);
  border-radius: 99px; padding: 2px 10px; font-size: 13px;
}

#chart-wrap {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px; height: 46vh; min-height: 280px; max-height: 430px;
}
#chart { width: 100%; height: 100%; display: block; }

.ask { text-align: center; margin: 14px 0 10px; font-size: 15px; }
.buckets { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.bucket {
  background: var(--panel); color: var(--ink); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 2px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: border-color .15s, transform .06s;
}
.bucket b { font-size: 12.5px; }
.bucket small { font-size: 10px; color: var(--ink-dim); }
.bucket:hover { border-color: var(--amber); }
.bucket:active { transform: scale(.96); }
.bucket:disabled { opacity: .45; cursor: default; }
.bucket.picked { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber); }
.scoring-note { text-align: center; font-size: 11.5px; color: var(--ink-dim); margin-top: 10px; }

#result-panel { margin-top: 14px; text-align: center; }
#result-verdict { font-size: 22px; font-weight: 800; margin-bottom: 6px; }
#result-reveal {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; font-size: 14.5px; color: var(--ink-dim);
}
#result-reveal b { color: var(--ink); }
#result-reveal .ret-up { color: var(--up); font-weight: 700; }
#result-reveal .ret-down { color: var(--down); font-weight: 700; }
.result-actions { display: flex; gap: 8px; justify-content: center; margin: 14px 0 6px; }
button.primary {
  background: var(--amber); color: #1a1408; border: none; font-weight: 800;
  border-radius: 10px; padding: 10px 22px; font-size: 15px; cursor: pointer;
}
#btn-see-stats, .modal-card button:not(.primary):not(.modal-close) {
  background: var(--panel); color: var(--ink); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 16px; font-size: 14px; cursor: pointer;
}
#countdown { font-size: 12.5px; color: var(--ink-dim); }

.modal {
  position: fixed; inset: 0; background: rgba(4, 8, 18, .72);
  display: flex; align-items: center; justify-content: center; padding: 18px; z-index: 20;
}
.modal-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  max-width: 440px; width: 100%; max-height: 82dvh; overflow-y: auto;
  padding: 20px; position: relative;
}
.modal-card h2 { font-size: 18px; margin-bottom: 10px; }
.modal-card p { font-size: 14.5px; color: var(--ink-dim); margin-bottom: 10px; }
.modal-card p b { color: var(--ink); }
.modal-card .fine { font-size: 12px; }
.modal-close {
  position: absolute; top: 10px; right: 12px; background: none; border: none;
  color: var(--ink-dim); font-size: 22px; cursor: pointer;
}
.modal-ok { width: 100%; margin-top: 6px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.stat { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 4px; text-align: center; }
.stat b { display: block; font-size: 20px; }
.stat small { font-size: 10.5px; color: var(--ink-dim); }
.grid-row { font-size: 20px; letter-spacing: 2px; text-align: center; margin: 8px 0; }

.pro-card {
  border: 1px solid var(--amber); border-radius: 12px; padding: 14px; margin-top: 12px;
  text-align: center;
}
.pro-card h3 { font-size: 15px; margin-bottom: 4px; }
.pro-card p { font-size: 13px; }

.archive-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 4px; border-bottom: 1px solid var(--line); font-size: 14px;
}
.archive-row button { padding: 5px 12px !important; font-size: 13px !important; }

#toast {
  position: fixed; bottom: 74px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); border-radius: 10px;
  padding: 9px 16px; font-size: 14px; font-weight: 600; z-index: 30;
}

footer {
  text-align: center; font-size: 12px; color: var(--ink-dim);
  padding: 12px; border-top: 1px solid var(--line);
}
footer a { color: var(--ink-dim); }

@media (max-width: 400px) {
  .bucket b { font-size: 11px; }
  .bucket small { font-size: 9px; }
}

/* v3 additions: reveal fact line, candle legend, A2HS nudge */
.fact { color: var(--amber, #f5b942); font-size: 0.9em; display: inline-block; margin-top: 6px; }
.candle-legend { text-align: center; margin: 6px 0 2px; }
#a2hs { margin-top: 10px; text-align: center; }
#a2hs a { color: var(--ink-dim, #8fa0c2); }
