@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@400;500;600;700;800&display=swap');

/*
  AxisQuest — Light Theme (Modernist)
  Binding for all surfaces. One accent (red), spent sparingly. Structure is
  communicated with 2px solid ink rules, never tinted panels. Zero corner
  radius everywhere - --radius/--radius-sm stay at 0 so every existing
  border-radius: var(--radius) reference collapses automatically; a few
  hardcoded circle/pill shapes (999px, 50%) are flattened explicitly below.
  Game-state color mapping lives inline next to the relevant component.
*/
:root {
  --bg: #f3f2f2;
  --surface: var(--bg);
  --surface-2: var(--bg);
  --text: #201e1d;
  --text-secondary: #55514e;
  --divider: #201e1d;
  --border: var(--divider);

  --accent: #ec3013;
  --accent-rgb: 236, 48, 19;

  --neutral-100: #e8e6e5;
  --neutral-200: #d6d3d1;
  --neutral-300: #b3aeab;
  --neutral-400: #8a8480;
  --locked: var(--neutral-400);

  --font-heading: 'Archivo', system-ui, sans-serif;
  --font-body: 'Archivo', system-ui, sans-serif;

  --radius: 0;
  --radius-sm: 0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
}

h1, h2, h3, h4 { font-family: var(--font-heading); font-weight: 800; margin: 0 0 8px; text-align: left; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 16px 16px 96px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
}

.app-shell.wide { max-width: 720px; }

/* ---- layout utilities ---- */
.grow { flex: 1; min-width: 0; }

/* ---- text utilities ---- */
.text-secondary { color: var(--text-secondary); }
.text-center { text-align: center; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.tabular { font-variant-numeric: tabular-nums; }
.glow-text { font-weight: 800; }

/* ---- cards ---- */
.card {
  background: var(--surface);
  border: 2px solid var(--divider);
  border-radius: var(--radius);
  padding: 16px;
}
.card--hover:hover { border-color: var(--accent); }
.card--glow { border-color: var(--accent); border-width: 3px; }
.card--flat { background: transparent; border-style: dashed; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: flex-start; gap: 8px;
  font-family: var(--font-heading); font-weight: 800; font-size: 15px;
  padding: 13px 20px; border-radius: var(--radius-sm); border: 2px solid var(--divider);
  cursor: pointer; transition: background 100ms ease, color 100ms ease;
  text-decoration: none; text-align: left;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--text); border-color: var(--text); color: var(--bg); }
.btn-primary:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-gold { background: var(--text); border-color: var(--text); color: var(--bg); }
.btn-secondary { background: transparent; border-color: var(--divider); color: var(--text); }
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: none; justify-content: flex-start; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 13px; }

/* ---- forms ---- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--text-secondary); text-align: left; }
.input {
  width: 100%; background: var(--surface-2); border: 2px solid var(--divider); color: var(--text);
  border-radius: var(--radius-sm); padding: 12px 14px; font: inherit; font-size: 15px;
  transition: border-color 150ms ease;
}
.input:focus { outline: none; border-color: var(--accent); }
.input::placeholder { color: var(--neutral-400); }

/* ---- tabs (auth toggle) ---- */
.tabgroup { display: flex; gap: 8px; background: var(--surface-2); padding: 4px; border-radius: var(--radius-sm); border: 2px solid var(--divider); }
.tabgroup .tab-btn {
  flex: 1; text-align: center; padding: 10px; border-radius: 0;
  font-family: var(--font-heading); font-weight: 800; font-size: 13px; color: var(--text-secondary);
  background: transparent; border: none; cursor: pointer;
}
.tabgroup .tab-btn.active { background: var(--text); color: var(--bg); }

/* ---- bars (HP / XP) ---- */
.bar { height: 10px; border-radius: 0; background: var(--neutral-200); overflow: hidden; border: 2px solid var(--divider); }
.bar > i { display: block; height: 100%; border-radius: 0; transition: width 300ms ease; background: var(--text); }
.bar.xp > i { background: var(--text); }
.bar.hp > i { background: var(--text); }
.bar.hp.critical > i { background: var(--accent); }

.icon { display: inline-block; width: 1em; height: 1em; vertical-align: -0.125em; }

.hp-bar-wrap { display: flex; flex-direction: column; gap: 2px; min-width: 90px; }
.hp-bar-label { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---- chips / badges ---- */
.chip {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700;
  padding: 3px 10px; border-radius: 0; border: 2px solid var(--divider); color: var(--text);
}
.chip.accent { border-color: var(--accent); color: var(--accent); }
.chip.gold { border-color: var(--divider); color: var(--text); }
.chip.difficulty-easy,
.chip.difficulty-normal,
.chip.difficulty-expert { border-color: var(--divider); color: var(--text); }

/* ---- top status bar ---- */
.status-bar {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: var(--bg);
  border: 2px solid var(--divider); border-radius: var(--radius);
}
.status-bar .name { font-family: var(--font-heading); font-weight: 800; }

/* ---- bottom tab nav ---- */
.bottom-tabs {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0;
  width: 100%; max-width: 480px;
  display: flex; background: var(--bg);
  border-top: 2px solid var(--divider); padding: 6px; z-index: 20;
}
.bottom-tabs a, .bottom-tabs span {
  flex: 1; text-align: center; padding: 8px 4px; font-size: 18px;
  color: var(--locked); cursor: default;
}
.bottom-tabs a.active { color: var(--accent); }
.bottom-tabs a:hover { color: var(--accent); }

/* ---- gym card (hub) ---- */
.gym-card { display: flex; gap: 12px; align-items: center; width: 82%; }
.gym-card.align-end { align-self: flex-end; }
.gym-card .art {
  width: 52px; height: 52px; border-radius: 0; flex: none; display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800; color: var(--bg); background: var(--text); border: 2px solid var(--divider);
}
.gym-card.locked { opacity: .5; }
.gym-card.locked .art { background: var(--neutral-300) !important; color: var(--bg); border-color: var(--neutral-400); }
.path-connector { text-align: center; color: var(--text-secondary); opacity: .5; width: 82%; }

/* ---- challenge/boss card ---- */
.challenge-card { display: flex; align-items: center; gap: 10px; }
.challenge-card .status-icon { width: 22px; text-align: center; flex: none; }
.boss-card { border-width: 3px; }

/* ---- numpad ---- */
.numpad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.numpad-key {
  background: var(--surface-2); border: 2px solid var(--divider); color: var(--text);
  border-radius: var(--radius-sm); padding: 16px 0; text-align: center; font-size: 19px; font-weight: 700;
  cursor: pointer; user-select: none; transition: background 100ms ease, color 100ms ease;
}
.numpad-key.op { color: var(--text); }
.numpad-key:active { background: var(--text); color: var(--bg); }
.answer-display {
  text-align: right; font-size: 26px; font-family: var(--font-heading); font-weight: 800;
  background: var(--surface-2); border: 2px solid var(--divider); border-radius: var(--radius-sm);
  padding: 12px 16px; min-height: 56px; letter-spacing: 1px; font-variant-numeric: tabular-nums;
}
.answer-display .cursor { color: var(--accent); animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---- timer ring ---- */
.timer-ring {
  --pct: 100;
  width: 76px; height: 76px; border-radius: 0; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-heading); font-weight: 800; font-size: 17px;
  background: conic-gradient(var(--ring-color, var(--text)) calc(var(--pct) * 1%), var(--neutral-200) 0);
  border: 2px solid var(--divider);
  transition: background 900ms linear;
}
.timer-ring::before {
  content: ''; position: absolute; width: 60px; height: 60px; border-radius: 0; background: var(--surface);
}
.timer-ring span { position: relative; z-index: 1; font-variant-numeric: tabular-nums; }

/* ---- problem area ---- */
.problem-box { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 28px 16px; text-align: center; }
.problem-text { font-family: var(--font-heading); font-size: 26px; font-weight: 800; }

/* ---- feedback flashes ---- */
.flash-correct { animation: flashNeutral 700ms ease; }
.flash-incorrect { animation: flashAccent 700ms ease, shake 400ms ease; }
.flash-timeout { animation: flashAccent 700ms ease; }
@keyframes flashNeutral { 0% { background: var(--neutral-200); } 100% { background: transparent; } }
@keyframes flashAccent { 0% { background: rgba(var(--accent-rgb),.3); } 100% { background: transparent; } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.result-toast {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  padding: 10px 20px; border-radius: 0; font-weight: 800; font-family: var(--font-heading);
  border: 2px solid var(--divider);
  z-index: 30; opacity: 0; transition: opacity 300ms ease, top 300ms ease;
}
.result-toast.show { opacity: 1; top: 30px; }
.result-toast.correct { background: var(--text); color: var(--bg); border-color: var(--text); }
.result-toast.incorrect { background: var(--accent); color: #fff; border-color: var(--accent); }
.result-toast.timeout { background: var(--accent); color: #fff; border-color: var(--accent); }
.result-toast .icon { margin-right: 4px; }

/* ---- boss duel ---- */
.duel-row { display: flex; align-items: stretch; gap: 10px; }
.duel-card { flex: 1; text-align: center; border-color: var(--divider); }
.duel-card.boss { border-color: var(--accent); }
.duel-card .art {
  width: 56px; height: 56px; border-radius: 0; margin: 0 auto 8px; display: flex; align-items: center;
  justify-content: center; font-size: 22px; font-weight: 800; color: var(--bg); background: var(--text); border: 2px solid var(--divider);
}
.duel-vs { align-self: center; font-family: var(--font-heading); font-weight: 800; font-size: 20px; color: var(--accent); }

/* ---- character/hero cards ---- */
.hero-card { padding: 0; overflow: hidden; }
.hero-art { height: 170px; background: var(--neutral-200); display: flex; align-items: center; justify-content: center; color: var(--text-secondary); font-size: 13px; }
.hero-body { padding: 14px; display: flex; flex-direction: column; gap: 8px; }

/* ---- difficulty select cards ---- */
.difficulty-card {
  border: 2px solid var(--divider); border-radius: var(--radius); padding: 14px; cursor: pointer;
  transition: border-color 150ms ease;
}
.difficulty-card.selected,
.difficulty-card:has(input:checked) { border-color: var(--accent); border-width: 3px; }
.difficulty-card input { display: none; }

/* ---- leaderboard-ish rows (used minimally, future screens) ---- */
.row { display: flex; align-items: center; gap: 10px; }
.row.stretch { align-items: stretch; }

/* ---- misc ---- */
.divider { border: none; border-top: 2px solid var(--divider); margin: 4px 0; }
.center-icon {
  width: 64px; height: 64px; border-radius: 0; display: flex; align-items: center; justify-content: center;
  font-size: 28px; margin: 0 auto; background: var(--surface-2); border: 2px solid var(--accent);
}

.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; border: 2px solid var(--divider); color: var(--text); }
.alert-error { border-color: var(--accent); color: var(--text); }
.alert-warning { border-color: var(--divider); color: var(--text); }
.alert-success { border-color: var(--divider); color: var(--text); }

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