:root {
  color-scheme: dark;
  --page: #0c140f;
  --screen: #101b14;
  --green: #bdd49b;
  --bright: #d3e6ad;
  --dim: #829574;
  --line: #687d54;
  --amber: #e6b968;
  --danger: #ed977d;
  --rare: #d3e6ad;
  --common: #829574;
  --epic: #e6b968;
  --legendary: #ed977d;
  --crt-strength: .2;
  font-family: "Cascadia Mono", "Consolas", "Liberation Mono", monospace;
  font-size: 13px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  padding: clamp(14px, 4vw, 58px) clamp(12px, 4vw, 60px) 20px;
  color: var(--green);
  background: radial-gradient(ellipse at 50% 35%, #233629 0%, #142219 44%, #0b110e 85%);
}
button, input { font: inherit; }
button { cursor: pointer; }
button, input, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 4px;
}
button:disabled { cursor: not-allowed; }
[hidden] { display: none !important; }
pre { font: inherit; margin: 0; white-space: pre; }
p { margin: 0; }
.amber { color: var(--amber); }
.muted { color: var(--dim); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip-link {
  position: absolute;
  top: -60px;
  background: var(--amber);
  color: #101b14;
  padding: 10px;
  z-index: 5;
}
.skip-link:focus { top: 10px; }
.terminal-shell {
  max-width: 1450px;
  margin: 0 auto;
  padding: 0 19px;
  border: 1px solid #485045;
  border-radius: 17px;
  background: linear-gradient(115deg, #343a32, #222923 45%, #30372e);
  box-shadow: 0 30px 80px #0009, inset 0 1px 2px #ffffff18;
}
.case-top, .case-bottom {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #a7afa0;
  font-size: 9px;
  letter-spacing: 1.5px;
}
.case-top { justify-content: space-between; padding: 16px 8px 13px; }
.case-bottom { padding: 14px 8px; }
.case-bottom > :first-child { margin-right: auto; }
.power-light {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #badb79;
  box-shadow: 0 0 8px #badb79aa;
}
.screen {
  position: relative;
  isolation: isolate;
  padding: clamp(18px, 2.4vw, 34px);
  border: 8px solid #101710;
  border-radius: 23px / 18px;
  background: radial-gradient(ellipse at center, #17261a, #0d1711);
  box-shadow: inset 0 0 35px #000a, 0 0 0 1px #505948;
}
.screen::after {
  content: "";
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  background:
    repeating-linear-gradient(transparent 0 2px, rgb(0 0 0 / .45) 2px 3px),
    radial-gradient(ellipse at center, transparent 40%, rgb(0 0 0 / .6));
  opacity: var(--crt-strength);
}
.screen {
  text-shadow:
    0 0 calc(12px * var(--crt-strength)) rgb(189 212 155 / calc(var(--crt-strength) * .8)),
    0 0 calc(28px * var(--crt-strength)) rgb(189 212 155 / calc(var(--crt-strength) * .4));
}
.masthead {
  display: grid;
  grid-template-columns: minmax(200px, .65fr) minmax(180px, .35fr) minmax(0, 1fr);
  align-items: center;
  gap: 28px;
  padding: 4px 2px 26px;
  margin-bottom: 23px;
  border-bottom: 1px solid #687d5433;
}
.eyebrow {
  color: var(--dim);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.4px;
  line-height: 1.7;
}
.signal {
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-right: 7px;
  background: var(--green);
  vertical-align: 1px;
}
.brand { min-width: 0; }
h1 {
  display: flex;
  align-items: flex-end;
  margin: 14px 0 0;
  color: var(--bright);
  font-size: clamp(26px, 3.5vw, 47px);
  letter-spacing: 5px;
  line-height: .96;
  font-weight: 800;
}
.brand-logo {
  display: block;
  width: auto;
  height: 1.92em;
  max-width: calc(100% - 38px);
  object-fit: contain;
  object-position: left bottom;
  filter: drop-shadow(0 0 calc(10px * var(--crt-strength)) rgb(189 212 155 / calc(var(--crt-strength) * .5)));
}
.version { margin: 0 0 3px 8px; font-size: 11px; letter-spacing: 0; font-weight: 400; }
.system-status { display: grid; gap: 10px; margin-top: 16px; font-size: 10px; line-height: 1.5; }
.system-status > div { display: grid; gap: 4px; }
.label { color: var(--dim); min-width: 69px; font-size: 10px; letter-spacing: 1px; }
.system-status strong { color: var(--amber); font-weight: 500; }
progress {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--line);
  border-radius: 0;
  height: 11px;
  width: 120px;
  background: #080f0a;
}
progress::-webkit-progress-bar { background: #080f0a; }
progress::-webkit-progress-value { background: var(--green); }
progress::-moz-progress-bar { background: var(--green); }
.player-health { width: 100%; margin-bottom: 14px; }
.workspace { display: grid; grid-template-columns: 190px minmax(0, 1fr) 220px; gap: 18px; }
.panel-tabs { display: none; }
.panel {
  position: relative;
  border: 1px solid transparent;
  background: rgb(189 212 155 / .025);
}
.panel::before {
  position: absolute;
  content: "";
  inset: -1px;
  pointer-events: none;
  background:
    linear-gradient(var(--line), var(--line)) top left / 12px 1px,
    linear-gradient(var(--line), var(--line)) top left / 1px 12px,
    linear-gradient(var(--line), var(--line)) top right / 12px 1px,
    linear-gradient(var(--line), var(--line)) top right / 1px 12px,
    linear-gradient(var(--line), var(--line)) bottom left / 12px 1px,
    linear-gradient(var(--line), var(--line)) bottom left / 1px 12px,
    linear-gradient(var(--line), var(--line)) bottom right / 12px 1px,
    linear-gradient(var(--line), var(--line)) bottom right / 1px 12px;
  background-repeat: no-repeat;
}
.character-panel, .context-panel { padding: 19px 16px; }
h2, h3 { margin: 0; font-size: 11px; font-weight: 600; letter-spacing: .5px; }
.character-panel h2, .context-panel h2 { white-space: nowrap; }
.character-panel > h2, .context-panel > h2, .objective-panel > h2, .actions-panel > h3 {
  display: flex;
  align-items: center;
  gap: 7px;
}
.character-panel > h2::after, .context-panel > h2::after, .objective-panel > h2::after,
.actions-panel > h3::after, .journal-panel > h2::after, .panel-topline::after {
  content: "";
  flex: 1;
  min-width: 8px;
  height: 1px;
  background: linear-gradient(to right, #687d5470, #687d5410);
}
h2 > span:first-child { color: var(--dim); margin-right: 7px; font-size: 9px; }
.character-panel > h2 > span:first-child, .context-panel > h2 > span:first-child { margin-right: 0; }
.hero-emblem { position: relative; isolation: isolate; display: grid; container-type: inline-size; text-align: center; color: var(--bright); padding: 20px 0 16px; line-height: 1; }
.hero-frame { grid-area: 1 / 1; align-self: center; justify-self: center; text-align: left; font-size: min(6px, 1.33cqw); text-shadow: none; animation: hero-idle 11s ease-in-out infinite; }
.hero-emblem::before, .hero-emblem::after {
  content: "";
  position: absolute;
  inset: 8px 0;
  z-index: 1;
  pointer-events: none;
}
.hero-emblem::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='128' height='128'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Cpath fill='%23fff' filter='url(%23n)' d='M0 0h128v128H0z'/%3E%3C/svg%3E");
  background-size: 128px 128px;
  mix-blend-mode: screen;
  opacity: calc(var(--crt-strength) * .12);
  animation: portrait-static .8s steps(1, end) infinite;
}
.hero-emblem::after {
  background-image:
    linear-gradient(transparent, rgb(211 230 173 / .4), transparent),
    repeating-linear-gradient(transparent 0 3px, rgb(0 0 0 / .35) 3px 4px);
  background-size: 100% 20%, 100% 100%;
  background-position: 0 -25%, 0 0;
  background-repeat: no-repeat;
  opacity: calc(var(--crt-strength) * .45);
  animation: portrait-scan 10s linear infinite;
}
@keyframes portrait-static {
  0%, 100% { background-position: 0 0; }
  25% { background-position: 37px 61px; }
  50% { background-position: 83px 19px; }
  75% { background-position: 11px 97px; }
}
@keyframes portrait-scan {
  0%, 60% { background-position: 0 -25%, 0 0; }
  100% { background-position: 0 125%, 0 0; }
}
@keyframes hero-idle {
  0%, 82%, 100% { transform: translateY(0) rotate(0deg); }
  88% { transform: translateY(-1px) rotate(-.35deg); }
  94% { transform: translateY(0) rotate(.25deg); }
}
.hero-name { text-align: center; font-weight: 700; font-size: 14px; color: var(--bright); overflow-wrap: anywhere; }
.hero-role { font-size: 9px; text-align: center; margin: 8px 0 22px; }
.stats { display: grid; gap: 13px; margin: 0; font-size: 10px; }
.stats > div { display: flex; justify-content: space-between; gap: 10px; }
dt { color: var(--dim); }
dd { margin: 0; color: var(--bright); }
.section-divider { border-top: 1px dotted #687d5466; margin: 23px 0; }
.character-panel h3 { color: var(--dim); font-size: 9px; }
.mini-map { margin: 22px 0 17px; font-size: 10px; line-height: 1.7; white-space: nowrap; }
.mini-map > .map-node { display: block; }
.mini-map > .map-path { padding-left: 32px; display: block; }
.map-node { color: var(--dim); }
.map-node.active { color: var(--amber); text-shadow: 0 0 calc(20px * var(--crt-strength)) rgb(230 185 104 / var(--crt-strength)); }
.map-path { color: #61744e; }
.map-caption { color: var(--dim); font-size: 8px; letter-spacing: .5px; }
.map-key { background: var(--amber); width: 4px; height: 4px; display: inline-block; margin-right: 6px; vertical-align: 1px; }
.adventure-column { display: flex; flex-direction: column; min-width: 0; background: rgb(189 212 155 / .012); }
.story-panel { position: relative; padding: 20px 22px; flex: 1; min-height: 310px; display: flex; flex-direction: column; }
.panel-topline { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 8px; color: var(--dim); letter-spacing: 1px; }
.panel-topline > :last-child { order: 1; }
.topline-right { display: flex; align-items: center; gap: 8px; }
.round-chip { border: 1px solid var(--line); padding: 2px 8px; color: var(--dim); letter-spacing: 1px; }
.round-chip.active { border-color: var(--amber); color: var(--amber); box-shadow: 0 0 10px #e6b96840; }
.ability-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0 0 16px;
  padding: 10px 14px;
  border: 1px solid var(--amber);
  background: rgb(230 185 104 / .06);
  color: var(--amber);
  font-size: 11px;
  letter-spacing: 1px;
  text-align: center;
  animation: ability-pulse 1.6s ease-in-out infinite alternate;
}
@keyframes ability-pulse {
  from { box-shadow: inset 0 0 18px #e6b96818, 0 0 8px #e6b96820; }
  to { box-shadow: inset 0 0 26px #e6b96830, 0 0 18px #e6b96845; }
}
.enemy-emblem.ability-surge .hero-frame {
  color: var(--amber);
  text-shadow: 0 0 14px rgb(230 185 104 / .8);
  animation: ability-surge 1.6s ease-in-out infinite alternate;
}
@keyframes ability-surge {
  from { opacity: .85; }
  to { opacity: 1; }
}
.scene-heading { display: flex; align-items: baseline; gap: 12px; margin: 28px 0 23px; }
.scene-heading h2 { color: var(--bright); font-size: 16px; letter-spacing: 1px; line-height: 1.5; }
.prompt-mark { color: var(--amber); font-weight: 700; }
.story { color: var(--amber); font-size: 12px; line-height: 1.95; }
.story p + p { margin-top: 17px; }
.story-signoff { margin-top: auto; padding-top: 32px; font-size: 8px; color: #829574b0; letter-spacing: 1px; display: flex; justify-content: space-between; gap: 8px; }
.actions-panel { position: relative; padding: 18px 20px 0; }
.actions-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 16px;
  right: 16px;
  height: 1px;
  background: linear-gradient(to right, #687d5470, #687d5410);
}
.actions-panel h3 { color: var(--dim); font-size: 9px; margin-bottom: 13px; }
.choices { display: grid; gap: 7px; margin-bottom: 17px; }
.choice {
  text-align: left;
  color: var(--green);
  background: transparent;
  border: 1px solid #687d544d;
  padding: 10px 12px;
  display: flex;
  align-items: baseline;
  gap: 11px;
  line-height: 1.4;
  font-size: 11px;
}
.choice:hover { background: #bed49b0b; border-color: var(--green); color: var(--bright); }
.choice.selected {
  color: var(--bright);
  border-color: var(--bright);
  background: linear-gradient(100deg, #bdd49b24, #bdd49b0a 70%);
  box-shadow: inset 3px 0 var(--amber), inset 0 0 16px #bdd49b0a, 0 0 6px #bdd49b12;
}
.choice.selected:not(:disabled) { animation: choice-glow 2.8s ease-in-out infinite alternate; }
.choice:focus-visible { outline: none; }
.choice:disabled { opacity: .55; cursor: not-allowed; }
.choice:disabled:hover { background: transparent; border-color: #687d544d; color: var(--green); }
.choice.selected::after { content: "<"; margin-left: auto; color: var(--amber); }
.choice-number { color: var(--dim); flex: 0 0 auto; }
.choice.selected .choice-number { color: var(--bright); }
.choice small { flex: 1 1 auto; min-width: 0; text-align: right; color: var(--amber); font-size: 9px; line-height: 1.5; overflow-wrap: break-word; }
@keyframes choice-glow {
  to { box-shadow: inset 3px 0 var(--amber), inset 0 0 22px #bdd49b18, 0 0 12px #bdd49b30; }
}
.controls-hint { color: var(--dim); font-size: 8px; line-height: 1.8; margin: -4px 0 13px; }
.feedback { color: var(--amber); min-height: 26px; font-size: 10px; line-height: 1.5; padding: 5px 0; }
.adventure-column.is-busy .feedback { animation: feedback-pulse 0.8s ease-in-out infinite alternate; }
@keyframes feedback-pulse {
  from { opacity: .55; }
  to { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .adventure-column.is-busy .feedback { animation: none; }
  .type-cursor { animation: none; }
}
.type-cursor {
  display: inline-block;
  margin-left: 1px;
  color: var(--amber);
  animation: type-blink 0.9s steps(1) infinite;
}
@keyframes type-blink {
  50% { opacity: 0; }
}
.hero-name-form { display: grid; gap: 8px; margin-bottom: 14px; }
.hero-name-form label { color: var(--dim); font-size: 9px; }
.hero-name-form input, .reconnect {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 0;
  color: var(--bright);
  background: #101b14;
  padding: 10px;
}
.reconnect { margin-bottom: 12px; color: var(--amber); font-size: 10px; }
.journal-panel { min-width: 0; padding: 12px 16px; }
.journal-panel h2, .objective-panel h2 { display: flex; align-items: center; gap: 10px; }
.objective-panel { min-width: 0; padding: 12px 16px; }
.objective-panel p { margin: 10px 0 0; font-size: 10px; line-height: 1.8; overflow-wrap: anywhere; }
.live-dot { height: 4px; width: 4px; background: var(--green); order: 1; }
.event-log { list-style: none; padding: 0 6px 0 0; margin: 10px 0 0; height: 66px; overflow-y: auto; scrollbar-color: var(--line) transparent; scrollbar-width: thin; }
.event-log li { display: grid; grid-template-columns: 5ch minmax(0, 1fr); gap: 12px; margin-bottom: 7px; font-size: 10px; line-height: 1.5; overflow-wrap: anywhere; }
.event-log time { color: var(--dim); font-size: inherit; }
.event-log li:first-child { color: var(--amber); border-color: var(--amber); }
.context-panel { display: flex; flex-direction: column; gap: 18px; min-width: 0; min-height: 0; }
.context-panel > h2 { flex-shrink: 0; }
.context-content { flex: 1; min-height: 0; overflow-y: auto; padding: 2px 6px 6px; scrollbar-color: var(--line) transparent; scrollbar-width: thin; }
.context-content h3 { color: var(--bright); font-size: 14px; margin: 14px 0 10px; line-height: 1.5; overflow-wrap: anywhere; }
.context-note { color: var(--dim); font-size: 10px; line-height: 1.8; }
.shop-card, .town-card, .enemy-card, .board-card, .drill-card { display: flex; flex-direction: column; }
.shop-card > :not(.hero-emblem), .town-card > :not(.hero-emblem), .enemy-card > :not(.hero-emblem), .board-card > :not(.hero-emblem), .drill-card > :not(.hero-emblem) { flex-shrink: 0; }
.shopkeeper-emblem, .context-emblem, .drill-emblem { height: 260px; margin: 4px 0; padding: 8px 0; container-type: size; }
.shopkeeper-emblem .hero-frame, .context-emblem .hero-frame, .drill-emblem .hero-frame { font-size: min(6px, 1.33cqw, 1.33cqh); }
.town-card .hero-frame { animation: none; }
.shop-card h3 { font-size: 13px; margin: 5px 0; }
.stock-heading { color: var(--dim); font-size: 9px; font-weight: 500; letter-spacing: 1px; margin: 12px 0 6px; }
.shop-stock { list-style: none; margin: 0; padding: 0; }
.shop-stock li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 8px; border-top: 1px dotted #687d5466; padding: 6px 0; font-size: 11px; }
.shop-stock li > div { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 10px; color: var(--bright); }
.shop-stock strong { color: var(--amber); white-space: nowrap; font-weight: 500; }
.shop-stock p { color: var(--dim); font-size: 9px; line-height: 1.5; }
.shop-stock .stock-availability { color: var(--green); font-size: 8px; letter-spacing: .5px; text-align: right; }
.shop-stock .unaffordable .stock-availability { color: var(--amber); }
.board-list { list-style: none; margin: 12px 0; padding: 0; }
.board-list li { display: grid; grid-template-columns: 3ch minmax(0, 1fr) auto; gap: 10px; align-items: baseline; border-top: 1px solid #687d5433; padding: 6px 0; }
.board-list li > span:first-child { color: var(--dim); }
.board-list strong { color: var(--amber); white-space: nowrap; font-weight: 500; }
.board-list .own-entry { color: var(--bright); }
.board-list .own-entry > span:first-child { color: var(--amber); }
.rarity-badge { font-size: 8px; letter-spacing: 1px; padding: 1px 5px; border: 1px solid currentcolor; white-space: nowrap; }
.rarity-common { color: var(--common); }
.rarity-rare { color: var(--rare); }
.rarity-epic { color: var(--epic); }
.rarity-legendary { color: var(--legendary); }
.enemy-badges { display: flex; gap: 6px; margin: 0 0 8px; min-height: 0; }
.enemy-badges:empty { display: none; }
.equipped { list-style: none; margin: 0 0 12px; padding: 0; font-size: 10px; line-height: 1.9; color: var(--dim); }
.equipped span:first-child { color: var(--green); }
.equipped small { color: var(--amber); font-size: 9px; }
.dev-panel {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 50;
  width: min(360px, 92vw);
  max-height: 72vh;
  overflow: auto;
  background: var(--screen);
  border: 1px dashed var(--danger);
  padding: 10px 12px;
  font-size: 10px;
}
.dev-panel h3 { color: var(--danger); font-size: 11px; letter-spacing: 1px; margin: 0 0 6px; }
.dev-status { color: var(--dim); margin: 0 0 8px; }
.dev-controls { display: grid; gap: 6px; margin-bottom: 8px; }
.dev-controls label { display: flex; gap: 6px; align-items: center; }
.dev-controls select, .dev-controls input { flex: 1; min-width: 0; font: inherit; color: var(--bright); background: var(--screen); border: 1px solid var(--line); padding: 4px 6px; }
.dev-controls button { font: inherit; color: var(--danger); background: transparent; border: 1px solid var(--danger); padding: 4px 8px; }
.dev-state { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--dim); font-size: 9px; margin: 0; }
.shop-purse { color: var(--amber); border-top: 1px dashed var(--line); padding-top: 10px; font-size: 11px; }
.enemy-card { position: relative; }
.enemy-card h3 { color: var(--danger); }
.enemy-card progress { width: 100%; margin: 8px 0 20px; }
.enemy-card progress::-webkit-progress-value { background: var(--danger); }
.enemy-card progress::-moz-progress-bar { background: var(--danger); }
.enemy-stats { gap: 16px; margin-bottom: 22px; }
.enemy-card .context-note { min-height: 3.6em; }
.enemy-emblem { overflow: clip; }
.enemy-fragment { display: inline-block; vertical-align: top; }
.enemy-defeat {
  position: absolute;
  inset: 50% 8px auto;
  transform: translateY(-50%);
  z-index: 2;
  color: var(--amber);
  font-size: clamp(10px, 4cqw, 14px);
  line-height: 1.8;
  letter-spacing: 1px;
  white-space: pre-line;
}
.enemy-emblem.is-defeated .hero-frame { animation: enemy-glitch .2s steps(1, end) both; }
.enemy-emblem.is-defeated .enemy-fragment { animation: enemy-dissolve .65s ease-in var(--dissolve-delay) both; }
.enemy-emblem.is-defeated .enemy-defeat { animation: enemy-reward .2s ease-out 1.25s both; }
@keyframes enemy-glitch {
  0%, 100% { transform: none; }
  20% { transform: translateX(-4px) skewX(-5deg); }
  45% { transform: translateX(3px) skewX(4deg); }
  70% { transform: translateX(-2px); }
}
@keyframes enemy-dissolve {
  0% { opacity: 1; transform: none; }
  35% { opacity: .7; }
  100% { opacity: 0; transform: translate(var(--scatter-x), var(--scatter-y)); }
}
@keyframes enemy-reward {
  from { opacity: 0; }
  to { opacity: 1; }
}
.dice-result { display: flex; align-items: center; justify-content: center; gap: clamp(18px, 4vh, 48px); margin: 18px 0; flex: 1; font-size: clamp(30px, 8vh, 76px); }
.dice-result div { display: flex; flex-direction: column; text-align: center; gap: 8px; }
.dice-result div > span, .dice-vs { font-size: 8px; color: var(--dim); }
.dice-result strong { border: 1px solid var(--line); padding: .35em .8em; font-size: 1em; min-width: 3ch; text-align: center; color: var(--amber); }
.dice-result.rolling strong { animation: dice-tumble .16s ease-in-out infinite alternate; color: var(--bright); }
.dice-result.rolling > div:last-child strong { animation-direction: alternate-reverse; }
.die-winner strong { border-color: var(--amber); color: var(--bright); box-shadow: 0 0 18px #e6b96855, inset 0 0 14px #e6b96825; }
.die-loser strong { opacity: .5; }
@media (prefers-reduced-motion: reduce) {
  .ability-banner, .enemy-emblem.ability-surge .hero-frame, .dice-result.rolling strong { animation: none; }
}
.hit-player { animation: damage-impact .4s ease-out; box-shadow: inset 0 0 32px rgb(237 151 125 / .2); }
.hit-enemy { animation: damage-impact .4s ease-out; box-shadow: inset 0 0 24px rgb(230 185 104 / .2); }
.damage-number {
  position: absolute;
  right: 12px;
  top: 10px;
  z-index: 1;
  pointer-events: none;
  padding: 4px 7px;
  background: #101b14;
  border: 1px solid currentColor;
  color: var(--danger);
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  animation: damage-rise .85s ease-out both;
}
.hit-enemy > .damage-number { color: var(--amber); }
@keyframes dice-tumble {
  from { transform: translateY(-4px) rotate(-12deg) scale(1.06); }
  to { transform: translateY(4px) rotate(12deg) scale(.96); }
}
@keyframes damage-impact {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-3px); }
  40%, 80% { transform: translateX(3px); }
}
@keyframes damage-rise {
  0% { opacity: 0; transform: translateY(8px); }
  20%, 65% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-14px); }
}
.screen-footer { display: flex; justify-content: space-between; gap: 15px; margin-top: 23px; padding-top: 15px; border-top: 1px solid #687d5433; color: var(--dim); font-size: 8px; line-height: 1.8; letter-spacing: .2px; }
.screen-footer > div { display: flex; gap: 10px; align-items: center; }
.crt-control { display: flex; gap: 8px; align-items: center; }
.crt-control label { color: var(--green); white-space: nowrap; }
.crt-control input { width: 96px; height: 16px; margin: 0; accent-color: var(--green); cursor: pointer; }
.crt-control output { min-width: 4ch; color: var(--amber); text-align: right; font-variant-numeric: tabular-nums; }
.screen-footer button { background: none; color: var(--green); border: 0; padding: 0; font-size: 8px; letter-spacing: .3px; white-space: nowrap; }
.screen-footer button:hover { color: var(--amber); }
.footer-divider { margin: 0 7px; color: #647357; }
.outside-caption { margin: 20px 0 0; text-align: center; font-size: 8px; letter-spacing: 2px; color: #8b9b80; line-height: 1.8; }

@media (min-width: 1500px) {
  :root { font-size: 14px; }
  .workspace { grid-template-columns: 210px minmax(0, 1fr) 240px; }
  .story { font-size: 14px; }
  .choice { font-size: 12px; }
}
@media (min-width: 1101px) and (max-height: 699px) {
  .masthead { padding-bottom: 10px; margin-bottom: 12px; }
  h1 { font-size: 28px; }
  .system-status { margin-top: 8px; }
  .ability-banner { padding: 6px 10px; margin-bottom: 10px; font-size: 10px; }
  .scene-heading { margin: 14px 0 12px; }
  .story { line-height: 1.75; }
  .story p + p { margin-top: 10px; }
  .story-panel { min-height: 200px; }
  .story-signoff { padding-top: 12px; }
  .dice-result { margin: 10px 0; font-size: clamp(24px, 7vh, 40px); }
}
@media (min-width: 1101px) and (min-height: 700px) {
  body {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    padding: 16px clamp(16px, 2vw, 40px) 12px;
  }
  .terminal-shell { display: flex; flex-direction: column; flex: 1; min-height: 0; width: 100%; max-width: none; }
  .case-top, .case-bottom { flex-shrink: 0; padding-top: 10px; padding-bottom: 10px; }
  .screen { display: flex; flex-direction: column; flex: 1; min-height: 0; padding: 18px 24px; }
  .masthead { flex-shrink: 0; padding-bottom: 15px; margin-bottom: 16px; }
  h1 { margin-top: 8px; font-size: 34px; }
  .system-status { gap: 10px; }
  .workspace {
    flex: 1;
    min-height: 0;
    grid-template-columns: clamp(190px, 15vw, 280px) minmax(0, 1fr) clamp(220px, 17vw, 300px);
    grid-template-rows: minmax(0, 1fr);
    gap: 16px;
  }
  .character-panel, .context-panel { padding: 12px 16px; }
  .character-panel { display: flex; flex-direction: column; }
  .character-panel > :not(.hero-emblem) { flex-shrink: 0; }
  .character-panel .hero-emblem { flex: 1 0 auto; container-type: inline-size; padding: 4px 0; }
  .character-panel .hero-frame { font-size: min(6px, 1.33cqw); }
  .character-panel.unfit { overflow-y: auto; overflow-x: hidden; min-height: 0; }
  .context-panel { min-height: 0; }
  .hero-emblem { flex: 1; min-height: 0; container-type: size; padding: 8px 0; }
  .hero-frame { font-size: min(6px, 1.33cqw, 1.33cqh); }
  .shop-card, .town-card, .enemy-card, .board-card, .drill-card { height: 100%; }
  .shopkeeper-emblem, .context-emblem, .drill-emblem { height: auto; }
  .hero-role { margin-bottom: 16px; }
  .stats { gap: 10px; }
  .character-panel .stats { gap: 7px; }
  .section-divider { margin: 12px 0; }
  .mini-map { margin: 15px 0 12px; }
  .adventure-column { min-height: 0; }
  .story-panel { min-height: 210px; padding: 16px 20px; }
  .scene-heading { margin: 16px 0 14px; }
  .story { max-width: 85ch; font-size: 12px; line-height: 1.75; }
  .story p + p { margin-top: 12px; }
  .story-signoff { padding-top: 16px; }
  .actions-panel { flex-shrink: 0; padding: 12px 16px 0; }
  .actions-panel h3 { margin-bottom: 9px; }
  .choices { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-bottom: 12px; }
  .choice { padding: 8px 10px; font-size: 11px; gap: 8px; }
  .controls-hint { margin-bottom: 8px; }
  .feedback { min-height: 23px; }
  .adventure-column[data-scene="choose"] .feedback:empty { min-height: 0; padding: 0; }
  .dice-result { margin: 10px 0; gap: 18px; font-size: clamp(26px, 6vh, 44px); }
  .screen-footer { flex-shrink: 0; margin-top: 16px; padding-top: 12px; }
  .outside-caption { flex-shrink: 0; margin-top: 12px; }
}
@media (min-width: 1101px) and (min-height: 700px) and (max-height: 1000px) {
  .character-panel { padding: 12px; }
  .character-panel .hero-emblem { padding: 4px 0; }
  .character-panel .hero-frame { font-size: min(6px, 1.1cqw); }
  .hero-role { margin: 6px 0 10px; }
  .stats { gap: 6px; }
  .section-divider { margin: 8px 0; }
  .equipped { margin-bottom: 8px; }
  .system-status { gap: 8px; margin-top: 8px; }
}

@media (min-width: 1500px) and (min-height: 851px) {
  .workspace { grid-template-columns: clamp(280px, 20vw, 380px) minmax(0, 1fr) clamp(220px, 17vw, 300px); }
  .character-panel .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; }
  .hero-role { margin-bottom: 6px; }
  .section-divider { margin: 8px 0; }
  .mini-map { margin: 10px 0 8px; }
  h1 { font-size: 42px; }
  .scene-heading h2 { font-size: 20px; }
  .story { font-size: 15px; line-height: 1.85; }
  .choice { padding: 11px 12px; font-size: 13px; }
  .choice small { font-size: 11px; }
  .journal-panel h2 { font-size: 13px; }
  .system-status { font-size: 11px; }
  .event-log li { font-size: 12px; }
}
@media (min-width: 1500px) and (min-height: 1000px) {
  .hero-name { font-size: 18px; }
  .stats { font-size: 12px; gap: 14px; }
  .character-panel h2 { font-size: 13px; }
  .mini-map { font-size: 12px; }
}
@media (min-width: 1101px) and (min-height: 700px) and (max-height: 850px) {
  body { padding-top: 8px; padding-bottom: 8px; }
  .case-top, .case-bottom { padding-top: 6px; padding-bottom: 6px; }
  .screen { padding-top: 12px; padding-bottom: 12px; }
  .masthead { padding-bottom: 10px; margin-bottom: 12px; }
  h1 { font-size: 28px; }
  .hero-role { display: none; }
  .stats { gap: 8px; }
  .character-panel .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 12px; }
  .character-panel .stats > div { flex-direction: column; gap: 3px; }
  .character-panel .stats dt { font-size: 8px; }
  .section-divider { margin: 10px 0; }
  .mini-map { margin: 12px 0 8px; }
  .story-panel { min-height: 190px; padding: 12px 16px; }
  .scene-heading { margin: 12px 0 10px; }
  .scene-heading h2 { font-size: 14px; }
  .story p + p { margin-top: 10px; }
  .story-signoff { padding-top: 12px; }
  .choice { padding-top: 7px; padding-bottom: 7px; }
  .context-panel { gap: 12px; }
  .shop-stock li { padding: 4px 0; gap: 3px 8px; }
  .outside-caption { margin-top: 6px; }
}
@media (max-width: 1100px) {
  body { padding: 20px 14px; }
  .terminal-shell { padding: 0 12px; }
  .screen { padding: 20px; }
  .workspace { grid-template-columns: 160px minmax(0, 1fr); gap: 15px; }
  .character-panel { padding: 18px 12px; }
  .context-panel { grid-column: 1 / -1; }
}
@media (max-width: 650px) {
  body { padding: 10px 8px 18px; }
  .terminal-shell { padding: 0 6px; border-radius: 12px; }
  .case-top { font-size: 7px; padding: 12px 6px; letter-spacing: .4px; }
  .case-top > :last-child { display: none; }
  .case-bottom { font-size: 6px; padding: 12px 6px; letter-spacing: .5px; }
  .screen { border-width: 4px; padding: 19px 12px; border-radius: 14px; }
  .masthead { grid-template-columns: 1fr; gap: 22px; margin-bottom: 20px; padding-bottom: 20px; }
  h1 { font-size: 35px; letter-spacing: 4px; }
  .eyebrow { font-size: 7px; letter-spacing: .6px; }
  .system-status { grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr)); font-size: 9px; gap: 12px; margin: 0; }
  .label { min-width: 64px; }
  progress { width: 95px; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .panel-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 12px;
  }
  .panel-tabs button {
    background: transparent;
    border: 1px solid #687d544d;
    color: var(--dim);
    padding: 12px 6px;
    font-size: 10px;
    letter-spacing: 1px;
  }
  .panel-tabs button[aria-selected="true"] {
    color: var(--bright);
    border-color: var(--amber);
    box-shadow: inset 3px 0 var(--amber);
  }
  .workspace[data-active-panel="character"] > .adventure-column,
  .workspace[data-active-panel="character"] > .context-panel { display: none; }
  .workspace[data-active-panel="adventure"] > .character-panel,
  .workspace[data-active-panel="adventure"] > .context-panel { display: none; }
  .workspace[data-active-panel="nearby"] > .character-panel,
  .workspace[data-active-panel="nearby"] > .adventure-column { display: none; }
  .character-panel { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 12px; }
  .character-panel .hero-emblem, .hero-role, .section-divider, .character-panel h3 { display: none; }
  .character-panel h2 { grid-column: 1; grid-row: 1; font-size: 10px; }
  .hero-name { grid-column: 2; grid-row: 1; text-align: right; font-size: 12px; }
  .player-health { grid-column: 1 / -1; margin: 0; }
  .stats { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; gap: 12px 18px; }
  .stats > div { font-size: 9px; }
  .story-panel { padding: 18px 15px; min-height: 270px; }
  .scene-heading { margin: 22px 0 18px; }
  .scene-heading h2 { font-size: 14px; }
  .story { font-size: 11px; }
  .actions-panel { padding: 17px 14px 0; }
  .choice { min-height: 44px; padding: 12px 9px; font-size: 11px; }
  .choice { flex-wrap: wrap; }
  .choice small { white-space: normal; }
  .screen-footer { flex-direction: column; gap: 13px; font-size: 7px; }
  .screen-footer > div { justify-content: space-between; }
  .screen-footer .footer-divider { margin: 0 3px; }
  .outside-caption { font-size: 7px; letter-spacing: 1px; }
  .story-signoff { font-size: 7px; letter-spacing: .3px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  .hero-emblem::before, .hero-emblem::after, .hero-frame, .choice.selected:not(:disabled), .dice-result.rolling strong, .hit-player, .hit-enemy, .damage-number, .type-cursor { animation: none; }
  .enemy-emblem.is-defeated .hero-frame, .enemy-emblem.is-defeated .enemy-fragment, .enemy-emblem.is-defeated .enemy-defeat { animation: none; }
  .enemy-emblem.is-defeated .enemy-fragment { opacity: 0; }
}
