:root {
  --bg: #14161c;
  --panel: #1d2029;
  --panel-2: #262a36;
  --line: #333847;
  --text: #eceef4;
  --muted: #8d93a5;
  --accent: #7c9cff;
  --accent-2: #5b7cf0;
  --good: #4ade80;
  --bad: #f87171;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body { min-height: 100vh; min-height: 100dvh; }

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
}

.screen[hidden], [hidden] { display: none !important; }

/* ---------- marca ---------- */
.brand { text-align: center; margin: 8px 0 22px; }
.brand h1 { margin: 0; font-size: 2.2rem; letter-spacing: -0.5px; }
.brand h1 span { color: var(--accent); }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 0.95rem; }
.brand.small { margin-bottom: 14px; }
.brand.small h1 { font-size: 1.5rem; }

/* ---------- cartão de rating ---------- */
.rating-card {
  background: linear-gradient(160deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: center;
  padding: 18px 12px;
  margin-bottom: 14px;
}
.rating-card.compact { padding: 12px; }
.rating-label { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px; }
.rating-value { font-size: 3rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.rating-card.compact .rating-value { font-size: 2.2rem; }
.rating-rank { color: var(--accent); font-weight: 600; }
.rating-note { color: var(--muted); font-size: 0.85rem; margin-top: 6px; }
.rating-note:empty { display: none; }
.delta { font-style: normal; font-size: 1.1rem; font-weight: 700; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }

/* ---------- ratings por operação ---------- */
.ops-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.op-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.op-sym {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  background: var(--panel-2);
  border-radius: 9px;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  flex: none;
}
.op-info { min-width: 0; }
.op-info small { display: block; color: var(--muted); font-size: 0.72rem; }
.op-info b { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.op-info em { font-style: normal; font-size: 0.8rem; margin-left: 4px; font-weight: 700; }
.op-info em.up { color: var(--good); }
.op-info em.down { color: var(--bad); }

/* ---------- desafio diário ---------- */
.daily-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--panel); border: 1px solid var(--accent-2);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 18px;
}
.daily-info b { display: block; font-size: 1.05rem; }
.daily-info small { color: var(--muted); font-size: 0.8rem; }
.daily-card .btn { padding: 11px 18px; font-size: 0.95rem; flex: none; }
.btn:disabled { opacity: 0.55; cursor: default; }

/* ---------- modo ---------- */
.mode-block { margin-bottom: 14px; }
.mode-label { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.chips { display: flex; gap: 8px; }
.chip {
  flex: 1;
  padding: 11px 0;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
}
.chip.active { background: var(--accent-2); border-color: var(--accent); }

/* ---------- botões ---------- */
.actions { display: grid; gap: 10px; margin: 14px 0 18px; }
.btn {
  padding: 15px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
}
.btn.primary { background: var(--accent-2); border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .chip:focus-visible, .link:focus-visible, #g-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.link {
  background: none; border: 0; color: var(--muted);
  font-size: 0.9rem; cursor: pointer; padding: 6px 0;
}
.link.danger { display: block; margin: 20px auto 0; font-size: 0.8rem; }
.link.danger:hover { color: var(--bad); }

/* ---------- estatísticas ---------- */
.stats-row { display: flex; justify-content: space-around; text-align: center; margin-bottom: 14px; }
.stats-row span { display: block; font-size: 1.6rem; font-weight: 800; }
.stats-row small, .result-stats small, .hud small { color: var(--muted); font-size: 0.75rem; }

.history h2 { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin: 18px 0 8px; font-weight: 600; }
.history ul { list-style: none; margin: 0; padding: 0; }
.history li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 12px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; margin-bottom: 6px;
  font-size: 0.9rem;
}
.history li .h-score { font-weight: 700; }
.history li .h-meta { color: var(--muted); font-size: 0.8rem; }

/* ---------- jogo ---------- */
.game-top { display: flex; justify-content: space-between; align-items: center; }
.game-meta { color: var(--muted); font-size: 0.85rem; }

.timer { height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; margin: 10px 0 16px; }
.timer-bar { height: 100%; width: 100%; background: var(--accent); border-radius: 99px; transition: width 0.1s linear; }
.timer-bar.low { background: var(--bad); }

.hud { display: flex; justify-content: space-around; text-align: center; margin-bottom: 8px; }
.hud b { display: block; font-size: 1.6rem; font-variant-numeric: tabular-nums; }

.question-wrap { text-align: center; padding: 28px 0 10px; }
.question {
  font-size: clamp(2.6rem, 14vw, 4.2rem);
  font-weight: 800;
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
  min-height: 1.2em;
  margin-bottom: 18px;
}
#g-input {
  width: 100%;
  max-width: 320px;
  text-align: center;
  font-size: 2.4rem;
  font-weight: 700;
  padding: 12px;
  background: var(--panel);
  color: var(--text);
  border: 2px solid var(--line);
  border-radius: 14px;
  font-variant-numeric: tabular-nums;
}
#g-input.ok { border-color: var(--good); }
#g-input.no { border-color: var(--bad); animation: shake 0.25s; }
.last { margin-top: 14px; color: var(--muted); min-height: 1.4em; font-size: 0.95rem; }
.last.ok { color: var(--good); }
.last.no { color: var(--bad); }
.hint { text-align: center; color: var(--muted); font-size: 0.8rem; margin-top: 20px; }

@keyframes shake {
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* ---------- resultado ---------- */
.result-score { text-align: center; margin-bottom: 14px; }
.result-score .big { font-size: 4.5rem; font-weight: 800; line-height: 1; }
.result-score .sub { color: var(--muted); }
.badge-new {
  display: inline-block; margin-top: 8px; padding: 4px 12px;
  background: rgba(74, 222, 128, 0.15); color: var(--good);
  border: 1px solid var(--good); border-radius: 99px; font-weight: 700; font-size: 0.85rem;
}
.result-stats { display: flex; justify-content: space-around; text-align: center; margin: 4px 0 16px; }
.result-stats b { display: block; font-size: 1.4rem; }

@media (prefers-reduced-motion: reduce) {
  #g-input.no { animation: none; }
  .timer-bar { transition: none; }
}
