/* Defense Buddy Coach. Brand colors and fonts come from the seed deck. */
:root {
  color-scheme: dark;
  --bg: #0c0c0c;
  --surface: #161614;
  --surface-2: #1f1f1c;
  --line: #33332f;
  --text: #f1f1ea;
  --muted: #c0c0bb;
  --faint: #8a8a82;
  --accent: #c6f000;
  --accent-ink: #0c0c0c;
  --bad: #ff6b57;
  --radius: 16px;
  --font-head: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
h3 {
  font-family: var(--font-head);
  line-height: 1.15;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 21px;
}

h3 {
  font-size: 17px;
}

p {
  margin: 0 0 12px;
}

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

button,
input {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.muted {
  color: var(--muted);
}

.fine {
  color: var(--faint);
  font-size: 13px;
}

.flush {
  margin-bottom: 0;
}

.bar + .fine {
  margin-top: 10px;
}

.block-link {
  display: block;
}

/* Loading screen */
.boot {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  color: var(--muted);
}

/* App shell */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: rgba(12, 12, 12, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 17px;
}

.brand img {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

.brand em {
  font-style: normal;
  color: var(--accent);
}

.page {
  max-width: 680px;
  margin: 0 auto;
  padding: 20px 16px calc(96px + var(--safe-bottom));
}

.banner {
  max-width: 680px;
  margin: 12px auto 0;
  padding: 0 16px;
}

.banner p {
  margin: 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px dashed var(--line);
  color: var(--muted);
  font-size: 13px;
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 6px 8px calc(6px + var(--safe-bottom));
  background: rgba(12, 12, 12, 0.96);
  border-top: 1px solid var(--line);
}

.tabbar a {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 6px 0;
  color: var(--faint);
  font-size: 12px;
  font-weight: 600;
}

.tabbar a.on {
  color: var(--accent);
}

.tabbar svg {
  width: 22px;
  height: 22px;
}

/* Buttons and forms */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}

.btn svg {
  flex: none;
  width: 20px;
  height: 20px;
}

.btn {
  white-space: nowrap;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn.block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.55;
  cursor: progress;
}

.link {
  background: none;
  border: 0;
  padding: 6px 4px;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}

label.field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  font-weight: 600;
  font-size: 14px;
}

input[type='text'] {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
}

input[type='text']:focus {
  border-color: var(--accent);
  outline: none;
}

.error {
  color: var(--bad);
  font-size: 14px;
  min-height: 1.5em;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.card.accent {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.card.accent .muted {
  color: #3a4400;
}

.eyebrow {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

.card.accent .eyebrow {
  color: #3a4400;
}

.bar {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.bar.bad > span {
  background: var(--bad);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.stat strong {
  display: block;
  font-family: var(--font-head);
  font-size: 34px;
  line-height: 1.1;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
}

.stat strong small {
  font-size: 18px;
}

.stat.highlight strong {
  color: var(--accent);
}

/* Drill list */
.section-title {
  margin: 24px 0 10px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.drills {
  display: grid;
  gap: 10px;
}

.drill-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
}

.drill-row:hover {
  border-color: var(--faint);
}

.drill-row b {
  display: block;
  font-family: var(--font-head);
  font-size: 17px;
}

.drill-row small {
  color: var(--muted);
}

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.pill.done {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* Drill detail */
.back {
  display: inline-block;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
}

.steps {
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  position: relative;
  padding: 0 0 12px 40px;
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -2px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-weight: 700;
  font-size: 14px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 14px;
}

.chip.pass {
  border-color: var(--accent);
  color: var(--accent);
}

.chip.fail {
  border-color: var(--bad);
  color: var(--bad);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  margin-bottom: 16px;
}

.segmented button {
  min-height: 42px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}

.segmented button[aria-pressed='true'] {
  background: var(--text);
  color: var(--bg);
}

.tip {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 16px;
}

.tip svg {
  flex: none;
  width: 22px;
  height: 22px;
  color: var(--accent);
}

/* Role picker */
.choices {
  display: grid;
  gap: 10px;
  margin: 0 0 16px;
  padding: 0;
  border: 0;
}

.choices legend {
  padding: 0;
}

.code-input {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  text-transform: uppercase;
  letter-spacing: 0.2em;
}

.choice {
  display: grid;
  gap: 2px;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
}

.choice:has(input:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice b {
  font-family: var(--font-head);
  font-size: 17px;
}

/* Sign-in */
.hero {
  min-height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  padding: calc(48px + var(--safe-top)) 20px calc(32px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hero .logo {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  margin-bottom: 24px;
}

.hero h1 {
  font-size: 38px;
}

.hero h1 em {
  font-style: normal;
  color: var(--accent);
}

.privacy {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 20px;
  color: var(--muted);
  font-size: 14px;
}

.privacy svg {
  flex: none;
  width: 18px;
  height: 18px;
  color: var(--accent);
}

/* Results */
.score {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 18px;
  align-items: center;
}

.ring {
  position: relative;
  width: 112px;
  height: 112px;
}

.ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring strong {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-head);
  font-size: 34px;
}

.check-bars {
  display: grid;
  gap: 12px;
}

.check-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  margin-bottom: 4px;
}

.coach-note {
  font-size: 18px;
  line-height: 1.5;
  margin: 0 0 12px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Tables */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  text-align: left;
  color: var(--faint);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0 8px 8px 0;
}

.table td {
  padding: 10px 8px 10px 0;
  border-top: 1px solid var(--line);
}

.table td.num,
.table th.num {
  text-align: right;
}

.code {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--accent);
}

.week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  text-align: center;
  font-size: 12px;
  color: var(--faint);
}

.week i {
  display: block;
  height: 28px;
  margin-bottom: 4px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.week i.on {
  background: var(--accent);
  border-color: var(--accent);
}

/* Practice screen */
.practice {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: #000;
  overflow: hidden;
}

.practice video,
.practice canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: scaleX(-1);
}

.hud-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(10px + var(--safe-top)) 12px 10px;
  background: linear-gradient(rgba(0, 0, 0, 0.75), transparent);
}

.hud-top h2 {
  margin: 0;
  font-size: 18px;
  text-align: center;
}

.round {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(241, 241, 234, 0.25);
  background: rgba(12, 12, 12, 0.6);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.round svg {
  width: 22px;
  height: 22px;
}

.hud-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 40px 16px calc(16px + var(--safe-bottom));
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.85) 40%);
  display: grid;
  gap: 12px;
  justify-items: center;
  text-align: center;
}

.counter {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 64px;
  line-height: 1;
}

.counter small {
  font-size: 24px;
  color: var(--muted);
}

.status {
  max-width: 520px;
  min-height: 1.5em;
  font-size: 18px;
  font-weight: 600;
}

.status.bad {
  color: var(--bad);
}

.status.good {
  color: var(--accent);
}

.hud-bottom .chips {
  justify-content: center;
}

.hud-bottom .chip {
  background: rgba(12, 12, 12, 0.7);
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  background: rgba(12, 12, 12, 0.82);
}

/* The get-ready countdown lets the camera show through. */
.overlay.soft {
  background: rgba(12, 12, 12, 0.45);
}

.overlay .big {
  font-family: var(--font-head);
  font-size: 96px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.overlay p {
  max-width: 420px;
  color: var(--muted);
}

.debug {
  position: absolute;
  top: calc(64px + var(--safe-top));
  left: 8px;
  max-width: 60vw;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.7);
  font: 12px/1.4 ui-monospace, Menlo, monospace;
  color: var(--accent);
  white-space: pre;
  pointer-events: none;
}

.spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 3s;
  }
}

@media (min-width: 720px) {
  h1 {
    font-size: 36px;
  }

  .page {
    padding-top: 28px;
  }
}
