:root {
  --bg: #0A0A0B;
  --surface: #141417;
  --text: #FFFFFF;
  --muted: #8A8A94;
  --danger: #FF2D2D;
  --accent: #00E5FF;
  --accent2: #7CFBFF;
  --ink: #0A0A0B;
}
html[data-tier="1"] { --accent: #00E676; --accent2: #B9F6CA; }
html[data-tier="2"] { --accent: #FFAB00; --accent2: #FFE082; }
html[data-tier="3"] { --accent: #FF2D95; --accent2: #FFD600; }

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  font-weight: 800;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

#fx {
  position: fixed; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 90;
}

/* ---- screens ---------------------------------------------------------- */
.screen { display: none; position: fixed; inset: 0; z-index: 10; }
.screen.is-active { display: flex; }

/* ---- onboarding ------------------------------------------------------- */
#onboarding {
  flex-direction: column; align-items: center; justify-content: center;
  gap: 2rem; padding: 2rem;
}
.lede { font-size: 1.5rem; letter-spacing: -0.02em; text-align: center; }
.fine { font-size: 0.8rem; font-weight: 600; color: var(--muted); text-align: center; }

.block-btn {
  background: var(--accent); color: var(--ink);
  font-size: 2rem; letter-spacing: 0.04em;
  padding: 1.4rem 3rem; border-radius: 4px;
}
.block-btn.danger { background: var(--danger); color: #fff; }
.text-btn { font-size: 0.9rem; font-weight: 700; color: var(--muted); padding: 0.75rem 0.5rem; }
.text-btn.danger-text { color: var(--danger); }

/* ---- gate ------------------------------------------------------------- */
#gate { flex-direction: column; z-index: 40; }
.gate-half {
  flex: 1; display: grid; place-items: center;
  font-size: clamp(3.5rem, 18vw, 8rem); letter-spacing: 0.02em;
}
#gate-no  { background: var(--accent); color: var(--ink); align-items: start; padding-top: 12vh; }
#gate-yes { background: var(--danger); color: #fff;      align-items: end;   padding-bottom: 12vh; }

#gate-question {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: var(--bg); color: var(--text);
  font-size: clamp(1.4rem, 7vw, 2.4rem); line-height: 1.05; text-align: center;
  padding: 1.1rem 1.6rem; border-radius: 4px;
}

#gate-confirm { display: none; }
#gate.is-confirming #gate-no,
#gate.is-confirming #gate-question { display: none; }
#gate.is-confirming #gate-yes { visibility: hidden; }
#gate.is-confirming {
  background: var(--danger);
}
#gate.is-confirming #gate-confirm {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1.5rem; padding: 2rem;
}
.confirm-lede { font-size: 1.25rem; text-align: center; }
#gate.is-confirming .block-btn.danger { background: var(--bg); color: #fff; }
#gate.is-confirming .text-btn { color: rgba(255, 255, 255, 0.75); }

/* ---- home ------------------------------------------------------------- */
#home {
  flex-direction: column; gap: 0.75rem;
  padding: calc(env(safe-area-inset-top) + 1.25rem) 1rem
           calc(env(safe-area-inset-bottom) + 0.5rem);
}
.home-head { text-align: center; }
#streak {
  font-size: clamp(2.2rem, 11vw, 3.5rem);
  letter-spacing: -0.03em; font-variant-numeric: tabular-nums;
}
#tier-chip {
  display: inline-block; margin-top: 0.6rem;
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink); background: var(--accent);
  padding: 0.4rem 0.75rem; border-radius: 2px;
}

#collect {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--accent); color: var(--ink); border-radius: 6px;
  transition: transform 90ms ease-out, background-color 200ms linear;
}
#collect:active { transform: scale(0.97); }
#collect.is-empty { background: var(--surface); color: var(--muted); }
#pending { font-size: clamp(5rem, 30vw, 11rem); line-height: 0.85; font-variant-numeric: tabular-nums; }
#collect.is-empty #pending { font-size: clamp(2rem, 11vw, 3rem); }
#collect-sub {
  margin-top: 0.9rem;
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
}

#ms-bar {
  position: relative; display: block; width: 100%;
  background: var(--surface); border-radius: 4px; overflow: hidden;
  padding: 0.7rem 0.85rem; text-align: left;
}
#ms-fill {
  position: absolute; inset: 0 auto 0 0; width: 0;
  background: var(--accent); opacity: 0.22;
  transition: width 400ms ease-out;
}
#ms-label {
  position: relative;
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; color: var(--muted);
}

.home-foot { display: flex; justify-content: space-between; align-items: center; }

/* ---- sheet ------------------------------------------------------------ */
#sheet {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-end;
  background: rgba(0, 0, 0, 0.65);
}
#sheet[hidden] { display: none; }
.sheet-panel {
  width: 100%; max-height: 82vh; overflow-y: auto;
  background: var(--surface); border-radius: 12px 12px 0 0;
  padding: 1.25rem 1rem calc(env(safe-area-inset-bottom) + 1.25rem);
  -webkit-overflow-scrolling: touch;
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.sheet-head h2 { font-size: 1.1rem; letter-spacing: 0.02em; text-transform: uppercase; }

.row { padding: 0.7rem 0; border-top: 1px solid rgba(255, 255, 255, 0.08); font-weight: 700; }
.row:first-child { border-top: 0; }
.row .when { font-size: 0.95rem; }
.row .note { font-size: 0.8rem; font-weight: 600; color: var(--muted); margin-top: 0.15rem; }
.row.locked { opacity: 0.38; }
.row .badge {
  display: inline-block; margin-right: 0.5rem;
  font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink); background: var(--accent); padding: 0.15rem 0.4rem; border-radius: 2px;
}
.row.locked .badge { background: var(--muted); }
.empty { color: var(--muted); font-weight: 600; font-size: 0.9rem; }

#backup-text {
  width: 100%; min-height: 9rem; resize: vertical;
  background: var(--bg); color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 4px;
  padding: 0.6rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem; font-weight: 500;
  -webkit-user-select: text; user-select: text;
}
.backup-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; }
.backup-actions button {
  flex: 1; background: var(--accent); color: var(--ink);
  font-size: 0.85rem; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 0.8rem 0.5rem; border-radius: 4px;
}

/* ---- toast ------------------------------------------------------------ */
#toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 5rem);
  transform: translateX(-50%);
  z-index: 120; max-width: 88vw;
  background: var(--text); color: var(--ink);
  font-size: 0.85rem; font-weight: 700; text-align: center;
  padding: 0.7rem 1rem; border-radius: 4px;
}
#toast[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 1ms !important; animation-duration: 1ms !important; }
}
