*,*::before,*::after{box-sizing:border-box;}

/* Self-hosted, subset to the glyphs the card actually uses. No external font
   host, so the export is never a font race and there is no third-party request. */
@font-face{
  font-family:'Anton';
  src:url('assets/fonts/anton.woff2') format('woff2');
  font-weight:400; font-style:normal; font-display:swap;
}
@font-face{
  font-family:'Inter';
  src:url('assets/fonts/inter.woff2') format('woff2');
  font-weight:100 900; font-style:normal; font-display:swap;
}
@font-face{
  font-family:'JetBrains Mono';
  src:url('assets/fonts/jetbrains-mono.woff2') format('woff2');
  font-weight:100 800; font-style:normal; font-display:swap;
}

/* Page chrome tokens. The card below keeps its own fixed paper palette, so the
   exported PNG is identical in both themes. tests/theme.test.js checks the
   text pairings here for WCAG AA. */
:root{
  --ui-bg:#0e0e0e;
  --ui-fg:#edeae3;
  --ui-muted:#a8a8a0;
  --ui-faint:#8a8a8a;
  --ui-placeholder:#8f8f8f;
  --ui-panel:#161616;
  --ui-panel-2:#181818;
  --ui-line:rgba(255,255,255,.12);
  --ui-line-strong:rgba(255,255,255,.15);
  --ui-hover:rgba(255,255,255,.06);
  --ui-accent:#ff6a00;
  --ui-accent-ink:#0e0e0e;
  --ui-toast-bg:#edeae3;
  --ui-toast-fg:#0e0e0e;
}
[data-theme="light"]{
  --ui-bg:#f4f1ea;
  --ui-fg:#141414;
  --ui-muted:#454540;
  --ui-faint:#54544d;
  --ui-placeholder:#6b6b63;
  --ui-panel:#ffffff;
  --ui-panel-2:#fbf9f4;
  --ui-line:rgba(20,20,20,.16);
  --ui-line-strong:rgba(20,20,20,.22);
  --ui-hover:rgba(20,20,20,.05);
  /* Darkened from #ff6a00 so accent text passes AA on the light surface. */
  --ui-accent:#a84200;
  --ui-accent-ink:#ffffff;
  --ui-toast-bg:#141414;
  --ui-toast-fg:#f4f1ea;
}

html,body{margin:0;padding:0;}
body{
  background:var(--ui-bg); color:var(--ui-fg);
  font-family:'Inter',system-ui,sans-serif;
  -webkit-font-smoothing:antialiased;
  min-height:100vh; min-height:100dvh;
  transition:background-color .2s, color .2s;
}

.wrap{
  max-width:1080px; margin:0 auto;
  padding:48px 22px 100px;
  display:grid; grid-template-columns:1fr;
  gap:44px; align-items:start;
}
@media (min-width:980px){
  .wrap{grid-template-columns:400px minmax(0,1fr); gap:64px; padding-top:72px;}
}

/* ---------- THEME TOGGLE ---------- */
.theme-toggle{
  position:fixed; top:18px; right:18px; z-index:100;
  width:46px; height:46px;
  display:inline-flex; align-items:center; justify-content:center;
  cursor:pointer;
  background:var(--ui-panel); color:var(--ui-fg);
  border:1px solid var(--ui-line-strong);
  font-size:18px; line-height:1;
  transition:background .2s, border-color .2s, transform .18s;
}
.theme-toggle:hover{background:var(--ui-hover); border-color:var(--ui-accent);}
.theme-toggle:active{transform:scale(.94);}
.theme-toggle:focus-visible{outline:2px solid var(--ui-accent); outline-offset:2px;}
.theme-toggle-icon{pointer-events:none;}

/* ---------- PANEL ---------- */
.panel{max-width:460px;}
@media (min-width:980px){ .panel{position:sticky; top:72px;} }

.eyebrow{
  display:inline-flex; align-items:center; gap:12px;
  font-family:'JetBrains Mono',monospace;
  font-size:10px; font-weight:800;
  letter-spacing:.38em; text-transform:uppercase;
  color:var(--ui-accent);
  padding:9px 15px;
  border:1px solid var(--ui-accent);
  background:var(--ui-hover);
  margin-bottom:28px;
}
.eyebrow::before{content:''; width:6px; height:6px; background:var(--ui-accent);}

h1{
  font-family:'Anton',sans-serif;
  font-size:clamp(40px,6vw,60px);
  line-height:.98; font-weight:400;
  letter-spacing:.005em;
  margin:0 0 20px; color:var(--ui-fg);
  text-transform:uppercase;
}
h1 em{ font-style:normal; color:var(--ui-accent); }
.sub{
  font-size:16px; line-height:1.65; color:var(--ui-muted);
  margin:0 0 34px; max-width:42ch;
}

.form{display:flex; flex-direction:column; gap:10px; margin-bottom:14px;}

/* Visually hidden but available to screen readers. */
.sr-only{
  position:absolute; width:1px; height:1px;
  padding:0; margin:-1px; overflow:hidden;
  clip:rect(0 0 0 0); clip-path:inset(50%);
  white-space:nowrap; border:0;
}

.input-wrap{
  display:flex; align-items:center;
  background:var(--ui-panel);
  border:1px solid var(--ui-line);
  padding:0 20px; height:60px;
  transition:border-color .2s, background .2s;
}
.input-wrap:focus-within{ border-color:var(--ui-accent); background:var(--ui-panel-2); }
.input-wrap .at{
  font-family:'JetBrains Mono',monospace;
  font-size:17px; font-weight:800;
  color:var(--ui-accent); margin-right:4px;
}
.input-wrap input{
  flex:1; min-width:0;
  background:none; border:0; outline:none;
  color:var(--ui-fg);
  font-family:'JetBrains Mono',monospace;
  font-size:16px; font-weight:500;
  padding:0;
}
.input-wrap input::placeholder{color:var(--ui-placeholder);}
/* Ring the whole control, not the bare input inside it. */
.input-wrap:focus-within{ outline:2px solid var(--ui-accent); outline-offset:2px; }

.btn{
  appearance:none; cursor:pointer;
  border:1px solid var(--ui-line-strong);
  background:transparent; color:var(--ui-fg);
  font-family:'JetBrains Mono',monospace;
  font-size:11px; font-weight:800;
  letter-spacing:.26em; text-transform:uppercase;
  min-height:50px; padding:0 18px;
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  transition:all .18s; white-space:nowrap;
}
.btn:hover:not(:disabled){background:var(--ui-hover); border-color:var(--ui-line-strong);}
.btn:active:not(:disabled){transform:scale(.985);}
.btn:disabled{opacity:.5; cursor:not-allowed;}

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

.btn-primary{
  min-height:60px; font-size:12.5px;
  border:0; color:var(--ui-accent-ink);
  background:var(--ui-accent);
  font-weight:900;
  letter-spacing:.30em;
}
.btn-primary:hover:not(:disabled){filter:brightness(1.08);}

.actions{display:grid; grid-template-columns:1fr 1fr; gap:8px;}
.actions .btn:first-child{grid-column:1 / -1;}

.hint{
  font-family:'JetBrains Mono',monospace;
  font-size:11px; line-height:1.8; color:var(--ui-faint);
  margin:20px 0 0; max-width:40ch;
}

/* ---------- STAGE ---------- */
.stage-col{display:flex; justify-content:center;}
.stage{position:relative; width:100%; max-width:470px; --s:.435;}

/* ============================================================
   CARD — download-safe CSS only
   ============================================================ */
.card{
  --accent:#ff6a00;
  --accent-deep:#ad4800;
  --accent-ink:#0e0e0e;
  --ink:#0e0e0e;
  --paper:#edeae3;
  --tier:#d32f2f;
  --tier-ink:#ffffff;
  position:absolute; top:0; left:0;
  width:1080px; height:1350px;
  transform-origin:top left;
  transform:scale(var(--s));
  background:var(--paper);
  color:var(--ink);
  font-family:'Inter',sans-serif;
  overflow:hidden;
}

/* black diagonal — gradient hard-stop, html2canvas-safe */
.diag-bg{
  position:absolute;
  top:0; right:0;
  width:64%; height:64%;
  background:linear-gradient(to bottom left,
    var(--ink) 0%,
    var(--ink) 60%,
    rgba(14,14,14,0) 60%,
    rgba(14,14,14,0) 100%);
  z-index:1;
}
/* orange accent stripe rotated across the black area */
.diag-stripe{
  position:absolute;
  top:150px; right:-120px;
  width:880px; height:190px;
  background:var(--accent);
  transform:rotate(-14deg);
  transform-origin:top right;
  z-index:2;
}

/* subtle watermark — one SVG pattern node (solid faint fill, html2canvas-safe) */
.watermark{
  position:absolute;
  inset:0;
  width:100%; height:100%;
  z-index:3;
  pointer-events:none;
}

.card-inner{
  position:relative; z-index:5;
  height:100%;
  padding:68px 72px 60px;
  display:flex;
  flex-direction:column;
}

/* ---------- TOP BAR ---------- */
.top-bar{
  display:flex; align-items:center; justify-content:space-between;
  padding-bottom:22px;
  border-bottom:2px solid var(--ink);
  flex-shrink:0;
  position:relative; z-index:6;
}
.brand{
  display:flex; align-items:center; gap:14px;
  font-family:'JetBrains Mono',monospace;
  font-size:20px; font-weight:800;
  letter-spacing:.26em; text-transform:uppercase;
  color:var(--ink);
}
.brand-mark{
  width:15px; height:15px;
  background:var(--accent);
  transform:rotate(45deg);
  box-shadow:0 0 0 3px var(--paper), 0 0 0 5px var(--ink);
}
.nav{
  font-family:'JetBrains Mono',monospace;
  font-size:15px; font-weight:800;
  letter-spacing:.26em; text-transform:uppercase;
  color:var(--ink); opacity:.68;
}

/* ---------- HERO ---------- */
.hero{
  display:grid;
  grid-template-columns:1fr 400px;
  gap:40px;
  padding:48px 0 40px;
  align-items:start;
  flex-shrink:0;
  position:relative; z-index:6;
}
.hero-left{min-width:0;}

.eyebrow-card{
  display:inline-flex; align-items:center; gap:16px;
  font-family:'JetBrains Mono',monospace;
  font-size:16px; font-weight:800;
  letter-spacing:.28em; text-transform:uppercase;
  color:var(--accent-deep);
  margin-bottom:22px;
}
.eyebrow-card::after{
  content:''; width:56px; height:3px; background:var(--accent);
}

/* BIG title + Death-Note strikes */
.title-wrap{
  position:relative;
  display:inline-block;
  margin-bottom:28px;
  z-index:7;
}
.title{
  font-family:'Anton',sans-serif;
  font-size:148px;
  line-height:.88;
  letter-spacing:-.005em;
  color:var(--ink);
  margin:0; padding:14px 0;
  font-weight:400;
  position:relative;
  z-index:2;
}
.strike{
  position:absolute;
  left:-16px; right:-16px;
  background:var(--paper);
  z-index:3;
  pointer-events:none;
}
.strike.s1{ top:42%; height:8px; }
.strike.s2{ top:70%; height:5px; }

.meta-row{
  display:flex; align-items:center; gap:18px;
  margin-bottom:30px;
  flex-wrap:wrap;
}
.handle{
  font-family:'JetBrains Mono',monospace;
  font-size:32px; font-weight:700;
  letter-spacing:-.01em;
  color:var(--ink);
  line-height:1;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
  max-width:100%;
}
.tier{
  display:inline-block;
  font-family:'JetBrains Mono',monospace;
  font-size:15px; font-weight:800;
  letter-spacing:.26em; text-transform:uppercase;
  color:var(--tier-ink);
  background:var(--tier);
  padding:10px 16px;
  line-height:1;
  flex-shrink:0;
}

.title-kicker{
  font-family:'JetBrains Mono',monospace;
  font-size:17px; font-weight:800;
  letter-spacing:.16em; text-transform:uppercase;
  color:var(--ink);
  margin-bottom:16px;
  padding-left:16px;
  border-left:4px solid var(--accent);
  line-height:1.4;
}
.synopsis{
  font-size:21px;
  line-height:1.55;
  color:#2b2b2b;
  margin:0;
  max-width:46ch;
  letter-spacing:-.005em;
}

/* character panel */
.hero-right{
  display:flex; flex-direction:column; align-items:center;
  gap:24px;
  padding-top:8px;
}
.avatar-circle{
  position:relative;
  width:328px; height:328px;
  border-radius:50%;
  overflow:hidden;
  background:#1a1a1a;
  box-shadow:
    0 0 0 8px var(--paper),
    0 0 0 11px var(--ink);
  flex-shrink:0;
}
.avatar-circle img{
  position:absolute; inset:0;
  width:100%; height:100%;
  object-fit:cover;
  display:block;
  z-index:2;
}
.avatar-fallback{
  position:absolute; inset:0;
  display:none; align-items:center; justify-content:center;
  background:var(--accent);
  color:var(--accent-ink);
  font-family:'Anton',sans-serif;
  font-size:150px;
  line-height:1;
  z-index:1;
}
.id-badge{
  font-family:'JetBrains Mono',monospace;
  font-size:15px; font-weight:800;
  letter-spacing:.24em; text-transform:uppercase;
  color:var(--ink);
  background:var(--paper);
  padding:12px 22px;
  border:2px solid var(--ink);
  line-height:1;
}
/* Shown only when the picture could not be fetched (contrast 5.9:1 on paper). */
.avatar-hint{
  margin:0;
  font-family:'JetBrains Mono',monospace;
  font-size:14px; font-weight:800;
  letter-spacing:.18em; text-transform:uppercase;
  color:#5a5a5a;
}

/* ---------- SCORE BAND ---------- */
.score-band{
  padding:34px 0 30px;
  border-top:2px solid var(--ink);
  flex-shrink:0;
  position:relative; z-index:6;
}
.score-label{
  font-family:'JetBrains Mono',monospace;
  font-size:16px; font-weight:800;
  letter-spacing:.34em; text-transform:uppercase;
  color:var(--accent-deep);
  margin-bottom:10px;
}
.score-row{display:flex; align-items:baseline; gap:20px;}
.score{
  font-family:'Anton',sans-serif;
  font-size:138px;
  line-height:.88;
  letter-spacing:-.015em;
  color:var(--ink);
  font-variant-numeric:tabular-nums;
  margin:0; font-weight:400;
}
.score-max{
  font-family:'JetBrains Mono',monospace;
  font-size:24px; font-weight:800;
  color:#5a5a5a;
  letter-spacing:.04em;
}

/* ---------- STATS ---------- */
.stats{
  display:grid;
  grid-template-columns:repeat(3, 1fr);
  gap:28px 44px;
  padding:32px 0 34px;
  border-bottom:1px solid rgba(14,14,14,.22);
  flex-shrink:0;
  position:relative; z-index:6;
}
.stat{display:flex; flex-direction:column;}
.stat-head{
  display:flex; justify-content:space-between; align-items:baseline;
  margin-bottom:10px;
}
.stat-name{
  font-family:'JetBrains Mono',monospace;
  font-size:14px; font-weight:800;
  letter-spacing:.22em; text-transform:uppercase;
  color:var(--ink);
}
.stat-val{
  font-family:'Anton',sans-serif;
  font-size:32px;
  line-height:1;
  color:var(--ink);
  letter-spacing:-.005em;
  font-variant-numeric:tabular-nums;
}
.stat-val small{
  font-family:'JetBrains Mono',monospace;
  font-size:13px; font-weight:800;
  color:var(--accent-deep);
  margin-left:2px;
  vertical-align:top;
  letter-spacing:0;
}
.stat-bar{
  height:7px;
  background:#c8c4bb;
  overflow:hidden;
}
.stat-bar i{
  display:block; height:100%;
  background:var(--accent);
}

/* ---------- FOOTER ---------- */
.footer{
  margin-top:auto;
  padding-top:30px;
  display:flex; justify-content:space-between; align-items:center;
  font-family:'JetBrains Mono',monospace;
  font-size:15px; font-weight:800;
  letter-spacing:.28em; text-transform:uppercase;
  color:var(--ink);
  flex-shrink:0;
  position:relative; z-index:6;
}
.footer b{color:var(--accent-deep);}
/* Engine schema version. Fixed card palette, so it renders the same in every
   page theme and is part of the exported PNG. */
.schema-badge{
  border:1px solid var(--ink);
  padding:3px 10px;
  letter-spacing:.18em;
  font-size:12px;
}

/* ---------- TOAST ---------- */
.toast{
  position:fixed; left:50%; bottom:28px;
  transform:translate(-50%,26px);
  background:var(--ui-toast-bg); color:var(--ui-toast-fg);
  border:2px solid var(--ui-toast-fg);
  padding:13px 22px;
  font-family:'JetBrains Mono',monospace;
  font-size:11px; font-weight:800;
  letter-spacing:.20em; text-transform:uppercase;
  box-shadow:6px 6px 0 var(--ui-accent);
  opacity:0; pointer-events:none;
  transition:opacity .2s, transform .2s;
  z-index:99; max-width:88vw; text-align:center;
}
.toast.on{opacity:1; transform:translate(-50%,0);}
/* ---------- PAGE FOOTER ---------- */
.page-footer{
  text-align:center;
  padding:6px 20px 40px;
  font-family:'JetBrains Mono',monospace;
  font-size:11px; font-weight:800;
  letter-spacing:.28em; text-transform:uppercase;
  color:var(--ui-muted);
}
.page-footer a{
  color:var(--ui-accent);
  text-decoration:none;
  border-bottom:1px solid var(--ui-accent);
  padding-bottom:1px;
}
.page-footer a:hover{color:var(--ui-fg); border-color:var(--ui-fg);}
.page-footer a:focus-visible{outline:2px solid var(--ui-accent); outline-offset:2px;}
.noscript{
  max-width:640px; margin:24px auto; padding:16px 20px;
  background:var(--ui-panel); border:1px solid var(--ui-line-strong);
  color:var(--ui-fg);
  font-family:'JetBrains Mono',monospace;
  font-size:13px; line-height:1.7; text-align:center;
}
.spin{
  width:12px; height:12px; border-radius:50%;
  border:2px solid rgba(14,14,14,.25);
  border-top-color:currentColor;
  animation:sp .7s linear infinite;
}
@keyframes sp{to{transform:rotate(360deg);}}

/* Honour reduced-motion: no spinner, no fades, no theme cross-fade. */
@media (prefers-reduced-motion: reduce){
  .spin{animation:none;}
  *,*::before,*::after{
    animation-duration:.001ms !important;
    animation-iteration-count:1 !important;
    transition-duration:.001ms !important;
  }
}
