/* Reset + base layout ------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
  /* iOS safe areas */
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
ul, ol { list-style: none; padding: 0; }
a { color: var(--accent); text-decoration: none; }
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Tabular numerals everywhere numbers matter */
.num, .score, input[type="number"] {
  font-family: var(--font-score);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* App shell ---------------------------------------------------------------- */
#app { min-height: 100%; display: flex; flex-direction: column; }

.view {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--sp-4);
  padding-bottom: calc(var(--sp-7) + env(safe-area-inset-bottom));
  animation: view-in var(--dur) var(--ease);
}
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Top app bar -------------------------------------------------------------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  height: var(--header-h);
  padding: 0 var(--sp-3);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.appbar__title {
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.appbar__title small {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0;
}

/* Brand wordmark with a chalk underline */
.wordmark {
  font-size: var(--fs-xl);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}
.wordmark b { color: var(--accent); font-weight: 800; }
.wordmark::after {
  content: "";
  display: block;
  height: 3px;
  width: 46px;
  margin-top: 6px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
}

/* Boot splash -------------------------------------------------------------- */
#boot {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-content: center; justify-items: center; gap: 18px;
  background: var(--bg);
  transition: opacity 320ms var(--ease);
}
#boot.hide { opacity: 0; pointer-events: none; }
.boot-mark {
  width: 76px; height: 76px; border-radius: 20px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  position: relative;
  box-shadow: var(--shadow-2);
}
.boot-mark::before {
  content: ""; position: absolute; inset: 22px 20px auto 20px; height: 30px;
  background:
    repeating-linear-gradient(90deg, var(--text) 0 3px, transparent 3px 12px);
  border-bottom: 3px solid var(--accent); padding-bottom: 6px;
}
.boot-mark::after {
  content: ""; position: absolute; inset: 20px 16px 24px 16px;
  border-left: 3px solid var(--win);
  transform: rotate(58deg); transform-origin: bottom left;
  animation: tally 900ms var(--ease) infinite alternate;
}
@keyframes tally { from { opacity: 0.35; } to { opacity: 1; } }
.boot-name { font-size: var(--fs-lg); font-weight: 800; letter-spacing: -0.02em; }

/* Utility ------------------------------------------------------------------ */
.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.row { display: flex; align-items: center; gap: var(--sp-3); }
.row--between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--text-muted); }
.center { text-align: center; }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.section-title {
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: var(--sp-5) 0 var(--sp-2);
  font-weight: 700;
}
.section-title:first-child { margin-top: 0; }
