/* Keep of the Iron Oath — "Tinctures".
   Every colour is a heraldic tincture with one job, and every bar also carries
   that tincture's engraver's hatching (Petra Sancta, 1638), so state never
   rests on colour alone. */

:root {
  color-scheme: dark;
  /* Tinctures */
  --sable: #0d0c10;
  --sable-2: #16141b;
  --sable-3: #211e27;
  --sable-line: #3a3542;
  --argent: #dcd8cf;
  --argent-2: #b1ab9f;
  --argent-3: #8a8479;
  --gules: #b8323a;      /* life */
  --gules-ghost: #e6a1a0;
  --vert: #4f9a66;       /* stamina */
  --or: #d8a640;         /* the Oath: parry, posture, fulfilled */
  --or-deep: #8f6a22;
  --azure: #5a86c8;      /* the spectral */
  --purpure: #8c4bb5;    /* abyssal corruption */

  /* Hatching (Petra Sancta) */
  --hatch-gules: repeating-linear-gradient(90deg, rgb(0 0 0 / .32) 0 1px, transparent 1px 4px);
  --hatch-vert: repeating-linear-gradient(45deg, rgb(0 0 0 / .32) 0 1px, transparent 1px 5px);
  --hatch-or: radial-gradient(circle at 50% 50%, rgb(0 0 0 / .34) 0 .9px, transparent 1.2px) 0 0 / 4px 4px;
  --hatch-azure: repeating-linear-gradient(0deg, rgb(0 0 0 / .32) 0 1px, transparent 1px 4px);
  --hatch-purpure: repeating-linear-gradient(-45deg, rgb(0 0 0 / .32) 0 1px, transparent 1px 5px);
  --hatch-sable: repeating-linear-gradient(0deg, rgb(255 255 255 / .022) 0 1px, transparent 1px 6px), repeating-linear-gradient(90deg, rgb(255 255 255 / .022) 0 1px, transparent 1px 6px);

  /* Type: two Zapf faces from system stacks (no font files) */
  --font-display: "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", P052, Georgia, serif;
  --font-ui: Optima, "Optima nova", Candara, "Noto Sans", "Segoe UI", system-ui, sans-serif;
  --step--2: .64rem;
  --step--1: .8rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.563rem;
  --step-3: 1.953rem;
  --step-4: 2.441rem;
  --step-5: 3.052rem;
  --step-6: 3.815rem;

  /* Space (4 px base) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

  /* Forged surfaces: near-square plates, two-layer shadows */
  --r-plate: 2px;
  --shadow-plate: inset 0 1px 0 rgb(255 255 255 / .05), 0 1px 2px rgb(0 0 0 / .6), 0 10px 28px rgb(0 0 0 / .45);
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --ease-io: cubic-bezier(.65, 0, .35, 1);
  --dur-1: 120ms; --dur-2: 200ms; --dur-3: 260ms;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--sable); color: var(--argent); }
body {
  font-family: var(--font-ui);
  font-size: var(--step-0);
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
kbd {
  display: inline-grid; place-items: center;
  min-width: 1.7em; height: 1.7em; padding: 0 .4em;
  font-family: var(--font-ui); font-size: .78em; font-weight: 600; line-height: 1;
  color: var(--argent); background: var(--sable-3);
  border: 1px solid var(--sable-line); border-bottom-width: 2px; border-radius: var(--r-plate);
  font-variant-numeric: tabular-nums;
}
:focus-visible { outline: 2px solid var(--or); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: fixed; left: var(--s4); top: -60px; z-index: 100; padding: var(--s2) var(--s3); background: var(--or); color: var(--sable); border-radius: var(--r-plate); }
.skip:focus { top: var(--s4); }

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; }

/* ------------------------------------------------------------------ buttons */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 44px; padding: 0 var(--s5);
  font-family: var(--font-display); font-size: var(--step-0); letter-spacing: .08em; font-variant: small-caps;
  border-radius: var(--r-plate); cursor: pointer;
  transition: background-color var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out);
}
.btn:active { transform: translateY(1px); }
.btn--oath { color: var(--sable); background: var(--or); border: 1px solid #f0c66a; box-shadow: inset 0 -2px 0 var(--or-deep), 0 2px 6px rgb(0 0 0 / .5); }
.btn--oath:hover { background: #e6b552; }
.btn--plain { color: var(--argent); background: var(--sable-2); border: 1px solid var(--sable-line); }
.btn--plain:hover { border-color: var(--argent-3); background: var(--sable-3); }
.btn--small { min-height: 36px; padding: 0 var(--s4); font-size: var(--step--1); }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; font-size: 24px; line-height: 1; color: var(--argent-2); background: transparent; border: 0; border-radius: var(--r-plate); cursor: pointer; }
.icon-btn:hover { color: var(--argent); background: var(--sable-3); }

/* ------------------------------------------------------------------ screens */
.screen { position: fixed; inset: 0; z-index: 20; }

.loading {
  display: grid; place-content: center; gap: var(--s4); text-align: center;
  background: var(--sable); background-image: var(--hatch-sable);
}
.loading__title { margin: 0; font-family: var(--font-display); font-size: var(--step-3); font-variant: small-caps; letter-spacing: .1em; }
.loading__steps { margin: 0; padding: 0; list-style: none; color: var(--argent-3); font-size: var(--step--1); }
.loading__steps li { transition: color var(--dur-2) var(--ease-out); }
.loading__steps li.done { color: var(--argent-2); }
.loading__steps li.done::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 8px; transform: rotate(45deg) translateY(-1px); background: var(--or); }

.fault { display: grid; place-content: center; gap: var(--s4); text-align: center; padding: var(--s6); background: var(--sable); }
.fault h2 { margin: 0; font-family: var(--font-display); font-size: var(--step-4); font-variant: small-caps; color: var(--gules); }
.fault p { max-width: 52ch; margin: 0 auto; color: var(--argent-2); }

/* Title: copy left, the escutcheon hero right, over the live citadel */
.title {
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: center; gap: var(--s7);
  padding: calc(var(--s7) + var(--safe-t)) calc(var(--s8) + var(--safe-r)) calc(var(--s7) + var(--safe-b)) calc(var(--s8) + var(--safe-l));
  background: linear-gradient(90deg, rgb(13 12 16 / .92) 0%, rgb(13 12 16 / .7) 45%, rgb(13 12 16 / .15) 100%);
}
.title__copy { max-width: 34rem; }
.title__kicker { margin: 0 0 var(--s3); color: var(--or); font-family: var(--font-display); font-style: italic; font-size: var(--step-1); }
.title__name {
  margin: 0; font-family: var(--font-display); font-weight: 400;
  font-size: clamp(var(--step-4), 6.4vw, 5.6rem); line-height: .95; letter-spacing: .02em; font-variant: small-caps;
  text-wrap: balance;
}
.title__name span { display: block; letter-spacing: .06em; }
.title__lede { max-width: 44ch; margin: var(--s5) 0 var(--s6); font-size: var(--step-1); line-height: 1.55; color: var(--argent-2); text-wrap: pretty; }
.title__actions { display: flex; flex-wrap: wrap; gap: var(--s3); }
.title__device { margin: var(--s5) 0 0; color: var(--argent-3); font-size: var(--step--1); }
.title__shield { margin: 0; display: grid; justify-items: center; gap: var(--s4); }
.shield-hero { width: min(360px, 40vw); aspect-ratio: 200 / 232; }
.readout {
  width: min(340px, 100%); min-height: 8.5em; padding: var(--s3) var(--s4);
  font-size: var(--step--1); line-height: 1.55; color: var(--argent-2);
  background: rgb(22 20 27 / .86); background-image: var(--hatch-sable);
  border-left: 2px solid var(--or); border-radius: var(--r-plate);
}
.readout strong { display: block; margin-bottom: 2px; font-family: var(--font-display); font-size: var(--step-0); font-weight: 400; font-variant: small-caps; letter-spacing: .05em; color: var(--argent); }
.readout .status { color: var(--or); }

/* Escutcheon SVG */
.escutcheon { width: 100%; height: 100%; display: block; overflow: visible; }
.escutcheon .ward { cursor: pointer; outline: none; }
.escutcheon .ward__field { transition: fill var(--dur-3) var(--ease-out); }
.escutcheon .ward__charge { transition: fill var(--dur-3) var(--ease-out), stroke var(--dur-3) var(--ease-out); }
.escutcheon .ward:hover .ward__edge, .escutcheon .ward:focus-visible .ward__edge { stroke: var(--or); stroke-width: 3; }
.escutcheon .ward__edge { fill: none; stroke: transparent; stroke-width: 2.5; transition: stroke var(--dur-2) var(--ease-out); }
.escutcheon .ward[data-current="true"] .ward__edge { stroke: var(--argent); }
.escutcheon .rim { fill: none; stroke: #6d6672; stroke-width: 5; }
.escutcheon .rim-inner { fill: none; stroke: #0a090c; stroke-width: 1.5; }

/* ------------------------------------------------------------------ HUD */
.hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.hud button, .hud a { pointer-events: auto; }

.vitals { position: absolute; top: calc(var(--s5) + var(--safe-t)); left: calc(var(--s5) + var(--safe-l)); display: flex; gap: var(--s3); align-items: flex-start; }
.mini-shield { width: 54px; height: 63px; margin: 0; filter: drop-shadow(0 2px 3px rgb(0 0 0 / .7)); }
.vitals__bars { display: grid; gap: 6px; padding-top: 3px; }

/* Fess: a heraldic bar with chamfered ends in a forged frame */
.fess {
  --w: 300px;
  position: relative; width: var(--w); height: 14px;
  background: rgb(10 9 12 / .82);
  clip-path: polygon(7px 0, calc(100% - 7px) 0, 100% 50%, calc(100% - 7px) 100%, 7px 100%, 0 50%);
  box-shadow: inset 0 0 0 1px #4d4754;
}
.fess::before { /* iron frame highlight */
  content: ""; position: absolute; inset: 0; z-index: 3; pointer-events: none;
  background: linear-gradient(180deg, rgb(255 255 255 / .12), transparent 40%, rgb(0 0 0 / .35));
}
.fess--short { --w: 210px; height: 10px; }
.fess__fill, .fess__ghost {
  position: absolute; inset: 2px 3px; transform-origin: 0 50%; transform: scaleX(1);
}
.fess__fill { z-index: 2; transition: transform 90ms linear; }
.fess__ghost { z-index: 1; background: var(--gules-ghost); opacity: .55; transition: transform 480ms var(--ease-io) 260ms; }
.fess--gules .fess__fill { background: var(--hatch-gules), var(--gules); }
.fess--vert .fess__fill { background: var(--hatch-vert), var(--vert); }
.fess--or .fess__fill { background: var(--hatch-or), var(--or); }
.fess--or.is-full { box-shadow: inset 0 0 0 1px var(--or); }
.fess--boss { --w: min(720px, 72vw); height: 13px; }

.flasks { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.vial {
  width: 9px; height: 16px; border-radius: 4px 4px 3px 3px;
  background: var(--hatch-gules), var(--gules);
  box-shadow: inset 0 0 0 1px #e07a7a55, 0 1px 2px rgb(0 0 0 / .6);
  transition: opacity var(--dur-2) var(--ease-out);
}
.vial.is-spent { background: transparent; box-shadow: inset 0 0 0 1px #6b5a5a; opacity: .7; }
.flasks__key kbd { font-size: 11px; min-width: 18px; height: 18px; margin-left: 4px; opacity: .8; }

.roll { position: absolute; top: calc(118px + var(--safe-t)); left: calc(var(--s5) + var(--safe-l)); width: min(320px, 70vw); }
.roll__title { margin: 0 0 var(--s1); font-family: var(--font-display); font-weight: 400; font-size: var(--step--1); font-variant: small-caps; letter-spacing: .12em; color: var(--argent-3); }
.roll__list { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
.roll__list li {
  position: relative; padding: 2px 0 2px 18px; font-size: var(--step--1); line-height: 1.4; color: var(--argent-2);
  text-shadow: 0 1px 2px rgb(0 0 0 / .9);
}
.roll__list li::before { content: ""; position: absolute; left: 3px; top: .62em; width: 7px; height: 7px; transform: rotate(45deg); border: 1px solid var(--argent-3); }
.roll__list li.is-current { color: var(--argent); }
.roll__list li.is-current::before { border-color: var(--or); }
.roll__list li.is-done { color: var(--argent-3); text-decoration: line-through; text-decoration-color: rgb(216 166 64 / .5); }
.roll__list li.is-done::before { background: var(--or); border-color: var(--or); }
.roll__list li.is-optional::after { content: " (shortcut)"; color: var(--argent-3); }

.prompt {
  position: absolute; left: 50%; bottom: calc(150px + var(--safe-b)); transform: translateX(-50%);
  display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s4) var(--s2) var(--s2);
  background: rgb(22 20 27 / .9); background-image: var(--hatch-sable);
  border: 1px solid var(--sable-line); border-radius: var(--r-plate); box-shadow: var(--shadow-plate);
  font-size: var(--step--1); white-space: nowrap;
  animation: rise var(--dur-2) var(--ease-out);
}
.prompt kbd { color: var(--sable); background: var(--argent); border-color: var(--argent); }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 6px); } }

.boss { position: absolute; left: 50%; bottom: calc(var(--s7) + var(--safe-b)); transform: translateX(-50%); display: grid; justify-items: center; gap: 6px; }
.boss__name { margin: 0; justify-self: start; font-family: var(--font-display); font-size: var(--step-1); font-variant: small-caps; letter-spacing: .06em; text-shadow: 0 2px 4px #000; }
.boss.is-corrupt .boss__name { color: #cfb3e3; }
.posture { position: relative; width: min(360px, 40vw); height: 6px; background: rgb(10 9 12 / .8); box-shadow: inset 0 0 0 1px #4d4754; }
.posture__fill { position: absolute; inset: 1px; transform: scaleX(0); transform-origin: 50% 50%; background: var(--hatch-or), var(--or); transition: transform 90ms linear; }
.posture.is-broken .posture__fill { background: var(--or); }

.target { position: absolute; left: 0; top: 0; display: grid; gap: 2px; justify-items: center; transform: translate(-50%, -100%); will-change: transform; }
.target__name { font-family: var(--font-display); font-size: var(--step--1); font-variant: small-caps; letter-spacing: .06em; text-shadow: 0 1px 3px #000; }
.target__hp, .target__posture { position: relative; width: 120px; height: 5px; background: rgb(10 9 12 / .8); box-shadow: inset 0 0 0 1px #4d4754; }
.target__posture { height: 3px; width: 90px; }
.target__hp span, .target__posture span { position: absolute; inset: 1px; transform-origin: 0 50%; }
.target__hp span { background: var(--gules); }
.target__posture span { background: var(--or); transform-origin: 50% 50%; }

/* Lozenge reticle: a heraldic diamond that closes in */
.reticle { position: absolute; left: 0; top: 0; width: 0; height: 0; will-change: transform; }
.reticle span {
  position: absolute; left: -9px; top: -9px; width: 18px; height: 18px;
  border: 2px solid var(--argent); transform: rotate(45deg);
  box-shadow: 0 0 0 1px rgb(0 0 0 / .6);
  animation: lozenge var(--dur-3) var(--ease-out);
}
.reticle span::after { content: ""; position: absolute; inset: 5px; background: var(--argent); }
.reticle.is-broken span { border-color: var(--or); }
.reticle.is-broken span::after { background: var(--or); }
@keyframes lozenge { from { transform: rotate(45deg) scale(2.2); opacity: 0; } }

.crit-prompt {
  position: absolute; left: 50%; top: 58%; transform: translateX(-50%);
  padding: var(--s1) var(--s3); font-family: var(--font-display); font-variant: small-caps; letter-spacing: .08em;
  color: var(--sable); background: var(--or); border-radius: var(--r-plate);
}
.crit-prompt kbd { margin-left: var(--s2); background: var(--sable); }

.banner { position: absolute; left: 0; right: 0; top: 24%; text-align: center; opacity: 0; transition: opacity 600ms var(--ease-io); }
.banner.is-shown { opacity: 1; }
.banner__sub { margin: 0; font-family: var(--font-display); font-style: italic; font-size: var(--step-0); color: var(--or); text-shadow: 0 2px 6px #000; }
.banner__title {
  margin: var(--s1) auto 0; display: inline-block; padding: 0 var(--s6) var(--s2);
  font-family: var(--font-display); font-size: clamp(var(--step-3), 4.5vw, var(--step-5)); font-variant: small-caps; letter-spacing: .06em;
  text-shadow: 0 3px 10px #000; border-bottom: 1px solid rgb(220 216 207 / .45);
}

.toast {
  position: absolute; left: 50%; top: calc(var(--s6) + var(--safe-t)); transform: translateX(-50%);
  max-width: min(560px, 90vw); padding: var(--s2) var(--s4);
  font-size: var(--step--1); text-align: center;
  background: rgb(22 20 27 / .9); border-left: 2px solid var(--or); border-radius: var(--r-plate);
  opacity: 0; transition: opacity var(--dur-3) var(--ease-out);
}
.toast.is-shown { opacity: 1; }
.toast[data-tone="life"] { border-left-color: var(--gules); }
.toast[data-tone="spectral"] { border-left-color: var(--azure); }
.toast[data-tone="corrupt"] { border-left-color: var(--purpure); }

.lock-hint { position: absolute; left: 50%; bottom: calc(var(--s5) + var(--safe-b)); transform: translateX(-50%); margin: 0; font-size: var(--step--1); color: var(--argent-3); text-shadow: 0 1px 2px #000; }
.keycap-btn {
  position: absolute; right: calc(var(--s5) + var(--safe-r)); bottom: calc(var(--s5) + var(--safe-b));
  display: inline-flex; align-items: center; gap: var(--s2); min-height: 40px; padding: 0 var(--s2) 0 var(--s3);
  font-family: var(--font-display); font-variant: small-caps; letter-spacing: .06em; color: var(--argent-2);
  background: rgb(22 20 27 / .82); border: 1px solid var(--sable-line); border-radius: var(--r-plate); cursor: pointer;
}
.keycap-btn:hover { color: var(--argent); border-color: var(--argent-3); }

/* Damage and parry: meta-layer feedback */
.damage-veil { position: fixed; inset: 0; z-index: 5; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, transparent 55%, rgb(120 16 22 / .55) 100%); }
.parry-flash { position: fixed; inset: 0; z-index: 6; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, transparent 50%, rgb(216 166 64 / .38) 92%); }
.parry-flash.is-on { animation: parry 260ms var(--ease-out); }
@keyframes parry { from { opacity: 1; } to { opacity: 0; } }
.centre-anchor { position: fixed; left: 50%; top: 50%; width: 180px; height: 180px; transform: translate(-50%, -50%); pointer-events: none; }

/* Special move key: lights Or when the Oath is half full */
.special { display: inline-flex; align-items: center; gap: 6px; margin-top: 2px; font-size: var(--step--1); color: var(--argent-3); text-shadow: 0 1px 2px #000; }
.special kbd { font-size: 11px; min-width: 18px; height: 18px; opacity: .7; }
.special.is-ready { color: var(--or); }
.special.is-ready kbd { opacity: 1; color: var(--sable); background: var(--or); border-color: #f0c66a; }
#bar-oath::after { content: ""; position: absolute; z-index: 4; left: 50%; top: 1px; bottom: 1px; width: 2px; background: rgb(13 12 16 / .85); }

/* ------------------------------------------------------------------ class select */
.select { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 46rem); align-items: center; padding: calc(var(--s6) + var(--safe-t)) calc(var(--s7) + var(--safe-r)) calc(var(--s6) + var(--safe-b)) var(--s6); background: linear-gradient(90deg, rgb(13 12 16 / 0) 0%, rgb(13 12 16 / .55) 45%, rgb(13 12 16 / .92) 70%); }
.select__panel { grid-column: 2; }
.select__title { margin: 0 0 var(--s5); font-family: var(--font-display); font-weight: 400; font-size: clamp(var(--step-4), 4.4vw, var(--step-5)); font-variant: small-caps; letter-spacing: .04em; line-height: 1; }
.select__cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
.oath-card {
  position: relative; display: grid; align-content: start; gap: var(--s2); padding: var(--s4) var(--s3) var(--s3); text-align: left; cursor: pointer;
  background: rgb(22 20 27 / .9); background-image: var(--hatch-sable);
  border: 1px solid var(--sable-line); border-top: 3px solid var(--sable-line); border-radius: var(--r-plate);
  transition: border-color var(--dur-1) var(--ease-out), transform var(--dur-2) var(--ease-out);
}
.oath-card:hover { border-color: var(--argent-3); }
.oath-card[aria-checked="true"] { border-color: var(--or); border-top-color: var(--or); transform: translateY(-4px); box-shadow: var(--shadow-plate); }
.oath-card__sigil { width: 44px; height: 50px; }
.oath-card__name { margin: 0; font-family: var(--font-display); font-size: var(--step-1); font-variant: small-caps; letter-spacing: .03em; line-height: 1.15; color: var(--argent); }
.oath-card__epithet { margin: 0; font-family: var(--font-display); font-style: italic; color: var(--or); font-size: var(--step--1); }
.oath-card__blurb { margin: 0; font-size: var(--step--1); line-height: 1.45; color: var(--argent-2); text-wrap: pretty; }
.oath-card__stats { margin: var(--s1) 0 0; display: grid; grid-template-columns: auto 1fr; gap: 4px var(--s2); align-items: center; font-size: 11px; color: var(--argent-3); }
.oath-card__stats dd { margin: 0; display: flex; gap: 2px; }
.pip { width: 100%; height: 6px; background: var(--sable-3); box-shadow: inset 0 0 0 1px #3f3a46; }
.pip.on.life { background: var(--hatch-gules), var(--gules); }
.pip.on.stamina { background: var(--hatch-vert), var(--vert); }
.pip.on.might { background: var(--hatch-or), var(--or); }
.pip.on.speed { background: var(--argent-2); }
.oath-card__special { margin: var(--s1) 0 0; padding-top: var(--s2); border-top: 1px solid var(--sable-line); font-size: 12px; line-height: 1.4; color: var(--argent-2); }
.oath-card__special strong { display: block; color: var(--or); font-family: var(--font-display); font-weight: 400; font-variant: small-caps; letter-spacing: .04em; font-size: var(--step-0); }
.oath-card__deflect { font-size: 11px; color: var(--argent-3); font-variant-numeric: tabular-nums; }
.select__actions { display: flex; gap: var(--s3); margin-top: var(--s5); }
.select__hint { margin: var(--s3) 0 0; font-size: var(--step--1); color: var(--argent-3); }

/* ------------------------------------------------------------------ inspector */
.inspector { position: fixed; z-index: 30; top: calc(var(--s4) + var(--safe-t)); right: calc(var(--s4) + var(--safe-r)); display: grid; justify-items: end; gap: var(--s2); }
.inspector__toggle {
  min-height: 34px; padding: 0 var(--s3);
  font-family: var(--font-display); font-variant: small-caps; letter-spacing: .06em; font-size: var(--step--1);
  color: var(--argent-3); background: rgb(22 20 27 / .7); border: 1px solid var(--sable-line); border-radius: var(--r-plate); cursor: pointer;
}
.inspector__toggle:hover, .inspector__toggle[aria-expanded="true"] { color: var(--argent); }
.inspector__panel {
  width: 248px; padding: var(--s3); display: grid; gap: var(--s3);
  font-size: var(--step--1); background: rgb(22 20 27 / .95); background-image: var(--hatch-sable);
  border: 1px solid var(--sable-line); border-radius: var(--r-plate); box-shadow: var(--shadow-plate);
}
.inspector fieldset { margin: 0; padding: 0; border: 0; display: grid; gap: var(--s1); }
.inspector legend { margin-bottom: var(--s1); font-family: var(--font-display); font-variant: small-caps; letter-spacing: .1em; color: var(--argent-3); }
.inspector label { display: flex; gap: var(--s2); align-items: center; min-height: 26px; cursor: pointer; }
.inspector input { accent-color: var(--or); }
.warp { grid-template-columns: 1fr 1fr; }
.warp legend { grid-column: 1 / -1; }
.warp button { min-height: 32px; padding: 0 var(--s2); font-size: var(--step--1); background: var(--sable-3); border: 1px solid var(--sable-line); border-radius: var(--r-plate); cursor: pointer; }
.warp button:hover { border-color: var(--argent-3); }
.inspector__stats { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px var(--s3); font-variant-numeric: tabular-nums; }
.inspector__stats dt { color: var(--argent-3); }
.inspector__stats dd { margin: 0; text-align: right; }

/* ------------------------------------------------------------------ death, victory, pause */
.death { display: grid; place-content: center; text-align: center; gap: var(--s3); background: radial-gradient(ellipse at center, rgb(13 12 16 / .55), rgb(13 12 16 / .9)); animation: fadein 900ms var(--ease-io); }
.death__title { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: clamp(var(--step-5), 8vw, 6rem); font-variant: small-caps; letter-spacing: .08em; color: var(--gules); }
.death__sub { margin: 0; color: var(--argent-2); font-style: italic; font-family: var(--font-display); font-size: var(--step-1); }
@keyframes fadein { from { opacity: 0; } }

.victory { display: grid; place-items: center; padding: var(--s6); background: rgb(13 12 16 / .84); background-image: var(--hatch-sable); animation: fadein 1200ms var(--ease-io); }
.victory__inner { display: grid; grid-template-columns: auto 1fr; gap: var(--s7); align-items: center; max-width: 880px; }
.shield-victory { width: 240px; aspect-ratio: 200 / 232; }
.victory__kicker { margin: 0; color: var(--argent-2); font-family: var(--font-display); font-style: italic; font-size: var(--step-1); }
.victory__title { margin: var(--s1) 0 var(--s5); font-family: var(--font-display); font-weight: 400; font-size: clamp(var(--step-5), 7vw, 5.4rem); line-height: 1; font-variant: small-caps; letter-spacing: .05em; color: var(--or); }
.victory__stats { display: grid; grid-template-columns: repeat(4, auto); gap: var(--s5); margin: 0 0 var(--s6); }
.victory__stats div { border-top: 1px solid var(--sable-line); padding-top: var(--s2); }
.victory__stats dt { font-size: var(--step--1); color: var(--argent-3); }
.victory__stats dd { margin: 0; font-family: var(--font-display); font-size: var(--step-3); font-variant-numeric: tabular-nums lining-nums; }

dialog { color: var(--argent); }
dialog::backdrop { background: rgb(5 4 8 / .6); }
.pause { padding: var(--s6); width: min(420px, 92vw); background: var(--sable-2); background-image: var(--hatch-sable); border: 1px solid var(--sable-line); border-radius: var(--r-plate); box-shadow: var(--shadow-plate); }
.pause h2 { margin: 0 0 var(--s5); font-family: var(--font-display); font-weight: 400; font-variant: small-caps; letter-spacing: .06em; font-size: var(--step-3); }
.pause__actions { display: grid; gap: var(--s2); }

/* Help drawer */
.drawer {
  position: fixed; inset: 0 0 0 auto; margin: 0; height: 100%; max-height: none; width: min(460px, 100vw);
  padding: 0; border: 0; border-left: 1px solid var(--sable-line);
  background: var(--sable-2); background-image: var(--hatch-sable);
  box-shadow: -20px 0 40px rgb(0 0 0 / .5);
}
.drawer[open] { animation: drawer var(--dur-3) var(--ease-out); }
@keyframes drawer { from { transform: translateX(32px); opacity: 0; } }
.drawer__head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: var(--s4) var(--s3) var(--s4) var(--s5); background: var(--sable-2); border-bottom: 1px solid var(--sable-line); }
.drawer__head h2 { margin: 0; font-family: var(--font-display); font-weight: 400; font-variant: small-caps; letter-spacing: .06em; font-size: var(--step-2); }
.drawer__body { padding: var(--s4) var(--s5) var(--s7); display: grid; gap: var(--s6); }
.drawer h3 { margin: 0 0 var(--s3); font-family: var(--font-display); font-weight: 400; font-variant: small-caps; letter-spacing: .1em; color: var(--or); font-size: var(--step-1); }
.drawer__row { display: flex; flex-wrap: wrap; gap: var(--s2); }
.keys { width: 100%; border-collapse: collapse; font-size: var(--step--1); }
.keys th { padding: var(--s2) var(--s3) var(--s2) 0; text-align: left; white-space: nowrap; font-weight: 400; vertical-align: top; }
.keys th kbd + kbd { margin-left: 3px; }
.keys td { padding: var(--s2) 0; color: var(--argent-2); border-bottom: 1px solid rgb(58 53 66 / .6); }
.keys th { border-bottom: 1px solid rgb(58 53 66 / .6); }
.pipeline { margin: 0; padding-left: 1.3em; display: grid; gap: var(--s2); font-size: var(--step--1); color: var(--argent-2); }
.pipeline strong { color: var(--argent); font-weight: 600; }
.pipeline li::marker { color: var(--or); font-family: var(--font-display); }
.glossary { margin: 0; display: grid; gap: var(--s3); font-size: var(--step--1); }
.glossary dt { font-family: var(--font-display); font-variant: small-caps; letter-spacing: .05em; font-size: var(--step-0); display: flex; align-items: center; gap: var(--s2); }
.glossary dd { margin: 2px 0 0; color: var(--argent-2); }
.swatch { width: 12px; height: 12px; transform: rotate(45deg); display: inline-block; }
.swatch--or { background: var(--hatch-or), var(--or); }
.swatch--gules { background: var(--hatch-gules), var(--gules); }
.swatch--azure { background: var(--hatch-azure), var(--azure); }
.swatch--purpure { background: var(--hatch-purpure), var(--purpure); }

/* ------------------------------------------------------------------ guide: invite + pennon coach marks */
.invite {
  position: fixed; z-index: 60; right: calc(var(--s5) + var(--safe-r)); bottom: calc(var(--s5) + var(--safe-b));
  width: min(360px, calc(100vw - 32px)); padding: var(--s4);
  background: var(--sable-2); background-image: var(--hatch-sable);
  border: 1px solid var(--sable-line); border-top: 3px solid var(--or); border-radius: var(--r-plate); box-shadow: var(--shadow-plate);
  animation: rise-plain var(--dur-3) var(--ease-out);
}
@keyframes rise-plain { from { opacity: 0; transform: translateY(8px); } }
.invite__title { margin: 0 0 var(--s1); font-family: var(--font-display); font-size: var(--step-1); font-variant: small-caps; letter-spacing: .04em; }
.invite__body { margin: 0 0 var(--s4); color: var(--argent-2); font-size: var(--step--1); }
.invite__actions { display: flex; gap: var(--s2); }

.coach { position: fixed; inset: 0; z-index: 70; pointer-events: none; }
.coach__hole { position: fixed; border-radius: var(--r-plate); box-shadow: 0 0 0 200vmax rgb(5 4 8 / .62); outline: 1px solid var(--argent); outline-offset: 3px; }
.coach__lance { position: fixed; inset: 0; width: 100%; height: 100%; overflow: visible; }
.coach__lance line { stroke: var(--argent); stroke-width: 1.5; }
.coach__lance rect { fill: var(--argent); }
.coach__card {
  position: fixed; width: min(360px, calc(100vw - 32px)); pointer-events: auto;
  background: var(--sable-2); background-image: var(--hatch-sable);
  border: 1px solid var(--sable-line); border-top: 0; border-radius: 0 0 var(--r-plate) var(--r-plate);
  box-shadow: var(--shadow-plate);
  animation: rise-plain var(--dur-2) var(--ease-out);
}
.coach__pennon {
  --tinct: var(--or); --hatch: var(--hatch-or);
  display: flex; align-items: baseline; gap: var(--s3);
  padding: var(--s2) 46px var(--s2) var(--s4);
  color: var(--sable); background: var(--hatch), var(--tinct);
  clip-path: polygon(0 0, 100% 0, calc(100% - 20px) 50%, 100% 100%, 0 100%);
}
.coach__pennon[data-tinct="gules"] { --tinct: var(--gules); --hatch: var(--hatch-gules); color: var(--argent); }
.coach__pennon[data-tinct="vert"] { --tinct: var(--vert); --hatch: var(--hatch-vert); color: var(--sable); }
.coach__pennon[data-tinct="azure"] { --tinct: var(--azure); --hatch: var(--hatch-azure); color: var(--sable); }
.coach__pennon[data-tinct="purpure"] { --tinct: var(--purpure); --hatch: var(--hatch-purpure); color: var(--argent); }
.coach__pennon[data-tinct="argent"] { --tinct: var(--argent); --hatch: none; color: var(--sable); }
.coach__title { font-family: var(--font-display); font-size: var(--step-1); font-variant: small-caps; letter-spacing: .04em; line-height: 1.2; }
.coach__count { font-size: var(--step--1); font-variant-numeric: tabular-nums; opacity: .85; white-space: nowrap; }
.coach__body { margin: 0; padding: var(--s3) var(--s4) var(--s2); font-size: var(--step--1); line-height: 1.55; color: var(--argent-2); text-wrap: pretty; }
.coach__body kbd { font-size: 11px; }
.coach__progress { margin: var(--s1) var(--s4) 0; height: 3px; background: var(--sable-3); }
.coach__progress span { display: block; height: 100%; background: var(--or); transform-origin: 0 50%; transition: transform var(--dur-2) var(--ease-out); }
.coach__actions { display: flex; justify-content: flex-end; gap: var(--s2); padding: var(--s3) var(--s4) var(--s4); }
.coach__close { position: absolute; top: 0; right: 4px; width: 36px; height: 36px; font-size: 20px; color: var(--sable); }
.coach__pennon[data-tinct="gules"] ~ .coach__close, .coach__pennon[data-tinct="purpure"] ~ .coach__close { color: var(--argent); }
.coach__close:hover { background: rgb(0 0 0 / .15); color: inherit; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 900px) {
  .select { grid-template-columns: 1fr; overflow-y: auto; align-content: start; padding: var(--s5); background: rgb(13 12 16 / .86); }
  .select__panel { grid-column: 1; }
  .select__cards { grid-template-columns: 1fr; }
  .title { grid-template-columns: 1fr; gap: var(--s5); padding: calc(var(--s6) + var(--safe-t)) var(--s5) var(--s6); overflow-y: auto; align-content: start; background: rgb(13 12 16 / .84); }
  .title__shield { order: -1; }
  .shield-hero { width: min(200px, 52vw); }
  .readout { min-height: 0; }
  .victory__inner { grid-template-columns: 1fr; justify-items: center; text-align: center; gap: var(--s5); }
  .shield-victory { width: 160px; }
  .victory__stats { grid-template-columns: repeat(2, auto); }
  body { overflow: auto; }
}
@media (max-width: 600px) {
  .fess { --w: 200px; }
  .fess--short { --w: 150px; }
  .roll { display: none; }
  .coach__lance { display: none; }
  .invite { left: 16px; right: 16px; width: auto; }
  .title__name { font-size: var(--step-5); }
}
@media (pointer: fine) { .title__device { display: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .parry-flash.is-on { animation: none; opacity: .5; transition: opacity 200ms; }
}
