@import './settings.css?v=225';
/* Dark Academia interface layer — visual-only overrides, game state remains untouched. */
@font-face {
  font-family: "Galmuri11";
  src: url("./Galmuri11.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

/* 두뇌 풀가동 모드 */
.brain-access { max-width: 420px; margin: 10px auto; display: grid; gap: 13px; text-align: center; }
.brain-access .brain-lock { width: 64px; height: 64px; margin: 0 auto 4px; display: grid; place-items: center; border: 1px solid #62bbaa; border-radius: 50%; color: #9ff5e3; background: rgba(35,114,103,.15) url("./assets/ui/icons/brain-mode-pixel-v2.png") center/52px 52px no-repeat; font-size: 30px; box-shadow: 0 0 28px rgba(80,218,190,.13); image-rendering: pixelated; }
.brain-access p { margin: 0 0 5px; color: #c9d7d3; line-height: 1.65; }
.brain-access label { color: #93aaa6; font-size: 11px; letter-spacing: .12em; text-align: left; }
.brain-access input { text-align: center; letter-spacing: .15em; text-transform: uppercase; }
.brain-access button { min-height: 46px; margin-top: 3px; }
.brain-quiz { width: min(720px,100%); margin: 0 auto; }
.brain-quiz-status { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; color: #9bb2ae; font-size: 11px; }
.brain-quiz-status b { color: #ff9caf; }
.brain-timer { position: relative; height: 28px; margin-bottom: 20px; overflow: hidden; border: 1px solid #3f615d; background: #091216; }
.brain-timer span { position: absolute; inset: 0; transform-origin: left; background: linear-gradient(90deg,#2fbaa0,#8be4d1); transition: transform .1s linear; }
.brain-timer b { position: relative; z-index: 1; display: block; color: #06110f; font: 900 14px/26px var(--display); text-align: center; font-variant-numeric: tabular-nums; }
.brain-quiz h3 { margin: 0 0 20px; color: #f2ead9; font: 800 clamp(17px,2.4vw,23px)/1.55 var(--display); word-break: keep-all; }
.brain-answers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.brain-answers button { min-height: 66px; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-color: #40555a; background: linear-gradient(145deg,#17252c,#101a20); text-align: left; }
.brain-answers button:hover { border-color: #79cfc0; background: #1a3436; }
.brain-answers button em { flex: 0 0 30px; width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid #5a7775; border-radius: 50%; color: #b8e4da; font: 800 13px var(--display); font-style: normal; }
.brain-answers button span { color: #e2e8e4; line-height: 1.45; word-break: keep-all; }
.brain-answers button.correct { border-color: #61d2ad; background: rgba(37,116,91,.36); }
.brain-answers button.wrong { border-color: #e36683; background: rgba(115,34,52,.38); }
.brain-feedback { min-height: 0; margin-top: 15px; padding: 0; opacity: 0; transform: translateY(5px); transition: .18s ease; text-align: center; }
.brain-feedback.show { min-height: 58px; padding: 12px; opacity: 1; transform: none; border: 1px solid #4b5e5e; background: rgba(8,16,20,.65); }
.brain-feedback b,.brain-feedback span,.brain-feedback strong { display: block; }
.brain-feedback.good b { color: #7de5be; }.brain-feedback.bad b,.brain-feedback strong { color: #ff8ca5; }
.brain-feedback span { margin-top: 5px; color: #c6cfcb; }.brain-feedback strong { margin-top: 7px; }
.brain-feedback small { display: block; margin-top: 7px; color: #8fa6a1; line-height: 1.45; }
.brain-slot { width: min(620px,100%); margin: 0 auto; text-align: center; }
.brain-slot>p { color: #abb9b5; }
.brain-slot-machine { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin: 20px auto; padding: 16px; border: 2px solid #8b744b; background: linear-gradient(180deg,#2c251b,#0b1114 28%,#111a1d 74%,#2c251b); box-shadow: inset 0 0 0 4px #0b1013,0 12px 35px #0007; }
.brain-reel { height: 92px; display: grid; place-items: center; overflow: hidden; border: 2px solid #514733; background: radial-gradient(circle,#eef5e8,#a9b9ad 70%,#77877d); color: #16221f; box-shadow: inset 0 4px 14px #fff8,inset 0 -5px 14px #31453d66; }
.brain-reel span { font: 900 clamp(18px,4vw,34px)/1 var(--display); }
.brain-slot.bad .brain-slot-machine { border-color: #7d4051; }.brain-slot.bad .brain-reel { background: radial-gradient(circle,#f0d8dd,#b28691 70%,#70404c); color: #35111b; }
.brain-reel.stopped { animation: brain-reel-stop .24s ease-out; }
@keyframes brain-reel-stop { 0% { transform: translateY(-8px); } 55% { transform: translateY(4px); } 100% { transform: none; } }
.brain-slot-result { margin: 14px 0; padding: 17px; border: 1px solid #4c7c6c; background: rgba(26,66,55,.35); }
.brain-slot.bad .brain-slot-result { border-color: #774253; background: rgba(80,27,42,.34); }
.brain-slot-result small { color: #83d8bd; letter-spacing: .15em; }.brain-slot.bad .brain-slot-result small { color: #ed829b; }
.brain-slot-result h3 { margin: 8px 0; color: #f2ead9; font: 800 22px var(--display); }.brain-slot-result p { margin: 0; color: #c5cfca; line-height: 1.55; }
.brain-slot>button { min-width: 230px; min-height: 46px; }
@media (max-width:640px) {
  .brain-answers { grid-template-columns: 1fr; }
  .brain-answers button { min-height: 56px; }
  .brain-quiz h3 { font-size: 17px; }
  .brain-slot-machine { gap: 6px; padding: 10px; }
  .brain-reel { height: 70px; }
}

/* 운명의 균열 룰렛 */
.event-roulette-lead { margin: 0 0 15px; color: #c7c0b3; font-size: 13px; line-height: 1.7; text-align: center; }
.event-roulette-lead b { color: #ffe09a; }
.fate-spin-progress { display: flex; align-items: center; justify-content: center; margin: -3px 0 8px; }
.fate-spin-progress span { display: grid; place-items: center; width: 23px; height: 23px; border: 1px solid #645b49; border-radius: 50%; color: #777166; font: 800 9px var(--ui); background: #111b1e; transition: .25s; }
.fate-spin-progress b { width: 34px; height: 1px; background: #4b463a; }
.fate-spin-progress span.active { color: #17130b; border-color: #ffe29c; background: #ffe29c; box-shadow: 0 0 16px #e8b955aa; transform: scale(1.13); }
.fate-spin-progress span.done.good { color: #a5f3d0; border-color: #63bd98; background: #173b30; }
.fate-spin-progress span.done.bad { color: #ff9bb3; border-color: #d85c7a; background: #411a27; }
.fate-wheel-stage { position: relative; display: grid; place-items: center; width: 300px; height: 300px; margin: 0 auto 7px; filter: drop-shadow(0 16px 28px #000b); isolation: isolate; }
.fate-wheel-aura { position: absolute; z-index: -1; inset: 18px; border: 1px solid #826d42; border-radius: 50%; background: radial-gradient(circle,rgba(230,188,91,.12),transparent 65%); opacity: .6; }
.fate-wheel-lights { position: absolute; z-index: 3; inset: 0; pointer-events: none; }
.fate-wheel-lights i { --angle: calc(var(--i) * 15deg); position: absolute; top: 50%; left: 50%; width: 7px; height: 7px; margin: -3.5px; border-radius: 50%; background: #6d6042; box-shadow: 0 0 0 1px #211b11; transform: rotate(var(--angle)) translateY(-140px); transition: background .12s,box-shadow .12s; }
.fate-wheel-pointer { position: absolute; z-index: 5; top: 5px; left: 50%; width: 0; height: 0; border-right: 14px solid transparent; border-left: 14px solid transparent; border-top: 34px solid #ffe29c; transform: translateX(-50%); transform-origin: 50% 2px; filter: drop-shadow(0 2px 2px #000); }
.fate-wheel-pointer.tick { animation: fate-pointer-tick .085s ease-out; }
@keyframes fate-pointer-tick { 45% { transform: translateX(-50%) rotate(13deg); } }
.fate-wheel { position: relative; width: 250px; height: 250px; overflow: hidden; border: 8px solid #c6a765; border-radius: 50%; background: radial-gradient(circle at center,transparent 0 43%,#0004 44% 46%,transparent 47%),repeating-conic-gradient(from -15deg,#2b7b67 0 30deg,#96334f 30deg 60deg); box-shadow: inset 0 0 0 4px #19130d,inset 0 0 38px #000c,0 0 0 3px #6d5730,0 0 0 7px #17140e; will-change: transform; }
.fate-wheel::before { content: ""; position: absolute; inset: 0; border-radius: 50%; background: repeating-conic-gradient(from -1deg,transparent 0 28deg,#f0dda5 28deg 30deg); opacity: .72; }
.fate-wheel::after { content: ""; position: absolute; inset: 10px; border: 1px solid #f1d58c66; border-radius: 50%; box-shadow: inset 0 0 18px #0009; }
.fate-wheel > span { --angle: calc(var(--i) * 30deg); position: absolute; z-index: 1; top: 50%; left: 50%; width: 44px; margin-left: -22px; color: #fff5dc; font: 800 9px var(--ui); text-align: center; text-shadow: 0 2px 4px #000; transform: rotate(var(--angle)) translateY(-92px) rotate(calc(var(--angle) * -1)); }
.fate-wheel-core { position: absolute; z-index: 2; top: 50%; left: 50%; display: grid; place-content: center; width: 92px; height: 92px; border: 4px solid #d3b875; border-radius: 50%; color: #f5e9ce; text-align: center; background: radial-gradient(circle at 38% 30%,#51452e,#16130e 72%); box-shadow: 0 5px 20px #000e,inset 0 0 0 2px #786339,inset 0 0 18px #0008; transform: translate(-50%,-50%); }
.fate-wheel-core small { color: #bba874; font-size: 8px; letter-spacing: .2em; }
.fate-wheel-core strong { margin-top: 3px; font: 800 16px var(--display); }
.fate-result-burst { position: absolute; z-index: 4; inset: 34px; border-radius: 50%; opacity: 0; pointer-events: none; }
.fate-wheel-stage.spinning .fate-wheel-aura { animation: fate-aura-spin .7s ease-in-out infinite alternate; }
.fate-wheel-stage.spinning .fate-wheel-lights i:nth-child(3n+1) { background: #ffe19a; box-shadow: 0 0 10px #ffc94f; }
.fate-wheel-stage.spinning .fate-wheel-lights i:nth-child(3n+2) { animation: fate-light-chase .34s linear infinite alternate; }
.fate-wheel-stage.landed.good .fate-result-burst { animation: fate-good-burst .7s ease-out; background: radial-gradient(circle,#c9ffe788,rgba(78,255,185,.18) 45%,transparent 70%); }
.fate-wheel-stage.landed.bad { animation: fate-bad-shake .32s ease-out; }
.fate-wheel-stage.landed.bad .fate-result-burst { animation: fate-bad-burst .72s ease-out; background: radial-gradient(circle,#ff688c99,rgba(255,44,92,.18) 48%,transparent 72%); }
@keyframes fate-aura-spin { to { opacity: 1; box-shadow: 0 0 34px #dcae4f55,inset 0 0 25px #dcae4f33; transform: scale(1.035); } }
@keyframes fate-light-chase { to { background: #fff4c9; box-shadow: 0 0 12px #ffe08c; } }
@keyframes fate-good-burst { 0% { opacity: 0; transform: scale(.35); } 32% { opacity: 1; } 100% { opacity: 0; transform: scale(1.65); } }
@keyframes fate-bad-burst { 0% { opacity: 0; transform: scale(.4); } 22% { opacity: 1; } 100% { opacity: 0; transform: scale(1.55); } }
@keyframes fate-bad-shake { 20% { transform: translateX(-7px); } 45% { transform: translateX(6px); } 70% { transform: translateX(-3px); } }
.fate-current-result { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 37px; margin: 0 auto 14px; color: #c8c1b4; font-size: 12px; text-align: center; }
.fate-current-result small { padding: 3px 6px; border: 1px solid currentColor; font-size: 8px; letter-spacing: .1em; }
.fate-current-result strong { color: #f4ead7; font: 800 16px var(--display); }
.fate-current-result.good { color: #75d2ad; }
.fate-current-result.bad { color: #f07b98; }
.fate-current-result.rolling strong { animation: fate-status-flicker .48s ease-in-out infinite alternate; }
.fate-current-result.complete { animation: fate-result-pulse .45s ease-out; }
@keyframes fate-status-flicker { to { opacity: .55; letter-spacing: .035em; } }
@keyframes fate-result-pulse { 50% { transform: scale(1.045); filter: brightness(1.35); } }
.event-result-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; }
.event-result-card { min-height: 136px; padding: 16px 15px; border: 1px solid #475356; border-top: 3px solid #7f8d8d; background: linear-gradient(155deg,#17252b,#0b151a); transition: opacity .24s,transform .24s,filter .24s; }
.event-result-card.pending { opacity: .18; filter: grayscale(1) blur(2px); transform: translateY(7px) scale(.97); }
.event-result-card.revealed { animation: fate-card-reveal .34s ease-out; }
@keyframes fate-card-reveal { 0% { opacity: .15; transform: translateY(10px) scale(.94); } 70% { transform: translateY(-3px) scale(1.02); } }
.event-result-card.good { border-color: #4e806f; border-top-color: #78d1ac; background: linear-gradient(155deg,#18362e,#0b1918); }
.event-result-card.bad { border-color: #754353; border-top-color: #e66b89; background: linear-gradient(155deg,#381b27,#180d14); }
.event-result-card small { color: #aeb9b5; font-size: 9px; letter-spacing: .13em; }
.event-result-card.good small { color: #8ed6b9; }
.event-result-card.bad small { color: #f08aa2; }
.event-result-card h3 { margin: 15px 0 8px; color: #f1e7d4; font: 800 18px/1.3 var(--display); word-break: keep-all; }
.event-result-card p { margin: 0; color: #bbb8af; font-size: 12px; line-height: 1.7; word-break: keep-all; }
.event-roulette-actions { position: sticky; z-index: 12; bottom: 0; display: flex; justify-content: center; margin-top: 22px; padding: 12px 0 4px; background: linear-gradient(180deg,transparent,#111f28 32%); }
.event-roulette-actions button { position: relative; z-index: 13; min-width: 260px; padding: 14px 20px; pointer-events: auto; touch-action: manipulation; }

@media (max-width: 760px) {
  .event-roulette-lead { margin-bottom: 8px; }
  .fate-spin-progress { margin-bottom: 4px; }
  .fate-wheel-stage { width: 230px; height: 230px; }
  .fate-wheel { width: 194px; height: 194px; border-width: 6px; }
  .fate-wheel-lights i { width: 6px; height: 6px; transform: rotate(var(--angle)) translateY(-107px); }
  .fate-wheel-pointer { top: -1px; border-right-width: 12px; border-left-width: 12px; border-top-width: 29px; }
  .fate-wheel > span { width: 38px; margin-left: -19px; transform: rotate(var(--angle)) translateY(-70px) rotate(calc(var(--angle) * -1)); font-size: 7.5px; }
  .fate-wheel-core { width: 72px; height: 72px; border-width: 3px; }
  .fate-wheel-core strong { font-size: 13px; }
  .event-result-grid { grid-template-columns: 1fr; gap: 9px; }
  .event-result-card { min-height: 0; padding: 16px; }
  .event-result-card h3 { margin: 12px 0 7px; font-size: 17px; }
  dialog#panel[open]:has(.event-result-grid) { height: calc(100dvh - 20px); overflow: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .fate-wheel,.event-result-card,.fate-current-result { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
/* 불멸 등급: 선명한 빨강과 낮은 강도의 보랏빛 후광으로 기존 카드 체계를 유지한다. */
.hero-card.immortal,
.inspector-hero.immortal,
.unit-detail.immortal .unit-art {
  border-color: #ff0000;
  box-shadow: 0 0 0 1px rgba(255, 0, 0, .24), 0 0 22px rgba(154, 72, 255, .18);
}
@media (max-width: 760px) {
  .unit-detail.immortal .unit-info,
  .inspector-hero.immortal + .live-stats { min-width: 0; }
  .craft-tabs { overflow-x: auto; overscroll-behavior-x: contain; }
}

.settings-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}
.settings-actions button {
  display: grid;
  place-items: center;
  width: 100%;
  min-width: 0;
  height: 58px;
  padding: 6px 4px;
  font-size: 14px;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  word-break: keep-all;
}

@media (max-width: 760px) {
  .settings-actions { gap: 6px; }
  .settings-actions button {
    height: 54px;
    font-size: 13px;
  }
}

/* Infinite-mode online leaderboard */
.ranking-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 14px;
}
.ranking-tabs button {
  min-width: 0;
  padding: 10px 8px;
  font-weight: 700;
  white-space: nowrap;
}
.ranking-tabs button.active {
  color: var(--gold);
  border-color: #ad915a;
  background: #b9964f1a;
}
.ranking-list {
  min-height: 260px;
  max-height: min(60dvh, 620px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  background: #0812199c;
}
.ranking-head,
.ranking-row {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) 120px;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 0 16px;
}
.ranking-head {
  position: sticky;
  top: 0;
  z-index: 1;
  min-height: 38px;
  color: #81959d;
  background: #12212a;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
}
.ranking-head span:last-child,
.ranking-row strong { text-align: right; }
.ranking-row {
  border-bottom: 1px solid #29383d;
  font-size: 13px;
}
.ranking-row:last-child { border-bottom: 0; }
.ranking-row b { color: #b9c7c7; }
.ranking-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ranking-row strong {
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.ranking-row.mine { background: #86b8ab12; }
.ranking-state {
  display: grid;
  min-height: 260px;
  margin: 0;
  place-items: center;
  color: #91a3aa;
  font-size: 13px;
}
.nickname-prompt {
  width: min(100%, 480px);
  margin: 0 auto;
}
.nickname-run {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: #0b171f;
}
.nickname-run span { color: #9babb0; }
.nickname-run strong { color: var(--gold); }
.nickname-prompt > label {
  display: block;
  margin-bottom: 8px;
  color: #aebbbd;
  font-size: 12px;
}
.nickname-error {
  min-height: 20px;
  margin: -8px 0 0;
  color: #e39aa2;
  font-size: 11px;
}

@media (max-width: 760px) {
  .ranking-list { max-height: calc(88dvh - 178px); }
  .ranking-head,
  .ranking-row {
    grid-template-columns: 54px minmax(0, 1fr) 84px;
    gap: 7px;
    padding: 0 10px;
  }
  .ranking-row { font-size: 12px; }
  .nickname-prompt .modal-buttons { display: grid; grid-template-columns: 1fr 1fr; }
  .nickname-prompt .modal-buttons button { width: 100%; }
}
@font-face {
  font-family: "Galmuri11";
  src: url("./Galmuri11-Bold.woff2") format("woff2");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}
: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: "Galmuri11", "Noto Sans KR", monospace;
  --ui: "Galmuri11", "Noto Sans KR", monospace;
}

* { box-sizing: border-box; }
html, body { background: var(--ink); color: #e9e1cf; font-family: var(--ui); font-synthesis: none; }
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: #0b1418 url("./atom-icon.svg") center / 26px 26px no-repeat;
  box-shadow: inset 0 0 0 3px #081014, inset 0 0 0 4px rgba(197,162,100,.22);
}
.game-brand { white-space: nowrap; font: 700 16px/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("./assets/ui/pc-main-background-v2.png") center center / 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, #craft-summon-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); }
.craft-summon-section { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.craft-summon-section .section-label { flex: 0 0 auto; margin-bottom: 0; font-size: 10px; letter-spacing: .04em; white-space: nowrap; }
.craft-summon-list { flex: 1 1 auto; min-height: 74px; overflow-y: auto; overscroll-behavior: contain; padding-right: 3px; }
.craft-summon-list .empty-copy { margin: 0; padding: 8px 0; }
.craft-summon-item { width: 100%; min-height: 34px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 9px; border: 0; border-left: 2px solid var(--tier); border-bottom: 1px solid var(--line-soft); border-radius: 0; background: rgba(20, 34, 38, .72); color: var(--paper); text-align: left; }
.craft-summon-item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.craft-summon-item small { flex: 0 0 auto; color: var(--tier); font-size: 10px; }
.craft-summon-item:hover { background: rgba(67, 99, 93, .35); color: #fff4d5; }
.craft-summon-item:disabled { opacity: .5; cursor: default; }
.craft-summon-list::-webkit-scrollbar { width: 4px; }
.craft-summon-list::-webkit-scrollbar-thumb { background: #4b4435; }
.sidebar-collapsed-prompt, .sidebar-expanded-handle { display: none; }
.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); }
@media (min-width: 751px) {
  .sidebar > #selected-card { display: none !important; }
}
.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, 300px); }
.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; }
.army-tray header > b { min-width: 0; white-space: nowrap; }
.sale-head-actions { display: flex; align-items: center; gap: 5px; }
.army-tray header .sale-mode-switch { display: grid; grid-template-columns: repeat(2, 58px); gap: 2px; }
.army-tray header .sale-mode-switch button {
  width: 58px; height: 28px; min-height: 0; padding: 0 4px;
  border: 1px solid var(--line-soft); background: #0d1a1f; color: #928a79;
  font-size: 10px; font-weight: 700; line-height: 1; white-space: nowrap;
}
.army-tray header .sale-mode-switch button.active { border-color: var(--brass); background: #25352f; color: var(--paper); }
.tier-sale-grid button.auto-selected { border-color: var(--brass-bright) !important; background: #31443b; box-shadow: inset 0 0 0 1px rgba(225,196,134,.24); }
#toast { border-radius: 0; border: 1px solid var(--brass); background: #101b1f; color: var(--paper); }

@media (max-width: 420px) {
  .army-tray header small { display: none; }
  .army-tray header .sale-mode-switch { grid-template-columns: repeat(2, 52px); }
  .army-tray header .sale-mode-switch button { width: 52px; padding-inline: 2px; font-size: 9px; }
}

@media (max-width: 1350px) {
  .game-layout { grid-template-columns: 180px minmax(500px, 1fr) 260px; }
  .game-layout.inspecting { 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) 250px; }
  .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: 10px; }
  .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="5"] { 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;
  }
  /* The mobile inspector floats over the field; selecting a unit must not
     change either grid track or trigger a battlefield canvas resize. */
  .game-layout.inspecting { display: grid; grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) 42px; }
  .game-layout.inspecting > .arena { grid-row: 1; }
  .game-layout.inspecting > .unit-inspector { position: absolute; grid-row: 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-collapsed-prompt {
    box-sizing: border-box; width: 100%; height: 100%; padding: 0 13px;
    display: flex; align-items: center; justify-content: flex-start; gap: 8px;
    color: var(--paper); font-size: clamp(11px, 3.2vw, 12px); line-height: 1;
    letter-spacing: 0; white-space: nowrap; overflow: hidden;
  }
  .sidebar-collapsed-accent { flex: 0 0 3px; width: 3px; height: 18px; background: #6e9c91; }
  .sidebar.mobile-expanded {
    position: fixed; left: 5px; right: 5px; top: 113px;
    bottom: calc(var(--mobile-command-height, 116px) + 5px);
    width: auto; min-width: 0; max-width: none; height: auto;
    z-index: 30; display: grid !important; grid-template-rows: max-content minmax(0, 1fr) 42px; align-items: stretch;
    overflow: hidden;
  }
  .sidebar:not(.mobile-expanded) .side-section { display: none; }
  .sidebar.mobile-expanded .sidebar-collapsed-prompt { display: none; }
  .sidebar-expanded-handle {
    box-sizing: border-box; width: 100%; height: 42px; min-height: 42px; padding: 0 13px;
    align-items: center; justify-content: flex-start; gap: 8px;
    border: 0; border-top: 1px solid var(--line-soft); border-radius: 0;
    background: #091217; color: var(--paper); font: inherit;
    font-size: clamp(11px, 3.2vw, 12px); line-height: 1; letter-spacing: 0;
    text-align: left; white-space: nowrap; overflow: hidden;
  }
  .sidebar.mobile-expanded .sidebar-expanded-handle { display: flex; grid-row: 3; }
  .sidebar .side-section { padding: 11px 13px; }
  .sidebar .side-section:not(:first-child), .sidebar .selected-card { display: none; }
  .sidebar.mobile-expanded .side-section {
    box-sizing: border-box; display: flex; flex: 0 0 auto; flex-direction: column;
    align-items: stretch; width: 100%; min-width: 0;
  }
  .sidebar.mobile-expanded .section-label {
    display: flex; align-items: center; width: 100%; min-width: 0;
    min-height: 20px; line-height: 19px;
  }
  .sidebar.mobile-expanded .section-label-copy {
    display: inline-flex; align-items: center; gap: 4px; min-width: 0; height: 20px;
  }
  .sidebar.mobile-expanded .section-label-title {
    font-size: 14px; font-weight: 700; line-height: 19px;
    letter-spacing: 0; white-space: nowrap;
  }
  .sidebar.mobile-expanded .section-label-hint {
    font-size: 10px; font-weight: 400; line-height: 19px;
    letter-spacing: .04em; white-space: nowrap;
  }
  .sidebar.mobile-expanded .section-label .tiny {
    display: inline-flex; align-items: center; height: 19px; line-height: 19px;
  }
  .sidebar.mobile-expanded .side-section::before { top: 11px; }
  .sidebar.mobile-expanded .craft-summon-section {
    grid-row: 2; min-height: 0; align-self: stretch; overflow: hidden;
    display: grid; grid-template-rows: max-content minmax(0, 1fr);
  }
  .sidebar.mobile-expanded .craft-summon-list {
    width: 100%; min-width: 0; min-height: 0; height: auto; max-height: none;
    overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: contain;
    touch-action: pan-y; -webkit-overflow-scrolling: touch; scrollbar-gutter: stable;
    padding-bottom: 8px;
  }
  .sidebar.mobile-expanded .craft-summon-item { width: 100%; min-width: 0; min-height: 40px; user-select: none; -webkit-user-select: none; }
  .sidebar.mobile-expanded .selected-card { display: none !important; }
  #mission-card { display: none; }
  .sidebar.mobile-expanded #mission-card { display: block; width: 100%; min-width: 0; }
  .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 > #auto-fusion { grid-column: 3 / 4; grid-row: 2; }
  .commandbar > button[data-panel="upgrades"] { grid-column: 4 / 5; grid-row: 2; }
  .commandbar > button[data-panel="recipes"] { 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; }
}

/* Final supplied logo and UI asset mapping. Keep every existing control footprint. */
.brand { min-width: 230px; }
.brand-logo {
  display: block;
  width: auto;
  height: 62px;
  max-width: 341px;
  object-fit: contain;
  image-rendering: pixelated;
}
.topbar nav button > .header-ui-icon {
  display: block;
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  margin: 0;
  object-fit: contain;
  image-rendering: pixelated;
}
.topbar nav #patch-notes-button { position: relative; }
.topbar nav #patch-notes-button .patch-notes-icon { object-fit: contain; image-rendering: pixelated; }
.patch-unread-dot {
  position: absolute; top: 7px; right: 5px; width: 6px; height: 6px; margin: 0;
  border: 1px solid #071014; border-radius: 50%; background: #d94a48; pointer-events: none;
}
body:not(:has(#menu-screen:not(.hidden))) #patch-notes-button { display: none; }
.topbar nav .iconbtn::before { display: none; }

.patch-notes-list { display: grid; align-content: start; gap: 16px; max-width: 760px; margin: 0 auto; }
dialog#panel[open]:has(.patch-notes-list) { display: flex; flex-direction: column; height: min(720px,88dvh); overflow: hidden; }
#panel:has(.patch-notes-list) .dialog-head { flex: 0 0 auto; }
#panel:has(.patch-notes-list) #panel-content { flex: 1 1 auto; min-height: 0; max-height: none; overflow-y: auto; overscroll-behavior: contain; }
.patch-note { overflow: hidden; border: 1px solid #3a4748; border-top: 2px solid var(--brass); background: linear-gradient(145deg,#17252b,#0e191e); }
.patch-note-toggle {
  position: relative; display: block; width: 100%; min-height: 65px; padding: 14px 48px 14px 20px;
  border: 0; border-radius: 0; background: transparent; text-align: left;
}
.patch-note-toggle:hover { border: 0; background: rgba(197,162,100,.08); }
.patch-note-toggle:active { transform: none; }
.patch-note-toggle::after {
  content: '▼'; position: absolute; top: 50%; right: 20px; transform: translateY(-50%);
  color: var(--brass-bright); font-size: 10px;
}
.patch-note-toggle[aria-expanded="true"]::after { content: '▲'; }
.patch-note-heading { display: grid; grid-template-columns: 92px minmax(0,1fr); align-items: center; gap: 14px; margin: 0; }
.patch-note-heading time { color: var(--brass-bright); font-size: 10px; letter-spacing: .09em; white-space: nowrap; }
.patch-note-heading strong { overflow: hidden; color: var(--paper); font: 700 17px/1.4 var(--display); text-overflow: ellipsis; white-space: nowrap; word-break: keep-all; }
.patch-note-detail { border-top: 1px solid #303d3e; }
.patch-note-detail > h3 { margin: 0; padding: 18px 22px 0; color: var(--paper); font: 700 20px/1.35 var(--display); word-break: keep-all; }
.patch-note section { padding: 18px 22px; border-bottom: 1px solid rgba(77,91,91,.45); }
.patch-note section:last-child { border-bottom: 0; }
.patch-note h4 { margin: 0 0 12px; color: #dfc487; font-size: 13px; }
.patch-note-group + .patch-note-group { margin-top: 14px; }
.patch-note-group p { margin: 0 0 7px; color: #d8d4c9; font-size: 12px; font-weight: 700; }
.patch-note ul { margin: 0; padding-left: 19px; color: #aebbb9; font-size: 12px; line-height: 1.8; }
.patch-note li::marker { color: #ad9561; }

.lobby-relic::before,
.menu-actions button::before {
  background-position: center !important;
  background-size: contain !important;
  background-repeat: no-repeat !important;
}
.lobby-relic::before { background-image: url("./assets/ui/icons/chest.png") !important; }
.menu-actions #new-game::before { background-image: url("./assets/ui/icons/flask.png") !important; }
.menu-actions #continue-game::before { background-image: url("./assets/ui/icons/save.png") !important; }
.menu-actions #infinite-game::before { background-image: url("./assets/ui/icons/infinity.png") !important; }
.menu-actions .primary::before { filter: none; }

.coin.resource-ui-icon {
  width: 25px;
  height: 25px;
  border: 0;
  border-radius: 0 !important;
  background: none;
  box-shadow: none;
  object-fit: contain;
  image-rendering: pixelated;
}
.summon-button { gap: 0; }
.summon-button::before { display: none !important; }
.summon-button > span { display: grid; place-items: center; }

.commandbar .command::before,
.commandbar .save-button::before {
  background-position: center !important;
  background-size: contain !important;
  background-repeat: no-repeat !important;
}
.commandbar #merge::before { background-image: url("./assets/ui/icons/sell.png") !important; }
.commandbar #auto-fusion::before { background-image: url("./assets/ui/icons/merge.png") !important; }
.commandbar button[data-panel="upgrades"]::before { background-image: url("./assets/ui/icons/upgrade.png") !important; }
.commandbar button[data-panel="recipes"]::before { background-image: url("./assets/ui/icons/recipe.png") !important; }
.commandbar .save-button::before { background-image: url("./assets/ui/icons/save.png") !important; }

@media (max-width: 760px) {
  .brand { min-width: 0; }
  .brand-logo { height: 41px; max-width: 222px; }
  .topbar nav button > .header-ui-icon {
    flex-basis: 17px;
    width: 17px;
    height: 17px;
  }
  .topbar nav #patch-notes-button { width: 40px; min-width: 40px; padding: 0; }
  .topbar nav #patch-notes-button .patch-notes-label { display: none; }
  .topbar nav #patch-notes-button .patch-unread-dot { top: 6px; right: 4px; }
  dialog#panel[open]:has(.patch-notes-list) { height: calc(100dvh - 20px); }
  .patch-note-toggle { min-height: 59px; padding: 12px 40px 12px 14px; }
  .patch-note-toggle::after { right: 14px; }
  .patch-note-heading { grid-template-columns: 75px minmax(0,1fr); gap: 9px; }
  .patch-note-heading time { font-size: 9px; letter-spacing: .03em; }
  .patch-note-heading strong { font-size: 14px; }
  .patch-note-detail > h3, .patch-note section { padding-inline: 16px; }
  .patch-note-detail > h3 { font-size: 17px; }
  .coin.resource-ui-icon { width: 22px; height: 22px; }
}

/* Fusion and deterministic crafting use the existing archive dialog. */
.craft-tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; margin-bottom: 16px; }
.craft-tabs button { min-height: 44px; padding: 7px 10px; border-top: 2px solid var(--tier); font-weight: 700; }
.craft-tabs button small { display: block; margin-top: 2px; color: #8fa2aa; font-size: 9px; font-weight: 400; }
.craft-tabs button.active { color: var(--tier); background: #203139; border-color: var(--tier); }
.fusion-units { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 8px; min-height: 130px; }
.material-unit,.recipe-targets button { display: flex; align-items: center; gap: 9px; min-width: 0; padding: 8px; text-align: left; border-top: 2px solid var(--tier); background: #0d191e; }
.material-unit img,.recipe-targets img { width: 42px; height: 48px; flex: 0 0 auto; object-fit: cover; filter: saturate(.72); }
.material-unit span,.recipe-targets span { min-width: 0; }
.material-unit b,.recipe-targets b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.material-unit small,.recipe-targets small { display: block; margin-top: 3px; color: #8fa2aa; font-size: 9px; }
.material-unit.selected,.recipe-targets button.active { color: var(--tier); border-color: var(--tier); background: #23362f; box-shadow: inset 3px 0 0 var(--tier); }
.recipe-workbench { display: grid; grid-template-columns: 210px minmax(0,1fr); gap: 14px; }
.recipe-targets { display: flex; flex-direction: column; gap: 6px; max-height: 59dvh; overflow: auto; padding-right: 4px; }
.recipe-detail { min-width: 0; padding: 15px; border: 1px solid var(--line); background: #0c171c; }
.recipe-detail>header { display: flex; align-items: center; gap: 14px; padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.recipe-detail>header>img { width: 78px; height: 92px; object-fit: cover; border: 1px solid #6d6655; }
.recipe-detail h3 { margin: 3px 0 5px; font: 22px 'Noto Serif KR',serif; }
.recipe-detail header p { margin: 0; color: #9fb0b7; font-size: 11px; line-height: 1.7; }
.recipe-material-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; margin-top: 12px; }
.recipe-material { padding: 9px; border: 1px solid color-mix(in srgb,var(--material-tier) 64%,#34474e); border-left: 3px solid var(--material-tier); background: linear-gradient(90deg,color-mix(in srgb,var(--material-tier) 14%,#101f25),#101f25 58%); }
.recipe-material.navigable { width: 100%; min-width: 0; appearance: none; color: inherit; font: inherit; text-align: left; cursor: pointer; touch-action: manipulation; }
.recipe-material.navigable:hover { border-color: var(--material-tier); background: linear-gradient(90deg,color-mix(in srgb,var(--material-tier) 22%,#101f25),#101f25 64%); }
.recipe-material.navigable:active { transform: translateY(1px); }
.recipe-material.ready { box-shadow: inset 0 0 0 1px color-mix(in srgb,var(--material-tier) 18%,transparent); }
.recipe-material.missing { opacity: .68; filter: saturate(.58); }
.recipe-material.missing .recipe-material-head small { color: #d18c8c; }
.recipe-material-head { display: flex; align-items: center; gap: 8px; }
.recipe-material-head img { width: 34px; height: 39px; object-fit: cover; }
.recipe-material-head span { min-width: 0; }
.recipe-material-head b { display: block; color: var(--material-tier); font-size: 11px; }
.recipe-material-head small { display: block; overflow: hidden; margin-top: 2px; color: #8fa2aa; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.recipe-relation { margin: 13px 0 0; padding: 11px 12px; border-left: 3px solid #9f8653; background: #1c1b16; color: #c8bfa8; font-size: 11px; line-height: 1.75; }
.craft-footer { display: flex; align-items: center; gap: 8px; margin-top: 15px; }
.craft-footer>span { flex: 1; color: #9eb0b7; font-size: 11px; }
.craft-footer button { min-height: 38px; padding: 8px 13px; }
.empty-recipe { grid-column: 1/-1; align-self: center; text-align: center; color: #82959c; }

@media (max-width: 760px) {
  .craft-tabs { gap: 3px; }
  .craft-tabs button { min-width: 0; padding-inline: 4px; font-size: 11px; }
  .fusion-units { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .recipe-workbench { grid-template-columns: 1fr; }
  .recipe-targets { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); max-height: 160px; }
  .recipe-detail { padding: 10px; }
  .recipe-detail>header>img { width: 60px; height: 70px; }
  .recipe-detail h3 { font-size: 18px; }
  .recipe-material-list { grid-template-columns: 1fr; }
  .craft-footer { align-items: stretch; flex-wrap: wrap; }
  .craft-footer>span { flex-basis: 100%; }
  .craft-footer button { flex: 1; }
}

@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="5"] { 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;
    flex: 0 1 auto;
    min-width: 0;
    max-width: 100%;
    font-size: clamp(15px, 4.8vw, 19px);
    line-height: 1;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.04em;
  }
  .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 > #auto-fusion {
    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="recipes"] {
    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 { gap: 4px; padding-inline: 4px; }
  .commandbar .resources strong { font-size: 15px; max-width: 100%; }
  .commandbar #summon b { font-size: 13px; }
  .commandbar .command b { font-size: 11px; }
}

/* Reference-matched lobby: the artwork stays dominant and controls sit directly on it. */
.topbar nav { gap: 10px; align-items: center; }
.topbar nav button {
  height: 40px; min-width: auto; padding-inline: 10px; border: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; line-height: 1;
  background: transparent; color: #eee7d7; font-weight: 700;
}
.topbar nav button > span[aria-hidden="true"] {
  display: inline-block; flex: 0 0 16px; width: 16px; height: 16px; margin: 0;
  vertical-align: 0; overflow: hidden; color: transparent; font-size: 0;
  background: url("./menu-icons.svg") -64px 0 / 128px 16px no-repeat;
  image-rendering: pixelated;
}
.topbar nav button:nth-child(2) > span[aria-hidden="true"] { background-position: -80px 0; }
.topbar nav .iconbtn { position: relative; min-width: 40px; width: 40px; color: transparent; font-size: 0; }
.topbar nav .iconbtn::before {
  content: ""; width: 16px; height: 16px;
  background: url("./menu-icons.svg") -96px 0 / 128px 16px no-repeat;
  image-rendering: pixelated;
}
.topbar nav #menu-button::before { background-position: -112px 0; }

body:has(#menu-screen:not(.hidden)) .topbar {
  position: absolute; inset: 0 0 auto; height: 66px; padding: 0 40px; z-index: 5;
  border: 0; background: linear-gradient(180deg, rgba(3,7,10,.72), transparent);
  box-shadow: none;
}
body:has(#menu-screen:not(.hidden)) .brand { min-width: 0; gap: 13px; }
body:has(#menu-screen:not(.hidden)) .brandmark {
  width: 42px; height: 42px; overflow: hidden; color: transparent;
}
body:has(#menu-screen:not(.hidden)) .game-brand {
  font: 700 14px/1 var(--display); letter-spacing: -.02em;
}
body:has(#menu-screen:not(.hidden)) .game-brand small {
  margin-top: 6px; color: #a69d8d; font-size: 7px; letter-spacing: .27em;
}
body:has(#menu-screen:not(.hidden)) .top-center,
body:has(#menu-screen:not(.hidden)) #menu-button { display: none; }

#menu-screen { min-height: 100dvh; background-position: center center; }
#menu-screen::before {
  background:
    linear-gradient(90deg, rgba(3,7,9,.93) 0%, rgba(3,7,9,.72) 24%, rgba(3,7,9,.17) 49%, rgba(3,7,9,.05) 72%),
    linear-gradient(0deg, rgba(3,7,9,.62), transparent 35%, rgba(3,7,9,.2));
}
#menu-screen::after { display: none; }
.menu-content {
  display: flex; flex-direction: column; width: 392px; margin: 0; padding: 88px 0 58px 62px;
  background: none; border: 0; box-shadow: none; transform: none;
}
.menu-content::before { display: none; }
.menu-content .eyebrow {
  order: 1; margin: 0 0 20px; padding-bottom: 10px; color: #bbb09a;
  border-bottom: 1px solid rgba(197,162,100,.36); font-size: 8px; letter-spacing: .28em;
}
.menu-content .eyebrow::before { display: none; }
.game-title {
  order: 2; margin: 0; color: #f2e8d2; font: 700 clamp(46px,4.2vw,64px)/1.03 var(--display);
  letter-spacing: -.055em; text-shadow: 0 3px 18px #000;
}
.game-title em { font-size: 1em; color: #f2e8d2; letter-spacing: inherit; }
.game-title-image { display: none; }
.menu-chapter {
  order: 3; margin: 19px 0 12px; padding: 0 0 0 12px; border: 0; border-left: 1px solid var(--brass);
  background: none; box-shadow: none;
}
.menu-chapter small { font-size: 8px; }
.menu-chapter strong { margin: 5px 0 6px; font-size: 18px; }
.menu-chapter p { max-width: 230px; color: #c2b9a8; font-size: 12px; line-height: 1.45; }
.lobby-relic {
  order: 4; position: relative; width: 100%; min-height: 48px; margin: 0 0 11px; padding: 7px 42px 7px 48px;
  display: grid; grid-template-columns: 1fr; grid-template-rows: auto auto; row-gap: 2px;
  border: 1px solid #8d8779 !important; background: rgba(8,17,21,.78); box-shadow: none;
}
.lobby-relic::before, .menu-actions button::before {
  content: ""; position: absolute; left: 15px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%);
  background: url("./menu-icons.svg") -48px 0 / 128px 16px no-repeat; image-rendering: pixelated;
}
.lobby-relic::after { content: "→"; position: absolute; right: 16px; top: 50%; transform: translateY(-50%); color: var(--paper); }
.lobby-relic > span { display: none; }
.lobby-relic b { color: var(--paper); font-size: 13px; }
.lobby-relic small { color: #aaa294; font-size: 10px; }
.difficulty-choice {
  order: 5; display: grid; grid-template-columns: 1fr; justify-items: center; gap: 7px; min-height: 0; margin: 0 0 12px;
  padding: 0; border: 0; background: none;
}
.difficulty-choice label { padding: 0; color: #e4dac6; font-size: 12px; letter-spacing: .02em; }
.difficulty-choice > small { max-width: 360px; color: #c9b987; font-size: 11px; line-height: 1.45; text-align: center; overflow-wrap: anywhere; }
.difficulty-choice select {
  width: 176px; min-height: 38px; padding: 0 12px; border: 1px solid #77736b;
  background: rgba(8,17,21,.88); color: #f0e6d1; text-align: center; font-weight: 700;
}
.menu-actions { order: 6; display: grid; gap: 5px; }
.menu-actions button {
  position: relative; min-height: 43px; padding: 0 16px 0 48px; border: 1px solid #79766e !important;
  background: rgba(7,16,20,.85); box-shadow: none; font-size: 14px;
}
.menu-actions button::before { background-position: 0 0; }
.menu-actions #continue-game::before { background-position: -16px 0; }
.menu-actions #infinite-game::before { background-position: -32px 0; }
.menu-actions #event-game {
  min-height: 50px; border-color: #a04f65 !important;
  background: linear-gradient(100deg,rgba(82,23,43,.92),rgba(28,18,35,.92));
}
.menu-actions #event-game::before { background-position: -64px 0; filter: sepia(1) saturate(2) hue-rotate(285deg) brightness(1.35); }
.menu-actions #event-game b { display: flex; align-items: center; gap: 8px; font: 800 14px var(--display); color: #ffe0e8; }
.menu-actions #event-game em { padding: 2px 5px; border: 1px solid #ff8ba8; color: #ffabc0; font: 800 8px var(--ui); letter-spacing: .12em; }
.menu-actions #event-game > span { color: #dca6b4; font-size: 10px; letter-spacing: .05em; }
.menu-actions #brain-game {
  min-height: 50px; border-color: rgba(121,214,196,.58) !important;
  background: linear-gradient(100deg,rgba(18,78,75,.9),rgba(14,29,43,.94));
  justify-content: flex-start;
}
.menu-actions #brain-game::before { width: 20px; height: 20px; background-image: url("./assets/ui/icons/brain-mode-pixel-v2.png") !important; filter: none; }
.menu-actions #brain-game::after { content: "→"; margin-left: auto; color: #b8eee4; }
.menu-actions #brain-game b { display: flex; align-items: center; gap: 8px; color: #dcfff8; font: 800 14px var(--display); }
.menu-actions .primary {
  min-height: 48px; border-color: #ecd59e !important; background: linear-gradient(100deg,#f0ddb0,#d4b978);
  color: #1b1b17; font: 800 16px var(--display); box-shadow: 3px 3px 0 rgba(58,44,24,.72);
}
.menu-actions .primary::before { filter: brightness(.2); }
.menu-actions button:hover, .lobby-relic:hover { transform: translateX(2px); }
.menu-links { order: 7; justify-content: space-between; width: 100%; margin-top: 10px; }
.menu-links button { min-height: 28px; padding: 0; color: #ddd5c4; font-size: 11px; }
.menu-links span { height: 15px; background: rgba(197,162,100,.45); }
.menu-caption { top: 88px; right: 72px; bottom: auto; max-width: 260px; }
.menu-caption p { font: italic 16px/1.7 var(--display); color: #d7cfbd; }
.menu-bottom { height: 32px; padding-inline: 40px; border: 0; background: linear-gradient(0deg,rgba(3,7,9,.8),transparent); }

@media (max-width: 760px) {
  body:has(#menu-screen:not(.hidden)) .topbar { height: 52px; padding: 0 14px; }
  body:has(#menu-screen:not(.hidden)) .brand { gap: 8px; }
  body:has(#menu-screen:not(.hidden)) .brandmark { width: 32px; height: 32px; background-size: 21px 21px; }
  body:has(#menu-screen:not(.hidden)) .game-brand { font-size: 10px; letter-spacing: -.04em; }
  body:has(#menu-screen:not(.hidden)) .game-brand small { font-size: 6px; letter-spacing: .18em; }
  .topbar nav { gap: 1px; }
  .topbar nav button:not(.iconbtn) { width: 40px; min-width: 40px; padding: 0; font-size: 0; }
  .topbar nav button:not(.iconbtn) span { margin: 0; }
  .topbar nav .iconbtn { width: 36px; min-width: 36px; }
  #menu-screen {
    min-height: 100dvh;
    overflow-y: auto;
    background-image: url("./lobby-science-mobile.webp");
    background-position: center top;
    background-size: cover;
  }
  #menu-screen::before { background: linear-gradient(90deg,rgba(3,7,9,.96),rgba(3,7,9,.83) 70%,rgba(3,7,9,.45)); }
  .menu-content { width: min(330px,calc(100% - 34px)); min-height: auto; margin: 0; padding: 76px 0 50px 22px; }
  .menu-content .eyebrow { margin-bottom: 15px; font-size: 7px; }
  .game-title { font-size: clamp(42px,13vw,54px); }
  .menu-chapter { margin: 16px 0 11px; }
  .menu-chapter p { font-size: 11px; }
  .lobby-relic { min-height: 46px; }
  .difficulty-choice { margin-bottom: 10px; }
  .menu-actions { gap: 5px; }
  .menu-actions button { min-height: 43px; }
  .menu-links { justify-content: space-between; }
  .menu-links button { padding: 0; }
  .menu-bottom { padding-inline: 16px; }
}

@media (max-height: 700px) and (min-width: 761px) {
  .menu-content { width: 360px; padding-top: 68px; padding-left: 50px; }
  .menu-content .eyebrow { margin-bottom: 11px; }
  .game-title { font-size: 43px; }
  .menu-chapter { margin: 12px 0 8px; }
  .menu-chapter p { display: none; }
  .lobby-relic { min-height: 42px; margin-bottom: 7px; }
  .difficulty-choice { margin-bottom: 8px; gap: 4px; }
  .difficulty-choice select { min-height: 34px; }
  .menu-actions button { min-height: 38px; }
  .menu-actions .primary { min-height: 43px; }
  .menu-links { margin-top: 6px; }
}

/* Equal command tiles for random and designated summoning. */
.commandbar > .summon-button {
  flex: 1 1 0;
  min-width: 108px;
  width: auto;
  height: 64px;
  margin: 0;
  padding: 0 8px;
  justify-content: center;
  text-align: center;
}
.commandbar > .summon-button b { font-size: 13px; white-space: nowrap; }
.commandbar > .summon-button small { font-size: 9px; white-space: nowrap; }
.commandbar > .designated-summon-button {
  background: linear-gradient(130deg, #d4b678, #e8d3a3);
  color: #111;
  border-color: #e2c77f !important;
  box-shadow: 3px 3px 0 #5c492a, 5px 5px 0 #020608 !important;
}
.commandbar > .designated-summon-button small { color: #29261c; }

@media (max-width: 1350px) and (min-width: 761px) {
  .commandbar > .summon-button { min-width: 82px; padding-inline: 4px; }
  .commandbar > .summon-button b { font-size: 12px; }
  .commandbar > .summon-button small { font-size: 8px; }
}

@media (max-width: 760px) {
  .commandbar #summon { grid-column: 4 / 7 !important; grid-row: 1 !important; }
  .commandbar #summon-batch { grid-column: 7 / 10 !important; grid-row: 1 !important; }
  .commandbar #designated-summon { grid-column: 10 / 13 !important; grid-row: 1 !important; }
  .commandbar > .summon-button { padding: 0 3px; border-radius: 0; box-shadow: 2px 2px 0 #5c492a !important; }
  .commandbar > .summon-button b { font-size: 11px; }
  .commandbar > .summon-button small { font-size: 8px; }
}

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

.designated-summon { display: grid; gap: 18px; }
.designated-summary { display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--line-soft); background: #0a151a; color: #9aa9a7; font-size: 13px; }
.designated-summary b, .designated-summary strong { color: #e6c77f; }
.designated-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.designated-card { min-width: 0; padding: 8px; display: grid; grid-template-rows: 106px auto auto; gap: 5px; align-items: center; text-align: center; border: 1px solid #3b4b4d; background: #0d191e; overflow: hidden; }
.designated-card::after { display: none; }
.designated-card img { width: 100%; height: 106px; object-fit: cover; object-position: center 16%; filter: saturate(.72) contrast(1.05); }
.designated-card b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #dfd8c9; font-size: 13px; }
.designated-card small { color: #8b9998; font-size: 10px; }
.designated-card.selected { border-color: #edc86f; background: #2a2418; box-shadow: inset 0 0 0 2px rgba(237,200,111,.25); }
.designated-card.selected b { color: #ffe6a7; }
.designated-glyph { height: 106px; display: grid; place-items: center; font-size: 42px; color: #d2b36d; background: #132329; }
.designated-confirm { position: sticky; bottom: -24px; z-index: 2; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 14px; border-top: 1px solid #625536; background: #0b151af2; box-shadow: 0 -8px 18px rgba(0,0,0,.35); }
.designated-confirm p { margin: 0; color: #ba8d78; font-size: 12px; }
.designated-confirm p.ready { color: #9bc7b9; }
.designated-confirm button { min-width: 190px; padding: 12px 16px; }

@media (max-width: 760px) {
  .designated-summon { gap: 12px; }
  .designated-summary { font-size: 11px; }
  .designated-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .designated-card { grid-template-columns: 54px minmax(0, 1fr); grid-template-rows: auto auto; min-height: 64px; padding: 5px; text-align: left; }
  .designated-card img, .designated-glyph { grid-row: 1 / 3; width: 54px; height: 54px; }
  .designated-card b { align-self: end; font-size: 11px; }
  .designated-card small { align-self: start; font-size: 9px; }
  .designated-confirm { bottom: -16px; grid-template-columns: 1fr; gap: 7px; padding: 10px; }
  .designated-confirm button { width: 100%; min-width: 0; }
}

/* Pixel-game interface pass: typography and icons only; layout remains unchanged. */
button, select, input, dialog { font-family: var(--ui); font-synthesis: none; }
.game-title,
.menu-chapter strong,
.next-wave-panel h2,
.battle-left blockquote,
.dialog-head h2,
.unit-inspector h2,
#mission-card h3 { font-family: var(--display); font-style: normal; }
.game-title { font-size: clamp(42px,3.7vw,52px); line-height: 1.08; letter-spacing: -.06em; }
.menu-caption p { font-family: var(--ui); font-style: normal; letter-spacing: .03em; }

.battle-hud,
.commandbar,
.battle-left,
.sidebar,
.arena,
dialog#panel,
.army-tray,
.quick-upgrades,
.unit-inspector { image-rendering: pixelated; }
.battle-left,
.sidebar,
.arena,
dialog#panel,
.army-tray,
.quick-upgrades,
.unit-inspector {
  box-shadow: 4px 4px 0 #020609, inset 0 0 0 2px rgba(197,162,100,.08);
}
.side-section::before,
.live-dot { border-radius: 0; }
.section-label,
.battle-hud small,
.commandbar b,
.commandbar small,
.tiny { letter-spacing: 0; }
.speed-group button,
.textbtn,
.tiny {
  border-radius: 0 !important;
  box-shadow: inset 0 0 0 1px rgba(197,162,100,.08);
}

.coin {
  overflow: hidden;
  border-radius: 0 !important;
  color: transparent;
  font-size: 0;
  background: transparent url("./game-icons.svg") 0 50% / 250px 25px no-repeat;
  box-shadow: none;
  image-rendering: pixelated;
}
.mission-icon,
.selection-glyph {
  display: inline-block;
  width: 24px;
  height: 24px;
  overflow: hidden;
  color: transparent !important;
  font-size: 0 !important;
  background: url("./game-icons.svg") -144px 0 / 240px 24px no-repeat;
  image-rendering: pixelated;
}
.selection-glyph {
  width: 32px;
  height: 32px;
  background-position: -224px 0;
  background-size: 320px 32px;
}

.summon-button { gap: 7px; }
.summon-button::before {
  content: "";
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  background: url("./game-icons.svg") -128px 0 / 160px 16px no-repeat;
  filter: brightness(.25);
  image-rendering: pixelated;
}
.commandbar .command > span { display: none !important; }
.commandbar .command::before,
.commandbar .save-button::before {
  content: "";
  display: block;
  width: 18px;
  height: 18px;
  margin: 0 auto 4px;
  background: url("./game-icons.svg") -18px 0 / 180px 18px no-repeat;
  image-rendering: pixelated;
  position: relative;
  top: 2px;
}
.commandbar #auto-fusion::before { background-position: -36px 0; }
.commandbar button[data-panel="upgrades"]::before { background-position: -54px 0; }
.commandbar button[data-panel="recipes"]::before { background-position: -72px 0; }
.commandbar .save-button::before { background-position: -90px 0; }
.commandbar .command,
.commandbar .save-button {
  border: 1px solid rgba(197,162,100,.18) !important;
  background: #0b161b !important;
  box-shadow: 2px 2px 0 #020608, inset 0 0 0 1px rgba(111,156,145,.08);
}
.commandbar .command:hover,
.commandbar .save-button:hover {
  border-color: rgba(197,162,100,.48) !important;
  background: #122329 !important;
}
.battle-hud .speed-group button {
  font-weight: 700;
  line-height: 1;
  text-align: center;
}
#pause {
  color: #c8ad73;
  font-family: var(--ui);
  font-size: 14px;
  font-weight: 700;
}

@media (max-width: 760px) {
  .battle-left,
  .sidebar,
  .arena,
  dialog#panel,
  .army-tray,
  .quick-upgrades,
  .unit-inspector { box-shadow: 2px 2px 0 #020609, inset 0 0 0 1px rgba(197,162,100,.08); }
  .commandbar .command { align-content: center; gap: 2px; }
  .commandbar .command::before,
  .commandbar .save-button::before {
    width: 14px;
    height: 14px;
    margin-bottom: 2px;
    background-size: 140px 14px;
  }
  .commandbar #merge::before { background-position: -14px 0; }
  .commandbar #auto-fusion::before { background-position: -28px 0; }
  .commandbar button[data-panel="upgrades"]::before { background-position: -42px 0; }
  .commandbar button[data-panel="recipes"]::before { background-position: -56px 0; }
  .commandbar .save-button::before { background-position: -70px 0; }
  .commandbar .command b { font-size: 11px; }
  .summon-button::before {
    flex-basis: 13px;
    width: 13px;
    height: 13px;
    background-position: -104px 0;
    background-size: 130px 13px;
  }
}

/* Asset rules must win over the legacy sprite declarations above. */
.coin.resource-ui-icon { background: none !important; }
.menu-actions .primary::before { filter: none !important; }
.summon-button { gap: 0 !important; }
.summon-button::before { display: none !important; }

/* 2026-10-22 mobile lobby: fresh artwork with live, responsive controls. */
@media (max-width: 760px) and (orientation: portrait) {
  body:has(#menu-screen:not(.hidden)) .topbar {
    position: absolute;
    inset: 0 0 auto;
    z-index: 20;
    height: 54px;
    padding: 7px 10px 0;
    justify-content: flex-end;
    background: linear-gradient(180deg, rgba(2, 7, 12, .76), transparent);
  }
  body:has(#menu-screen:not(.hidden)) .brand,
  body:has(#menu-screen:not(.hidden)) .top-center,
  body:has(#menu-screen:not(.hidden)) #menu-button { display: none; }
  body:has(#menu-screen:not(.hidden)) .topbar nav { gap: 1px; margin-left: auto; }
  /* Transparent lobby controls should not inherit the global button bottom edge. */
  body:has(#menu-screen:not(.hidden)) .topbar nav button { box-shadow: none; }

  #menu-screen {
    height: 100dvh;
    min-height: 620px;
    padding: 0;
    overflow: hidden;
    background: #07111d url("./assets/ui/mobile-main-background-v8.png") center -4.2vh / cover no-repeat;
  }
  #menu-screen::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
      linear-gradient(180deg, rgba(3, 8, 14, .2) 0%, rgba(3, 8, 14, .02) 36%, rgba(3, 8, 14, .13) 47%, rgba(3, 8, 14, .56) 100%),
      linear-gradient(90deg, rgba(3, 8, 14, .12), transparent 20% 80%, rgba(3, 8, 14, .12));
  }
  #menu-screen::after,
  #menu-screen .menu-art,
  #menu-screen .eyebrow,
  #menu-screen .menu-chapter,
  #menu-screen .menu-links,
  #menu-screen .menu-bottom { display: none !important; }

  #menu-screen .menu-content {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100dvh;
    min-height: 620px;
    margin: 0;
    padding: 0;
    display: block;
  }
  #menu-screen .game-title {
    position: absolute;
    top: max(60px, 8%);
    left: 50%;
    width: calc(100% - 34px);
    margin: 0;
    transform: translateX(-50%);
    color: #f4e7c9;
    font: 800 clamp(42px, 13.7vw, 58px) / 1.18 var(--display);
    letter-spacing: -.07em;
    text-align: center;
    text-shadow: 0 4px 0 #342819, 3px 6px 0 rgba(3, 7, 10, .9), 0 10px 24px rgba(0, 0, 0, .8);
  }
  #menu-screen .game-title-text { display: none; }
  #menu-screen .game-title-image {
    display: block;
    width: 100%;
    height: auto;
    margin: 0 auto;
  }
  #menu-screen .game-title em { color: inherit; font-size: 1em; letter-spacing: inherit; }
  #menu-screen .game-title::after {
    content: none;
    display: none;
  }

  #menu-screen .lobby-relic,
  #menu-screen .difficulty-choice,
  #menu-screen .menu-actions {
    position: absolute;
    left: 50%;
    width: min(82vw, 380px);
    margin: 0;
    transform: translateX(-50%);
  }
  #menu-screen .lobby-relic {
    top: 50.8%;
    min-height: 50px;
    padding: 0 42px 0 48px;
    display: flex;
    align-items: center;
    border: 1px solid #ad9157 !important;
    background: rgba(6, 15, 22, .9);
    box-shadow: 3px 3px 0 rgba(1, 5, 9, .88);
  }
  #menu-screen .lobby-relic b { color: #f0dfb6; font-size: 14px; }
  #menu-screen .lobby-relic small,
  #menu-screen .lobby-relic::after { display: none; }

  #menu-screen .difficulty-choice {
    top: calc(50.8% + 57px);
    min-height: 50px;
    padding: 0 13px 0 48px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    border: 1px solid #ad9157;
    background: rgba(6, 15, 22, .9);
    box-shadow: 3px 3px 0 rgba(1, 5, 9, .88);
  }
  #menu-screen .difficulty-choice::before {
    content: "";
    position: absolute;
    left: 15px;
    top: 50%;
    width: 16px;
    height: 16px;
    transform: translateY(-50%);
    background: url("./assets/ui/icons/upgrade.png") center / contain no-repeat;
    image-rendering: pixelated;
  }
  #menu-screen .difficulty-choice label { color: #f0dfb6; font-size: 14px; font-weight: 700; }
  #menu-screen .difficulty-choice select {
    width: auto;
    min-width: 88px;
    min-height: 34px;
    padding: 0 20px 0 8px;
    border: 0;
    background-color: transparent;
    color: #e9c878;
    font-size: 14px;
    text-align: right;
  }

  #menu-screen .menu-actions {
    top: calc(50.8% + 114px);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }
  #menu-screen .menu-actions button {
    min-width: 0;
    min-height: 50px;
    padding: 0 12px 0 48px;
    border: 1px solid #ad9157 !important;
    background: rgba(6, 15, 22, .92);
    box-shadow: 3px 3px 0 rgba(1, 5, 9, .88);
    font-size: 13px;
    white-space: nowrap;
  }
  #menu-screen .menu-actions #new-game,
  #menu-screen .menu-actions #brain-game { grid-column: 1 / -1; }
  #menu-screen .menu-actions #new-game {
    min-height: 50px;
    border-color: #ead294 !important;
    background: linear-gradient(100deg, #ead396, #d2b46d);
    color: #151714;
    font-size: 15px;
  }
  #menu-screen .menu-actions #brain-game {
    min-height: 50px;
    border-color: #4ab6ac !important;
    background: rgba(5, 56, 66, .92);
  }
  #menu-screen .menu-actions #brain-game::after,
  #menu-screen .menu-actions #new-game > span,
  #menu-screen .menu-actions #continue-game > span { display: none; }
  #menu-screen .menu-actions #continue-game,
  #menu-screen .menu-actions #infinite-game { padding-left: 40px; font-size: 12px; }
  #menu-screen .menu-actions #continue-game::before,
  #menu-screen .menu-actions #infinite-game::before { left: 13px; }
  #menu-screen .menu-actions #infinite-lock { margin-left: auto; color: #a99771; font-size: 8px; }
  #menu-screen .menu-actions button:hover,
  #menu-screen .lobby-relic:hover { transform: none; }
}

@media (max-width: 380px) and (orientation: portrait) {
  #menu-screen .game-title { font-size: clamp(39px, 13vw, 49px); }
  #menu-screen .lobby-relic,
  #menu-screen .difficulty-choice,
  #menu-screen .menu-actions { width: min(86vw, 350px); }
  #menu-screen .menu-actions button { font-size: 12px; }
  #menu-screen .menu-actions #continue-game,
  #menu-screen .menu-actions #infinite-game { padding-left: 36px; font-size: 11px; }
}

/* Desktop unit profile: reflow only the contents of the fixed right rail. */
@media (min-width: 761px) {
  #unit-inspector { min-width: 0; }
  #unit-inspector > header { gap: 8px; padding: 13px 14px; }
  #unit-inspector > header > div { min-width: 0; }
  #unit-inspector h2 {
    overflow: hidden;
    margin-top: 3px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  #inspector-content { overflow-x: hidden; }
  #unit-inspector .inspector-hero {
    display: grid;
    grid-template-columns: minmax(88px, 40%) minmax(0, 1fr);
    align-items: center;
    gap: 11px;
    width: 100%;
    height: auto;
    min-height: 168px;
    padding: 11px 12px;
  }
  #unit-inspector .inspector-hero img {
    width: 100% !important;
    height: 146px !important;
    min-width: 0;
    object-fit: contain !important;
  }
  #unit-inspector .inspector-hero > div {
    min-width: 0;
    padding: 0;
  }
  #unit-inspector .inspector-hero b,
  #unit-inspector .inspector-hero small,
  #unit-inspector .inspector-hero span {
    word-break: keep-all;
    overflow-wrap: normal;
  }
  #unit-inspector .inspector-hero b {
    margin: 7px 0;
    font-size: 18px;
    line-height: 1.35;
  }
  #unit-inspector .inspector-hero span { line-height: 1.5; }
  #unit-inspector .live-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    margin: 0 12px;
    padding: 4px;
  }
  #unit-inspector .live-stats > span {
    display: flex;
    min-width: 0;
    min-height: 58px;
    padding: 8px 7px;
    flex-direction: column;
    justify-content: center;
    font-size: 13px;
    line-height: 1.25;
    white-space: nowrap;
    word-break: keep-all;
  }
  #unit-inspector .live-stats b {
    overflow: hidden;
    margin-top: 5px;
    font-size: 18px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  #unit-inspector .combat-summary {
    margin: 10px 12px 0;
    padding: 0;
  }
  #unit-inspector .combat-role,
  #unit-inspector .proc-info b,
  #unit-inspector .proc-info span,
  #unit-inspector .proc-info p,
  #unit-inspector .inspection-section h3,
  #unit-inspector .inspection-section p {
    word-break: keep-all;
    overflow-wrap: break-word;
  }
  #unit-inspector .proc-info { padding: 8px 9px; }
  #unit-inspector .proc-info span { line-height: 1.45; }
  #unit-inspector .inspection-section { padding: 14px 14px 0; }
  #unit-inspector .inspection-section p { line-height: 1.7; }
  #unit-inspector .inspection-actions {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr) minmax(0, .8fr);
    gap: 6px;
    padding: 10px 12px 12px;
  }
  #unit-inspector .inspection-actions button {
    width: 100%;
    min-width: 0;
    padding-inline: 3px;
    font-size: 13px;
    white-space: nowrap;
  }
}

/* Combat archive: keep large values inside their cards on narrow phones. */
dialog#panel:has(.record-grid) {
  width: min(720px, calc(100vw - 20px));
  overflow: hidden;
}
dialog#panel:has(.record-grid) #panel-content { min-width: 0; }
.record-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.record-grid > div {
  min-width: 0;
  padding: 24px;
  overflow: hidden;
  background: linear-gradient(145deg, #17282e, #0d191e);
  border: 1px solid rgba(197,162,100,.32);
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.2);
}
.record-grid span {
  display: block;
  color: #9fb3b1;
  font: 400 13px/1.45 var(--ui);
  word-break: keep-all;
}
.record-grid strong {
  display: block;
  max-width: 100%;
  margin-top: 14px;
  color: var(--brass-bright);
  font: 500 clamp(24px, 4.4vw, 40px)/1.15 var(--display);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.055em;
  white-space: nowrap;
}
@media (max-width: 520px) {
  dialog#panel:has(.record-grid) .dialog-head { padding: 14px 16px; }
  dialog#panel:has(.record-grid) #panel-content { padding: 14px; }
  .record-grid { gap: 8px; }
  .record-grid > div { min-height: 116px; padding: 16px 12px; }
  .record-grid span { font-size: 12px; }
  .record-grid strong { margin-top: 12px; font-size: clamp(18px, 6.2vw, 27px); }
}

/* Battle result actions: preserve readable labels and balanced touch targets. */
.end-actions button {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: nowrap;
  word-break: keep-all;
  line-height: 1.2;
}
dialog#panel:has(.end-actions) #panel-content {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
@media (max-width: 760px) {
  .end-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    margin-top: 24px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .end-actions button {
    width: 100%;
    min-width: 0;
    min-height: 58px;
    padding: 12px 8px;
    font-size: clamp(14px, 4.2vw, 18px);
  }
  .end-actions #end-infinite { grid-column: 1 / -1; }
}
.visitor-stats{display:grid;grid-template-columns:1fr;gap:10px;margin:20px 0 4px;padding:14px;border:1px solid #42535d;background:linear-gradient(135deg,#0d1a22,#172832);border-radius:4px}.visitor-stats>div{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 12px;background:#ffffff05;border:1px solid #ffffff0d}.visitor-stats span{font-size:12px;color:#9fb0b7}.visitor-stats strong{font:24px Georgia,serif;color:var(--gold);font-variant-numeric:tabular-nums}.visitor-stats small{color:#728993;font-size:10px;text-align:right}
.presence-operator:empty{display:none}.presence-operator{display:grid;gap:9px;padding-top:12px;border-top:1px solid #ffffff18}.presence-operator .presence-operator-head{padding:0;border:0;background:none}.presence-operator-head b{font-size:12px;color:#d8c393}.presence-member-list{display:flex;flex-wrap:wrap;justify-content:flex-start!important;gap:6px!important;padding:0!important;border:0!important;background:none!important}.presence-member-list span{padding:6px 9px;border:1px solid #c7a86642;background:#c7a86612;color:#ead9ad;border-radius:3px}.presence-member-list em,.presence-operator p{margin:0;color:#728993;font-size:10px;font-style:normal}
.relic-pity{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin:14px 0;padding:12px;border:1px solid #42535d;background:#0b171d}.relic-pity>b,.relic-pity>small{grid-column:1/-1}.relic-pity>b{color:#e1d4b6;font-size:13px}.relic-pity>div{display:grid;grid-template-columns:1fr auto;gap:3px 10px;padding:10px 12px;border-left:3px solid var(--rarity);background:#14242c}.relic-pity>div span{color:var(--rarity);font-size:12px;font-weight:700}.relic-pity>div strong{font-variant-numeric:tabular-nums;font-size:12px}.relic-pity>div small{grid-column:1/-1;color:#91a4ab;font-size:10px}.relic-pity>small{color:#728993;font-size:10px}@media(max-width:560px){.relic-pity{grid-template-columns:1fr}}
.relic-result-actions #relic-result-repeat,.relic-result-actions #relic-result-repeat:hover,.relic-result-actions #relic-result-repeat:active{background:linear-gradient(110deg,#d4b579,#ead4a3);border-color:#ead4a3;color:#242521}.relic-result-actions #relic-result-repeat:disabled,.relic-result-actions #relic-result-repeat:disabled:hover,.relic-result-actions #relic-result-repeat:disabled:active{background:#172229;border-color:#34434a;color:#697980;opacity:.72;filter:saturate(0)}

/* Keep the batch action and its settings trigger in the original command tile. */
.commandbar > .summon-batch-control { display:flex; padding:0; gap:0; overflow:visible; }
.commandbar > .summon-batch-control:active { transform:none; }
.summon-batch-control > button { height:100%; min-height:44px; min-width:0; margin:0; border:0; background:transparent; color:inherit; box-shadow:none; }
.summon-batch-control > .summon-batch-action { flex:1 1 auto; padding:0 3px; display:flex; align-items:center; justify-content:center; }
.summon-batch-control > .summon-count-settings { flex:0 0 28px; width:28px; padding:0; border-left:1px solid #75633d66; font-size:12px; }
.summon-batch-control > button:hover { background:#fff2; }
.summon-batch-control > button:disabled { cursor:default; }
dialog#panel:has(.summon-count-picker) { width:min(380px,92vw); }
#panel:has(.summon-count-picker) #panel-subtitle { display:none; }
.summon-count-options { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
.summon-count-options button { min-height:64px; padding:12px; border:1px solid #596861; background:#16272e; color:#eadfc8; font-size:22px; }
.summon-count-options button.active { border-color:#e0bd76; background:#e0bd7624; color:#ffe3a6; box-shadow:inset 0 0 0 1px #e0bd76; }
.summon-count-picker p { margin:18px 0; color:#adbbb8; font-size:12px; line-height:1.7; text-align:center; }
#summon-count-done { width:100%; min-height:44px; }
@media(max-width:760px){
 .commandbar > .summon-batch-control { padding:0; }
 .commandbar > .summon-batch-control b { font-size:clamp(9px,2.75vw,11px); }
 .commandbar > .summon-batch-control small { font-size:8px; }
}
