:root {
  color-scheme: dark;
  --game-font: 'Segoe UI Variable', 'Segoe UI', system-ui, sans-serif;
  font-family: var(--game-font);
  --ink: #f6ebce;
  --muted: #b7bda2;
  --dim: #919982;
  --gold: #f2c177;
  --line: #b9b57d36;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-width: 300px;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, #13242875, #101d2039 43%, #101a1d95 77%, #0c181bee),
    #162326 var(--woodland, url('../assets/bilder/wald.webp')) center top / cover fixed no-repeat;
}
body[data-biome="schlucht"] { --woodland: url('../assets/bilder/schlucht.webp'); }
body[data-biome="nacht"] { --woodland: url('../assets/bilder/schlucht.webp'); background-color: #111929; background-blend-mode: multiply, normal; }
body[data-biome="hochland"] { --woodland: url('../assets/bilder/hochland.webp'); }
body[data-biome="stollen"] { --woodland: url('../assets/bilder/stollen.webp'); }
body[data-biome="fluss"] { --woodland: url('../assets/bilder/fluss.webp'); }
body[data-biome="nebelbucht"] { --woodland: url('../assets/bilder/fluss.webp'); background-color: #13212a; background-blend-mode: multiply, normal; }
body[data-biome="koenigsstollen"] { --woodland: url('../assets/bilder/koenigsstollen.webp'); }
body:has(.title-screen:not([hidden])) { --woodland: none; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .47; }
button:focus-visible { outline: 2px solid #f6cf83; outline-offset: 3px; }
button, h1, h2, p { margin: 0; }
.title-screen { position: fixed; z-index: 20; inset: 0; overflow: hidden; isolation: isolate; background: #000; }
body:has(.title-screen:not([hidden])) { overflow: hidden; }
.title-load { position: absolute; z-index: 3; top: 50%; left: 50%; transform: translate(-50%, -50%); }
.title-world, .title-forest, .title-light, .title-wolf, .title-world::after { position: absolute; inset: 0; pointer-events: none; }
.title-world { opacity: 0; overflow: hidden; background: #102b27; }
.title-forest {
  inset: -3%;
  background: #10191a url('../assets/bilder/start-wolfswald.webp') center 53% / cover no-repeat;
  animation: forest-drift 20s ease-in-out infinite alternate;
}
.title-light {
  background: radial-gradient(ellipse at 68% 34%, #cde59a33, #8fdacb10 32%, transparent 62%);
  mix-blend-mode: screen;
  animation: forest-light 11s ease-in-out infinite alternate;
}
.title-world::after {
  content: '';
  background: radial-gradient(ellipse at 50% 45%, transparent 30%, #06131048 72%, #061310a6),
    linear-gradient(180deg, #0819121c, #08191210 54%, #06110e95 100%);
}
.title-wolf { width: 100%; height: 100%; z-index: 1; }
.title-content {
  position: absolute; z-index: 2; top: 43%; left: 50%; transform: translate(-50%, -50%);
  width: min(91%, 850px); display: grid; place-items: center; gap: clamp(9px, 1.8dvh, 23px);
  text-align: center; text-shadow: 0 2px 4px #0f2117, 0 8px 27px #07140deb;
}
.title-lettering { display: grid; justify-items: center; gap: clamp(9px, 1.8dvh, 23px); width: 100%; opacity: 0; visibility: hidden; }
.title-logo {
  display: block; width: min(100%, clamp(300px, 44vw, 742px)); height: auto;
  filter: drop-shadow(0 4px 5px #11180de6) drop-shadow(0 0 24px #d5ab481f);
}
.title-content h1 {
  color: #fff0cf; font: 760 clamp(21px, 3.25vw, 54px)/1.08 var(--game-font); letter-spacing: -.037em;
  text-wrap: balance;
}
.title-action { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px 14px; margin-top: clamp(5px, 2.2dvh, 23px); animation: title-reveal .62s both; }
.title-action[hidden] { display: flex !important; visibility: hidden; animation: none; }
.title-action .start-button { font-size: clamp(16px, 2.2vw, 27px); padding-inline: clamp(12px, 2.1vw, 28px); }
.title-action .start-button:not(.primary) { background: #10251ce8; border-color: #b8a8748c; }
.title-action .start-button:not(.primary, :disabled):hover { background: #2e4636; }
.title-action p { flex: 0 0 100%; margin: 0; min-height: 1.4em; text-align: center; color: #ecdcb3; font-size: clamp(12px, 1.4vw, 15px); }
@keyframes forest-drift { from { transform: scale(1.015) translate3d(-.9%, .45%, 0); } to { transform: scale(1.065) translate3d(1%, -.65%, 0); } }
@keyframes forest-light { from { opacity: .35; transform: translateX(2%); } to { opacity: .82; transform: translateX(-3%); } }
@keyframes title-reveal { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes start-pulse {
  0%, 100% { box-shadow: inset 0 1px #ffefbca0, 0 4px 16px #0d160ed1, 0 0 0 0 #f4c57810; }
  50% { box-shadow: inset 0 1px #fff0cddd, 0 5px 22px #0d160ee1, 0 0 0 8px #f4c57828, 0 0 34px #ffd17e5c; }
}
.frame { width: calc(100% - clamp(24px, 2.1vw, 40px)); margin-inline: auto; }
.masthead { background: #102123ec; border-bottom: 1px solid #c3bb8e45; }
.masthead-inner { min-height: 57px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: 'brand chapter hud actions'; align-items: center; gap: 4px clamp(8px, 1.4vw, 25px); padding-block: 3px; }
.brand { grid-area: brand; display: flex; align-items: center; gap: 11px; min-width: 0; font: bold clamp(14px, 1.35vw, 21px)/1 var(--game-font); letter-spacing: -.03em; }
.brand-logo { display: block; flex: none; width: clamp(104px, 8vw, 154px); height: auto; filter: drop-shadow(0 2px 3px #0007); }
.top-actions { grid-area: actions; justify-self: end; }
.top-actions, .play-actions { display: flex; align-items: center; gap: 8px; }
.separator { width: 1px; height: 23px; background: var(--line); margin-inline: 5px; }
.button { min-height: 38px; display: inline-flex; justify-content: center; align-items: center; gap: 8px; padding: 0 13px; border: 1px solid #b4b58836; border-radius: 8px; font-size: 14px; font-weight: 650; white-space: nowrap; background: #b2aa7510; transition: background .15s, border-color .15s; }
.button:not(:disabled):hover { background: #cac28526; border-color: #cfbe7e7e; }
.stock-button { color: #e8d7a8; }
.stock-count { min-width: 21px; padding: 2px 5px; border-radius: 4px; color: #bde9be; background: #70a77929; font-size: 11px; font-variant-numeric: tabular-nums; }
.analysis-button { min-width: 94px; gap: 6px; color: #e5d7ae; }
.analysis-dot { width: 7px; height: 7px; border-radius: 50%; background: #778482; }
.analysis-button[data-recording="true"] .analysis-dot { background: #e77763; box-shadow: 0 0 7px #e7776366; }
.analysis-button[data-recording="true"] { border-color: #e777638a; color: #ffd5c2; background-color: #bd615022; }
.analysis-icon { display: none; }
.square { width: 38px; padding: 0; font-size: 18px; }
#sound-button[aria-pressed="false"] { color: var(--dim); text-decoration: line-through; }

.chapter-heading { grid-area: chapter; min-width: 0; width: 100%; text-align: center; }
.chapter-heading > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chapter-heading h1 { color: #f2c880; font: bold clamp(15px, 1.28vw, 24px)/1.1 var(--game-font); }
#chapter-title { margin-top: 2px; color: #dddbc3; font-size: 11px; line-height: 1.25; }
.chapter-description { margin-top: 10px; color: #d7dcc0; font-size: 12px; line-height: 1.42; }
.hud { grid-area: hud; display: grid; grid-template-columns: repeat(3, auto); gap: 5px; }
.hud-card { min-height: 44px; display: flex; gap: 7px; align-items: center; padding: 5px 9px; border: 1px solid #c7bd823b; border-radius: 8px; background: #192114ec; box-shadow: inset 0 1px #eee7ac10; }
.hud-card > div { min-width: 0; }
.hud-icon { display: grid; place-items: center; flex: 0 0 25px; height: 27px; border-radius: 6px; font: 18px/1 var(--game-font); }
.dew-icon { background: #2f594343; }
.dew-icon i, .price i { display: block; width: 9px; height: 12px; border-radius: 70% 44% 60% 56%; transform: rotate(37deg); background: linear-gradient(145deg,#d3ffe4 0%,#72d4a9 52%,#327453 100%); box-shadow: 0 0 7px #9de3b364; }
.core-icon { color: #f0bf79; background: #6d4f2849; }
.wave-icon { color: #c4b8e3; background: #64517941; font-size: 25px; }
.hud-label { display: block; color: #bfc0a8; font-size: 9px; line-height: 1; letter-spacing: .07em; font-weight: 760; margin-bottom: 3px; }
.hud-card strong { display: block; font: bold 20px/1 var(--game-font); white-space: nowrap; font-variant-numeric: tabular-nums; }
.hud-card strong .muted { color: #b2b397; font: 600 13px 'Segoe UI', sans-serif; }
#core-health:is([data-cores="0"], [data-cores="1"], [data-cores="2"]) { color: #ffc098; }

.game-layout { --sidebar-width: clamp(154px, 13.25vw, 260px); --layout-gap: 12px; --footer-height: 48px; --min-board-height: 310; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); grid-template-areas: 'sidebar arena'; align-items: start; gap: var(--layout-gap); padding: 9px 0 7px; }
.field-sidebar { grid-area: sidebar; min-width: 0; align-self: stretch; display: flex; flex-direction: column; justify-content: space-between; gap: 13px; padding-bottom: var(--footer-height); }
.field-status { padding: 9px 11px 11px; border: 1px solid #b8a87438; border-radius: 8px; background: #152722df; }
.field-advisor { --wolf-emblem-size: clamp(61px, 6vw, 89px); min-width: 0; padding-inline: 3px; }
.advisor-figure { display: block; width: 100%; aspect-ratio: 2 / 3; max-height: max(145px, calc(44vh - var(--wolf-emblem-size))); overflow: hidden; mask-image: linear-gradient(#000 84%, #0000 100%); }
.advisor-figure img { display: block; width: 100%; height: 100%; object-fit: contain; object-position: center bottom; filter: drop-shadow(0 8px 14px #08100dc2); }
.advisor-speech { position: relative; margin-top: -12px; padding: 11px 12px; border: 1px solid #dec28d; border-radius: 10px; background: linear-gradient(145deg, #f1e5cb, #e6d1a7); color: #27382d; box-shadow: 0 9px 24px #1018158a; }
.advisor-speech::before { position: absolute; content: ''; top: -7px; left: 31px; width: 12px; height: 12px; background: #efe2c6; border-left: 1px solid #dec28d; border-top: 1px solid #dec28d; transform: rotate(45deg); }
.advisor-speech h2 { margin: 0 0 4px; color: #52674f; font: 800 10px/1 'Segoe UI', sans-serif; text-transform: uppercase; letter-spacing: .12em; }
.advisor-speech p { font: 15px/1.37 var(--game-font); }
h2 { font: bold 23px/1.05 var(--game-font); letter-spacing: -.035em; }
.seed-bar { --seed-card-height: 57px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px 14px; margin-bottom: 7px; padding: 4px 6px; border: 1px solid #b8a8744f; border-radius: 8px; background: linear-gradient(95deg, #2a382b, #233027ec 54%, #192925ed); box-shadow: inset 0 1px #e8d2a315; }
.plant-cards { display: flex; min-width: 0; gap: 5px; padding: 2px; overflow-x: auto; scrollbar-width: thin; }
.plant-card { position: relative; flex: 0 0 64px; height: var(--seed-card-height); display: grid; place-items: center; padding: 1px 0 12px; border: 1px solid #d7c7915c; border-radius: 7px; background: radial-gradient(ellipse at 50% 48%, #64734680, #23302ce8 80%); isolation: isolate; }
.plant-card:hover { border-color: #e2ca8c; background-color: #91926026; }
.plant-card:focus-visible { outline: 2px solid #f3d69b; outline-offset: -2px; }
.plant-card[aria-pressed="true"] { border-color: #e7b86d; background-color: #b6923e24; box-shadow: inset 0 0 12px #eac47712, 0 0 13px #c3893c19; }
.plant-card[data-affordable="false"] .price { color: #bcb097; }
.plant-card[data-reloading="true"] .plant-portrait { opacity: .6; }
.plant-portrait { width: 47px; height: 43px; object-fit: contain; filter: drop-shadow(0 3px 3px #10160dc2); }
.plant-rank, .plant-card kbd, .reload-time { position: absolute; top: 3px; z-index: 1; }
.plant-rank { right: 3px; min-width: 13px; padding: 1px 2px; border-radius: 3px; color: #f2c783; background: #141b13e0; font: 750 9px/1 'Segoe UI', sans-serif; text-align: center; }
.plant-card kbd { left: 3px; min-width: 13px; padding: 0 2px; font-size: 9px; }
.reload-time { left: 3px; padding: 1px 3px; border-radius: 4px; color: #ffd89a; background: #141b13ed; font-size: 10px; font-weight: 760; font-variant-numeric: tabular-nums; white-space: nowrap; }
.reload-track { display: none; pointer-events: none; position: absolute; inset: auto 5px 2px; height: 3px; overflow: hidden; border-radius: 5px; background: #161f13; }
.plant-card[data-reloading="true"] .reload-track { display: block; }
.reload-track > span { display: block; height: 100%; background: #e2b971; border-radius: inherit; transform: scaleX(var(--reload, 0)); transform-origin: left center; }
.price { color: #b7e7c5; font-size: 12px; font-weight: 760; display: flex; gap: 4px; line-height: 1; align-items: center; }
.price i { width: 6px; height: 8px; }
.plant-card .price { position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%); text-shadow: 0 1px 3px #14201b; }
.seed-tooltip { position: fixed; z-index: 9; width: min(244px, calc(100vw - 16px)); padding: 9px 11px; border: 1px solid #e2c083a6; border-radius: 8px; color: #f2e7c8; background: #162b28; box-shadow: 0 6px 24px #0b150dd9; pointer-events: none; }
.seed-tooltip strong { display: block; font: bold 16px/1.2 var(--game-font); }
.seed-tooltip p { margin: 4px 0 5px; font-size: 12px; line-height: 1.35; }
.seed-tooltip small { color: #bcdbbd; font-size: 11px; }
kbd { display: inline-block; min-width: 19px; padding: 1px 4px; color: #d8d9bf; font: 650 10px/1.4 'Segoe UI', sans-serif; background: #121a1290; border-radius: 4px; border: 1px solid #dad6a431; text-align: center; }
.seed-tools { display: flex; align-items: center; gap: 5px; flex: none; }
.seed-menu-button, .tool-button { min-height: 36px; padding-inline: 9px; font-size: 12px; color: #e6d7a7; border-color: #b9b57d47; }
.seed-menu-button > [aria-hidden] { color: #e3be80; }
.tool-button > [aria-hidden] { color: #acae84; font-size: 17px; transform: rotate(20deg); }
.tool-button[aria-pressed="true"] { border-color: var(--gold); }
.root-tool { position: relative; width: fit-content; margin: 0 5px 5px auto; }
.root-call-button { position: relative; display: grid; place-items: center; width: var(--wolf-emblem-size); aspect-ratio: 1; padding: 2px 6px 9px; border: 2px solid #a5a9886e; border-radius: 18px; background: radial-gradient(ellipse at 50% 42%, #49534b, #1d2b26 77%); box-shadow: 0 5px 18px #09110cbc; }
.root-call-button[data-level]:not([data-level="0"]) { border-color: #e66852; box-shadow: inset 0 0 18px #ec693434, 0 0 12px #ec69345e; }
.root-call-button[aria-disabled="false"]:hover { border-color: #ff9a79; background: radial-gradient(ellipse at 50% 42%, #65584b, #322b26 77%); }
.root-call-mark { display: block; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 2px 3px #131c19); pointer-events: none; }
.root-call-button[data-level="0"] .root-call-mark { opacity: .73; }
.root-call-level { position: absolute; top: -5px; right: -5px; display: grid; place-items: center; width: 25px; aspect-ratio: 1; border: 1px solid #ffc7a6; border-radius: 50%; color: #fff3da; background: #7e3028; font: 800 17px/1 var(--game-font); box-shadow: 0 2px 6px #131613; }
.root-call-cost { position: absolute; bottom: 8px; right: 4px; padding: 2px 4px; border-radius: 3px; color: #e2f5cf; background: #18251df4; font: 750 10px/1 var(--game-font); white-space: nowrap; }
.root-call-track { position: absolute; inset: auto 7px 3px; height: 3px; overflow: hidden; border-radius: 6px; background: #bdded029; }
.root-call-track span { display: block; width: 0%; height: 100%; border-radius: inherit; background: #d7deb0; transition: width .18s; }
.root-call-hint { position: absolute; z-index: 5; top: calc(100% + 7px); right: 0; width: min(190px, calc(100vw - 32px)); padding: 8px 10px; border: 1px solid #b98c67; border-radius: 8px; background: #292a22; color: #f5e1c3; box-shadow: 0 5px 16px #0e1b14bb; font-size: 12px; line-height: 1.4; pointer-events: none; }
.root-call-hint strong { display: block; margin-bottom: 3px; color: #ffd1a5; }

.arena { grid-area: arena; min-width: 0; container-type: inline-size; }
@container (max-width: 760px) {
  .seed-tools .tool-label { display: none; }
}
.arena-title, .arena-meta { display: flex; align-items: center; gap: 10px; }
.arena-mark { color: var(--gold); font-size: 17px; }
.arena-title h2 { font-size: clamp(16px, 1.4vw, 23px); }
.arena-meta { margin-top: 7px; }
.wave-markers { display: flex; align-items: center; gap: 5px; }
.wave-marker { width: 6px; height: 6px; background: #afb18448; transform: rotate(45deg); border-radius: 1px; }
.wave-marker.done { background: #aebc84; }
.wave-marker.current { background: #f5c276; box-shadow: 0 0 7px #f5c2769e; }
.phase-label { display: flex; justify-content: center; align-items: center; gap: 5px; padding: 4px 6px; border-radius: 6px; border: 1px solid #e4be7452; color: #f6dca8; background: #956d322e; font-size: 10px; font-weight: 720; white-space: nowrap; }
.phase-label i { width: 5px; height: 5px; border-radius: 50%; background: #e6b769; box-shadow: 0 0 7px #dfaa6fb2; }
.phase-label[data-phase="wave"] { border-color: #bd805d70; color: #ffe0bf; background: #b0744d36; }
.phase-label[data-phase="won"] { background: #487a414d; }
.wave-ledger { display: grid; gap: 4px; margin-top: 7px; color: #d5d8b8; font-size: 11px; font-weight: 650; }
.wave-ledger:has(.wave-status:empty):has(.wave-tally:empty) { display: none; }
.chapter-mission { display: grid; gap: 4px; margin: 10px 0 0; padding: 8px 0 0; border-top: 1px solid #b1b08947; }
.chapter-mission span { color: #ccb27f; font-size: 9px; font-weight: 740; text-transform: uppercase; letter-spacing: .09em; }
.chapter-mission strong { color: #f3e5b7; font: bold clamp(12px, 1vw, 15px)/1.28 var(--game-font); }
.wave-progress { display: flex; align-items: center; gap: 7px; }
.wave-progress:has(.wave-tally:empty) { display: none; }
.wave-meter { flex: 1; height: 4px; overflow: hidden; border-radius: 4px; background: #c9c98a26; }
.wave-meter > span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, #b3bb6e, #efc57a); border-radius: 4px; transition: width .18s ease-out; }
.wave-tally { min-width: 28px; color: #d3c494; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.board { position: relative; width: 100%; aspect-ratio: 960 / 520; overflow: hidden; isolation: isolate; border-radius: 8px; background: #354634; box-shadow: 0 0 0 1px #b9b78978, 0 12px 35px #0c1b1a9c; }
.board canvas, .drops { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#terrain { z-index: 0; }
.plots { position: absolute; z-index: 1; inset: 4.6154% 8.125% 6.9231% 6.875%; display: grid; grid-template: repeat(5, 1fr) / repeat(9, 1fr); }
.plot { min-width: 0; display: grid; place-items: center; padding: 0; border: 1px solid transparent; border-radius: 0; background: transparent; touch-action: manipulation; }
.board[data-tool="none"] .plot { cursor: default; }
.plot:focus-visible { z-index: 1; outline-offset: -3px; }
.board[data-seed-terrain="ground"]:is([data-tool="plant"], [data-tool="supply"]) .plot:not([data-terrain="water"])[data-occupied="false"][data-rubble="false"]:is(:hover, :focus-visible),
.board[data-seed-terrain="water"]:is([data-tool="plant"], [data-tool="supply"]) .plot[data-terrain="water"][data-occupied="false"][data-rubble="false"]:is(:hover, :focus-visible),
.board:is([data-tool="spade"], [data-tool="seed-power"]) .plot[data-occupied="true"]:is(:hover, :focus-visible) { border-color: #f2ce82c4; background: #f0cb8029; }
.plot[data-rubble="true"] { cursor: not-allowed; }
#battle { z-index: 2; }
.drops { z-index: 3; }
.drop { display: grid; place-items: center; position: absolute; top: 0; left: 0; width: clamp(25px, 5%, 44px); aspect-ratio: 1; padding: 0; border-radius: 50%; border: 1px solid #baf5cc9e; color: #f2fff2; font-size: 11px; font-weight: 800; text-shadow: 0 1px 3px #254b27; background: radial-gradient(circle at 43% 27%, #c7f9be, #5ca77c 38%, #2e6b4dea 66%, #122916d7); box-shadow: inset 0 1px 1px #fafdd5; pointer-events: auto; touch-action: manipulation; }
.drop:hover { border-color: #fff5be; box-shadow: 0 0 15px 6px #d2eda389; }
.drop::before { content: ''; position: absolute; inset: calc(-1 * clamp(4px, .7vw, 8px)); border-radius: 50%; }
.drop::after { content: ''; position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 12px 3px #ade979a3; pointer-events: none; animation: glimmer 1.7s ease-in-out infinite alternate; }
@media (pointer: coarse) { .drop::before { inset: -8px; } }
.drop.expiring::after { animation-duration: .45s; }
.drop:disabled::after { animation-play-state: paused; }
.drop[data-origin="plant"] { border-color: #ddf3a9c7; }
@keyframes glimmer { from { opacity: 1; } to { opacity: .43; } }
.board-banner { z-index: 4; pointer-events: none; position: absolute; inset: 50% auto auto 50%; transform: translate(-50%, -50%); max-width: 86%; min-width: 34%; padding: 15px 19px; border: 1px solid #e4bd728e; border-radius: 10px; background: #1d271ae8; color: #f5d39b; text-align: center; font: bold clamp(17px, 3vw, 30px)/1.1 var(--game-font); text-wrap: balance; box-shadow: 0 6px 26px #0e110bd0; }
.board-banner[data-kind="wave"] { inset: 6px auto auto 50%; transform: translateX(-50%); min-width: 0; padding: 5px 13px; border-radius: 6px; font-size: clamp(13px, 1.4vw, 21px); }
.board-banner[data-kind="breach"] { inset: 7% auto auto 50%; transform: translateX(-50%); min-width: 0; padding: 8px 15px; border-color: #e48d64; background: #482319f2; color: #ffe4c5; font-size: clamp(13px, 1.7vw, 23px); }
.board-banner[data-kind="surge"] { min-width: min(58%, 465px); padding: clamp(12px, 2.4vw, 28px); border-block: 2px solid #eea568; background: linear-gradient(90deg, #552818eb, #341b14f7, #552818eb); color: #ffe0ad; text-shadow: 0 2px 6px #260d07; font-size: clamp(24px, 5vw, 62px); animation: surge-reveal .36s ease-out both; }
@keyframes surge-reveal { from { opacity: 0; transform: translate(-50%, -50%) scale(.87); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
.board-start {
  position: absolute; z-index: 5; inset: 48% auto auto 50%; transform: translate(-50%, -50%);
  display: grid; justify-items: center; gap: 13px; width: min(94%, 342px); padding: 24px 12px;
  background: radial-gradient(ellipse, #101d17c9 20%, #13251b82 55%, transparent 74%);
  pointer-events: none;
}
.board-start p { color: #fff1d2; font: 650 clamp(11px, 1.6vw, 15px)/1.25 var(--game-font); text-align: center; text-shadow: 0 2px 6px #101a13; }
.board-start .start-button { pointer-events: auto; animation: start-pulse 2.6s ease-in-out infinite; }
.boss-meter { position: absolute; z-index: 4; pointer-events: none; top: 5px; left: 50%; width: min(390px, 68%); padding: 4px 11px 6px; transform: translateX(-50%); border: 1px solid #e1ad76b1; border-radius: 7px; color: #ffe4ba; background: #2b2023f5; box-shadow: 0 4px 16px #0e0a12a3; }
.boss-meter div { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; font-size: clamp(9px, 1vw, 13px); }
.boss-meter strong { font-family: var(--game-font); }
.boss-meter span { color: #f1c89d; text-align: right; }
.boss-meter progress { display: block; width: 100%; height: 7px; margin-top: 3px; accent-color: #df896c; }
.boss-meter[data-state="warning"] { border-color: #ffc480; background: #472b22; }
.boss-meter[data-state="guarded"] { border-color: #bcaddf; background: #342d43; }
.boss-meter[data-state="exposed"] { border-color: #bdde9b; background: #2a392b; }
.board:has(.boss-meter:not([hidden])) .board-banner[data-kind="wave"] { top: 46px; }
.arena-footer { min-height: var(--footer-height); display: flex; justify-content: end; align-items: center; padding-top: 8px; }
#wave-button small { padding: 2px 5px; border-radius: 4px; background: #5c3c2326; font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.field-tool { min-height: 34px; padding: 4px 7px; gap: 5px; color: #e6edba; border-color: #a3bc74ab; }
.field-tool[aria-pressed="true"] { border-color: #ffe7a0; background: #677443; box-shadow: 0 0 8px #d4df976b; }
.field-tool img { width: 23px; height: 23px; object-fit: contain; }
.fullscreen-button { font-size: 17px; }
.fullscreen-button[aria-pressed="true"] { border-color: var(--gold); }
.speed-button { min-width: 41px; padding: 0 7px; }
.restart-button { color: #d3c598; }
.primary { min-width: 132px; color: #2b2114; background: linear-gradient(#f2ca86, #e0aa60); border-color: #eac180; box-shadow: inset 0 1px #fff0bf88, 0 3px 9px #0c100b7c; font-weight: 750; }
.primary:not(:disabled):hover { color: #261c12; background: #f7d495; border-color: #ffdd9d; }
.primary > span { font-size: 10px; }
.start-button { min-width: clamp(120px, 12vw, 215px); min-height: clamp(42px, 6dvh, 67px); padding-inline: 23px; border-radius: 11px; font-size: clamp(20px, 2.5vw, 33px); font-weight: 790; gap: 12px; }
.start-button > span { font-size: .54em; }

.game-dialog { width: min(555px, calc(100% - 30px)); max-height: calc(100% - 25px); padding: 23px; border: 1px solid #c5ac6f8c; border-radius: 15px; color: var(--ink); background: #1b2b2b; box-shadow: 0 18px 85px #060a05e0; overflow: hidden; }
#dialog-content { max-height: max(130px, calc(100dvh - 126px)); overflow: auto; overscroll-behavior: contain; padding: 1px 3px 5px; scrollbar-width: thin; scrollbar-color: #828462 #252e24; }
.game-dialog::backdrop { background: #0a0f09a9; backdrop-filter: blur(3px); }
.dialog-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 13px; }
.dialog-top h2 { font-size: 32px; }
.game-dialog p, .game-dialog li { color: #e0dfc5; line-height: 1.5; font-size: 14px; }
.game-dialog ol { padding-left: 23px; }
.game-dialog li { padding-left: 3px; margin-bottom: 8px; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 17px; }
.save-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; margin-bottom: 16px; }
.save-form label { color: var(--ink); font-size: 14px; font-weight: 700; }
.save-form > div { display: flex; gap: 7px; }
.save-file-actions, .save-row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.save-file-actions { margin-bottom: 12px; }
.save-row-actions { justify-content: flex-end; flex: none; }
.save-row-actions .button { min-height: 32px; padding-inline: 8px; font-size: 12px; }
.save-form input { flex: 1; min-width: 0; padding: 8px 11px; color: var(--ink); background: #142422; border: 1px solid #b9b57d84; border-radius: 7px; font: inherit; }
.save-form button { min-width: 0; }
.save-form input::placeholder { color: #aeb8a9; }
.save-form input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.save-list { display: grid; gap: 6px; margin: 8px 0 0; padding: 0; list-style: none; }
.game-dialog .save-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0; padding: 9px 10px; border: 1px solid #b9b57d3d; border-radius: 8px; background: #a9a67514; }
.save-list li > div { min-width: 0; overflow-wrap: anywhere; }
.save-list strong, .save-list small { display: block; }
.save-list strong { color: var(--ink); }
.save-list small { color: #c7d0bc; font-size: 12px; }
@media (max-width: 425px) {
  .save-form > div, .game-dialog .save-list li { flex-wrap: wrap; }
  .save-form input { flex-basis: 100%; }
  .save-file-actions .button { padding-inline: 8px; font-size: 12px; }
}
.stock-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid #b9b57d3c; border-radius: 9px; background: #93ac6230; }
.stock-summary p { color: #dfe4c9; font-size: 12px; }
.stock-summary strong { color: #c7ecb1; font: bold 21px/1 var(--game-font); white-space: nowrap; }
.game-dialog .stock-status { margin-top: 10px; padding: 7px 11px; border-radius: 6px; color: #dbe9bd; background: #a0b27426; font-size: 13px; }
.stock-list { display: grid; gap: 6px; margin: 12px 0 0; padding: 0; list-style: none; }
.game-dialog .stock-item { display: grid; grid-template-columns: 50px minmax(0, 1fr) 100px; align-items: center; gap: 8px; min-height: 66px; margin: 0; padding: 6px 7px; border: 1px solid #b9b57d29; border-radius: 8px; background: #a9a67510; }
.stock-item img { width: 50px; height: 50px; object-fit: contain; }
.stock-item-info { display: grid; gap: 2px; min-width: 0; }
.stock-item-info strong { color: var(--ink); font: bold 17px/1.2 var(--game-font); }
.stock-item-info strong small { display: inline-block; color: var(--gold); font: 700 10px/1.15 'Segoe UI', sans-serif; }
.stock-item-info > span { color: var(--muted); line-height: 1.2; font-size: 12px; }
.stock-item-info .stock-detail { color: #dde2ba; font-size: 11px; }
.stock-purchase { flex-direction: column; gap: 1px; padding: 4px; font-size: 12px; }
.stock-purchase span { color: #bce5b2; font-size: 11px; }
.stock-max { text-align: center; color: var(--gold); font-size: 11px; }
.mode-switch { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 11px; }
.mode-switch .button[aria-pressed="true"], .seed-filled { border: 1px solid #e3ba73; background: #aa8c453b; color: #ffe9bc; }
.game-dialog .menu-hint { font-size: 13px; color: #d4d8be; }
.game-dialog[data-layout="seeds"] { width: min(870px, calc(100% - 24px)); }
.game-dialog:is([data-layout="seeds"], [data-layout="stock"]) #dialog-content { scroll-padding-block-end: 61px; }
.game-dialog:is([data-layout="seeds"], [data-layout="stock"]) .dialog-actions { position: sticky; z-index: 3; bottom: -5px; padding: 9px 0; border-top: 1px solid #b9b57d3d; background: #1b2b2b; }
.game-dialog[data-layout="stock"] #dialog-content { scroll-padding-block-start: 64px; }
.game-dialog[data-layout="stock"] .stock-summary { position: sticky; z-index: 2; top: -1px; background: #304337; }
.seed-slots { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; max-width: 398px; margin: 12px 0; }
.seed-slot { position: relative; aspect-ratio: 1.16; min-width: 0; padding: 3px; }
.seed-slot img { width: 96%; height: min(100%, 59px); object-fit: contain; }
.seed-slot kbd { position: absolute; top: 3px; left: 3px; }
.seed-empty, .seed-filled { display: grid; place-items: center; border-radius: 8px; }
.seed-empty { color: #9aa7a494; border: 1px dashed #bdc7ab3b; }
.seed-picker { display: grid; gap: 10px; align-items: start; margin-top: 10px; }
@media (min-width: 700px) { .seed-picker { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); } }
.seed-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 10px; }
.seed-picker .seed-options { margin-top: 0; }
.seed-demo { position: sticky; z-index: 2; top: 0; padding: 7px; border: 1px solid #899f776d; border-radius: 8px; background: #223631; box-shadow: 0 3px 8px #10171680; }
.seed-demo-info { display: grid; gap: 2px; margin: 0 2px 6px; }
.seed-demo-info strong { color: #f3dfaa; font: bold 15px var(--game-font); }
.game-dialog .seed-demo-info p { font-size: 12px; line-height: 1.25; }
.seed-demo canvas { display: block; width: 100%; height: auto; aspect-ratio: 620 / 218; border-radius: 5px; background: #334139; }
.seed-option[data-preview="true"] { border-color: #d7cd8d; background: #6b774344; }
.seed-option[aria-pressed="true"] { border-color: #e3ba73; background: #aa8c453b; }
.seed-option { text-align: left; justify-content: start; min-width: 0; min-height: 58px; padding: 4px; white-space: normal; }
.seed-option img { width: 42px; height: 44px; object-fit: contain; flex: none; }
.seed-option strong { display: block; font: bold 14px var(--game-font); }
.seed-option small { display: block; color: var(--muted); font-size: 10px; line-height: 1.2; }
.seed-option strong small { display: inline-block; color: var(--gold); }
.seed-brief { padding: 8px 10px; margin-bottom: 10px; border: 1px solid #778b686d; border-radius: 8px; background: #223631; }
.seed-brief ul { display: flex; flex-wrap: wrap; gap: 5px; padding: 0; margin: 8px 0 0; list-style: none; }
.game-dialog .seed-brief li { display: flex; align-items: center; gap: 4px; padding: 1px 5px; margin: 0; border-radius: 5px; background: #364833; font-size: 11px; }
.seed-brief li.brief-boss { color: #ffe3b5; border: 1px solid #d6b66f80; background: #544530; }
.seed-brief img { width: 28px; height: 28px; object-fit: contain; }
.game-dialog h3 { margin: 12px 0 4px; color: var(--gold); font: bold 16px var(--game-font); }
.field-guide-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 5px; }
.game-dialog .field-guide-list li { display: grid; align-items: center; grid-template-columns: 54px minmax(0, 1fr); gap: 8px; margin: 0; padding: 5px 6px; border: 1px solid #b4b97c29; border-radius: 8px; background: #a5ad7c13; }
.field-guide-list img { width: 54px; height: 53px; object-fit: contain; }
.field-guide-list strong { font: bold 17px var(--game-font); color: #eee3c2; }
.game-dialog .field-guide-list p { font-size: 12px; line-height: 1.25; }
.game-dialog .unfound-seeds { margin-top: 12px; color: #bac8be; font-size: 12px; }
.game-dialog[data-layout="story"] { width: min(1115px, calc(100% - 38px)); padding: 24px; background: linear-gradient(135deg, #223437, #162628 70%); border-color: #dec4959c; }
.game-dialog[data-layout="story"]::backdrop { background: #0b1a1cbb; backdrop-filter: blur(4px); }
.game-dialog[data-layout="story"] .dialog-top { margin: 0 0 16px; }
.game-dialog[data-layout="story"] h2 { font-size: clamp(29px, 4vw, 54px); line-height: .98; }
.game-dialog[data-layout="film"] { width: min(1120px, calc(100% - 24px)); padding: clamp(12px, 2vw, 24px); background: #182327; }
.film-card video { display: block; width: 100%; max-height: 66dvh; aspect-ratio: 16 / 9; object-fit: contain; background: #10191b; border: 1px solid #ba9c6f71; border-radius: 8px; }
.film-card .dialog-actions { margin-top: 13px; }
.game-dialog .story-objective { color: #cbd9ba; font-size: 12px; }
.story-card { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 22px; align-items: center; }
.story-card figure { margin: 0; min-width: 0; overflow: hidden; border-radius: 10px; border: 1px solid #d5bb8a7a; background: #131e20; box-shadow: 0 10px 24px #0b1318a0; }
.story-image { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: contain; }
.story-copy { min-width: 0; align-self: stretch; display: flex; flex-direction: column; justify-content: center; gap: 11px; padding-inline: 4px 2px; }
.game-dialog .story-context { color: #d9b982; font-size: 11px; text-transform: uppercase; letter-spacing: .125em; font-weight: 760; }
.story-speech { position: relative; margin: 0; padding: 14px 16px; border: 1px solid #e5c88b; border-radius: 5px 13px 13px 13px; color: #24322a; background: linear-gradient(147deg, #f2e6cb, #e4d2a7); box-shadow: 0 5px 12px #111b1c50; }
.story-speech::before { position: absolute; content: ''; width: 12px; height: 12px; left: -7px; top: 20px; transform: rotate(45deg); background: #f0e3c7; border-left: 1px solid #e5c88b; border-bottom: 1px solid #e5c88b; }
.story-speech cite { color: #55725b; font: normal 760 10px/1 'Segoe UI', sans-serif; text-transform: uppercase; letter-spacing: .13em; }
.game-dialog .story-speech p { margin-top: 4px; color: #26382f; font: 16px/1.39 var(--game-font); }
.story-aside { background: #c7d4c5; border-color: #afc3b1; }
.story-aside::before { background: #c7d4c5; border-color: #afc3b1; }
.game-dialog .story-aside p { font-size: 14px; }
.story-audio { width: 100%; height: 40px; color-scheme: dark; }
.story-rewards { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.game-dialog .story-rewards li { display: flex; gap: 5px; align-items: center; margin: 0; padding: 4px 9px 4px 4px; border: 1px solid #adb88d63; border-radius: 7px; color: #f5e6c4; background: #89a27624; }
.story-rewards img { width: 38px; height: 38px; object-fit: contain; }
.story-rewards small { display: block; font-size: 9px; line-height: 1; color: #c8dbae; }
.story-rewards strong { font: bold 14px var(--game-font); }
.story-copy .dialog-actions { margin-top: 2px; }
.reward-card { border: 1px solid #9db88168; border-radius: 8px; padding: 8px 11px; background: #91a96016; }
.reward-total { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding-bottom: 5px; border-bottom: 1px solid #aeb47a3e; }
.reward-total span { color: #dce8c3; font-weight: 720; font-size: 13px; }
.reward-total strong { color: #d3efaa; font: bold 20px/1.1 var(--game-font); }
.reward-card dl { display: grid; gap: 3px; margin: 6px 0 0; color: #ebe6ce; font-size: 12px; }
.reward-card dl div { display: flex; justify-content: space-between; gap: 8px; }
.reward-card dd { margin: 0; color: #c9dfa8; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.game-dialog .reward-card p { margin-top: 5px; color: #bccfb4; font-size: 11px; }
.game-dialog[data-layout="analysis"] { width: min(820px, calc(100% - 24px)); }
#analysis-transcript { display: block; width: 100%; height: clamp(160px, 49dvh, 475px); resize: vertical; margin-top: 9px; padding: 11px; border: 1px solid #afc5a353; border-radius: 7px; color: #e8ebd6; background: #101d1e; font: 12px/1.48 var(--game-font); }
.game-dialog .analysis-status { margin-top: 6px; color: #dbe9bd; font-size: 12px; }
.playtest-rating { display: grid; gap: 5px; }
.game-dialog .playtest-rating p { color: #c7cdb2; font-size: 11px; }
.playtest-rating > div { display: flex; flex-wrap: wrap; gap: 4px; }
.playtest-rating .button { min-height: 28px; padding-inline: 7px; font-size: 11px; }
.playtest-rating .button[aria-pressed="true"] { border-color: #e4ba7c; background: #deba7450; }

@media (min-width: 900px) {
  .game-layout { max-width: calc(var(--board-width, 100vw) + var(--sidebar-width) + var(--layout-gap)); }
  :fullscreen .masthead-inner { min-height: 50px; }
  :fullscreen .game-layout { padding-top: 6px; }
}

@media (min-width: 791px) {
  .field-sidebar { contain: size; }
  .field-status, .root-tool, .advisor-speech { flex: none; }
  .field-advisor { display: flex; flex-direction: column; min-height: 0; }
  .advisor-figure { min-height: 0; }
  .plant-cards { min-height: calc(var(--seed-card-height) + 4px); }
}

@media (max-width: 1240px) {
  .masthead-inner { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'brand actions' 'chapter hud'; padding-block: 4px 6px; }
  .chapter-heading { text-align: left; }
  .hud-card { min-height: 38px; }
  .top-actions { gap: 5px; }
}

@media (max-width: 1040px) {
  .game-layout { --layout-gap: 10px; }
  .plant-card { flex-basis: 55px; }
  .seed-tools .tool-label { display: none; }
}

@media (min-width: 900px) and (max-height: 830px) {
  .game-layout { padding-top: 7px; }
  .advisor-figure img { object-fit: cover; object-position: center 8%; }
  .seed-bar { --seed-card-height: 51px; }
  .plant-portrait { height: 37px; }
}

@media (max-width: 790px) {
  .frame { width: calc(100% - 24px); }
  .masthead-inner { min-height: 54px; }
  .game-layout { --layout-gap: 8px; grid-template-columns: minmax(0, 1fr); grid-template-areas: 'sidebar' 'arena'; }
  .field-sidebar { padding-bottom: 0; gap: 6px; }
  .field-status { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'title meta' 'ledger ledger' 'mission mission' 'description description'; gap: 4px 7px; padding: 5px 8px; }
  .arena-title { grid-area: title; }
  .arena-meta { grid-area: meta; margin-top: 0; }
  .wave-ledger { grid-area: ledger; display: flex; align-items: center; justify-content: space-between; margin-top: 0; gap: 10px; }
  .wave-progress { width: min(34%, 120px); }
  .chapter-mission { grid-area: mission; }
  .chapter-description { grid-area: description; margin-top: 0; font-size: 11px; }
  .field-advisor { display: grid; grid-template-columns: 55px 58px minmax(0, 1fr); align-items: center; gap: 9px; }
  .root-tool { margin: 0; }
  .root-call-button { width: 53px; border-radius: 13px; }
  .root-call-hint { right: auto; left: 0; }
  .advisor-figure { aspect-ratio: auto; height: 60px; max-height: none; border-radius: 8px; border: 1px solid #d4c3986c; mask-image: none; }
  .advisor-figure img { object-fit: cover; object-position: center; }
  .advisor-speech { margin: 0; min-height: 62px; padding: 9px 11px; }
  .advisor-speech::before { top: 22px; left: -7px; transform: rotate(-45deg); }
  .game-dialog[data-layout="story"] { width: min(590px, calc(100% - 22px)); padding: 15px; }
  .story-card { grid-template-columns: 1fr; gap: 12px; }
  .story-card figure { max-height: min(50vh, 350px); display: grid; place-items: center; }
  .story-image { min-height: 0; max-height: min(50vh, 350px); }
  .story-speech::before { left: 18px; top: -7px; transform: rotate(135deg); }
  .story-copy { gap: 9px; }
}

@media (max-width: 565px) {
  .frame { width: calc(100% - 16px); }
  .masthead-inner { grid-template-areas: 'brand actions' 'chapter chapter' 'hud hud'; gap: 5px 4px; }
  .brand { display: grid; gap: 0; font-size: 13px; }
  .brand-logo { width: min(134px, 100%); }
  .chapter-heading { display: flex; align-items: baseline; gap: 7px; }
  .chapter-heading h1 { flex-shrink: 0; font-size: 14px; }
  .hud { grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
  .top-actions { gap: 3px; }
  .top-actions .separator { display: none; }
  .top-actions .button { min-height: 32px; font-size: 12px; }
  .top-actions .save-button { width: 30px; padding: 0; font-size: 16px; }
  .save-label { display: none; }
  .top-actions .square { width: 30px; font-size: 16px; }
  .stock-button { gap: 4px; padding-inline: 6px; }
  .top-actions .analysis-button { min-width: 0; width: 30px; padding: 0; }
  .analysis-label { display: none; }
  .analysis-icon { display: inline; font-size: 15px; }
  .analysis-dot { display: none; }
  .seed-bar { grid-template-columns: minmax(0, 1fr); gap: 3px 6px; padding: 3px 4px; }
  .plant-cards { gap: 4px; }
  .plant-card { flex-basis: clamp(39px, calc((100% - 20px) / 6), 44px); height: 48px; }
  .plant-portrait { width: 35px; height: 33px; }
  .plant-card kbd { display: none; }
  .seed-tools { margin-left: auto; }
  .seed-tools .seed-menu-button .tool-label { display: inline; }
  .seed-tools button { min-width: 31px; min-height: 31px; padding-inline: 6px; }
  .arena-title, .arena-meta { gap: 6px; }
  .play-actions { margin-left: auto; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
  .play-actions .square { width: 30px; }
  .play-actions .primary { min-width: 0; padding-inline: 8px; font-size: 12px; }
  .seed-options { gap: 4px; }
  .seed-option { gap: 4px; }
  .seed-option img { width: 33px; height: 37px; }
  .seed-option strong { font-size: 12px; }
  .game-dialog .story-speech p { font-size: 15px; }
  .game-dialog .story-aside p { font-size: 13px; }
}

@media (max-width: 410px) {
  .stock-count { display: none; }
  .game-dialog { padding: 13px; }
  .game-dialog .stock-item { grid-template-columns: 39px minmax(0, 1fr) 80px; gap: 5px; }
  .stock-item img { width: 39px; height: 45px; }
  .stock-purchase { font-size: 11px; }
}

@media (max-width: 345px) {
  .brand { font-size: 12px; max-width: 104px; }
  .brand-logo { width: min(98px, 100%); }
  .top-actions .square { width: 26px; }
  .top-actions .analysis-button { width: 26px; }
  .top-actions .save-button { width: 26px; }
  .wave-markers { display: none; }
  .hud { gap: 4px; }
  .hud-card { padding-inline: 5px; gap: 4px; }
  .hud-icon { flex-basis: 20px; height: 24px; font-size: 16px; }
  .hud-label { font-size: 8px; letter-spacing: .035em; }
}

@media (max-width: 420px) {
  .play-actions { gap: 3px; }
  .play-actions .button { min-height: 34px; }
  .play-actions .square { width: 28px; }
  .play-actions .speed-button, .play-actions .field-tool { min-width: 32px; padding-inline: 5px; }
  .play-actions #wave-button { gap: 4px; padding-inline: 6px; }
  #wave-button small { padding-inline: 3px; }
}

@media (max-width: 790px) and (orientation: portrait) {
  .field-advisor .advisor-speech { display: flex; flex-direction: column; justify-content: center; height: 74px; }
  .field-advisor .advisor-speech p { overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; }
}

@media (max-width: 420px) and (max-height: 740px) {
  .chapter-description { display: none; }
  .field-advisor { grid-template-columns: 45px 46px minmax(0, 1fr); gap: 7px; }
  .root-call-button { width: 44px; }
  .advisor-figure { height: 48px; }
  .advisor-speech { min-height: 48px; padding: 6px 8px; }
  .advisor-speech p { font-size: 12px; line-height: 1.18; }
  .field-advisor .advisor-speech { height: 70px; }
}

@media (max-width: 380px) and (max-height: 700px) {
  .brand strong { display: none; }
  .hud-card { min-height: 37px; padding-block: 3px; }
  .field-status { grid-template-areas: 'ledger meta' 'mission mission'; align-items: center; padding-block: 4px; }
  .arena-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .wave-ledger { gap: 5px; }
  .wave-progress { width: 36%; }
  .wave-status { font-size: 10px; }
  .game-layout { gap: 6px; }
  .arena-footer { padding-top: 5px; }
}

@media (max-width: 790px), (max-height: 640px) {
  .game-dialog[data-layout="story"] #dialog-content { scroll-padding-bottom: 65px; }
  .story-copy .dialog-actions { position: sticky; z-index: 1; bottom: -5px; padding: 8px 0; border-top: 1px solid #e5c88b42; background: #1b2b2b; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (max-width: 610px) {
  .field-tool strong, #supply-button span { display: none; }
  .field-tool { min-width: 35px; }
  .seed-demo canvas { max-height: 118px; object-fit: contain; }
  .chapter-mission { padding: 5px 0 0; margin-top: 4px; }
  .boss-meter { padding-block: 3px; }
}

@media (min-width: 500px) and (max-height: 640px) and (orientation: landscape) {
  .masthead-inner { min-height: 46px; grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: 'brand chapter hud actions'; gap: 5px 8px; padding-block: 3px; }
  .brand-logo { width: clamp(76px, 9.5vw, 112px); }
  .brand strong { display: none; }
  .chapter-heading h1 { font-size: clamp(12px, 1.5vw, 19px); }
  .hud { gap: 4px; }
  .hud-card { min-height: 34px; padding: 4px 5px; gap: 5px; }
  .hud-icon { flex-basis: 21px; height: 23px; }
  .hud-label { font-size: 8px; }
  .hud-card strong { font-size: 17px; }
  .hud-card strong .muted { font-size: 10px; }
  .top-actions { gap: 4px; }
  .top-actions .square, .top-actions .save-button, .top-actions .analysis-button { width: 30px; min-width: 30px; min-height: 32px; padding: 0; }
  .top-actions .save-label, .top-actions .analysis-label, .top-actions .analysis-dot, .top-actions .separator { display: none; }
  .top-actions .analysis-icon { display: inline; }
  .stock-button { min-height: 32px; padding-inline: 5px; }
  .game-layout { --sidebar-width: clamp(140px, 16vw, 181px); --layout-gap: 8px; --footer-height: 39px; --min-board-height: 190; max-width: calc(var(--board-width, 100vw) + var(--sidebar-width) + var(--layout-gap)); grid-template-columns: var(--sidebar-width) minmax(0, 1fr); grid-template-areas: 'sidebar arena'; padding-top: 6px; }
  .field-sidebar { contain: size; gap: 7px; padding-bottom: var(--footer-height); }
  .field-status { display: block; flex: none; padding: 6px 8px; }
  .arena-meta, .wave-ledger { margin-top: 5px; }
  .chapter-mission { margin-top: 6px; padding-top: 5px; }
  .chapter-mission strong, .chapter-description { font-size: 11px; }
  .chapter-description { margin-top: 5px; }
  .field-advisor { display: flex; flex-direction: column; min-height: 0; }
  .field-advisor .root-tool { flex: none; margin: 0 3px 4px auto; }
  .root-call-button { width: 53px; }
  .advisor-figure { min-height: 0; }
  .advisor-speech { flex: none; padding: 6px 8px; }
  .advisor-speech p { font-size: 13px; }
  .seed-bar { --seed-card-height: 44px; gap: 5px; }
  .plant-cards { min-height: calc(var(--seed-card-height) + 4px); }
  .plant-card { flex-basis: 48px; }
  .plant-portrait { height: 30px; }
  .arena-footer { padding-top: 5px; }
  .play-actions { gap: 4px; }
  .play-actions .button { min-height: 33px; }
  .play-actions .square { width: 31px; }
  .play-actions .primary { min-width: 0; padding-inline: 8px; font-size: 12px; }
}

@media (min-width: 500px) and (max-height: 520px) and (orientation: landscape) {
  .chapter-description { display: none; }
  .field-advisor { display: grid; grid-template: 'wolf speech' auto 'portrait speech' minmax(0, 1fr) / 46px minmax(0, 1fr); gap: 5px; }
  .field-advisor .root-tool { grid-area: wolf; margin: 0; }
  .root-call-button { width: 44px; }
  .advisor-figure { grid-area: portrait; width: 46px; height: 49px; mask-image: none; }
  .advisor-figure img { object-fit: cover; object-position: center; }
  .advisor-speech { grid-area: speech; align-self: stretch; margin: 0; }
  .advisor-speech::before { display: none; }
  .advisor-speech p { font-size: 11px; line-height: 1.28; }
  .seed-menu-button, .tool-button { padding-inline: 7px; }
  .film-card video { max-height: min(66dvh, calc(100dvh - 190px)); }
}

@media (min-width: 500px) and (max-width: 649px) and (max-height: 420px) and (orientation: landscape) {
  .game-layout { --sidebar-width: 126px; --min-board-height: 145; --footer-height: 35px; }
  .masthead-inner { grid-template-columns: auto minmax(32px, 1fr) auto auto; column-gap: 4px; }
  .chapter-heading h1 { font-size: 11px; }
  .chapter-prefix, #chapter-region { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  #chapter-title { display: none; }
  .top-actions .stock-count { display: none; }
  .field-status .arena-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .field-status .wave-status, .field-status .wave-ledger:has(.wave-tally:empty) { display: none; }
  .chapter-mission strong { font-size: 10px; }
  .field-advisor { grid-template: 'wolf portrait' 44px 'speech speech' 74px / 44px minmax(0, 1fr); }
  .field-advisor .advisor-figure { width: 44px; height: 44px; justify-self: center; }
  .field-advisor .advisor-speech { display: flex; flex-direction: column; }
  .field-advisor .advisor-speech p { overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; }
  .seed-bar { --seed-card-height: 39px; grid-template-columns: minmax(0, 1fr) auto; margin-bottom: 5px; }
  .plant-cards { gap: 3px; }
  .plant-card { flex-basis: calc((100% - 15px) / 6); height: var(--seed-card-height); min-width: 0; }
  .plant-portrait { width: 31px; height: 28px; }
  .plant-card kbd { display: none; }
  .seed-tools .seed-menu-button .tool-label { display: none; }
  .arena-footer { padding-top: 3px; }
  .play-actions { flex-wrap: nowrap; gap: 2px; }
  .play-actions .button { min-height: 31px; }
  .play-actions .square { width: 27px; }
  .play-actions .speed-button, .play-actions .field-tool { min-width: 29px; padding-inline: 4px; }
  .play-actions #wave-button { padding-inline: 6px; gap: 4px; font-size: 11px; }
  .play-actions #wave-button > span[aria-hidden] { display: none; }
}

@media (min-width: 500px) and (max-width: 580px) and (max-height: 420px) and (orientation: landscape) {
  .hud { grid-template-columns: repeat(3, auto); }
  .hud-icon { display: none; }
  .top-actions .square, .top-actions .save-button, .top-actions .analysis-button { width: 28px; min-width: 28px; }
}
