/* Dark Academia interface layer — visual-only overrides, game state remains untouched. */
:root {
  --ink: #070d11;
  --ink-soft: #0c151b;
  --panel: rgba(8, 16, 21, .94);
  --panel-soft: rgba(13, 25, 30, .9);
  --wood: #2b211b;
  --brass: #c5a264;
  --brass-bright: #e1c486;
  --paper: #e8d4a9;
  --paper-muted: #ad9d7e;
  --teal: #65aaa0;
  --teal-dark: #274b48;
  --line: rgba(197, 162, 100, .36);
  --line-soft: rgba(197, 162, 100, .17);
  --danger: #b55e50;
  --display: Georgia, "Times New Roman", "Noto Serif KR", serif;
  --ui: Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", sans-serif;
}

* { box-sizing: border-box; }
html, body { background: var(--ink); color: #e9e1cf; font-family: var(--ui); }
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 9999; opacity: .12;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='.72' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.18'/%3E%3C/svg%3E");
}
button, select { font-family: var(--ui); }
button { border-radius: 1px !important; }

.topbar {
  height: 68px; padding: 0 28px; z-index: 40;
  border: 0; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(6,12,16,.98), rgba(8,16,21,.92));
  box-shadow: 0 10px 30px rgba(0,0,0,.3);
}
.brand { gap: 12px; min-width: 230px; color: var(--paper); }
.brandmark {
  width: 42px; height: 42px; display: grid; place-items: center;
  border: 1px solid var(--brass); color: var(--brass-bright);
  font: 700 10px/1 var(--display); letter-spacing: .16em;
  background: radial-gradient(circle, #26312f, #0b1418 72%);
  box-shadow: inset 0 0 0 3px #081014, inset 0 0 0 4px rgba(197,162,100,.22);
}
.game-brand { font: 700 18px/1.05 var(--display); letter-spacing: -.03em; }
.game-brand small { display: block; margin-top: 5px; font: 700 8px/1 var(--ui); letter-spacing: .22em; color: var(--brass); }
.top-center { gap: 13px; color: var(--paper-muted); font-size: 12px; }
.top-center .chapter { color: var(--brass-bright); letter-spacing: .2em; }
.topbar nav { display: flex; height: 100%; align-items: stretch; gap: 0; }
.topbar nav button {
  min-width: 92px; padding: 0 16px; border: 0; border-left: 1px solid var(--line-soft);
  background: transparent; color: #c9c2b3; font-size: 12px;
}
.topbar nav button:hover { background: rgba(197,162,100,.09); color: var(--paper); }
.topbar nav button span { margin-right: 6px; color: var(--brass); }
.topbar nav .iconbtn { min-width: 50px; width: 50px; padding: 0; }

/* Main hall */
#menu-screen {
  min-height: calc(100dvh - 68px); overflow: hidden; isolation: isolate;
  background: #0a1115 url("./laboratory-menu.webp") center right / cover no-repeat;
}
#menu-screen::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(90deg, rgba(5,10,13,.98) 0%, rgba(5,10,13,.91) 26%, rgba(5,10,13,.5) 50%, rgba(5,10,13,.1) 76%),
    linear-gradient(0deg, rgba(5,10,13,.82), transparent 35%, rgba(5,10,13,.26));
}
#menu-screen::after {
  content: ""; position: absolute; inset: 22px; z-index: -1; pointer-events: none;
  border: 1px solid rgba(197,162,100,.18);
}
.menu-art { display: none; }
.menu-content {
  display: block;
  position: relative; inset: auto; width: min(470px, calc(100vw - 72px));
  margin: 0; padding: clamp(44px, 6vh, 76px) 0 90px clamp(42px, 5vw, 92px);
  transform: none; z-index: 2;
}
.menu-content .eyebrow {
  margin: 0 0 14px; color: var(--brass); font-size: 9px; letter-spacing: .28em; opacity: .95;
}
.game-title {
  margin: 0; color: #f0e4c9; font: 700 clamp(46px, 5vw, 74px)/.91 var(--display);
  letter-spacing: -.065em; text-shadow: 0 4px 24px #000;
}
.game-title em { color: var(--brass-bright); font-style: normal; font-size: .76em; letter-spacing: -.05em; }
.menu-chapter {
  margin: 26px 0 17px; padding: 14px 17px; border-left: 2px solid var(--brass);
  background: linear-gradient(90deg, rgba(12,23,28,.8), transparent);
}
.menu-chapter small { color: var(--brass); font-size: 9px; letter-spacing: .22em; }
.menu-chapter strong { display: block; margin: 4px 0; color: var(--paper); font: 700 17px var(--display); }
.menu-chapter p { margin: 0; max-width: 360px; color: #aaa291; font-size: 11px; line-height: 1.6; }
.difficulty-choice {
  display: grid; grid-template-columns: 84px 1fr; align-items: center; gap: 10px; margin: 0 0 10px;
  padding: 0; border: 1px solid var(--line); background: rgba(7,14,18,.86);
}
.difficulty-choice label { padding-left: 14px; color: var(--paper-muted); font-size: 10px; letter-spacing: .08em; }
.difficulty-choice select {
  min-height: 42px; padding: 0 12px; border: 0; border-left: 1px solid var(--line-soft);
  border-radius: 0; background: #101d22; color: #eee4d0; outline: 0;
}
.menu-actions { display: grid; gap: 7px; }
.menu-actions button, .lobby-relic {
  min-height: 48px; padding: 0 17px; border: 1px solid var(--line) !important;
  background: linear-gradient(90deg, rgba(14,27,32,.97), rgba(9,18,22,.92)); color: #e4dac4;
  box-shadow: inset 0 1px rgba(255,255,255,.03), 0 8px 22px rgba(0,0,0,.16);
}
.menu-actions button { display: flex; align-items: center; justify-content: space-between; font-weight: 700; letter-spacing: -.02em; }
.menu-actions button:hover, .lobby-relic:hover { border-color: var(--brass) !important; transform: translateX(3px); }
.menu-actions .primary {
  min-height: 58px; border-color: #ead29c !important;
  background: linear-gradient(135deg, #eadbb8, #cbb17c); color: #171914;
  font: 800 16px var(--display); box-shadow: 0 11px 28px rgba(0,0,0,.3);
}
.menu-actions #infinite-lock { color: #8e816b; font-size: 9px; letter-spacing: .12em; }
.lobby-relic { width: 100%; margin: 7px 0 0; display: grid; grid-template-columns: 27px auto; grid-template-rows: auto auto; text-align: left; }
.lobby-relic > span { grid-row: 1/3; color: var(--brass); font-size: 17px; }
.lobby-relic b { font-size: 12px; }
.lobby-relic small { color: #8e897c; font-size: 9px; }
.lobby-relic em { color: var(--brass-bright); font-style: normal; }
.menu-links { margin-top: 15px; display: flex; align-items: center; }
.menu-links button { padding: 0 13px; border: 0; background: none; color: #9e9788; font-size: 10px; }
.menu-links button:first-child { padding-left: 0; }
.menu-links span { width: 1px; height: 10px; background: var(--line); }
.menu-caption { right: clamp(28px, 5vw, 90px); bottom: 72px; text-align: right; color: var(--paper); }
.menu-caption span { color: var(--brass); font-size: 9px; letter-spacing: .2em; }
.menu-caption p { margin: 8px 0 0; font: italic 16px var(--display); }
.menu-bottom { left: 0; right: 0; bottom: 0; height: 40px; padding: 0 30px; border-top: 1px solid var(--line-soft); background: rgba(5,10,13,.72); color: #8d887d; font-size: 9px; letter-spacing: .12em; }

/* Battle command deck */
#game-screen { min-height: calc(100dvh - 68px); background: radial-gradient(circle at 50% 30%, #14292b, #070e12 65%); }
.battle-hud {
  min-height: 82px; margin: 0; padding: 0 clamp(14px, 2.2vw, 36px); gap: 0;
  border: 0; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #101d22, #0a1419);
  box-shadow: 0 12px 28px rgba(0,0,0,.2);
}
.battle-hud > div { min-height: 54px; padding: 0 24px; border-left: 1px solid var(--line-soft); }
.battle-hud > div:first-child { border-left: 0; padding-left: 0; }
.battle-hud small { color: #8f897b; letter-spacing: .13em; text-transform: uppercase; }
.battle-hud .wave { flex-direction: column; align-items: flex-start; gap: 3px; }
.battle-hud .wave > small { writing-mode: horizontal-tb; }
.battle-hud .wave strong { color: var(--paper); font: 700 27px var(--display); }
.battle-hud .wave i { color: #7b776e; font: 400 12px var(--ui); }
.base-health { flex: 1; max-width: 500px; }
.base-health b, .battle-stat b { color: var(--paper); }
.meter { border-radius: 0; overflow: hidden; background: #050a0d; border: 1px solid rgba(197,162,100,.18); }
.meter span { background: linear-gradient(90deg, #774137, #b76150); }
.battle-stat b { font: 700 20px var(--display); }
.speed-group { gap: 3px; }
.speed-group button { width: 42px; height: 38px; border: 1px solid var(--line-soft); background: #0b171c; color: #a9a294; }
.speed-group button.active { border-color: var(--brass); background: #26302b; color: var(--paper); }
#boss-bar { position: relative; z-index: 20; margin: 0; height: 34px; border: 0; border-bottom: 1px solid #8e4c40; background: #1a1111; border-radius: 0; }
#boss-bar.hidden { display: none !important; }
.game-layout {
  display: grid; grid-template-columns: minmax(180px, 220px) minmax(520px, 1fr) minmax(255px, 300px);
  gap: 10px; width: 100%; max-width: none; height: calc(100dvh - 68px - 82px - 102px);
  min-height: 480px; padding: 10px clamp(10px, 1.5vw, 24px); margin: 0;
}
.battle-left, .sidebar, .arena {
  position: relative; min-height: 0; border: 1px solid var(--line); border-radius: 1px;
  background: linear-gradient(145deg, rgba(15,27,31,.98), rgba(7,14,18,.98));
  box-shadow: inset 0 0 0 3px rgba(0,0,0,.2), 0 12px 30px rgba(0,0,0,.16);
}
.battle-left { display: flex; flex-direction: column; padding: 20px; overflow: hidden; }
.battle-left::before {
  content: ""; position: absolute; inset: 0; opacity: .14; pointer-events: none;
  background: radial-gradient(circle at 100% 100%, var(--teal), transparent 43%), repeating-linear-gradient(0deg, transparent 0 29px, rgba(197,162,100,.08) 30px);
}
.next-wave-panel { position: relative; padding: 4px 0 18px; border-bottom: 1px solid var(--line); }
.next-wave-panel small { color: var(--brass); font-size: 9px; letter-spacing: .22em; }
.next-wave-panel h2 { margin: 8px 0 20px; color: var(--paper); font: 700 20px var(--display); }
.next-wave-panel p { margin: 0; padding: 13px; border-left: 2px solid var(--teal); background: rgba(47,87,82,.2); color: #c2bbaa; font-size: 11px; line-height: 1.5; }
.battle-left blockquote { position: relative; margin: auto 0; color: #aaa18e; font: italic 16px/1.8 var(--display); }
.battle-left blockquote::before { content: "“"; display: block; color: var(--brass); font-size: 44px; line-height: .6; }
.battle-left-foot { position: relative; display: grid; gap: 6px; padding-top: 15px; border-top: 1px solid var(--line-soft); }
.battle-left-foot span { color: var(--paper); font-weight: 700; }
.battle-left-foot small { color: #77776e; font-size: 9px; }
.arena { overflow: hidden; padding: 29px 7px 28px; background: #0c171a; }
.arena::before { content: ""; position: absolute; inset: 4px; pointer-events: none; border: 1px solid rgba(197,162,100,.12); }
.arena-label { top: 0; left: 0; right: 0; height: 28px; padding: 0 12px; border: 0; border-bottom: 1px solid var(--line-soft); background: #091217; color: var(--brass); font-size: 8px; letter-spacing: .2em; }
.live-dot { background: var(--teal); box-shadow: 0 0 8px rgba(101,170,160,.6); }
#battlefield { width: 100%; height: 100%; touch-action: none; background: #101e1e; }
.arena-bottom { left: 0; right: 0; bottom: 0; height: 28px; padding: 0 12px; border: 0; border-top: 1px solid var(--line-soft); background: #081116; color: #8e8a7f; font-size: 9px; }
.arena-bottom #dps { margin-left: auto; color: var(--brass-bright); }
.next-wave { right: 13px; bottom: 40px; min-height: 40px; padding: 0 16px; border: 1px solid var(--brass) !important; background: #d5bd88 !important; color: #131713 !important; font-weight: 800; }
.sidebar { display: flex; flex-direction: column; overflow: auto; padding: 0; }
.side-section { margin: 0; padding: 17px; border: 0; border-bottom: 1px solid var(--line-soft); background: transparent; border-radius: 0; }
.section-label { color: var(--brass); font-size: 9px; letter-spacing: .15em; }
.section-label .tiny { color: #79766d; }
#mission-card, #track-card, #synergy-list { margin-top: 11px; border: 0; background: transparent; }
#mission-card h3 { color: var(--paper); font: 700 15px var(--display); }
#mission-card p, .empty-copy { color: #8e897d; font-size: 10px; line-height: 1.55; }
.mission-icon { color: var(--danger); }
.textbtn { color: var(--teal); }
.selected-card { margin: auto 12px 12px; min-height: 82px; border: 1px solid var(--line-soft); border-radius: 0; background: rgba(27,45,45,.35); }
.selection-glyph { color: var(--brass); }
.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-thumb { background: #4b4435; }
.game-layout.inspecting { grid-template-columns: minmax(180px, 220px) minmax(520px, 1fr) minmax(255px, 340px); }
.game-layout.inspecting > .sidebar { display: none; }

/* Action dock */
.commandbar {
  height: 102px; padding: 10px clamp(12px, 2vw, 30px); gap: 7px; z-index: 35;
  border: 0; border-top: 1px solid var(--line); background: linear-gradient(180deg, #101c21, #070d11);
  box-shadow: 0 -12px 30px rgba(0,0,0,.22);
}
.commandbar .resources { min-width: 154px; padding: 0 21px 0 8px; border-right: 1px solid var(--line); }
.coin { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--brass); color: var(--brass); background: #18221f; }
.resources strong { color: var(--paper); font: 700 23px var(--display); }
.resources small { color: #847e72; }
.summon-button, .command, .save-button {
  height: 76px; border: 1px solid var(--line) !important; background: linear-gradient(180deg, #17272b, #0b151a) !important;
  color: #d6cebd; box-shadow: inset 0 1px rgba(255,255,255,.03);
}
.summon-button { min-width: 205px; border-color: var(--brass) !important; background: linear-gradient(135deg, #d9c28f, #af9158) !important; color: #151813; }
.summon-symbol { color: #383126; }
.summon-button small { color: #554931; }
.summon-button kbd { border-color: rgba(0,0,0,.2); color: #332e24; }
.command { min-width: 105px; }
.command > span { color: var(--brass); font-size: 17px; }
.command b { font-size: 11px; }
.command small { color: #77766f; font-size: 8px; }
.command:hover, .save-button:hover { border-color: var(--brass) !important; background: #1b2b2e !important; }
.save-button { min-width: 52px; color: #a49c8b; }

/* Drawers and archive windows */
dialog#panel, .army-tray, .quick-upgrades, .unit-inspector {
  border: 1px solid var(--brass); border-radius: 1px; background: linear-gradient(145deg, #142329, #080f13 65%); color: #e1d8c5;
  box-shadow: 0 28px 90px rgba(0,0,0,.66), inset 0 0 0 3px rgba(0,0,0,.22);
}
dialog#panel::backdrop { background: rgba(3,7,9,.78); backdrop-filter: blur(3px); }
.dialog-head, .army-tray header, .quick-upgrades header, .unit-inspector header { border-bottom: 1px solid var(--line); background: rgba(5,11,14,.45); }
.dialog-head small, .unit-inspector header small { color: var(--brass); letter-spacing: .18em; }
.dialog-head h2, .unit-inspector h2 { color: var(--paper); font-family: var(--display); }
.tier-sale-grid button, #quick-upgrade-list button { border: 1px solid var(--line) !important; border-radius: 0; background: #101e23; color: #ddd4c2; }
#toast { border-radius: 0; border: 1px solid var(--brass); background: #101b1f; color: var(--paper); }

@media (max-width: 1350px) {
  .game-layout { grid-template-columns: 180px minmax(500px, 1fr) 260px; }
  .battle-left { padding: 16px; }
  .commandbar .resources { min-width: 120px; }
  .summon-button { min-width: 180px; }
  .command { min-width: 88px; padding-inline: 8px; }
}

@media (max-width: 1080px) {
  .topbar { padding: 0 14px; }
  .top-center { display: none; }
  .game-layout { grid-template-columns: minmax(500px, 1fr) 250px; }
  .game-layout.inspecting { grid-template-columns: minmax(500px, 1fr) 295px; }
  .battle-left { display: none; }
  .arena-bottom::before { content: ""; }
  .command small { display: none; }
  .commandbar { height: 92px; }
  .game-layout { height: calc(100dvh - 68px - 82px - 92px); }
  .summon-button, .command, .save-button { height: 66px; }
}

@media (max-width: 760px) {
  body::before { opacity: .06; }
  .topbar { height: 50px; padding: 0 10px; }
  .brand { min-width: 0; }
  .brandmark { width: 32px; height: 32px; font-size: 8px; }
  .game-brand { font-size: 14px; }
  .game-brand small { font-size: 6px; }
  .topbar nav button:not(.iconbtn) { width: 46px; min-width: 46px; padding: 0; font-size: 0; }
  .topbar nav button:not(.iconbtn) span { margin: 0; font-size: 15px; }
  .topbar nav .iconbtn { min-width: 42px; width: 42px; }
  #menu-screen { display: block; min-height: calc(100dvh - 50px); padding: 0; overflow-y: auto; background-position: 64% center; }
  #menu-screen::before { background: linear-gradient(90deg, rgba(5,10,13,.97), rgba(5,10,13,.78) 65%, rgba(5,10,13,.42)); }
  #menu-screen::after { inset: 10px; }
  .menu-content { width: 100%; min-height: calc(100dvh - 50px); padding: 32px 22px 64px; }
  .menu-content .eyebrow { font-size: 7px; }
  .game-title { font-size: clamp(40px, 14vw, 58px); }
  .menu-chapter { margin: 20px 0 14px; }
  .menu-chapter p { font-size: 10px; }
  .menu-actions button, .lobby-relic { min-height: 48px; }
  .menu-caption { display: none; }
  .menu-bottom { position: absolute; height: 34px; padding: 0 14px; font-size: 7px; }
  .menu-bottom span:last-child { display: none; }

  #game-screen { min-height: calc(100dvh - 50px); }
  .battle-hud { min-height: 58px; height: 58px; padding: 0 8px; }
  .battle-hud > div { min-height: 42px; padding: 0 9px; }
  .battle-hud .wave strong { font-size: 20px; }
  .battle-hud .base-health { min-width: 0; }
  .base-health > div:first-child span { display: none; }
  .base-health b { font-size: 10px; }
  .battle-stat { display: none !important; }
  .speed-group button { width: 32px; height: 32px; font-size: 9px; }
  .speed-group button[data-speed="3"] { display: none; }
  #boss-bar { height: 28px; }
  .game-layout {
    display: grid; grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) 42px;
    height: calc(100dvh - 50px - 58px - 124px); min-height: 360px; padding: 5px; gap: 5px;
  }
  .game-layout.inspecting { display: grid; grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) minmax(180px, 258px); }
  .game-layout.inspecting > .arena { grid-row: 1; }
  .game-layout.inspecting > .unit-inspector { grid-row: 2; height: auto; min-height: 0; border: 1px solid var(--line); }
  .arena { grid-column: 1; grid-row: 1; padding: 23px 3px 24px; }
  .arena-label { height: 22px; }
  .arena-bottom { height: 23px; }
  .arena-bottom .desktop-hint { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; max-width: 72%; }
  .next-wave { bottom: 31px; min-height: 38px; }
  .sidebar {
    grid-column: 1; grid-row: 2; display: block; height: 42px; overflow: hidden;
    border-color: var(--line); transition: height .2s ease;
  }
  .sidebar:focus-within { position: absolute; left: 5px; right: 5px; bottom: 5px; height: min(48vh, 330px); z-index: 30; overflow: auto; }
  .sidebar .side-section { padding: 11px 13px; }
  .sidebar .side-section:not(:first-child), .sidebar .selected-card { display: none; }
  .sidebar:focus-within .side-section, .sidebar:focus-within .selected-card { display: block; }
  #mission-card { display: none; }
  .sidebar:focus-within #mission-card { display: block; }
  .section-label { min-height: 20px; }
  .commandbar {
    height: 124px; padding: 5px; display: grid; grid-template-columns: 74px repeat(5, minmax(48px, 1fr)); grid-template-rows: 54px 54px; gap: 4px;
  }
  .commandbar .resources { grid-row: 1 / 3; min-width: 0; padding: 4px; border: 1px solid var(--line-soft); flex-direction: column; justify-content: center; text-align: center; }
  .coin { width: 24px; height: 24px; }
  .resources strong { font-size: 17px; }
  .summon-button { grid-column: 2 / 5; min-width: 0; height: 54px; padding: 0 10px; }
  .command, .save-button { min-width: 0; width: auto; height: 54px; padding: 4px; }
  .command > span { font-size: 14px; }
  .command b { font-size: 9px; }
  #save { grid-column: 5 / 7; grid-row: 1; }
  #merge { grid-column: 2 / 3; grid-row: 2; }
  .commandbar > button[data-panel="odds"] { grid-column: 3 / 4; grid-row: 2; }
  .commandbar > button[data-panel="upgrades"] { grid-column: 4 / 5; grid-row: 2; }
  .commandbar > button[data-panel="codex"] { grid-column: 5 / 7; grid-row: 2; }
  dialog#panel { width: calc(100vw - 14px); max-height: calc(100dvh - 20px); }
  .army-tray, .quick-upgrades, .unit-inspector { left: 6px; right: 6px; width: auto; max-height: 70dvh; }
}

@media (max-width: 430px) {
  .menu-content { padding-inline: 17px; }
  .menu-chapter p { max-width: 310px; }
  .menu-links button { padding: 0 9px; }
  .battle-hud > div { padding-inline: 6px; }
  .speed-group button { width: 29px; }
  .commandbar { grid-template-columns: 65px repeat(5, minmax(44px, 1fr)); }
}

@media (max-height: 700px) and (min-width: 761px) {
  .menu-content { padding-top: 26px; }
  .game-title { font-size: 50px; }
  .menu-chapter { margin-block: 15px 10px; padding-block: 9px; }
  .menu-actions button { min-height: 43px; }
  .lobby-relic { min-height: 43px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* Indie-game finish: tactile edges, print texture and restrained step motion. */
#menu-screen::after {
  inset: 18px;
  border: 1px solid rgba(226, 196, 134, .26);
  background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(3, 8, 10, .08) 4px);
  box-shadow: inset 0 0 0 4px rgba(4, 10, 13, .28);
}
.topbar { box-shadow: 0 3px 0 #03080b, 0 12px 26px rgba(0,0,0,.28); }
.brandmark { box-shadow: 3px 3px 0 #020609, inset 0 0 0 3px #081014, inset 0 0 0 4px rgba(197,162,100,.22); }
.menu-chapter {
  background-color: rgba(9,19,22,.82);
  background-image: repeating-linear-gradient(0deg, transparent 0 25px, rgba(197,162,100,.055) 26px);
}
.menu-chapter p { font-size: 13px; }
.difficulty-choice label, .menu-links button { font-size: 12px; }
.menu-actions button, .lobby-relic { box-shadow: 3px 3px 0 rgba(2,6,8,.9), inset 0 1px rgba(255,255,255,.03); }
.menu-actions button:hover, .lobby-relic:hover { transform: translate(2px, 1px); box-shadow: 1px 2px 0 #020608; }
.menu-actions button:active, .lobby-relic:active { transform: translate(3px, 3px); box-shadow: none; }
.menu-actions .primary { box-shadow: 4px 4px 0 #594929, 7px 7px 0 rgba(2,6,8,.72); }
.menu-actions .primary:hover { box-shadow: 2px 3px 0 #594929, 4px 5px 0 rgba(2,6,8,.72); }
.menu-content .eyebrow::before { content: "▰"; margin-right: 9px; color: #6aa69a; }

.battle-hud, .commandbar { background-image: repeating-linear-gradient(90deg, transparent 0 63px, rgba(197,162,100,.025) 64px), linear-gradient(180deg, #101d22, #081216); }
.battle-left, .sidebar, .arena { border-width: 2px; box-shadow: 4px 4px 0 #03080a, inset 0 0 0 3px rgba(0,0,0,.2); }
.arena { border-color: rgba(197,162,100,.5); }
.side-section { position: relative; }
.side-section::before { content: ""; position: absolute; left: 0; top: 17px; width: 3px; height: 19px; background: #6e9c91; }
.section-label { font-size: 12px; }
#mission-card p, .empty-copy { font-size: 12px; }
.commandbar button { position: relative; }
.commandbar button::after { content: ""; position: absolute; left: 6px; right: 6px; top: 5px; height: 1px; background: rgba(225,196,134,.18); }
.summon-button { box-shadow: 3px 3px 0 #5c492a, 5px 5px 0 #020608 !important; }
.summon-button:active { transform: translate(3px,3px); box-shadow: none !important; }
.next-wave { box-shadow: 3px 3px 0 #5c492a, 6px 6px 0 rgba(0,0,0,.55); }
.battle-stat.boss-timer {
  min-width: 108px; border: 1px solid #9f594d; background: #2a1716;
  box-shadow: inset 3px 0 0 #c36a59;
}
.battle-stat.boss-timer small { color: #e5a18f; }
.battle-stat.boss-timer b { color: #ffd0b8; font-variant-numeric: tabular-nums; }
.battle-stat.boss-timer.urgent { animation: bossUrgent .7s steps(2, end) infinite; }
@keyframes bossUrgent { 50% { background: #56231f; border-color: #e0836d; } }
.wave-banner { border-block: 1px solid rgba(197,162,100,.35); text-transform: uppercase; }
#toast { box-shadow: 3px 3px 0 #020608; }

@media (max-width: 760px) {
  #menu-screen::after { inset: 8px; }
  .menu-chapter p { font-size: 12px; }
  .battle-stat.boss-timer { display: flex !important; min-width: 70px; padding-inline: 7px; }
  .battle-stat.boss-timer small { font-size: 8px; }
  .battle-stat.boss-timer b { font-size: 16px; }
  .battle-left, .sidebar, .arena { box-shadow: 2px 2px 0 #03080a, inset 0 0 0 2px rgba(0,0,0,.2); }
}

/* Bottom dock: one primary action, flat utilities, no decorative diamonds. */
.commandbar {
  height: 92px;
  gap: 0;
  padding-block: 9px;
  background: linear-gradient(180deg, #111e22, #080f13);
}
.game-layout { height: calc(100dvh - 68px - 82px - 92px); }
.commandbar .resources {
  min-width: 148px;
  height: 64px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
}
.coin {
  width: 25px;
  height: 25px;
  border: 0;
  border-radius: 50% !important;
  background: #c8a35c;
  color: #352a18;
  font: 900 12px/25px ui-monospace, monospace;
  text-align: center;
  box-shadow: 0 3px 0 #6f572f, 0 5px 0 #020608;
}
.resources strong { font-size: 25px; }
.resources small { font-size: 11px; letter-spacing: .08em; }
.summon-button {
  height: 66px;
  margin: 0 10px;
  border: 1px solid #e2c77f !important;
  box-shadow: 3px 3px 0 #5c492a, 5px 5px 0 #020608 !important;
}
.summon-symbol {
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  border: 2px solid #3f3522;
  color: #332b1d;
  font: 900 25px/1 ui-monospace, monospace;
}
.commandbar .command,
.commandbar .save-button {
  height: 64px;
  min-width: 108px;
  border: 0 !important;
  border-left: 1px solid var(--line-soft) !important;
  background: transparent !important;
  box-shadow: none;
}
.commandbar .command::after,
.commandbar .save-button::after { display: none; }
.commandbar .command > span {
  color: #c8ad73;
  font: 800 20px/1 ui-monospace, "SFMono-Regular", monospace;
  text-shadow: 2px 2px 0 #020608;
}
.commandbar .command b { color: #e0d9cb; font-size: 12px; }
.commandbar .command small { color: #7f8079; font-size: 9px; }
.commandbar .command:hover,
.commandbar .save-button:hover {
  border-color: var(--line) !important;
  background: linear-gradient(180deg, rgba(87,126,116,.13), rgba(87,126,116,.03)) !important;
  transform: none;
}
.commandbar .command:active,
.commandbar .save-button:active { background: rgba(197,162,100,.12) !important; transform: translateY(1px); }
.selection-glyph { color: #6f8f86; font-family: ui-monospace, monospace; letter-spacing: 0; }

@media (max-width: 1080px) and (min-width: 761px) {
  .game-layout { height: calc(100dvh - 68px - 82px - 84px); }
  .commandbar { height: 84px; }
  .commandbar .resources { min-width: 112px; }
  .summon-button { min-width: 170px; margin-inline: 6px; }
  .commandbar .command { min-width: 82px; }
}

@media (max-width: 760px) {
  .commandbar { height: 116px; padding: 5px; gap: 3px; grid-template-rows: 50px 50px; }
  .game-layout { height: calc(100dvh - 50px - 58px - 116px); }
  .commandbar .resources { min-width: 0; height: auto; align-self: stretch; border: 1px solid var(--line-soft); border-right: 1px solid var(--line-soft); }
  .coin { width: 22px; height: 22px; line-height: 22px; }
  .summon-button { height: 50px; margin: 0; }
  .summon-symbol { width: 24px; height: 24px; font-size: 20px; }
  .commandbar .command, .commandbar .save-button { height: 50px; min-width: 0; }
  .commandbar .command > span { font-size: 17px; }
}

/* Mobile command deck: explicit placement prevents legacy dock rules from colliding. */
@media (max-width: 760px) {
  #game-screen {
    height: calc(100dvh - 50px);
    min-height: 0;
    --mobile-command-height: calc(116px + env(safe-area-inset-bottom));
  }

  .battle-hud {
    flex: 0 0 58px;
    min-height: 58px;
    gap: 0;
    overflow: hidden;
  }
  .battle-hud .wave {
    flex: 0 0 82px;
    min-width: 82px;
  }
  .battle-hud .wave > small {
    max-width: none;
    white-space: nowrap;
    font-size: 8px;
    letter-spacing: .08em;
  }
  .battle-hud .base-health {
    flex: 1 1 auto;
    width: auto;
    max-width: none;
    height: 42px;
    min-height: 42px;
    padding-block: 0;
    padding-right: 4px;
    display: grid;
    grid-template-rows: auto 5px;
    align-content: center;
    gap: 5px;
  }
  .battle-hud .base-health > div:first-child {
    margin-bottom: 0;
    line-height: 1;
  }
  .battle-hud .base-health .meter {
    width: 100%;
    height: 5px;
    margin: 0;
  }
  .battle-hud .speed-group {
    flex: 0 0 auto;
    height: 42px;
    min-height: 42px;
    align-items: center;
    justify-content: flex-end;
    gap: 2px;
    margin-left: 0;
    padding-block: 0;
    padding-left: 2px;
    padding-right: 0;
    border-left: 0;
  }
  .battle-hud .speed-group button {
    width: 27px;
    height: 32px;
    padding: 0;
    display: inline-grid;
    place-items: center;
    font-size: 10px;
    font-weight: 500;
    line-height: 1;
    text-align: center;
  }
  .battle-hud .speed-group button[data-speed="3"] { display: inline-grid; }

  .game-layout,
  .game-layout.inspecting {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
  }

  .commandbar {
    position: relative;
    inset: auto;
    flex: 0 0 var(--mobile-command-height);
    width: 100%;
    height: var(--mobile-command-height);
    min-height: var(--mobile-command-height);
    padding: 6px max(6px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-template-rows: 50px 50px;
    grid-auto-flow: row;
    align-items: stretch;
    gap: 4px;
    overflow: hidden;
  }
  .commandbar > * {
    position: relative !important;
    inset: auto !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 50px !important;
    min-height: 50px !important;
    margin: 0 !important;
    transform: none !important;
  }
  .commandbar .resources {
    grid-column: 1 / 4 !important;
    grid-row: 1 !important;
    display: flex !important;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 6px;
    text-align: left;
    border: 1px solid var(--line-soft);
    background: #0a1418;
  }
  .commandbar .resources .coin {
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    line-height: 20px;
    font-size: 9px;
  }
  .commandbar .resources strong {
    display: block;
    overflow: hidden;
    max-width: 54px;
    font-size: 19px;
    line-height: 1;
    text-overflow: ellipsis;
  }
  .commandbar .resources small { display: none; }

  .commandbar #summon {
    grid-column: 4 / 11 !important;
    grid-row: 1 !important;
    display: flex;
    justify-content: center;
    gap: 0;
    padding: 0 8px;
  }
  .commandbar #summon .summon-symbol,
  .commandbar #summon kbd { display: none; }
  .commandbar #summon b {
    font-size: 14px;
    white-space: nowrap;
  }
  .commandbar #summon b::after { content: none; }
  .commandbar #summon small {
    display: block;
    margin-top: 2px;
    font-size: 10px;
  }

  .commandbar #save {
    grid-column: 11 / 13 !important;
    grid-row: 1 !important;
    display: grid !important;
    place-items: center;
    padding: 0;
    border: 1px solid var(--line-soft) !important;
    font-size: 11px;
  }
  .commandbar #merge {
    grid-column: 1 / 4 !important;
    grid-row: 2 !important;
  }
  .commandbar > button[data-panel="odds"] {
    grid-column: 4 / 7 !important;
    grid-row: 2 !important;
  }
  .commandbar > button[data-panel="upgrades"] {
    grid-column: 7 / 10 !important;
    grid-row: 2 !important;
  }
  .commandbar > button[data-panel="codex"] {
    grid-column: 10 / 13 !important;
    grid-row: 2 !important;
  }
  .commandbar .command {
    display: grid;
    place-items: center;
    padding: 0 3px;
    border: 1px solid var(--line-soft) !important;
    background: #0d191d !important;
  }
  .commandbar .command > span,
  .commandbar .command small { display: none; }
  .commandbar .command b {
    font-size: 12px;
    line-height: 1.2;
    white-space: nowrap;
  }

  .army-tray,
  .quick-upgrades,
  .unit-inspector {
    bottom: calc(var(--mobile-command-height) + 6px);
  }
  #toast { bottom: calc(var(--mobile-command-height) + 8px); }
}

@media (max-width: 360px) {
  .battle-hud .wave { flex-basis: 72px; min-width: 72px; }
  .battle-hud > div { padding-inline: 4px; }
  .commandbar .resources strong { font-size: 17px; max-width: 45px; }
  .commandbar #summon b { font-size: 13px; }
  .commandbar .command b { font-size: 11px; }
}

/* Keep the original summon footprint while splitting it into equal actions. */
.commandbar .summon-group {
  display: flex;
  align-items: stretch;
  gap: 4px;
  min-width: 205px;
  height: 66px;
  margin: 0 10px;
}
.commandbar .summon-group .summon-button {
  flex: 1 1 0;
  min-width: 0;
  width: auto;
  height: 66px;
  margin: 0;
  padding: 0 8px;
  justify-content: center;
  text-align: center;
}
.commandbar .summon-group .summon-button b { font-size: 13px; white-space: nowrap; }
.commandbar .summon-group .summon-button small { font-size: 9px; white-space: nowrap; }

@media (max-width: 1350px) and (min-width: 761px) {
  .commandbar .summon-group { min-width: 180px; margin-inline: 6px; }
}

@media (max-width: 760px) {
  .commandbar .summon-group {
    grid-column: 4 / 11 !important;
    grid-row: 1 !important;
    width: auto !important;
    min-width: 0 !important;
    height: 50px !important;
    min-height: 50px !important;
    margin: 0 !important;
    gap: 3px;
  }
  .commandbar .summon-group .summon-button {
    width: auto !important;
    min-width: 0 !important;
    height: 50px !important;
    min-height: 50px !important;
    padding: 0 3px;
  }
  .commandbar .summon-group .summon-button b { font-size: 12px; }
  .commandbar .summon-group .summon-button small { font-size: 8px; }
}

@media (max-width: 360px) {
  .commandbar .summon-group .summon-button b { font-size: 11px; }
  .commandbar .summon-group .summon-button small { font-size: 7px; }
}
