:root {
  color-scheme: dark;
  --pixel: 4px;
  --void: #08080d;
  --wall-dark: #111018;
  --wall: #1c1a24;
  --wall-light: #292632;
  --wood-dark: #321910;
  --wood: #68381f;
  --wood-light: #a35d2f;
  --iron-dark: #151920;
  --iron: #303843;
  --iron-light: #66727c;
  --gold-dark: #70451e;
  --gold: #d69a36;
  --gold-light: #ffe08a;
  --paper-dark: #8f6935;
  --paper: #dfbd72;
  --paper-light: #ffe4a1;
  --ink: #25170f;
  --cyan-dark: #126782;
  --cyan: #59e7ff;
  --cyan-light: #eaffff;
  --red: #f04d58;
  --blue: #368cff;
  --green: #55d878;
  --yellow: #ffd34f;
  --violet: #b45cff;
  --scene-x: 0;
  --scene-y: 0;
  --font-pixel: "MS Gothic", "Yu Gothic UI", "Courier New", monospace;
  --font-display: Impact, "Arial Black", "Yu Gothic", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  min-width: 280px;
  min-height: 100%;
  margin: 0;
}

html {
  background: var(--void);
  font-family: var(--font-pixel);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  overflow: hidden;
  color: #fff5d1;
  background: var(--void);
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.title-screen {
  position: relative;
  isolation: isolate;
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  overflow: hidden;
  background: #0b0a10;
  image-rendering: pixelated;
}

.title-screen::before {
  position: absolute;
  z-index: 18;
  inset: 0;
  content: "";
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(4, 4, 7, 0.72) 0 3%, transparent 3% 97%, rgba(4, 4, 7, 0.72) 97%),
    linear-gradient(0deg, rgba(4, 4, 7, 0.68) 0 2%, transparent 2% 96%, rgba(4, 4, 7, 0.74) 96%);
  box-shadow: inset 0 0 0 4px #050508;
}

.title-screen::after {
  position: absolute;
  z-index: 19;
  inset: 0;
  content: "";
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 4px 4px;
  mix-blend-mode: screen;
}

.workshop-scene {
  position: absolute;
  z-index: 0;
  inset: -12px;
  overflow: hidden;
  transform: translate(calc(var(--scene-x) * 4px), calc(var(--scene-y) * 3px));
  transition: transform 120ms steps(3, end), filter 260ms steps(3, end);
}

.title-screen[data-phase="menu"] .workshop-scene {
  filter: brightness(0.72) saturate(0.9);
}

.stone-wall {
  position: absolute;
  inset: 0 0 35%;
  overflow: hidden;
  background:
    repeating-linear-gradient(90deg, transparent 0 76px, #0d0c12 76px 80px),
    repeating-linear-gradient(0deg, var(--wall) 0 36px, #100f16 36px 40px, var(--wall-dark) 40px 44px, var(--wall-light) 44px 48px, var(--wall) 48px 80px);
  border-bottom: 8px solid #0a0809;
}

.stone-wall::before {
  position: absolute;
  inset: 0;
  content: "";
  background:
    linear-gradient(90deg, #08070b 0 12%, transparent 12% 88%, #08070b 88%),
    linear-gradient(0deg, rgba(10, 9, 14, 0.18) 0 72%, rgba(0, 0, 0, 0.72) 100%);
}

.stone-wall::after {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 72%, rgba(89, 231, 255, 0.11) 0 24%, transparent 25%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.52), transparent 24% 76%, rgba(0, 0, 0, 0.52));
}

.timber {
  position: absolute;
  z-index: 5;
  display: block;
  background:
    repeating-linear-gradient(0deg, var(--wood-dark) 0 8px, var(--wood) 8px 20px, #7d4527 20px 24px, var(--wood) 24px 40px);
  border: 4px solid #1c0d09;
  box-shadow: inset 4px 0 #92502b, inset -5px 0 #29140d, 6px 6px 0 rgba(0, 0, 0, 0.45);
}

.timber--left,
.timber--right {
  top: 0;
  bottom: -8px;
  width: clamp(42px, 5.4vw, 72px);
}

.timber--left {
  left: 8.5%;
}

.timber--right {
  right: 8.5%;
}

.timber--top {
  top: 5%;
  right: 7%;
  left: 7%;
  height: clamp(34px, 5.5vh, 56px);
  background:
    repeating-linear-gradient(90deg, var(--wood-dark) 0 14px, var(--wood) 14px 42px, #7d4527 42px 48px, var(--wood) 48px 78px);
  box-shadow: inset 0 4px #92502b, inset 0 -6px #29140d, 6px 7px 0 rgba(0, 0, 0, 0.48);
}

.wall-crack {
  position: absolute;
  z-index: 2;
  width: 8px;
  height: 92px;
  background: #09080d;
  box-shadow: 8px 24px #09080d, -5px 51px #09080d, -12px 65px #09080d;
  transform: skew(-16deg);
}

.wall-crack--left {
  top: 19%;
  left: 22%;
}

.wall-crack--right {
  top: 35%;
  right: 20%;
  transform: scaleX(-1) skew(-16deg);
}

.shelf {
  position: absolute;
  z-index: 7;
  top: 27%;
  display: flex;
  width: clamp(180px, 19vw, 270px);
  height: clamp(102px, 15vh, 142px);
  align-items: end;
  justify-content: space-around;
  padding: 0 15px 19px;
}

.shelf--left {
  left: 2.5%;
}

.shelf--right {
  right: 2.5%;
}

.shelf__board {
  position: absolute;
  right: 0;
  bottom: 4px;
  left: 0;
  height: 18px;
  background: var(--wood);
  border: 4px solid #21100b;
  box-shadow: inset 0 4px #a35d2f, 5px 6px 0 rgba(0, 0, 0, 0.55);
}

.gem-jar {
  --jar-gem: var(--cyan);
  position: relative;
  width: clamp(42px, 4.4vw, 58px);
  height: clamp(66px, 9.5vh, 88px);
  background:
    linear-gradient(90deg, rgba(89, 231, 255, 0.1) 0 20%, rgba(202, 248, 255, 0.26) 20% 28%, rgba(46, 111, 127, 0.16) 28% 78%, rgba(5, 16, 21, 0.42) 78%),
    #152d35;
  border: 4px solid #69838a;
  border-top-width: 7px;
  box-shadow: inset -4px -4px #0b161b, 4px 5px 0 rgba(0, 0, 0, 0.55);
}

.gem-jar::before {
  position: absolute;
  top: -14px;
  right: -3px;
  left: -3px;
  height: 12px;
  content: "";
  background: #6d4b2c;
  border: 3px solid #25150e;
  box-shadow: inset 0 3px #b17a42;
}

.gem-jar i {
  position: absolute;
  bottom: 8px;
  left: 9px;
  width: 14px;
  height: 18px;
  background: var(--jar-gem);
  clip-path: polygon(50% 0, 100% 32%, 82% 100%, 18% 100%, 0 32%);
  box-shadow: inset 4px 0 rgba(255, 255, 255, 0.38);
  filter: drop-shadow(0 0 0 transparent);
}

.gem-jar i:nth-child(2) {
  bottom: 11px;
  left: 24px;
  width: 12px;
  height: 15px;
  filter: brightness(0.78);
}

.gem-jar i:nth-child(3) {
  bottom: 26px;
  left: 16px;
  width: 11px;
  height: 14px;
  filter: brightness(1.12);
}

.gem-jar--red { --jar-gem: var(--red); }
.gem-jar--blue { --jar-gem: var(--blue); }
.gem-jar--green { --jar-gem: var(--green); }
.gem-jar--gold { --jar-gem: var(--yellow); }
.gem-jar--violet { --jar-gem: var(--violet); }
.gem-jar--cyan { --jar-gem: var(--cyan); }

.hanging-tools {
  position: absolute;
  z-index: 6;
  top: 12%;
  left: 20%;
  width: 120px;
  height: 195px;
  opacity: 0.82;
}

.chain {
  position: absolute;
  top: 0;
  width: 7px;
  background: repeating-linear-gradient(0deg, #77818a 0 5px, #20262c 5px 10px);
  border-right: 2px solid #101318;
}

.chain--one {
  left: 20px;
  height: 108px;
}

.chain--two {
  left: 73px;
  height: 74px;
}

.tongs {
  position: absolute;
  top: 97px;
  left: 8px;
  width: 35px;
  height: 66px;
  border-right: 7px solid #3e4750;
  border-left: 7px solid #3e4750;
  clip-path: polygon(0 0, 100% 0, 84% 100%, 58% 100%, 50% 44%, 42% 100%, 16% 100%);
}

.small-hammer {
  position: absolute;
  top: 66px;
  left: 62px;
  width: 18px;
  height: 83px;
  background: #704326;
  border: 3px solid #21130d;
  transform: rotate(9deg);
}

.small-hammer::before {
  position: absolute;
  top: -8px;
  left: -18px;
  width: 50px;
  height: 20px;
  content: "";
  background: #505963;
  border: 4px solid #171b20;
  box-shadow: inset 0 4px #77838e;
}

.forge {
  position: absolute;
  z-index: 4;
  bottom: -7%;
  left: 50%;
  width: clamp(230px, 27vw, 350px);
  height: clamp(260px, 46vh, 410px);
  transform: translateX(-50%);
}

.forge::before {
  position: absolute;
  z-index: -1;
  right: 10%;
  bottom: 12%;
  left: 10%;
  height: 44%;
  content: "";
  background: rgba(89, 231, 255, 0.1);
  box-shadow:
    0 0 0 12px rgba(55, 170, 205, 0.08),
    0 0 0 25px rgba(27, 108, 137, 0.05);
  animation: forge-aura 1.4s steps(2, end) infinite;
}

.forge__chimney {
  position: absolute;
  top: 0;
  left: 37%;
  width: 26%;
  height: 35%;
  background:
    repeating-linear-gradient(0deg, #252832 0 22px, #0c0d12 22px 27px),
    #252832;
  border: 6px solid #0b0c10;
  box-shadow: inset 5px 0 #3c414d, inset -6px 0 #15171d;
}

.forge__hood {
  position: absolute;
  z-index: 3;
  top: 24%;
  left: 14%;
  width: 72%;
  height: 24%;
  background: #272d36;
  border: 6px solid #0d1014;
  box-shadow: inset 0 6px #505965, inset 0 -7px #171b20, 7px 7px 0 rgba(0, 0, 0, 0.55);
  clip-path: polygon(16% 0, 84% 0, 100% 76%, 100% 100%, 0 100%, 0 76%);
}

.forge__body {
  position: absolute;
  right: 5%;
  bottom: 8%;
  left: 5%;
  height: 58%;
  background:
    repeating-linear-gradient(90deg, #3a3130 0 48px, #1a1517 48px 53px),
    #3a3130;
  border: 7px solid #100e11;
  box-shadow: inset 7px 0 #5c4840, inset -8px 0 #231b1b, 8px 8px 0 rgba(0, 0, 0, 0.52);
}

.forge__brick {
  position: absolute;
  height: 5px;
  background: #171315;
}

.forge__brick--one { top: 25%; right: 4%; left: 4%; }
.forge__brick--two { top: 52%; right: 0; left: 0; }
.forge__brick--three { top: 78%; right: 5%; left: 5%; }

.forge__mouth {
  position: absolute;
  z-index: 4;
  right: 18%;
  bottom: 12%;
  left: 18%;
  height: 55%;
  overflow: hidden;
  background: #060b10;
  border: 7px solid #11161d;
  border-top-color: #59616b;
  box-shadow:
    inset 0 0 0 5px #162d38,
    0 0 0 5px #0d1015,
    0 0 0 10px rgba(89, 231, 255, 0.12);
  clip-path: polygon(18% 0, 82% 0, 100% 26%, 100% 100%, 0 100%, 0 26%);
}

.forge__flame {
  position: absolute;
  bottom: -8px;
  left: 50%;
  display: block;
  transform: translateX(-50%);
  transform-origin: bottom;
  animation: forge-flame 0.72s steps(2, end) infinite alternate;
}

.forge__flame--back {
  width: 80%;
  height: 76%;
  background: var(--cyan-dark);
  clip-path: polygon(0 100%, 8% 48%, 25% 62%, 34% 8%, 49% 44%, 67% 0, 75% 55%, 92% 34%, 100% 100%);
}

.forge__flame--mid {
  width: 58%;
  height: 62%;
  background: var(--cyan);
  animation-delay: -0.23s;
  clip-path: polygon(0 100%, 14% 38%, 33% 62%, 49% 0, 63% 52%, 85% 28%, 100% 100%);
}

.forge__flame--front {
  width: 30%;
  height: 42%;
  background: var(--cyan-light);
  animation-delay: -0.41s;
  clip-path: polygon(0 100%, 20% 42%, 47% 0, 62% 58%, 82% 34%, 100% 100%);
}

.forge__spark {
  position: absolute;
  width: 6px;
  height: 6px;
  background: var(--cyan-light);
  box-shadow: 0 0 0 3px var(--cyan-dark);
  animation: forge-spark 1.8s steps(5, end) infinite;
}

.forge__spark--one { bottom: 20%; left: 23%; animation-delay: -0.3s; }
.forge__spark--two { bottom: 15%; left: 61%; animation-delay: -1.1s; }
.forge__spark--three { bottom: 12%; left: 45%; animation-delay: -1.55s; }

.forge__base {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 13%;
  background: #20252c;
  border: 7px solid #0c0e12;
  box-shadow: inset 0 6px #56606a, 7px 7px 0 rgba(0, 0, 0, 0.58);
}

.workbench {
  position: absolute;
  z-index: 10;
  right: -2%;
  bottom: -3%;
  left: -2%;
  height: 41%;
  overflow: hidden;
  background:
    repeating-linear-gradient(90deg, transparent 0 128px, #2a140d 128px 135px),
    repeating-linear-gradient(0deg, #5c2e1b 0 24px, #7a4125 24px 51px, #4b2417 51px 57px, #8e4d28 57px 84px);
  border-top: 10px solid #21100b;
  box-shadow: inset 0 8px #b06634, inset 0 14px #6f3921, 0 -8px 0 rgba(0, 0, 0, 0.5);
  transform: translate(calc(var(--scene-x) * -3px), calc(var(--scene-y) * -2px));
  transition: transform 120ms steps(3, end);
}

.workbench::before {
  position: absolute;
  inset: 15px 0 0;
  content: "";
  pointer-events: none;
  background: linear-gradient(0deg, rgba(14, 7, 5, 0.52), transparent 55%);
}

.workbench__plank {
  position: absolute;
  z-index: 1;
  display: block;
  height: 5px;
  background: #2b140e;
  box-shadow: 0 4px rgba(176, 98, 47, 0.25);
}

.workbench__plank--one { top: 32%; right: 0; left: 0; }
.workbench__plank--two { top: 69%; right: 0; left: 0; }

.workbench__nail {
  position: absolute;
  z-index: 3;
  width: 12px;
  height: 12px;
  background: #30363c;
  border: 3px solid #111418;
  box-shadow: inset 3px 0 #77828b;
}

.workbench__nail--one { top: 18%; left: 7%; }
.workbench__nail--two { right: 6%; bottom: 12%; }

.blueprint {
  position: absolute;
  z-index: 4;
  top: 8%;
  left: 50%;
  width: clamp(220px, 27vw, 360px);
  height: clamp(145px, 21vh, 210px);
  background:
    repeating-linear-gradient(0deg, transparent 0 18px, rgba(102, 71, 34, 0.18) 18px 20px),
    var(--paper);
  border: 5px solid #3a2112;
  box-shadow: inset 0 0 0 4px var(--paper-light), 8px 9px 0 rgba(24, 10, 7, 0.62);
  transform: translateX(-50%) rotate(-2deg);
  clip-path: polygon(3% 0, 97% 0, 100% 6%, 99% 94%, 96% 100%, 4% 100%, 0 95%, 1% 7%);
}

.blueprint__line {
  position: absolute;
  display: block;
  height: 4px;
  background: #835f32;
}

.blueprint__line--one { right: 8%; bottom: 24%; left: 8%; }
.blueprint__line--two { right: 19%; bottom: 14%; left: 19%; }

.blueprint__rune {
  position: absolute;
  top: 15%;
  right: 10%;
  color: #765126;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 1;
}

.unfinished-card {
  position: absolute;
  z-index: 8;
  top: 4%;
  left: 50%;
  width: clamp(108px, 10vw, 145px);
  aspect-ratio: 0.71;
  background: #edce83;
  border: 5px solid #352012;
  box-shadow:
    inset 0 0 0 4px #fff0b2,
    inset 0 0 0 8px #9d7137,
    8px 10px 0 rgba(28, 12, 8, 0.68);
  transform: translateX(-50%) rotate(4deg);
  clip-path: polygon(5% 0, 95% 0, 100% 5%, 100% 95%, 95% 100%, 5% 100%, 0 95%, 0 5%);
}

.unfinished-card__cost {
  position: absolute;
  z-index: 2;
  top: -7px;
  right: -7px;
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  color: #10242c;
  background: var(--cyan);
  border: 4px solid #18232a;
  font-weight: 900;
  box-shadow: inset 3px 3px var(--cyan-light), 4px 4px 0 #311b12;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.unfinished-card__slot {
  position: absolute;
  top: 14%;
  right: 16%;
  left: 16%;
  height: 48%;
  background:
    linear-gradient(135deg, #26202c 0 25%, #332c3b 25% 50%, #1b1922 50% 75%, #2b2632 75%);
  border: 4px solid #5e4326;
  box-shadow: inset 0 0 0 3px #19151d;
}

.unfinished-card__gem {
  position: absolute;
  z-index: 2;
  top: 26%;
  left: 50%;
  width: 33%;
  height: 30%;
  background:
    linear-gradient(135deg, var(--cyan-light) 0 22%, var(--cyan) 22% 54%, #1e91bc 54% 76%, #16465e 76%);
  box-shadow: 0 0 0 4px #152d38, 0 0 0 8px rgba(89, 231, 255, 0.16);
  clip-path: polygon(50% 0, 88% 24%, 100% 62%, 72% 100%, 28% 100%, 0 62%, 12% 24%);
  transform: translateX(-50%);
  animation: card-gem 1.6s steps(3, end) infinite;
}

.unfinished-card__line {
  position: absolute;
  right: 18%;
  left: 18%;
  height: 4px;
  background: #765126;
}

.unfinished-card__line--one { bottom: 27%; }
.unfinished-card__line--two { right: 28%; bottom: 20%; }
.unfinished-card__line--three { left: 30%; bottom: 13%; }

.gem-tray {
  position: absolute;
  z-index: 7;
  top: 24%;
  left: 69%;
  width: clamp(145px, 17vw, 230px);
  height: clamp(70px, 10vh, 96px);
  background: #282d34;
  border: 6px solid #111419;
  box-shadow: inset 0 0 0 5px #4d5861, 7px 8px 0 rgba(24, 10, 7, 0.55);
  transform: rotate(-5deg);
}

.tray-gem {
  --gem-color: var(--cyan);
  position: absolute;
  bottom: 18px;
  width: clamp(22px, 2.5vw, 34px);
  height: clamp(29px, 3.7vw, 46px);
  background: var(--gem-color);
  box-shadow: inset 6px 0 rgba(255, 255, 255, 0.32), 3px 4px 0 #0c1014;
  clip-path: polygon(50% 0, 100% 30%, 82% 100%, 18% 100%, 0 30%);
}

.tray-gem--red { --gem-color: var(--red); left: 8%; transform: rotate(-8deg); }
.tray-gem--blue { --gem-color: var(--blue); left: 27%; transform: rotate(5deg); }
.tray-gem--green { --gem-color: var(--green); left: 46%; transform: rotate(-3deg); }
.tray-gem--gold { --gem-color: var(--yellow); left: 64%; transform: rotate(8deg); }
.tray-gem--violet { --gem-color: var(--violet); left: 80%; transform: rotate(-5deg); }

.loupe {
  position: absolute;
  z-index: 8;
  bottom: 16%;
  left: 25%;
  width: 98px;
  height: 145px;
  transform: rotate(22deg);
}

.loupe__glass {
  position: absolute;
  top: 0;
  left: 0;
  width: 82px;
  height: 82px;
  background:
    linear-gradient(135deg, rgba(234, 255, 255, 0.58) 0 12%, rgba(72, 169, 191, 0.16) 12% 72%, rgba(14, 45, 55, 0.38) 72%);
  border: 9px solid #bd8738;
  box-shadow: inset 0 0 0 5px #243944, 6px 7px 0 rgba(28, 12, 8, 0.62);
  clip-path: polygon(28% 0, 72% 0, 100% 28%, 100% 72%, 72% 100%, 28% 100%, 0 72%, 0 28%);
}

.loupe__handle {
  position: absolute;
  top: 73px;
  left: 57px;
  width: 23px;
  height: 67px;
  background: #774024;
  border: 5px solid #24130d;
  box-shadow: inset 5px 0 #a25b2f;
}

.engraving-tool {
  position: absolute;
  z-index: 6;
  top: 56%;
  left: 33%;
  width: 150px;
  height: 32px;
  transform: rotate(-11deg);
}

.engraving-tool__handle {
  position: absolute;
  right: 0;
  width: 74%;
  height: 27px;
  background: #703c22;
  border: 4px solid #24130d;
  box-shadow: inset 0 4px #ac6032;
}

.engraving-tool__blade {
  position: absolute;
  top: 7px;
  left: 0;
  width: 35%;
  height: 13px;
  background: #9ca7ad;
  border: 3px solid #21262c;
  clip-path: polygon(0 50%, 22% 0, 100% 0, 100% 100%, 22% 100%);
}

.workshop-hammer {
  position: absolute;
  z-index: 7;
  right: 17%;
  bottom: 16%;
  width: 145px;
  height: 88px;
  transform: rotate(15deg);
}

.workshop-hammer__head {
  position: absolute;
  top: 0;
  left: 0;
  width: 76px;
  height: 38px;
  background: #48515b;
  border: 5px solid #15191e;
  box-shadow: inset 0 5px #808b94, 5px 5px 0 rgba(28, 12, 8, 0.55);
  clip-path: polygon(7% 0, 93% 0, 100% 22%, 94% 100%, 6% 100%, 0 78%, 0 20%);
}

.workshop-hammer__handle {
  position: absolute;
  top: 28px;
  left: 54px;
  width: 25px;
  height: 70px;
  background: #764126;
  border: 5px solid #25140e;
  box-shadow: inset 5px 0 #ab6032;
  transform: rotate(-33deg);
  transform-origin: top;
}

.pixel-motes {
  position: absolute;
  z-index: 12;
  inset: 0;
  pointer-events: none;
}

.pixel-motes i {
  position: absolute;
  top: var(--y);
  left: var(--x);
  width: 4px;
  height: 4px;
  background: #ffe6a0;
  box-shadow: 6px 0 rgba(89, 231, 255, 0.42);
  animation: mote-drift 5.4s steps(8, end) infinite;
  animation-delay: var(--delay);
}

.brand {
  position: absolute;
  z-index: 30;
  top: max(4.5vh, calc(env(safe-area-inset-top) + 18px));
  left: 50%;
  width: min(76vw, 760px);
  color: #fff1b3;
  text-align: center;
  transform: translateX(-50%);
  transform-origin: top left;
  transition:
    top 360ms steps(4, end),
    left 360ms steps(4, end),
    width 360ms steps(4, end),
    transform 360ms steps(4, end);
}

.brand__kicker {
  display: inline-block;
  margin: 0 0 -2px;
  padding: 4px 12px;
  color: #c8eefa;
  background: #111820;
  border: 3px solid #45515c;
  font-size: clamp(0.62rem, 1vw, 0.8rem);
  font-weight: 900;
  letter-spacing: 0.2em;
  text-indent: 0.2em;
  text-shadow: 2px 2px #05070a;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.62);
}

.logo-plaque {
  position: relative;
  padding: clamp(8px, 1.4vh, 15px) clamp(18px, 3vw, 40px);
  background:
    linear-gradient(0deg, #171b21 0 18%, #2c333c 18% 48%, #3a424c 48% 54%, #232a32 54% 84%, #15191e 84%),
    var(--iron);
  border: 5px solid #120e0b;
  outline: 5px solid var(--gold);
  outline-offset: -10px;
  box-shadow:
    inset 0 0 0 4px #626c75,
    inset 0 -7px #0d1014,
    8px 9px 0 rgba(0, 0, 0, 0.72),
    0 0 0 4px #2c190e;
  clip-path: polygon(16px 0, calc(100% - 16px) 0, 100% 16px, 100% calc(100% - 16px), calc(100% - 16px) 100%, 16px 100%, 0 calc(100% - 16px), 0 16px);
}

.logo-plaque__rivet {
  position: absolute;
  z-index: 4;
  width: 10px;
  height: 10px;
  background: var(--gold-light);
  border: 3px solid var(--gold-dark);
  box-shadow: 2px 2px #090a0c;
}

.logo-plaque__rivet--tl { top: 13px; left: 16px; }
.logo-plaque__rivet--tr { top: 13px; right: 16px; }
.logo-plaque__rivet--bl { bottom: 13px; left: 16px; }
.logo-plaque__rivet--br { right: 16px; bottom: 13px; }

.brand__title {
  position: relative;
  z-index: 2;
  margin: 0;
  color: var(--gold-light);
  font-family: var(--font-display);
  font-size: clamp(3.2rem, 7.3vw, 6.15rem);
  font-weight: 900;
  line-height: 0.92;
  letter-spacing: 0.035em;
  text-indent: 0.035em;
  text-transform: uppercase;
  -webkit-text-stroke: 2px #24150d;
  text-shadow:
    4px 0 #7b4a21,
    0 4px #7b4a21,
    -4px 0 #2c190f,
    0 -4px #fff0a6,
    7px 7px #090b0e;
}

.brand__initial {
  position: relative;
  display: inline-block;
  color: var(--cyan);
  text-shadow:
    4px 0 #17647c,
    0 4px #17647c,
    -4px 0 #123748,
    0 -4px var(--cyan-light),
    7px 7px #090b0e;
}

.brand__jewel {
  position: absolute;
  z-index: 4;
  top: -21%;
  left: 31%;
  width: 25%;
  height: 34%;
  background:
    linear-gradient(135deg, var(--cyan-light) 0 20%, var(--cyan) 20% 48%, #238eaf 48% 74%, #163e50 74%);
  box-shadow: 0 0 0 3px #111a20, 4px 4px 0 #07090c;
  clip-path: polygon(50% 0, 100% 35%, 76% 100%, 24% 100%, 0 35%);
  animation: logo-jewel 1.7s steps(3, end) infinite;
}

.brand__subtitle {
  position: relative;
  z-index: 3;
  margin: -3px auto 0;
  color: #2a170e;
  font-size: clamp(0.76rem, 1.4vw, 1rem);
  font-weight: 900;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  text-shadow: 1px 1px #ffe4a0;
}

.brand__subtitle span {
  display: inline-block;
  padding: 7px 22px 6px;
  background: var(--paper);
  border: 4px solid #3a2112;
  box-shadow: inset 0 3px var(--paper-light), 5px 5px 0 rgba(0, 0, 0, 0.66);
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 8px, calc(100% - 5px) 100%, 5px 100%, 0 8px);
}

.title-screen[data-phase="menu"] .brand {
  top: max(5vh, calc(env(safe-area-inset-top) + 14px));
  left: 4.5vw;
  width: min(49vw, 620px);
  transform: translateX(0) scale(0.92);
}

.intro-gate {
  position: absolute;
  z-index: 60;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

.intro-gate:focus {
  outline: 0;
}

.intro-prompt {
  position: absolute;
  right: 50%;
  bottom: max(6vh, calc(env(safe-area-inset-bottom) + 18px));
  display: grid;
  min-width: min(82vw, 285px);
  grid-template-columns: 34px 1fr 34px;
  align-items: center;
  gap: 11px;
  padding: 7px 10px;
  color: #fff4c2;
  background: transparent;
  border: 0;
  outline: 0;
  filter:
    drop-shadow(3px 0 #090a0d)
    drop-shadow(-3px 0 #090a0d)
    drop-shadow(0 3px #090a0d)
    drop-shadow(0 -3px #090a0d);
  transform: translateX(50%);
  animation: prompt-pulse 1.25s steps(2, end) infinite;
}

.intro-gate:focus-visible .intro-prompt {
  outline: 4px solid var(--cyan-light);
  outline-offset: 4px;
  background: rgba(10, 12, 16, 0.76);
  box-shadow: 0 0 0 8px #11151a;
}

.intro-prompt__gem {
  width: 26px;
  height: 32px;
  background:
    linear-gradient(135deg, var(--cyan-light) 0 24%, var(--cyan) 24% 56%, #247c99 56% 78%, #153a49 78%);
  box-shadow: 3px 3px #07090c;
  clip-path: polygon(50% 0, 100% 28%, 82% 100%, 18% 100%, 0 28%);
}

.intro-prompt__copy {
  display: grid;
  gap: 2px;
  line-height: 1;
  text-align: left;
}

.intro-prompt__copy strong {
  font-size: clamp(0.95rem, 2vw, 1.1rem);
  letter-spacing: 0.16em;
}

.intro-prompt__copy small {
  color: #a9c9d0;
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 0.2em;
}

.intro-prompt__chevrons {
  color: var(--gold-light);
  font-size: 1.55rem;
  font-weight: 900;
  letter-spacing: -0.22em;
  animation: chevron-step 0.8s steps(2, end) infinite;
}

.menu-stage {
  position: absolute;
  z-index: 50;
  top: 28%;
  right: clamp(24px, 5vw, 76px);
  width: min(370px, calc(100% - 32px));
  padding: 27px 24px 23px;
  color: var(--ink);
  background:
    repeating-linear-gradient(0deg, transparent 0 19px, rgba(111, 73, 31, 0.13) 19px 21px),
    var(--paper);
  border: 6px solid var(--iron-dark);
  outline: 4px solid var(--gold);
  outline-offset: -10px;
  box-shadow:
    inset 0 0 0 5px var(--paper-light),
    9px 10px 0 rgba(0, 0, 0, 0.7),
    0 0 0 4px #2a160d;
  clip-path: polygon(12px 0, calc(100% - 12px) 0, 100% 12px, 100% calc(100% - 12px), calc(100% - 12px) 100%, 12px 100%, 0 calc(100% - 12px), 0 12px);
  animation: panel-enter 330ms steps(5, end) both;
}

.menu-stage__clip {
  position: absolute;
  top: -6px;
  width: 36px;
  height: 18px;
  background: #4c5660;
  border: 4px solid #15191e;
  box-shadow: inset 0 4px #8c969e;
}

.menu-stage__clip--left { left: 24px; }
.menu-stage__clip--right { right: 24px; }

.menu-stage__heading {
  margin: 0 0 14px;
  color: #fbe1a0;
  background: var(--iron);
  border: 4px solid var(--iron-dark);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.28em;
  line-height: 26px;
  text-align: center;
  text-indent: 0.28em;
  text-shadow: 2px 2px #101318;
  box-shadow: inset 0 3px var(--iron-light), 4px 4px 0 #6a4625;
}

.title-menu {
  display: grid;
  gap: 11px;
}

.menu-button {
  position: relative;
  display: grid;
  width: 100%;
  min-height: 58px;
  grid-template-columns: 31px 1fr 24px;
  align-items: center;
  gap: 10px;
  padding: 8px 13px;
  color: #24150e;
  background:
    linear-gradient(0deg, #b57a3f 0 14%, #d9a85d 14% 86%, #f0c873 86%),
    #d9a85d;
  border: 4px solid #3a2114;
  box-shadow: inset 0 0 0 3px #ffe09a, 5px 5px 0 #5e3b21;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 80ms steps(2, end), filter 80ms steps(2, end);
}

.menu-button::after {
  position: absolute;
  inset: 4px;
  content: "";
  border: 2px solid rgba(91, 53, 25, 0.54);
  pointer-events: none;
}

.menu-button:hover {
  filter: brightness(1.12) saturate(1.08);
  transform: translate(-2px, -2px);
}

.menu-button:active {
  box-shadow: inset 0 0 0 3px #ffe09a, 2px 2px 0 #5e3b21;
  transform: translate(3px, 3px);
}

.menu-button--primary {
  background:
    linear-gradient(0deg, #b7823f 0 14%, #edc46f 14% 86%, #ffe49a 86%),
    #edc46f;
}

.menu-button__gem,
.game-dialog__gem {
  --gem-color: var(--cyan);
  display: block;
  width: 22px;
  height: 29px;
  background: var(--gem-color);
  box-shadow: inset 5px 0 rgba(255, 255, 255, 0.42), 3px 3px #312015;
  clip-path: polygon(50% 0, 100% 28%, 82% 100%, 18% 100%, 0 28%);
}

.menu-button__gem--cyan,
.game-dialog__gem--cyan { --gem-color: var(--cyan); }
.menu-button__gem--gold,
.game-dialog__gem--gold { --gem-color: var(--yellow); }
.menu-button__gem--violet,
.game-dialog__gem--violet { --gem-color: var(--violet); }

.menu-button__label {
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0.13em;
  text-align: left;
}

.menu-button__arrow {
  color: #6a3d20;
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 900;
  line-height: 1;
}

.menu-stage__hint {
  margin: 15px 0 0;
  color: #65421f;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-align: center;
}

.intro-back {
  position: absolute;
  z-index: 55;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: max(12px, env(safe-area-inset-left));
  min-width: 82px;
  min-height: 44px;
  padding: 7px 12px;
  color: #d7e4e7;
  background: rgba(12, 14, 18, 0.58);
  border: 2px solid rgba(147, 169, 176, 0.62);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.52);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  opacity: 0.58;
  cursor: pointer;
  touch-action: manipulation;
  transition: opacity 100ms steps(2, end), transform 100ms steps(2, end);
}

.intro-back span {
  color: var(--cyan);
  font-size: 1.15rem;
}

.intro-back:hover,
.intro-back:focus-visible {
  opacity: 1;
}

.intro-back:active {
  transform: translate(2px, 2px);
}

.intro-back:focus-visible {
  outline: 3px solid var(--cyan-light);
  outline-offset: 3px;
}

.menu-button:focus-visible,
.dialog-button:focus-visible,
.option-row:has(input:focus-visible) {
  outline: 3px solid #0b0d11;
  outline-offset: 2px;
  box-shadow: 0 0 0 7px var(--cyan), 0 0 0 11px #0b0d11;
}

.build-mark {
  position: absolute;
  z-index: 55;
  right: max(13px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  margin: 0;
  color: #9ba7ad;
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-shadow: 2px 2px #08090c;
}

.build-mark span {
  color: var(--cyan);
}

.game-dialog {
  width: min(92vw, 570px);
  max-width: 570px;
  max-height: min(88vh, 720px);
  padding: 0;
  overflow: visible;
  color: var(--ink);
  background: transparent;
  border: 0;
}

.game-dialog::backdrop {
  background: rgba(4, 5, 8, 0.82);
}

.game-dialog[open] {
  animation: dialog-enter 180ms steps(3, end) both;
}

.game-dialog__frame {
  position: relative;
  max-height: min(88vh, 720px);
  padding: clamp(27px, 5vw, 43px);
  overflow-y: auto;
  background:
    repeating-linear-gradient(0deg, transparent 0 19px, rgba(111, 73, 31, 0.11) 19px 21px),
    var(--paper);
  border: 7px solid var(--iron-dark);
  outline: 4px solid var(--gold);
  outline-offset: -11px;
  box-shadow: inset 0 0 0 5px var(--paper-light), 10px 11px 0 rgba(0, 0, 0, 0.72);
  clip-path: polygon(12px 0, calc(100% - 12px) 0, 100% 12px, 100% calc(100% - 12px), calc(100% - 12px) 100%, 12px 100%, 0 calc(100% - 12px), 0 12px);
}

.game-dialog__gem {
  position: absolute;
  top: -15px;
  left: 50%;
  width: 32px;
  height: 42px;
  transform: translateX(-50%);
}

.game-dialog__eyebrow {
  margin: 0 0 8px;
  color: #4a3018;
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.2em;
  text-align: center;
}

.game-dialog h2 {
  margin: 0 0 17px;
  font-size: clamp(1.25rem, 4.5vw, 1.75rem);
  line-height: 1.3;
  text-align: center;
  text-shadow: 2px 2px #ffe5a0;
}

.game-dialog p:not(.game-dialog__eyebrow) {
  margin: 0 0 24px;
  font-weight: 700;
  line-height: 1.8;
}

.dialog-button {
  min-height: 50px;
  padding: 10px 18px;
  color: #fff1c1;
  background: var(--iron);
  border: 4px solid var(--iron-dark);
  box-shadow: inset 0 4px var(--iron-light), 5px 5px 0 #6a4524;
  font-weight: 900;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.dialog-button:hover {
  color: #15191e;
  background: var(--gold-light);
  box-shadow: inset 0 4px #fff4c0, 5px 5px 0 #6a4524;
}

.dialog-button--quiet {
  color: #2d1c12;
  background: #bd8d50;
}

.options-form {
  display: grid;
  gap: 12px;
}

.options-form h2 {
  margin-bottom: 6px;
}

.option-row {
  display: flex;
  min-height: 66px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 11px 13px;
  background: #c99d5c;
  border: 4px solid #614322;
  box-shadow: inset 0 3px #f2cd80;
  cursor: pointer;
}

.option-row:has(input:disabled),
.option-row input:disabled {
  cursor: not-allowed;
}

.option-row:has(input:disabled) {
  filter: saturate(0.72);
}

.option-row > span {
  display: grid;
  gap: 4px;
}

.option-row strong {
  font-size: 0.92rem;
}

.option-row small {
  color: #3a2614;
  font-size: 0.69rem;
  font-weight: 700;
  line-height: 1.35;
}

.option-row input {
  position: relative;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  margin: 0;
  appearance: none;
  background: #f4d78f;
  border: 4px solid #3c2817;
  box-shadow: inset 3px 3px #a57a3e;
  cursor: pointer;
}

.option-row input:checked {
  background: var(--cyan);
  box-shadow: inset 4px 4px var(--cyan-light), inset -4px -4px var(--cyan-dark);
}

.option-row input:checked::after {
  position: absolute;
  top: 4px;
  left: 8px;
  width: 7px;
  height: 13px;
  content: "";
  border-right: 5px solid #13232a;
  border-bottom: 5px solid #13232a;
  transform: rotate(45deg);
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 13px;
  margin-top: 9px;
}

html[data-large-text="true"] .menu-button__label {
  font-size: 1.13rem;
}

html[data-large-text="true"] .game-dialog,
html[data-large-text="true"] .option-row strong {
  font-size: 1.08rem;
}

html[data-large-text="true"] .option-row small {
  font-size: 0.78rem;
}

@keyframes forge-flame {
  from { transform: translateX(-50%) scaleX(0.92) scaleY(1); }
  to { transform: translateX(-50%) scaleX(1.06) scaleY(0.88); }
}

@keyframes forge-aura {
  0%, 100% { opacity: 0.62; }
  50% { opacity: 1; }
}

@keyframes forge-spark {
  0% { opacity: 0; transform: translate(0, 0); }
  15% { opacity: 1; }
  70% { opacity: 1; transform: translate(8px, -76px); }
  100% { opacity: 0; transform: translate(-4px, -108px); }
}

@keyframes card-gem {
  0%, 100% { filter: brightness(0.88); }
  50% { filter: brightness(1.35); }
}

@keyframes logo-jewel {
  0%, 66%, 100% { filter: brightness(1); }
  33% { filter: brightness(1.55); }
}

@keyframes mote-drift {
  0% { opacity: 0; transform: translate(0, 16px); }
  20%, 75% { opacity: 0.74; }
  100% { opacity: 0; transform: translate(8px, -38px); }
}

@keyframes prompt-pulse {
  0%, 100% { filter: brightness(0.82); }
  50% { filter: brightness(1.16); }
}

@keyframes chevron-step {
  0%, 100% { transform: translateX(-3px); }
  50% { transform: translateX(3px); }
}

@keyframes panel-enter {
  from { opacity: 0; transform: translate(32px, 16px); }
  to { opacity: 1; transform: translate(0, 0); }
}

@keyframes dialog-enter {
  from { opacity: 0; transform: translateY(18px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 900px) {
  .hanging-tools {
    left: 14%;
    transform: scale(0.82);
    transform-origin: top left;
  }

  .shelf {
    width: 210px;
  }

  .shelf--left { left: -20px; }
  .shelf--right { right: -20px; }

  .title-screen[data-phase="menu"] .brand {
    left: 3vw;
    width: 48vw;
    transform: none;
  }
}

@media (max-width: 700px) {
  .stone-wall {
    bottom: 38%;
  }

  .timber--left { left: 2%; }
  .timber--right { right: 2%; }
  .timber--top { right: 1%; left: 1%; }

  .shelf {
    top: 28%;
    width: 190px;
    transform: scale(0.86);
  }

  .shelf--left {
    left: -91px;
    transform-origin: left center;
  }

  .shelf--right {
    right: -91px;
    transform-origin: right center;
  }

  .hanging-tools {
    display: none;
  }

  .forge {
    bottom: -3%;
    width: clamp(205px, 55vw, 270px);
    height: clamp(255px, 41vh, 340px);
  }

  .workbench {
    height: 43%;
  }

  .blueprint {
    width: min(64vw, 270px);
  }

  .unfinished-card {
    width: clamp(96px, 27vw, 122px);
  }

  .gem-tray {
    top: 33%;
    left: 73%;
    width: 150px;
    transform: rotate(-5deg) scale(0.82);
  }

  .loupe {
    left: 8%;
    transform: rotate(22deg) scale(0.75);
  }

  .engraving-tool {
    top: 65%;
    left: 18%;
    transform: rotate(-11deg) scale(0.82);
  }

  .workshop-hammer {
    right: 3%;
    transform: rotate(15deg) scale(0.8);
  }

  .brand {
    top: max(3vh, calc(env(safe-area-inset-top) + 12px));
    width: calc(100% - 24px);
  }

  .brand__title {
    font-size: clamp(2.55rem, 12.3vw, 4.7rem);
    letter-spacing: 0.015em;
    text-indent: 0.015em;
  }

  .logo-plaque {
    padding-right: 17px;
    padding-left: 17px;
  }

  .brand__subtitle {
    font-size: clamp(0.69rem, 2.8vw, 0.85rem);
  }

  .title-screen[data-phase="menu"] .brand {
    top: max(2vh, calc(env(safe-area-inset-top) + 8px));
    left: 50%;
    width: calc(100% - 30px);
    transform: translateX(-50%) scale(0.76);
    transform-origin: top center;
  }

  .menu-stage {
    top: auto;
    right: auto;
    bottom: max(64px, calc(env(safe-area-inset-bottom) + 56px));
    left: 50%;
    width: min(calc(100% - 24px), 390px);
    padding: 24px 19px 19px;
    transform: translateX(-50%);
    animation-name: panel-enter-mobile;
  }

  .menu-button {
    min-height: 54px;
  }

  .menu-stage__hint {
    display: none;
  }

  .build-mark {
    right: max(10px, env(safe-area-inset-right));
    left: auto;
  }
}

@keyframes panel-enter-mobile {
  from { opacity: 0; transform: translate(-50%, 28px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (max-width: 420px) {
  .dialog-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .dialog-button {
    width: 100%;
  }
}

@media (max-width: 380px) {
  .brand__kicker {
    font-size: 0.55rem;
    letter-spacing: 0.13em;
    text-indent: 0.13em;
  }

  .brand__title {
    font-size: clamp(2.25rem, 12vw, 3rem);
  }

  .brand__subtitle span {
    padding-right: 13px;
    padding-left: 13px;
  }

  .intro-prompt {
    min-width: min(calc(100% - 32px), 285px);
  }

  .menu-stage {
    padding-right: 15px;
    padding-left: 15px;
  }

  .menu-button {
    grid-template-columns: 27px 1fr 20px;
    gap: 7px;
    padding-right: 9px;
    padding-left: 9px;
  }

  .menu-button__label {
    font-size: 0.91rem;
  }
}

@media (max-height: 540px) and (orientation: landscape) {
  .stone-wall {
    bottom: 36%;
  }

  .timber--top {
    top: 1%;
    height: 34px;
  }

  .shelf {
    top: 19%;
    height: 92px;
    transform: scale(0.68);
  }

  .shelf--left {
    left: -35px;
    transform-origin: left center;
  }

  .shelf--right {
    right: -35px;
    transform-origin: right center;
  }

  .forge {
    bottom: -14%;
    width: clamp(190px, 27vw, 250px);
    height: clamp(210px, 70vh, 300px);
  }

  .workbench {
    height: 44%;
  }

  .blueprint {
    top: 6%;
    width: min(30vw, 250px);
    height: 122px;
  }

  .unfinished-card {
    top: 2%;
    width: min(13vw, 102px);
  }

  .gem-tray {
    top: 19%;
    transform: rotate(-5deg) scale(0.7);
  }

  .loupe {
    top: 12%;
    bottom: auto;
    transform: rotate(22deg) scale(0.62);
  }

  .engraving-tool,
  .workshop-hammer {
    display: none;
  }

  .brand,
  .title-screen[data-phase="menu"] .brand {
    top: max(4vh, calc(env(safe-area-inset-top) + 8px));
    left: max(18px, calc(env(safe-area-inset-left) + 10px));
    width: min(51vw, 530px);
    transform: none;
  }

  .brand__kicker {
    padding: 3px 8px;
    font-size: 0.52rem;
  }

  .brand__title {
    font-size: clamp(2rem, 6.2vw, 3.45rem);
  }

  .logo-plaque {
    padding: 7px 15px;
  }

  .brand__subtitle span {
    padding: 4px 12px;
  }

  .intro-prompt {
    right: auto;
    bottom: max(14px, calc(env(safe-area-inset-bottom) + 8px));
    left: max(19px, calc(env(safe-area-inset-left) + 10px));
    min-width: min(48vw, 300px);
    padding: 7px 11px;
    transform: none;
  }

  .menu-stage {
    top: 50%;
    right: max(16px, calc(env(safe-area-inset-right) + 9px));
    bottom: auto;
    left: auto;
    width: min(42vw, 350px);
    padding: 20px 16px 16px;
    transform: translateY(-50%);
    animation-name: panel-enter-landscape;
  }

  .menu-stage__heading {
    margin-bottom: 9px;
    line-height: 22px;
  }

  .title-menu {
    gap: 8px;
  }

  .menu-button {
    min-height: 46px;
    grid-template-columns: 24px 1fr 17px;
    gap: 7px;
    padding: 5px 8px;
  }

  .menu-button__gem {
    width: 18px;
    height: 24px;
  }

  .menu-button__label {
    font-size: clamp(0.72rem, 2vw, 0.95rem);
  }

  .menu-stage__hint {
    display: none;
  }
}

@keyframes panel-enter-landscape {
  from { opacity: 0; transform: translate(26px, calc(-50% + 12px)); }
  to { opacity: 1; transform: translate(0, -50%); }
}

@media (max-height: 390px) and (orientation: landscape) {
  .menu-stage {
    padding: 15px 13px 12px;
  }

  .menu-stage__clip {
    display: none;
  }

  .menu-stage__heading {
    margin-bottom: 6px;
    font-size: 0.67rem;
    line-height: 19px;
  }

  .title-menu {
    gap: 6px;
  }

  .menu-button {
    min-height: 43px;
  }

  .brand__subtitle {
    margin-top: -5px;
    font-size: 0.62rem;
  }
}

/* Home: underground artisan outpost */
.home-screen {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  overflow: hidden;
  color: #fff3c4;
  background: #0b0a10;
  image-rendering: pixelated;
  animation: home-enter 260ms steps(4, end) both;
}

.home-scroll {
  position: relative;
  z-index: 10;
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-color: #59636d #111318;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.home-screen::before {
  position: absolute;
  z-index: 1;
  inset: 0;
  content: "";
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(2, 3, 5, 0.64) 0 3%, transparent 3% 97%, rgba(2, 3, 5, 0.64) 97%),
    linear-gradient(0deg, rgba(2, 3, 5, 0.54) 0 2%, transparent 2% 96%, rgba(2, 3, 5, 0.62) 96%);
  box-shadow: inset 0 0 0 4px #050508;
}

.home-screen::after {
  position: absolute;
  z-index: 2;
  inset: 0;
  content: "";
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 4px 4px;
  mix-blend-mode: screen;
}

.home-cavern {
  position: absolute;
  z-index: 0;
  inset: 0;
  overflow: hidden;
  background:
    repeating-linear-gradient(90deg, transparent 0 92px, #0c0b11 92px 97px),
    repeating-linear-gradient(0deg, #1d1a24 0 42px, #100f16 42px 47px, #292632 47px 53px, #17151e 53px 96px);
}

.home-cavern::before {
  position: absolute;
  inset: 0;
  content: "";
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.62), transparent 22% 78%, rgba(0, 0, 0, 0.62)),
    linear-gradient(0deg, rgba(10, 7, 8, 0.72), transparent 38% 82%, rgba(0, 0, 0, 0.5));
}

.home-cavern__strata {
  position: absolute;
  display: block;
  height: 7px;
  background: #3a303c;
  box-shadow: 0 5px #0a090e;
  transform: skewY(-4deg);
}

.home-cavern__strata--one {
  top: 31%;
  right: 2%;
  left: 2%;
}

.home-cavern__strata--two {
  right: -4%;
  bottom: 22%;
  left: -4%;
  transform: skewY(3deg);
}

.home-cavern__beam {
  position: absolute;
  top: 0;
  bottom: 0;
  width: clamp(38px, 5vw, 66px);
  background:
    repeating-linear-gradient(0deg, #3b1d13 0 15px, #6d3921 15px 42px, #9a572d 42px 47px, #552a1a 47px 74px);
  border: 5px solid #1c0d09;
  box-shadow: inset 5px 0 #a55d30, inset -6px 0 #2a140e, 7px 0 rgba(0, 0, 0, 0.42);
}

.home-cavern__beam--left { left: 6%; }
.home-cavern__beam--right { right: 6%; }

.home-cavern__crystal {
  position: absolute;
  bottom: 3%;
  width: 34px;
  height: 86px;
  background: var(--cyan);
  box-shadow: inset 9px 0 rgba(255, 255, 255, 0.38), 5px 6px #090b0e;
  clip-path: polygon(50% 0, 100% 24%, 82% 100%, 18% 100%, 0 24%);
  animation: home-crystal 2s steps(3, end) infinite;
}

.home-cavern__crystal--blue {
  left: 2.5%;
}

.home-cavern__crystal--violet {
  right: 2.5%;
  height: 68px;
  background: var(--violet);
  animation-delay: -0.8s;
}

.home-cavern__lamp {
  position: absolute;
  top: 13%;
  left: 50%;
  width: 20px;
  height: 32px;
  background: var(--gold-light);
  border: 5px solid #23272d;
  box-shadow:
    0 -54px 0 -8px #555e66,
    0 -29px 0 -8px #555e66,
    0 0 0 8px rgba(255, 211, 79, 0.12),
    0 0 0 18px rgba(255, 211, 79, 0.05);
  transform: translateX(-50%);
  animation: home-lamp 1.4s steps(2, end) infinite;
}

.home-header {
  position: relative;
  z-index: 20;
  display: grid;
  width: min(95vw, 1180px);
  min-height: 112px;
  grid-template-columns: minmax(126px, 0.7fr) minmax(300px, 2.6fr) minmax(126px, 0.7fr);
  align-items: center;
  gap: 20px;
  margin: 0 auto;
  padding: max(15px, env(safe-area-inset-top)) 0 8px;
}

.home-brand {
  min-width: 0;
  text-align: center;
}

.home-brand p {
  display: inline-block;
  margin: 0 0 -2px;
  padding: 3px 12px;
  color: #bdebf5;
  background: var(--iron-dark);
  border: 3px solid var(--iron-light);
  font-size: 0.61rem;
  font-weight: 900;
  letter-spacing: 0.2em;
  text-indent: 0.2em;
  text-shadow: 2px 2px #06080a;
  box-shadow: 4px 4px rgba(0, 0, 0, 0.56);
}

.home-brand h1 {
  margin: 0;
  padding: 8px 20px 7px;
  color: var(--gold-light);
  background:
    linear-gradient(0deg, #171b21 0 22%, #313944 22% 78%, #4b5661 78%),
    var(--iron);
  border: 5px solid #15100d;
  outline: 4px solid var(--gold);
  outline-offset: -9px;
  box-shadow: inset 0 -5px #11151a, 6px 7px rgba(0, 0, 0, 0.62);
  font-size: clamp(1.35rem, 3.1vw, 2.25rem);
  letter-spacing: 0.13em;
  text-indent: 0.13em;
  text-shadow: 3px 3px #4c2d18;
  clip-path: polygon(10px 0, calc(100% - 10px) 0, 100% 10px, 100% calc(100% - 10px), calc(100% - 10px) 100%, 10px 100%, 0 calc(100% - 10px), 0 10px);
}

.home-brand > span {
  display: inline-block;
  margin-top: -1px;
  padding: 4px 14px;
  color: #392311;
  background: var(--paper);
  border: 3px solid #3a2112;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  box-shadow: 4px 4px rgba(0, 0, 0, 0.48);
}

.home-nav-button {
  min-height: 48px;
  padding: 9px 12px;
  color: #dce9eb;
  background: rgba(30, 35, 42, 0.93);
  border: 4px solid #11151a;
  box-shadow: inset 0 4px #66727c, 5px 5px rgba(0, 0, 0, 0.55);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  cursor: pointer;
  touch-action: manipulation;
}

.home-nav-button:last-child {
  justify-self: end;
}

.home-nav-button span {
  color: var(--cyan);
  font-size: 1.05rem;
}

.home-nav-button:hover {
  color: #15191e;
  background: var(--gold-light);
}

.home-nav-button:active {
  box-shadow: inset 0 3px #66727c, 2px 2px rgba(0, 0, 0, 0.55);
  transform: translate(3px, 3px);
}

.home-hub {
  position: absolute;
  z-index: 10;
  top: 122px;
  right: 0;
  bottom: calc(70px + env(safe-area-inset-bottom));
  left: 0;
  display: grid;
  place-items: stretch center;
}

.facility-grid {
  display: grid;
  width: min(94vw, 1120px);
  height: 100%;
  min-height: 390px;
  grid-template-areas:
    "merchant mine board"
    "workshop mine house";
  grid-template-columns: minmax(170px, 0.88fr) minmax(290px, 1.35fr) minmax(170px, 0.88fr);
  grid-template-rows: repeat(2, minmax(160px, 1fr));
  gap: clamp(10px, 1.5vw, 18px);
}

.facility-card {
  --facility-accent: var(--gold);
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  color: #fff4c6;
  background: #171820;
  border: 5px solid #111015;
  outline: 3px solid #6b4b28;
  outline-offset: -9px;
  box-shadow: inset 0 0 0 4px #3e414b, 7px 8px rgba(0, 0, 0, 0.62);
  cursor: pointer;
  touch-action: manipulation;
  transition: filter 100ms steps(2, end), transform 100ms steps(2, end);
}

.facility-card--mine { grid-area: mine; --facility-accent: var(--cyan); }
.facility-card--workshop { grid-area: workshop; --facility-accent: #63dcf3; }
.facility-card--merchant { grid-area: merchant; --facility-accent: var(--violet); }
.facility-card--house { grid-area: house; --facility-accent: var(--gold-light); }
.facility-card--board { grid-area: board; --facility-accent: #89939a; }

.facility-card:hover {
  filter: brightness(1.18) saturate(1.08);
  transform: translateY(-3px);
}

.facility-card:active {
  transform: translate(3px, 3px);
}

.facility-card:focus-visible,
.home-nav-button:focus-visible {
  outline: 4px solid var(--cyan-light);
  outline-offset: 3px;
  box-shadow: 0 0 0 8px #0b0e12, 7px 8px rgba(0, 0, 0, 0.62);
}

.facility-card__art {
  position: absolute;
  inset: 0 0 66px;
  display: block;
  overflow: hidden;
  background:
    repeating-linear-gradient(90deg, transparent 0 52px, rgba(8, 8, 12, 0.55) 52px 57px),
    repeating-linear-gradient(0deg, #292530 0 34px, #100f15 34px 39px, #1c1a23 39px 72px);
}

.facility-card__art::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 7px;
  content: "";
  background: var(--facility-accent);
  box-shadow: 0 -4px rgba(0, 0, 0, 0.55);
  opacity: 0.72;
}

.facility-card__copy {
  position: absolute;
  z-index: 8;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  height: 67px;
  align-content: center;
  gap: 2px;
  padding: 8px 13px;
  color: #24150e;
  background:
    repeating-linear-gradient(0deg, transparent 0 15px, rgba(111, 73, 31, 0.14) 15px 17px),
    var(--paper);
  border-top: 5px solid #2b1a11;
  box-shadow: inset 0 4px var(--paper-light);
  text-align: left;
}

.facility-card__copy strong {
  font-size: clamp(0.95rem, 1.7vw, 1.28rem);
  letter-spacing: 0.16em;
}

.facility-card__copy small {
  color: #4d321a;
  font-size: 0.67rem;
  font-weight: 900;
  letter-spacing: 0.06em;
}

.facility-card__badge {
  position: absolute;
  z-index: 12;
  top: 12px;
  right: 10px;
  padding: 4px 7px;
  color: #fff1ba;
  background: rgba(21, 25, 31, 0.92);
  border: 3px solid var(--gold);
  box-shadow: 3px 3px rgba(0, 0, 0, 0.58);
  font-size: 0.56rem;
  font-weight: 900;
  letter-spacing: 0.06em;
}

.facility-card__badge--open {
  color: #102028;
  background: var(--cyan);
  border-color: var(--cyan-light);
}

.facility-card__badge--locked {
  color: #d7dde0;
  background: #30363d;
  border-color: #7f8990;
}

/* Mine */
.facility-card--mine .facility-card__art {
  background:
    linear-gradient(90deg, rgba(5, 7, 10, 0.72), transparent 24% 76%, rgba(5, 7, 10, 0.72)),
    repeating-linear-gradient(0deg, #282731 0 43px, #111017 43px 49px, #34313b 49px 88px);
}

.facility-card--mine .facility-card__art i:nth-child(1) {
  position: absolute;
  top: 12%;
  right: 12%;
  bottom: 0;
  left: 12%;
  background: #06080c;
  border: clamp(13px, 2vw, 24px) solid #3c3c46;
  border-bottom: 0;
  box-shadow: inset 0 0 0 7px #11151b, 0 0 0 6px #131217;
  clip-path: polygon(18% 0, 82% 0, 100% 18%, 100% 100%, 0 100%, 0 18%);
}

.facility-card--mine .facility-card__art i:nth-child(2) {
  position: absolute;
  z-index: 3;
  right: 25%;
  bottom: -8%;
  left: 25%;
  height: 58%;
  background:
    linear-gradient(76deg, transparent 0 40%, #7e858b 40% 45%, transparent 45% 55%, #7e858b 55% 60%, transparent 60%),
    repeating-linear-gradient(0deg, transparent 0 19px, #6d4a2c 19px 25px);
  clip-path: polygon(35% 0, 65% 0, 100% 100%, 0 100%);
}

.facility-card--mine .facility-card__art i:nth-child(3) {
  position: absolute;
  z-index: 4;
  top: 30%;
  left: 22%;
  width: clamp(24px, 4vw, 46px);
  height: clamp(43px, 7vw, 78px);
  background: var(--cyan);
  box-shadow: inset 8px 0 var(--cyan-light), 5px 5px #071015;
  clip-path: polygon(50% 0, 100% 28%, 82% 100%, 18% 100%, 0 28%);
  animation: home-crystal 1.7s steps(3, end) infinite;
}

/* Workshop */
.facility-card--workshop .facility-card__art {
  background:
    repeating-linear-gradient(90deg, transparent 0 62px, #24120c 62px 67px),
    repeating-linear-gradient(0deg, #5f301d 0 32px, #321911 32px 38px, #784123 38px 70px);
}

.facility-card--workshop .facility-card__art i:nth-child(1) {
  position: absolute;
  right: 10%;
  bottom: 0;
  left: 10%;
  height: 72%;
  background: #343b43;
  border: 6px solid #111419;
  box-shadow: inset 0 6px #69747d;
  clip-path: polygon(16% 0, 84% 0, 100% 22%, 100% 100%, 0 100%, 0 22%);
}

.facility-card--workshop .facility-card__art i:nth-child(2) {
  position: absolute;
  z-index: 3;
  bottom: 8%;
  left: 22%;
  width: 34%;
  height: 47%;
  background: var(--cyan);
  border: 6px solid #111820;
  box-shadow: inset 0 0 0 5px #174d61, 0 0 0 5px rgba(89, 231, 255, 0.14);
  clip-path: polygon(20% 0, 80% 0, 100% 25%, 100% 100%, 0 100%, 0 25%);
  animation: home-lamp 1.2s steps(2, end) infinite;
}

.facility-card--workshop .facility-card__art i:nth-child(3) {
  position: absolute;
  z-index: 4;
  right: 16%;
  bottom: 12%;
  width: 28%;
  height: 57%;
  background: var(--paper);
  border: 5px solid #342014;
  box-shadow: inset 0 0 0 4px var(--paper-light), 5px 5px rgba(0, 0, 0, 0.55);
  transform: rotate(5deg);
}

/* Merchant */
.facility-card--merchant .facility-card__art {
  background:
    repeating-linear-gradient(135deg, #5f2d74 0 28px, #d09a3e 28px 56px),
    var(--violet);
}

.facility-card--merchant .facility-card__art::before {
  position: absolute;
  z-index: 2;
  right: 6%;
  bottom: 0;
  left: 6%;
  height: 66%;
  content: "";
  background: #51301f;
  border: 6px solid #21130d;
  box-shadow: inset 0 6px #a15c31;
}

.facility-card--merchant .facility-card__art i {
  position: absolute;
  z-index: 4;
  bottom: 19%;
  width: 24px;
  height: 38px;
  background: #173c48;
  border: 4px solid #77949a;
  box-shadow: inset 5px 0 rgba(255, 255, 255, 0.28), 4px 4px #1b110d;
}

.facility-card--merchant .facility-card__art i:nth-child(1) { left: 18%; }
.facility-card--merchant .facility-card__art i:nth-child(2) { left: calc(50% - 12px); background: #4b254e; }
.facility-card--merchant .facility-card__art i:nth-child(3) { right: 18%; background: #5a4b18; }

/* House */
.facility-card--house .facility-card__art {
  background:
    repeating-linear-gradient(90deg, transparent 0 59px, #30170f 59px 65px),
    repeating-linear-gradient(0deg, #744023 0 31px, #2b160f 31px 37px, #92502a 37px 68px);
}

.facility-card--house .facility-card__art i:nth-child(1) {
  position: absolute;
  z-index: 3;
  top: 8%;
  right: 9%;
  left: 9%;
  height: 38%;
  background: #343943;
  border: 6px solid #12151a;
  box-shadow: inset 0 6px #68727a;
  clip-path: polygon(50% 0, 100% 72%, 92% 100%, 8% 100%, 0 72%);
}

.facility-card--house .facility-card__art i:nth-child(2) {
  position: absolute;
  z-index: 4;
  bottom: 0;
  left: 18%;
  width: 27%;
  height: 52%;
  background: #3b2116;
  border: 5px solid #1a0e0a;
  box-shadow: inset 5px 0 #78452a;
}

.facility-card--house .facility-card__art i:nth-child(3) {
  position: absolute;
  z-index: 4;
  right: 17%;
  bottom: 18%;
  width: 29%;
  height: 36%;
  background: var(--gold-light);
  border: 6px solid #24170f;
  box-shadow: inset 0 0 0 5px #bd6f2f, 0 0 0 5px rgba(255, 211, 79, 0.09);
  animation: home-lamp 1.8s steps(2, end) infinite;
}

/* Board */
.facility-card--board .facility-card__art {
  filter: saturate(0.65);
}

.facility-card--board .facility-card__art i:nth-child(1) {
  position: absolute;
  top: 14%;
  right: 10%;
  bottom: 5%;
  left: 10%;
  background: #63391f;
  border: 7px solid #23140d;
  box-shadow: inset 0 0 0 5px #9d6032, 6px 6px rgba(0, 0, 0, 0.5);
}

.facility-card--board .facility-card__art i:nth-child(2),
.facility-card--board .facility-card__art i:nth-child(3) {
  position: absolute;
  z-index: 3;
  top: 29%;
  left: 22%;
  width: 28%;
  height: 42%;
  background: #d5b574;
  border: 3px solid #452b17;
  transform: rotate(-5deg);
}

.facility-card--board .facility-card__art i:nth-child(3) {
  right: 19%;
  left: auto;
  transform: rotate(6deg);
}

.home-status {
  position: fixed;
  z-index: 30;
  right: 50%;
  bottom: env(safe-area-inset-bottom);
  display: grid;
  width: min(92vw, 560px);
  min-height: 48px;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  color: #f7e7b4;
  background: rgba(20, 24, 30, 0.94);
  border: 4px solid #0d1014;
  outline: 3px solid var(--gold);
  box-shadow: 6px 6px rgba(0, 0, 0, 0.56);
  transform: translateX(50%);
}

.home-status__gem {
  width: 25px;
  height: 31px;
  background: var(--cyan);
  box-shadow: inset 6px 0 var(--cyan-light), 3px 3px #080b0e;
  clip-path: polygon(50% 0, 100% 28%, 82% 100%, 18% 100%, 0 28%);
}

.home-status p {
  display: grid;
  gap: 1px;
  margin: 0;
}

.home-status strong {
  font-size: 0.76rem;
  letter-spacing: 0.12em;
}

.home-status small,
.home-status__stage {
  color: #aabcc0;
  font-size: 0.57rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.facility-dialog__note {
  padding: 10px 12px;
  color: #38230f;
  background: #c79852;
  border: 4px solid #62421f;
  box-shadow: inset 0 3px #f4d487;
  font-size: 0.78rem;
}

html[data-large-text="true"] .facility-card__copy strong {
  font-size: 1.2rem;
}

html[data-large-text="true"] .facility-card__copy small,
html[data-large-text="true"] .facility-card__badge {
  font-size: 0.68rem;
}

@keyframes home-enter {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes home-crystal {
  0%, 100% { filter: brightness(0.85); }
  50% { filter: brightness(1.35); }
}

@keyframes home-lamp {
  0%, 100% { filter: brightness(0.88); }
  50% { filter: brightness(1.18); }
}

@media (max-width: 760px) {
  .home-cavern {
    position: fixed;
  }

  .home-cavern__beam--left { left: -20px; }
  .home-cavern__beam--right { right: -20px; }

  .home-header {
    width: min(100% - 20px, 520px);
    min-height: 148px;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 8px 10px;
    padding-top: max(10px, env(safe-area-inset-top));
  }

  .home-brand {
    grid-row: 1;
    grid-column: 1 / -1;
  }

  .home-brand h1 {
    padding-top: 6px;
    padding-bottom: 6px;
    font-size: clamp(1.15rem, 5.6vw, 1.7rem);
  }

  .home-brand > span {
    font-size: 0.6rem;
  }

  .home-nav-button {
    min-height: 44px;
  }

  .home-nav-button:last-child {
    justify-self: stretch;
  }

  .home-hub {
    position: relative;
    top: auto;
    right: auto;
    bottom: auto;
    left: auto;
    display: block;
    padding: 4px 10px calc(66px + env(safe-area-inset-bottom));
  }

  .facility-grid {
    width: min(100%, 520px);
    height: auto;
    min-height: 0;
    grid-template-areas:
      "mine mine"
      "workshop merchant"
      "house board";
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: minmax(180px, 30vh) repeat(2, minmax(132px, 21vh));
    gap: 10px;
    margin: 0 auto;
  }

  .facility-card__art {
    bottom: 60px;
  }

  .facility-card__copy {
    height: 61px;
    padding: 7px 9px;
  }

  .facility-card__copy strong {
    font-size: clamp(0.86rem, 4vw, 1.05rem);
  }

  .facility-card__copy small {
    font-size: 0.59rem;
  }

  .facility-card__badge {
    top: 8px;
    right: 7px;
    max-width: calc(100% - 14px);
    overflow: hidden;
    font-size: 0.49rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .home-status {
    width: min(calc(100% - 20px), 500px);
    grid-template-columns: 29px 1fr;
  }

  .home-status__stage {
    display: none;
  }
}

@media (max-width: 360px) {
  .home-header {
    width: calc(100% - 14px);
  }

  .home-nav-button {
    padding-right: 7px;
    padding-left: 7px;
    font-size: 0.69rem;
  }

  .home-hub {
    padding-right: 7px;
    padding-left: 7px;
  }

  .facility-grid {
    gap: 7px;
  }

  .facility-card {
    border-width: 4px;
  }

  .facility-card__copy strong {
    letter-spacing: 0.08em;
  }
}

@media (max-height: 540px) and (orientation: landscape) {
  .home-screen {
    overflow: hidden;
  }

  .home-header {
    width: min(96vw, 1100px);
    min-height: 76px;
    grid-template-columns: minmax(108px, 0.7fr) minmax(260px, 2.4fr) minmax(108px, 0.7fr);
    grid-template-rows: 1fr;
    gap: 12px;
    padding: max(5px, env(safe-area-inset-top)) 0 4px;
  }

  .home-brand {
    grid-row: 1;
    grid-column: 2;
  }

  .home-brand p,
  .home-brand > span {
    display: none;
  }

  .home-brand h1 {
    padding: 6px 14px;
    font-size: clamp(1rem, 3.2vw, 1.55rem);
  }

  .home-nav-button {
    min-height: 44px;
    padding: 6px 8px;
    font-size: 0.67rem;
  }

  .home-nav-button:first-child {
    grid-column: 1;
  }

  .home-nav-button:last-child {
    grid-column: 3;
    justify-self: stretch;
  }

  .home-hub {
    position: absolute;
    top: 78px;
    right: 0;
    bottom: calc(42px + env(safe-area-inset-bottom));
    left: 0;
    padding: 0;
  }

  .facility-grid {
    width: min(96vw, 1040px);
    height: 100%;
    min-height: 0;
    grid-template-areas:
      "merchant mine board"
      "workshop mine house";
    grid-template-columns: minmax(125px, 0.9fr) minmax(220px, 1.35fr) minmax(125px, 0.9fr);
    grid-template-rows: repeat(2, minmax(80px, 1fr));
    gap: 7px;
  }

  .facility-card__art {
    bottom: 45px;
  }

  .facility-card__copy {
    height: 46px;
    padding: 4px 8px;
  }

  .facility-card__copy strong {
    font-size: clamp(0.7rem, 1.8vw, 0.93rem);
  }

  .facility-card__copy small {
    display: none;
  }

  .facility-card__badge {
    top: 6px;
    right: 5px;
    max-width: 70%;
    padding: 2px 4px;
    overflow: hidden;
    font-size: 0.55rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .home-status {
    bottom: env(safe-area-inset-bottom);
    width: min(70vw, 430px);
    min-height: 31px;
    grid-template-columns: 22px 1fr auto;
    padding: 3px 8px;
  }

  .home-status__gem {
    width: 18px;
    height: 23px;
  }

  .home-status p {
    display: flex;
    align-items: baseline;
    gap: 8px;
  }

  .home-status strong {
    font-size: 0.62rem;
  }

  .home-status small,
  .home-status__stage {
    font-size: 0.48rem;
  }
}

html[data-reduced-motion="true"] *,
html[data-reduced-motion="true"] *::before,
html[data-reduced-motion="true"] *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  scroll-behavior: auto !important;
  transition-duration: 0.001ms !important;
}

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

@media (forced-colors: active) {
  .intro-prompt,
  .logo-plaque,
  .menu-stage,
  .menu-button,
  .home-nav-button,
  .facility-card,
  .home-status,
  .game-dialog__frame,
  .dialog-button,
  .option-row {
    border: 3px solid ButtonText;
    forced-color-adjust: auto;
  }

  .intro-gate:focus-visible .intro-prompt,
  .menu-button:focus-visible,
  .dialog-button:focus-visible,
  .option-row:has(input:focus-visible) {
    outline: 4px solid Highlight;
  }
}

/* Card workshop: editor, archive, and exploration loadout */
.card-editor-screen {
  position: relative;
  isolation: isolate;
  display: grid;
  width: 100%;
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  min-height: 0;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
  color: #fff3c4;
  background: #09090e;
  image-rendering: pixelated;
}

.editor-backdrop {
  position: absolute;
  z-index: -2;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(4, 4, 8, 0.9), transparent 13% 87%, rgba(4, 4, 8, 0.9)),
    repeating-linear-gradient(0deg, #17151d 0 42px, #0b0a10 42px 47px, #211e28 47px 83px);
}

.editor-backdrop::before {
  position: absolute;
  inset: 0;
  content: "";
  background:
    repeating-linear-gradient(90deg, transparent 0 78px, rgba(4, 4, 8, 0.52) 78px 84px),
    linear-gradient(180deg, rgba(89, 231, 255, 0.06), transparent 34%),
    linear-gradient(0deg, rgba(4, 4, 8, 0.84), transparent 38%);
}

.editor-backdrop__beam {
  position: absolute;
  top: 0;
  bottom: 0;
  width: clamp(28px, 4vw, 54px);
  background: var(--wood);
  border: 6px solid #1a0d09;
  box-shadow: inset 7px 0 var(--wood-light), inset -7px 0 var(--wood-dark), 8px 0 rgba(0, 0, 0, 0.42);
}

.editor-backdrop__beam--left { left: 3%; }
.editor-backdrop__beam--right { right: 3%; }

.editor-backdrop__forge {
  position: absolute;
  right: 7%;
  bottom: -34px;
  width: clamp(130px, 17vw, 230px);
  height: clamp(120px, 24vh, 210px);
  background:
    linear-gradient(90deg, transparent 18%, #73e7f5 18% 82%, transparent 82%) 50% 58% / 54% 36% no-repeat,
    #303842;
  border: 8px solid #101319;
  box-shadow:
    inset 0 8px #66727c,
    0 0 0 8px rgba(89, 231, 255, 0.07),
    10px 10px rgba(0, 0, 0, 0.5);
  clip-path: polygon(16% 0, 84% 0, 100% 16%, 100% 100%, 0 100%, 0 16%);
  opacity: 0.58;
}

.editor-backdrop__bottle {
  position: absolute;
  bottom: 7%;
  width: 28px;
  height: 48px;
  background: var(--red);
  border: 5px solid #11171c;
  box-shadow: inset 6px 0 rgba(255, 255, 255, 0.32), 5px 5px rgba(0, 0, 0, 0.5);
  clip-path: polygon(33% 0, 67% 0, 67% 18%, 86% 31%, 100% 100%, 0 100%, 14% 31%, 33% 18%);
  opacity: 0.68;
}

.editor-backdrop__bottle--red { left: 8%; }
.editor-backdrop__bottle--blue { left: 12%; bottom: 5%; background: var(--blue); }
.editor-backdrop__bottle--green { left: 16%; background: var(--green); }

.editor-header {
  position: relative;
  z-index: 20;
  display: grid;
  width: min(100% - 32px, 1280px);
  min-height: 76px;
  grid-template-columns: minmax(112px, 0.65fr) minmax(280px, 2fr) minmax(90px, 0.65fr);
  align-items: center;
  gap: 16px;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) max(0px, env(safe-area-inset-right)) 7px max(0px, env(safe-area-inset-left));
}

.editor-header__back,
.editor-tabs button,
.workshop-button,
.small-tool-button,
.editor-dialog__frame > header button {
  min-height: 44px;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.editor-header__back {
  justify-self: start;
  min-width: 104px;
  padding: 9px 14px;
  color: #dce9eb;
  background: rgba(30, 35, 42, 0.96);
  border: 4px solid #10141a;
  box-shadow: inset 0 4px #66727c, 5px 5px rgba(0, 0, 0, 0.56);
  letter-spacing: 0.1em;
}

.editor-header__back span {
  color: var(--cyan);
  font-size: 1.08rem;
}

.editor-header__title {
  min-width: 0;
  text-align: center;
}

.editor-header__title p,
.form-heading p,
.preview-heading p,
.balance-heading p,
.section-heading p,
.editor-dialog__eyebrow {
  margin: 0;
  color: #9fdce8;
  font-size: 0.61rem;
  font-weight: 900;
  letter-spacing: 0.2em;
}

.editor-header__title h1 {
  display: inline-block;
  margin: 2px 0 0;
  padding: 7px 24px;
  color: var(--gold-light);
  background: #29313a;
  border: 5px solid #11151a;
  outline: 3px solid var(--gold);
  outline-offset: -8px;
  box-shadow: inset 0 5px #515d68, 6px 6px rgba(0, 0, 0, 0.56);
  font-size: clamp(1.12rem, 2.2vw, 1.65rem);
  letter-spacing: 0.13em;
  text-indent: 0.13em;
  text-shadow: 3px 3px #4c2d18;
  clip-path: polygon(9px 0, calc(100% - 9px) 0, 100% 9px, 100% calc(100% - 9px), calc(100% - 9px) 100%, 9px 100%, 0 calc(100% - 9px), 0 9px);
}

.editor-header__count {
  justify-self: end;
  display: grid;
  min-width: 78px;
  justify-items: center;
  gap: 0;
  margin: 0;
  padding: 7px 10px;
  color: var(--cyan-light);
  background: rgba(20, 25, 31, 0.96);
  border: 4px solid #0e1115;
  outline: 2px solid var(--cyan-dark);
  outline-offset: -7px;
  box-shadow: 4px 4px rgba(0, 0, 0, 0.5);
}

.editor-header__count span {
  font-size: 1.05rem;
  line-height: 1;
}

.editor-header__count small {
  color: #a9bbc0;
  font-size: 0.53rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.editor-tabs {
  position: relative;
  z-index: 21;
  display: grid;
  width: min(100% - 32px, 760px);
  min-height: 50px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin: 0 auto 8px;
  padding: 5px;
  background: #12161b;
  border: 4px solid #080a0d;
  box-shadow: inset 0 0 0 3px #3f4851, 5px 5px rgba(0, 0, 0, 0.48);
}

.editor-tabs button {
  min-width: 0;
  padding: 7px 10px;
  overflow: hidden;
  color: #b9c6c9;
  background: #292f37;
  border: 3px solid #11151a;
  box-shadow: inset 0 3px #56616b;
  font-size: 0.76rem;
  letter-spacing: 0.06em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-tabs button span {
  color: var(--gold-light);
}

.editor-tabs button b {
  color: var(--cyan-light);
  font-size: 0.66rem;
}

.editor-tabs button[aria-selected="true"] {
  color: #152027;
  background: var(--cyan);
  border-color: #d9fbff;
  box-shadow: inset 0 4px rgba(255, 255, 255, 0.45), inset 0 -4px var(--cyan-dark);
}

.editor-tabs button[aria-selected="true"] span,
.editor-tabs button[aria-selected="true"] b {
  color: #142028;
}

.editor-scroll {
  position: relative;
  z-index: 10;
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding: 5px max(16px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  scrollbar-color: #68747d #111318;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.editor-panel {
  width: min(100%, 1280px);
  min-height: 100%;
  margin: 0 auto;
}

.editor-design-grid {
  display: grid;
  grid-template-columns: minmax(410px, 1.55fr) minmax(250px, 0.78fr) minmax(245px, 0.72fr);
  align-items: start;
  gap: clamp(10px, 1.15vw, 17px);
}

.pixel-panel {
  position: relative;
  min-width: 0;
  color: #f9eabe;
  background:
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(255, 255, 255, 0.018) 31px 33px),
    rgba(25, 29, 36, 0.97);
  border: 5px solid #0d1014;
  outline: 3px solid #6d4d2b;
  outline-offset: -9px;
  box-shadow: inset 0 0 0 4px #3d454e, 7px 8px rgba(0, 0, 0, 0.58);
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px), 0 8px);
}

.card-design-form,
.card-preview-column,
.balance-column,
.collection-panel,
.deck-panel {
  padding: clamp(14px, 1.5vw, 21px);
}

.form-heading,
.preview-heading,
.section-heading {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 4px solid #704c28;
}

.form-heading h2,
.preview-heading h2,
.balance-heading h2,
.section-heading h2,
.editor-dialog__frame h2 {
  margin: 2px 0 0;
  color: var(--gold-light);
  font-size: clamp(1rem, 1.8vw, 1.3rem);
  letter-spacing: 0.1em;
  text-shadow: 2px 2px #4c2d18;
}

.design-fieldset {
  min-width: 0;
  margin: 0 0 14px;
  padding: 12px;
  color: #f7e8ba;
  background:
    repeating-linear-gradient(0deg, transparent 0 21px, rgba(100, 66, 31, 0.12) 21px 23px),
    #d4af67;
  border: 4px solid #382214;
  box-shadow: inset 0 4px #f6d58b, 4px 5px rgba(0, 0, 0, 0.36);
}

.design-fieldset legend {
  max-width: 100%;
  padding: 4px 11px 4px 6px;
  color: #fff2c0;
  background: #303842;
  border: 3px solid #101419;
  box-shadow: inset 0 3px #64717a, 3px 3px rgba(0, 0, 0, 0.44);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.design-fieldset legend span {
  display: inline-grid;
  width: 25px;
  height: 25px;
  margin-right: 5px;
  place-items: center;
  color: #102129;
  background: var(--cyan);
  border: 2px solid var(--cyan-light);
}

.field-grid {
  display: grid;
  min-width: 0;
  gap: 10px;
}

.field-grid--two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.editor-field {
  display: grid;
  min-width: 0;
  gap: 5px;
  color: #2b1a0f;
  font-size: 0.71rem;
  font-weight: 900;
  letter-spacing: 0.05em;
}

.editor-field > span:first-child {
  min-width: 0;
}

.editor-field small {
  color: #70451e;
  font-size: 0.57rem;
}

.editor-field input,
.editor-field select,
.deck-slot select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 8px 10px;
  color: #eef9f8;
  background: #252c34;
  border: 3px solid #11151a;
  border-radius: 0;
  box-shadow: inset 0 3px #59656f, 3px 3px rgba(0, 0, 0, 0.32);
  font: inherit;
  font-size: 0.78rem;
}

.editor-field input[type="number"] {
  font-variant-numeric: tabular-nums;
}

.editor-field input:disabled,
.editor-field select:disabled,
.deck-slot select:disabled,
.workshop-button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.9);
  opacity: 0.58;
}

.field-hint,
.section-lead,
.deck-warning,
.editor-save-status {
  margin: 9px 0 0;
  color: #4a2f18;
  font-size: 0.66rem;
  font-weight: 900;
  line-height: 1.55;
}

.field-hint {
  padding: 7px 9px;
  background: #efd187;
  border-left: 5px solid var(--cyan-dark);
}

.effect-editor-row {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(150px, 1.4fr) minmax(90px, 0.75fr) minmax(76px, 0.62fr);
  align-items: end;
  gap: 9px;
  padding: 9px;
  background: rgba(113, 72, 31, 0.14);
  border: 3px solid rgba(70, 42, 18, 0.72);
}

.effect-editor-row + .effect-editor-row {
  margin-top: 9px;
}

.effect-editor-row--optional {
  background: rgba(255, 255, 255, 0.12);
}

.condition-details {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 3px dashed #86602e;
}

.input-with-button {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
}

.small-tool-button {
  min-width: 62px;
  padding: 7px 9px;
  color: #1e170c;
  background: var(--gold-light);
  border: 3px solid #4a2d16;
  box-shadow: inset 0 3px #fff3bd, 3px 3px rgba(0, 0, 0, 0.34);
  font-size: 0.69rem;
}

.form-actions,
.deck-actions,
.editor-dialog__actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-top: 14px;
}

.deck-actions {
  grid-template-columns: minmax(180px, 320px);
  justify-content: end;
}

.workshop-button {
  min-width: 0;
  padding: 9px 12px;
  color: #f6e9c3;
  background: #303842;
  border: 4px solid #101419;
  box-shadow: inset 0 4px #68747d, 4px 5px rgba(0, 0, 0, 0.44);
  font-size: 0.75rem;
  letter-spacing: 0.07em;
}

.workshop-button--primary {
  color: #102129;
  background: var(--cyan);
  border-color: #082936;
  box-shadow: inset 0 4px var(--cyan-light), inset 0 -4px var(--cyan-dark), 4px 5px rgba(0, 0, 0, 0.44);
}

.workshop-button--quiet {
  color: #e8d9ad;
  background: #35323a;
}

.workshop-button--preview {
  width: 100%;
  color: #24190d;
  background: var(--gold-light);
  border-color: #59401d;
  box-shadow: inset 0 4px #fff4c2, inset 0 -4px var(--gold-dark), 4px 5px rgba(0, 0, 0, 0.44);
}

.workshop-button--danger {
  color: #fff7e2;
  background: #9e3040;
  border-color: #3e1018;
  box-shadow: inset 0 4px #e66b75, inset 0 -4px #5d1825, 4px 5px rgba(0, 0, 0, 0.44);
}

.editor-header__back:hover,
.editor-tabs button:hover,
.workshop-button:hover,
.small-tool-button:hover {
  filter: brightness(1.16) saturate(1.08);
}

.editor-header__back:active,
.editor-tabs button:active,
.workshop-button:active,
.small-tool-button:active {
  box-shadow: inset 0 3px rgba(0, 0, 0, 0.34), 2px 2px rgba(0, 0, 0, 0.46);
  transform: translate(2px, 2px);
}

.editor-header__back:focus-visible,
.editor-header__title h1:focus-visible,
.editor-tabs button:focus-visible,
.workshop-button:focus-visible,
.small-tool-button:focus-visible,
.editor-field input:focus-visible,
.editor-field select:focus-visible,
.deck-slot select:focus-visible,
.editor-dialog__frame > header button:focus-visible,
.saved-card-list button:focus-visible {
  outline: 4px solid var(--cyan-light);
  outline-offset: 3px;
}

.editor-field input[aria-invalid="true"],
.editor-field select[aria-invalid="true"] {
  border-color: #ff7a83;
  box-shadow: inset 0 3px #6c2932, 0 0 0 2px #40131a;
}

.field-hint[data-recommended="false"] {
  border-left-color: var(--gold-dark);
}

.card-preview-column,
.balance-column {
  position: sticky;
  top: 4px;
}

.preview-live {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #c9f9ff;
  font-size: 0.57rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.preview-live i {
  width: 9px;
  height: 9px;
  background: var(--cyan);
  box-shadow: 0 0 0 3px #153943;
  animation: editor-live 1.2s steps(2, end) infinite;
}

.crafted-card {
  --card-accent: var(--red);
  position: relative;
  display: grid;
  width: min(100% - 10px, 270px);
  aspect-ratio: 5 / 7;
  grid-template-rows: auto minmax(0, 1fr) minmax(76px, auto) auto;
  gap: 5px;
  margin: 6px auto 2px;
  padding: 13px 12px 9px;
  color: var(--ink);
  background:
    repeating-linear-gradient(0deg, transparent 0 18px, rgba(104, 69, 29, 0.09) 18px 20px),
    var(--paper);
  border: 6px solid #392315;
  outline: 4px solid var(--card-accent);
  outline-offset: -11px;
  box-shadow: inset 0 0 0 5px var(--paper-light), 8px 9px rgba(0, 0, 0, 0.56);
  clip-path: polygon(10px 0, calc(100% - 10px) 0, 100% 10px, 100% calc(100% - 10px), calc(100% - 10px) 100%, 10px 100%, 0 calc(100% - 10px), 0 10px);
}

.crafted-card[data-color="blue"] { --card-accent: var(--blue); }
.crafted-card[data-color="green"] { --card-accent: var(--green); }
.crafted-card[data-color="yellow"] { --card-accent: var(--yellow); }
.crafted-card[data-color="purple"] { --card-accent: var(--violet); }

.crafted-card__cost {
  position: absolute;
  z-index: 8;
  top: -12px;
  right: -10px;
  display: grid;
  width: 55px;
  height: 55px;
  place-items: center;
  color: #102129;
  background: var(--cyan);
  border: 5px solid #10171b;
  box-shadow: inset 6px 0 var(--cyan-light), inset -6px 0 var(--cyan-dark), 4px 5px rgba(0, 0, 0, 0.55);
  font-family: var(--font-display);
  font-size: 1.5rem;
  clip-path: polygon(28% 0, 72% 0, 100% 28%, 100% 72%, 72% 100%, 28% 100%, 0 72%, 0 28%);
}

.crafted-card > header {
  min-width: 0;
  padding: 3px 40px 7px 5px;
  border-bottom: 4px solid #775127;
}

.crafted-card > header h3 {
  margin: 0;
  overflow: hidden;
  font-size: clamp(0.83rem, 1.35vw, 1.04rem);
  letter-spacing: 0.06em;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crafted-card > header p {
  margin: 3px 0 0;
  color: #62401e;
  font-size: 0.56rem;
  font-weight: 900;
}

.crafted-card__art {
  position: relative;
  display: grid;
  min-height: 0;
  place-items: center;
  overflow: hidden;
  background:
    linear-gradient(135deg, transparent 0 42%, rgba(255, 255, 255, 0.18) 42% 46%, transparent 46%),
    radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--card-accent) 74%, #ffffff) 0 9%, var(--card-accent) 10% 28%, #18202a 29% 68%, #0b0e12 69%);
  border: 5px solid #3b2717;
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.2);
}

.crafted-card__art::before,
.crafted-card__art::after {
  position: absolute;
  width: 6px;
  height: 6px;
  content: "";
  background: var(--cyan-light);
  box-shadow:
    22px -16px var(--card-accent),
    -27px 12px var(--gold-light),
    34px 19px var(--cyan-light),
    -13px -29px rgba(255, 255, 255, 0.68);
}

.crafted-card__art::after {
  transform: rotate(45deg) scale(0.7);
}

.crafted-card__art > b {
  position: absolute;
  z-index: 4;
  right: 5px;
  bottom: 5px;
  padding: 3px 5px;
  color: #fff9dc;
  background: rgba(13, 17, 22, 0.88);
  border: 2px solid var(--card-accent);
  font-size: 0.54rem;
}

.pixel-art-icon {
  position: relative;
  z-index: 3;
  display: block;
  width: 76px;
  height: 76px;
  filter: drop-shadow(6px 7px 0 rgba(0, 0, 0, 0.52));
}

.pixel-art-icon i {
  position: absolute;
  display: block;
  background: var(--card-accent);
}

.crafted-card[data-art="blade"] .pixel-art-icon i:nth-child(1) {
  top: 3px;
  left: 31px;
  width: 21px;
  height: 49px;
  box-shadow: inset 7px 0 rgba(255, 255, 255, 0.45);
  transform: rotate(34deg);
  clip-path: polygon(50% 0, 100% 18%, 76% 100%, 24% 100%, 0 18%);
}

.crafted-card[data-art="blade"] .pixel-art-icon i:nth-child(2) {
  right: 10px;
  bottom: 18px;
  width: 43px;
  height: 9px;
  background: var(--gold-light);
  transform: rotate(34deg);
}

.crafted-card[data-art="blade"] .pixel-art-icon i:nth-child(3) {
  right: 8px;
  bottom: 5px;
  width: 13px;
  height: 25px;
  background: #754022;
  transform: rotate(34deg);
}

.crafted-card[data-art="shield"] .pixel-art-icon i:nth-child(1) {
  inset: 6px 7px 5px;
  box-shadow: inset 12px 0 rgba(255, 255, 255, 0.38), inset -9px 0 rgba(0, 0, 0, 0.25);
  clip-path: polygon(50% 0, 100% 17%, 88% 75%, 50% 100%, 12% 75%, 0 17%);
}

.crafted-card[data-art="shield"] .pixel-art-icon i:nth-child(2) {
  top: 23px;
  left: 27px;
  width: 23px;
  height: 29px;
  background: var(--cyan-light);
  clip-path: polygon(50% 0, 100% 28%, 82% 100%, 18% 100%, 0 28%);
}

.crafted-card[data-art="scroll"] .pixel-art-icon i:nth-child(1) {
  inset: 7px 10px;
  background: var(--paper-light);
  border: 6px solid #59391d;
  box-shadow: inset 0 0 0 4px var(--paper);
  transform: rotate(-6deg);
}

.crafted-card[data-art="scroll"] .pixel-art-icon i:nth-child(2),
.crafted-card[data-art="scroll"] .pixel-art-icon i:nth-child(3) {
  top: 28px;
  left: 26px;
  width: 30px;
  height: 6px;
  background: var(--card-accent);
  transform: rotate(-6deg);
}

.crafted-card[data-art="scroll"] .pixel-art-icon i:nth-child(3) {
  top: 43px;
  width: 24px;
}

.crafted-card[data-art="crystal"] .pixel-art-icon i:nth-child(1) {
  inset: 2px 9px 3px;
  box-shadow: inset 13px 0 rgba(255, 255, 255, 0.45), inset -10px 0 rgba(0, 0, 0, 0.24);
  clip-path: polygon(50% 0, 100% 30%, 82% 100%, 18% 100%, 0 30%);
}

.crafted-card[data-art="crystal"] .pixel-art-icon i:nth-child(2) {
  bottom: 2px;
  left: 2px;
  width: 28px;
  height: 42px;
  background: color-mix(in srgb, var(--card-accent) 74%, white);
  clip-path: polygon(50% 0, 100% 30%, 82% 100%, 18% 100%, 0 30%);
}

.crafted-card[data-art="crystal"] .pixel-art-icon i:nth-child(3) {
  right: 0;
  bottom: 1px;
  width: 25px;
  height: 37px;
  background: color-mix(in srgb, var(--card-accent) 70%, black);
  clip-path: polygon(50% 0, 100% 30%, 82% 100%, 18% 100%, 0 30%);
}

.crafted-card[data-art="pickaxe"] .pixel-art-icon i:nth-child(1) {
  top: 3px;
  left: 29px;
  width: 14px;
  height: 70px;
  background: #8b512d;
  box-shadow: inset 5px 0 #cf8250;
  transform: rotate(-35deg);
}

.crafted-card[data-art="pickaxe"] .pixel-art-icon i:nth-child(2) {
  top: 13px;
  left: 7px;
  width: 62px;
  height: 16px;
  background: #9aa4aa;
  box-shadow: inset 0 6px #e6f0f1;
  transform: rotate(-16deg);
  clip-path: polygon(0 42%, 44% 0, 100% 45%, 82% 100%, 43% 60%, 14% 100%);
}

.crafted-card[data-art="pickaxe"] .pixel-art-icon i:nth-child(3) {
  top: 21px;
  left: 29px;
  width: 20px;
  height: 24px;
  clip-path: polygon(50% 0, 100% 28%, 82% 100%, 18% 100%, 0 28%);
}

.crafted-card__description {
  display: grid;
  min-height: 76px;
  align-items: center;
  padding: 7px 8px;
  background: rgba(255, 236, 182, 0.78);
  border: 3px solid #775127;
}

.crafted-card__description p {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: clamp(0.61rem, 1.05vw, 0.72rem);
  font-weight: 900;
  line-height: 1.55;
}

.crafted-card > footer {
  display: flex;
  min-width: 0;
  justify-content: space-between;
  gap: 7px;
  color: #63401e;
  font-size: 0.49rem;
  font-weight: 900;
}

.crafted-card > footer span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.balance-column {
  display: grid;
  gap: 12px;
}

.balance-heading {
  padding-bottom: 9px;
  border-bottom: 4px solid #704c28;
}

.balance-score {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 2px 8px;
  padding: 10px;
  color: #24170d;
  background: var(--paper);
  border: 4px solid #392315;
  box-shadow: inset 0 4px var(--paper-light);
}

.balance-score > span {
  font-family: var(--font-display);
  font-size: 1.45rem;
  letter-spacing: 0.04em;
}

.balance-score small {
  font-size: 0.58rem;
  font-weight: 900;
}

.balance-score progress {
  width: 100%;
  height: 16px;
  grid-column: 1 / -1;
  overflow: hidden;
  color: var(--cyan);
  background: #2c3137;
  border: 3px solid #15191e;
  border-radius: 0;
}

.balance-score progress::-webkit-progress-bar { background: #2c3137; }
.balance-score progress::-webkit-progress-value { background: var(--cyan); }
.balance-score progress::-moz-progress-bar { background: var(--cyan); }

.balance-facts {
  display: grid;
  gap: 6px;
  margin: 0;
}

.balance-facts div {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px 9px;
  background: #252c34;
  border-left: 5px solid var(--gold);
}

.balance-facts dt,
.balance-facts dd {
  margin: 0;
  font-size: 0.66rem;
  font-weight: 900;
}

.balance-facts dt { color: #bdc9cb; }
.balance-facts dd { color: var(--cyan-light); text-align: right; }

.balance-facts dd[data-state="ok"] {
  color: #8ff0a8;
}

.balance-facts dd[data-state="warning"] {
  color: var(--gold-light);
}

.balance-facts dd[data-state="error"] {
  color: #ff9299;
}

.balance-messages {
  display: grid;
  min-height: 50px;
  gap: 6px;
  color: #fff1bd;
  font-size: 0.64rem;
  font-weight: 900;
  line-height: 1.45;
}

.balance-messages:empty::before {
  align-self: center;
  color: #8fa2a6;
  content: "入力内容を確認しています。";
}

.balance-messages > * {
  margin: 0;
  padding: 7px 8px;
  background: #3a301e;
  border-left: 5px solid var(--gold-light);
}

.balance-messages .error,
.balance-messages [data-level="error"],
.balance-messages .balance-message--error {
  background: #4a1d27;
  border-color: #ff7a83;
}

.balance-messages .balance-message--warning {
  background: #49391b;
  border-color: var(--gold-light);
}

.balance-messages .balance-message--success {
  color: #d9ffe2;
  background: #173c2a;
  border-color: #72dfa0;
}

.balance-messages .balance-message--notice {
  background: #223848;
  border-color: var(--cyan);
}

.editor-save-status {
  min-height: 42px;
  margin: 0;
  padding: 8px 9px;
  color: #c8d6d8;
  background: #20262d;
  border: 3px solid #49545d;
}

.collection-panel,
.deck-panel {
  width: min(100%, 1080px);
  min-height: min(560px, 100%);
  margin: 0 auto;
}

.section-heading {
  margin-bottom: 8px;
}

.section-lead {
  margin: 0 0 16px;
  color: #c5d1d3;
}

.saved-card-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.saved-card-list > article,
.saved-card-list > li,
.saved-card-list > div,
.saved-card-item,
.saved-card-entry,
.library-card {
  min-width: 0;
  padding: 12px;
  color: #2b1a0f;
  background: var(--paper);
  border: 4px solid #392315;
  box-shadow: inset 0 4px var(--paper-light), 5px 6px rgba(0, 0, 0, 0.42);
  list-style: none;
}

.saved-card-list h3,
.saved-card-list p {
  overflow-wrap: anywhere;
}

.saved-card-list h3 {
  margin: 0 0 5px;
  color: #2b1a0f;
  font-size: 0.9rem;
}

.saved-card-list p {
  margin: 4px 0;
  font-size: 0.65rem;
  font-weight: 900;
  line-height: 1.45;
}

.saved-card-list button {
  min-height: 44px;
  padding: 7px 9px;
  color: #f6e9c3;
  background: #303842;
  border: 3px solid #101419;
  font: inherit;
  font-size: 0.66rem;
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
}

.saved-card-item {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.saved-card-item__gem {
  --saved-gem-color: var(--red);
  display: block;
  width: 42px;
  height: 54px;
  background: var(--saved-gem-color);
  box-shadow: inset 9px 0 rgba(255, 255, 255, 0.4), inset -7px 0 rgba(0, 0, 0, 0.22), 4px 5px rgba(0, 0, 0, 0.42);
  clip-path: polygon(50% 0, 100% 27%, 82% 100%, 18% 100%, 0 27%);
}

.saved-card-item__gem[data-color="blue"] { --saved-gem-color: var(--blue); }
.saved-card-item__gem[data-color="green"] { --saved-gem-color: var(--green); }
.saved-card-item__gem[data-color="yellow"] { --saved-gem-color: var(--yellow); }
.saved-card-item__gem[data-color="purple"] { --saved-gem-color: var(--violet); }

.saved-card-item__copy {
  min-width: 0;
}

.saved-card-item__copy h3,
.saved-card-item__copy p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-mode {
  display: inline-block;
  margin-top: 3px;
  padding: 3px 6px;
  color: #f8f0d1;
  background: #3c4147;
  border: 2px solid #6f787e;
  font-size: 0.54rem;
  font-weight: 900;
}

.card-mode--normal {
  color: #12281c;
  background: #8be3a8;
  border-color: #34784b;
}

.card-mode--test {
  color: #3b250d;
  background: var(--gold-light);
  border-color: var(--gold-dark);
}

.saved-card-item__actions {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 2px;
}

.archive-action {
  min-width: 0;
  min-height: 44px;
  padding: 7px 6px;
  color: #f6e9c3;
  background: #303842;
  border: 3px solid #101419;
  box-shadow: inset 0 3px #68747d, 3px 4px rgba(0, 0, 0, 0.4);
  font: inherit;
  font-size: 0.68rem;
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
}

.archive-action:hover {
  filter: brightness(1.16);
}

.archive-action:active {
  box-shadow: inset 0 3px rgba(0, 0, 0, 0.35);
  transform: translate(2px, 2px);
}

.saved-card-item__actions .archive-action--danger {
  color: #fff6e5;
  background: #8f2b3a;
  border-color: #48131c;
}

.saved-card-actions,
.library-card__actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 9px;
}

.empty-collection {
  margin: 30px auto;
  padding: 22px;
  color: #33200f;
  background: var(--paper);
  border: 4px dashed #765126;
  font-size: 0.8rem;
  font-weight: 900;
  line-height: 1.6;
  text-align: center;
}

.deck-slots {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 17px;
}

.deck-slot {
  display: grid;
  min-width: 0;
  min-height: 150px;
  align-content: center;
  gap: 8px;
  padding: 16px;
  color: #2b1a0f;
  background:
    linear-gradient(135deg, transparent 0 46%, rgba(255, 255, 255, 0.2) 46% 49%, transparent 49%),
    var(--paper);
  border: 5px solid #392315;
  outline: 3px solid var(--cyan-dark);
  outline-offset: -10px;
  box-shadow: inset 0 5px var(--paper-light), 6px 7px rgba(0, 0, 0, 0.46);
}

.deck-slot__number {
  width: max-content;
  padding: 3px 7px;
  color: #e9fbff;
  background: #26313a;
  border: 2px solid var(--cyan);
  font-size: 0.6rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.deck-slot strong {
  font-size: 0.9rem;
  letter-spacing: 0.08em;
}

.slot-counter {
  display: inline-grid;
  min-width: 72px;
  min-height: 44px;
  place-items: center;
  color: #132127;
  background: var(--cyan);
  border: 4px solid #10212a;
  box-shadow: inset 0 4px var(--cyan-light), 4px 4px rgba(0, 0, 0, 0.4);
  font-size: 0.78rem;
  font-weight: 900;
}

.deck-summary {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 10px 13px;
  color: #f7e9bc;
  background: #272e36;
  border: 4px solid #101419;
  box-shadow: inset 0 4px #59656e;
}

.deck-summary > span {
  display: grid;
  width: 39px;
  height: 39px;
  place-items: center;
  color: var(--gold-light);
  background: #151a20;
  border: 3px solid var(--gold);
}

.deck-summary p {
  display: grid;
  gap: 2px;
  margin: 0;
}

.deck-summary strong { font-size: 0.8rem; }
.deck-summary small { color: #b7c5c7; font-size: 0.62rem; font-weight: 900; }

.deck-warning {
  padding: 9px 11px;
  color: #33210f;
  background: #d7b368;
  border-left: 6px solid var(--gold-dark);
}

.editor-dialog {
  width: min(calc(100% - 28px), 590px);
  max-width: 590px;
  max-height: calc(100vh - 28px);
  max-height: calc(100dvh - 28px);
  margin: auto;
  padding: 0;
  overflow: visible;
  color: #f6e9c3;
  background: transparent;
  border: 0;
}

.editor-dialog::backdrop {
  background: rgba(3, 4, 8, 0.82);
}

.editor-dialog[open] {
  animation: dialog-enter 180ms steps(3, end) both;
}

.editor-dialog__frame {
  max-height: calc(100vh - 28px);
  max-height: calc(100dvh - 28px);
  padding: clamp(18px, 4vw, 28px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  color: #f6e9c3;
  background: #252c34;
  border: 6px solid #0d1014;
  outline: 4px solid var(--gold);
  outline-offset: -11px;
  box-shadow: inset 0 0 0 5px #56616b, 9px 10px rgba(0, 0, 0, 0.62);
  clip-path: polygon(10px 0, calc(100% - 10px) 0, 100% 10px, 100% calc(100% - 10px), calc(100% - 10px) 100%, 10px 100%, 0 calc(100% - 10px), 0 10px);
}

.editor-dialog__frame > p:not(.editor-dialog__eyebrow) {
  margin: 10px 0;
  color: #d3dee0;
  font-size: 0.78rem;
  line-height: 1.6;
}

.editor-dialog__frame > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 4px solid #704c28;
}

.editor-dialog__frame > header h2 { margin: 0; }

.editor-dialog__frame > header button {
  min-width: 44px;
  padding: 4px;
  color: #f6e9c3;
  background: #3c3339;
  border: 4px solid #11151a;
  box-shadow: inset 0 4px #6d656b;
  font-size: 1.1rem;
}

.editor-dialog__frame--preview {
  display: grid;
  justify-items: center;
}

.editor-dialog__frame--preview > header {
  width: 100%;
}

.editor-dialog__frame--preview .crafted-card {
  width: min(100% - 20px, 310px);
}

html[data-large-text="true"] .editor-header__back,
html[data-large-text="true"] .editor-tabs button,
html[data-large-text="true"] .workshop-button {
  font-size: 0.88rem;
}

html[data-large-text="true"] .editor-field,
html[data-large-text="true"] .field-hint,
html[data-large-text="true"] .section-lead,
html[data-large-text="true"] .deck-warning,
html[data-large-text="true"] .editor-save-status,
html[data-large-text="true"] .balance-messages {
  font-size: 0.78rem;
}

html[data-large-text="true"] .editor-field input,
html[data-large-text="true"] .editor-field select,
html[data-large-text="true"] .deck-slot select {
  font-size: 0.88rem;
}

@keyframes editor-live {
  0%, 100% { filter: brightness(0.76); }
  50% { filter: brightness(1.35); }
}

@media (max-width: 1100px) {
  .editor-design-grid {
    grid-template-columns: minmax(390px, 1.35fr) minmax(260px, 0.8fr);
  }

  .card-design-form {
    grid-row: 1 / span 2;
  }

  .card-preview-column {
    grid-row: 1;
    grid-column: 2;
  }

  .balance-column {
    position: relative;
    top: auto;
    grid-row: 2;
    grid-column: 2;
  }
}

@media (max-width: 760px) {
  .card-editor-screen {
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  .editor-header {
    width: calc(100% - 16px);
    min-height: 58px;
    grid-template-columns: minmax(68px, 0.75fr) minmax(0, 2.3fr) minmax(48px, 0.75fr);
    gap: 6px;
    padding: max(6px, env(safe-area-inset-top)) 0 5px;
  }

  .editor-header__back {
    min-width: 0;
    width: 100%;
    padding: 6px;
    font-size: 0.69rem;
  }

  .editor-header__title p {
    display: none;
  }

  .editor-header__title h1 {
    display: block;
    margin: 0;
    padding: 7px 4px;
    overflow: hidden;
    font-size: clamp(0.82rem, 4.1vw, 1.08rem);
    letter-spacing: 0.06em;
    text-indent: 0;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .editor-header__count {
    min-width: 0;
    width: 100%;
    padding: 5px 2px;
  }

  .editor-header__count span { font-size: 0.85rem; }
  .editor-header__count small { font-size: 0.43rem; }

  .editor-tabs {
    width: calc(100% - 16px);
    min-height: 48px;
    gap: 4px;
    margin-bottom: 5px;
    padding: 3px;
  }

  .editor-tabs button {
    min-height: 44px;
    padding: 5px 3px;
    font-size: clamp(0.59rem, 2.8vw, 0.72rem);
    letter-spacing: 0.01em;
  }

  .editor-tabs button b {
    display: block;
    font-size: 0.48rem;
    line-height: 1;
  }

  .editor-scroll {
    padding: 4px max(8px, env(safe-area-inset-right)) calc(74px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }

  .editor-design-grid {
    display: flex;
    flex-direction: column;
    gap: 9px;
  }

  .card-design-form,
  .card-preview-column,
  .balance-column,
  .collection-panel,
  .deck-panel {
    width: 100%;
    padding: 11px;
  }

  .card-design-form {
    order: 1;
    clip-path: none;
  }

  .card-preview-column {
    display: none;
  }

  .balance-column {
    position: relative;
    top: auto;
    order: 2;
    clip-path: none;
  }

  .form-heading,
  .section-heading {
    align-items: flex-start;
    margin-bottom: 10px;
  }

  .form-heading h2,
  .section-heading h2 {
    font-size: 0.98rem;
  }

  .design-fieldset {
    margin-bottom: 10px;
    padding: 9px;
  }

  .field-grid--two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .effect-editor-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 8px;
  }

  .effect-editor-row > .editor-field:first-child {
    grid-column: 1 / -1;
  }

  .form-actions {
    display: block;
    margin-top: 10px;
  }

  #reset-card-button {
    width: 100%;
  }

  #open-preview-button,
  #save-card-button {
    position: fixed;
    z-index: 45;
    bottom: max(8px, env(safe-area-inset-bottom));
    width: calc(50% - 13px);
    min-height: 50px;
    padding: 7px 6px;
    box-shadow: 0 0 0 4px #090c10, 4px 5px rgba(0, 0, 0, 0.55);
    font-size: clamp(0.65rem, 3vw, 0.78rem);
  }

  #open-preview-button {
    left: max(8px, env(safe-area-inset-left));
  }

  #save-card-button {
    right: max(8px, env(safe-area-inset-right));
  }

  .collection-panel,
  .deck-panel {
    min-height: 100%;
  }

  .saved-card-list {
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .deck-slots {
    gap: 9px;
  }

  .deck-slot {
    min-height: 138px;
    padding: 11px;
  }

  .editor-dialog {
    width: calc(100% - 16px);
    max-height: calc(100dvh - 16px);
  }

  .editor-dialog__frame {
    max-height: calc(100dvh - 16px);
    padding: 16px;
  }

  .editor-dialog__frame--preview .crafted-card {
    width: min(100% - 18px, 270px);
  }

  html[data-large-text="true"] .editor-scroll {
    padding-bottom: calc(92px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 390px) {
  .editor-header {
    width: calc(100% - 10px);
    grid-template-columns: 66px minmax(0, 1fr) 46px;
  }

  .editor-tabs {
    width: calc(100% - 10px);
  }

  .editor-tabs button span {
    display: none;
  }

  .card-design-form,
  .balance-column,
  .collection-panel,
  .deck-panel {
    padding: 8px;
  }

  .field-grid--two,
  .condition-details {
    grid-template-columns: 1fr;
  }

  .input-with-button {
    grid-template-columns: minmax(0, 1fr) 62px;
  }

  .deck-slots {
    grid-template-columns: 1fr;
  }

  .deck-slot {
    min-height: 126px;
  }

  .section-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .section-heading .workshop-button {
    max-width: 116px;
    padding-right: 6px;
    padding-left: 6px;
    font-size: 0.65rem;
  }

  .editor-dialog__actions {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 540px) and (orientation: landscape) {
  .card-editor-screen {
    grid-template-rows: 52px minmax(0, 1fr);
  }

  .editor-header {
    width: 100%;
    min-height: 52px;
    grid-template-columns: 70px 128px minmax(0, 1fr);
    gap: 5px;
    margin: 0;
    padding: max(3px, env(safe-area-inset-top)) max(5px, env(safe-area-inset-right)) 3px max(5px, env(safe-area-inset-left));
  }

  .editor-header__back {
    min-height: 44px;
    padding: 4px;
  }

  .editor-header__title h1 {
    padding: 5px 3px;
    font-size: 0.72rem;
    letter-spacing: 0.02em;
  }

  .editor-header__count {
    display: none;
  }

  .editor-tabs {
    position: absolute;
    z-index: 30;
    top: max(2px, env(safe-area-inset-top));
    right: max(5px, env(safe-area-inset-right));
    width: min(53vw, 330px);
    min-height: 48px;
    height: 48px;
    gap: 3px;
    margin: 0;
    padding: 2px;
  }

  .editor-tabs button {
    min-height: 44px;
    padding: 2px 3px;
    font-size: clamp(0.52rem, 1.65vw, 0.65rem);
  }

  .editor-tabs button b {
    display: inline;
    font-size: 0.47rem;
  }

  .editor-scroll {
    grid-row: 2;
    min-height: 0;
    overflow: hidden;
    padding: 5px max(7px, env(safe-area-inset-right)) max(5px, env(safe-area-inset-bottom)) max(7px, env(safe-area-inset-left));
  }

  .editor-panel {
    height: 100%;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
  }

  #editor-panel-design {
    overflow: hidden;
  }

  .editor-design-grid {
    display: grid;
    height: 100%;
    min-height: 0;
    grid-template-columns: minmax(0, 1.12fr) minmax(190px, 0.88fr);
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 6px;
  }

  .card-design-form {
    grid-row: 1 / span 2;
    grid-column: 1;
    width: 100%;
    height: 100%;
    min-height: 0;
    order: initial;
    padding: 8px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
  }

  .card-preview-column {
    display: grid;
    min-height: 0;
    grid-row: 1;
    grid-column: 2;
    align-content: center;
    padding: 5px;
    overflow: hidden;
  }

  .preview-heading {
    display: none;
  }

  .card-preview-column .crafted-card {
    width: min(100% - 8px, 130px);
    margin: 0 auto;
    border-width: 4px;
    outline-width: 3px;
    outline-offset: -8px;
    padding: 7px 7px 5px;
    gap: 2px;
  }

  .card-preview-column .crafted-card__cost {
    top: -6px;
    right: -5px;
    width: 36px;
    height: 36px;
    border-width: 3px;
    font-size: 1rem;
  }

  .card-preview-column .crafted-card > header {
    padding: 1px 28px 3px 2px;
    border-bottom-width: 2px;
  }

  .card-preview-column .crafted-card > header h3 { font-size: 0.58rem; }
  .card-preview-column .crafted-card > header p { margin-top: 1px; font-size: 0.4rem; }

  .card-preview-column .crafted-card__art {
    border-width: 3px;
  }

  .card-preview-column .pixel-art-icon {
    width: 50px;
    height: 50px;
    transform: scale(0.66);
  }

  .card-preview-column .crafted-card__art > b { font-size: 0.38rem; }

  .card-preview-column .crafted-card__description {
    min-height: 36px;
    padding: 3px;
    border-width: 2px;
  }

  .card-preview-column .crafted-card__description p {
    display: -webkit-box;
    overflow: hidden;
    font-size: 0.44rem;
    line-height: 1.25;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
  }

  .card-preview-column .crafted-card > footer { font-size: 0.33rem; }

  .balance-column {
    position: relative;
    top: auto;
    display: grid;
    min-height: 55px;
    grid-row: 2;
    grid-column: 2;
    grid-template-columns: minmax(84px, 0.75fr) minmax(0, 1.25fr);
    align-items: stretch;
    gap: 5px;
    order: initial;
    padding: 5px;
  }

  .balance-heading,
  .balance-facts,
  .balance-column .workshop-button--preview,
  .balance-column .editor-save-status {
    display: none;
  }

  .balance-score {
    display: grid;
    grid-template-columns: auto;
    gap: 0;
    padding: 4px;
  }

  .balance-score > span { font-size: 0.85rem; }
  .balance-score small { font-size: 0.39rem; }
  .balance-score progress { height: 9px; border-width: 2px; }

  .balance-messages {
    min-height: 0;
    max-height: 56px;
    align-content: start;
    overflow-y: auto;
    font-size: 0.44rem;
    line-height: 1.2;
  }

  .balance-messages > * { padding: 3px 4px; border-left-width: 3px; }

  .form-heading {
    margin-bottom: 7px;
    padding-bottom: 6px;
  }

  .form-heading p { display: none; }
  .form-heading h2 { font-size: 0.82rem; }

  .design-fieldset {
    margin-bottom: 7px;
    padding: 7px;
  }

  .design-fieldset legend { font-size: 0.63rem; }

  .editor-field { font-size: 0.6rem; }

  .editor-field input,
  .editor-field select {
    min-height: 44px;
    padding: 5px 7px;
    font-size: 0.68rem;
  }

  .effect-editor-row {
    grid-template-columns: minmax(0, 1.2fr) repeat(2, minmax(0, 0.7fr));
  }

  .effect-editor-row > .editor-field:first-child {
    grid-column: auto;
  }

  .form-actions {
    position: sticky;
    z-index: 8;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin: 8px -3px -3px;
    padding: 6px 3px 3px;
    background: #191e24;
  }

  #reset-card-button,
  #save-card-button {
    position: static;
    width: auto;
    min-height: 44px;
    font-size: 0.62rem;
  }

  .collection-panel,
  .deck-panel {
    min-height: 100%;
    padding: 9px;
  }

  .section-heading {
    margin-bottom: 5px;
    padding-bottom: 5px;
  }

  .section-heading p { display: none; }
  .section-heading h2 { font-size: 0.82rem; }
  .section-lead { margin-bottom: 8px; font-size: 0.56rem; }

  .saved-card-list {
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 7px;
  }

  .deck-slots {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    margin-top: 7px;
  }

  .deck-slot {
    min-height: 105px;
    gap: 4px;
    padding: 8px;
  }

  .deck-slot select { min-height: 44px; padding: 5px; font-size: 0.64rem; }
  .deck-summary { margin-top: 7px; padding: 5px 8px; }
  .deck-warning { margin-top: 6px; padding: 5px 7px; font-size: 0.53rem; }
  .deck-actions { margin-top: 7px; }

  .editor-dialog__frame--preview {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    padding: 8px;
  }

  .editor-dialog__frame--preview > header {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
  }

  .editor-dialog__frame--preview .crafted-card {
    width: min(36vw, 172px);
    grid-column: 1;
    grid-row: 1;
  }

  html[data-large-text="true"] .editor-header__back,
  html[data-large-text="true"] .editor-tabs button,
  html[data-large-text="true"] .workshop-button {
    font-size: 0.68rem;
  }
}

@media (max-height: 360px) and (orientation: landscape) {
  .editor-header__title h1 {
    font-size: 0.66rem;
  }

  .editor-tabs {
    width: min(52vw, 300px);
  }

  .card-preview-column .crafted-card {
    width: min(100% - 8px, 122px);
  }

  .balance-column {
    min-height: 50px;
  }
}

@media (forced-colors: active) {
  .card-editor-screen,
  .editor-header__back,
  .editor-header__title h1,
  .editor-header__count,
  .editor-tabs,
  .editor-tabs button,
  .pixel-panel,
  .design-fieldset,
  .editor-field input,
  .editor-field select,
  .deck-slot select,
  .workshop-button,
  .small-tool-button,
  .archive-action,
  .crafted-card,
  .crafted-card__art,
  .deck-slot,
  .editor-dialog__frame,
  .editor-dialog__frame > header button {
    border: 3px solid ButtonText;
    forced-color-adjust: auto;
  }

  .editor-backdrop {
    display: none;
  }

  .editor-tabs button[aria-selected="true"] {
    color: HighlightText;
    background: Highlight;
  }

  .editor-header__back:focus-visible,
  .editor-header__title h1:focus-visible,
  .editor-tabs button:focus-visible,
  .workshop-button:focus-visible,
  .small-tool-button:focus-visible,
  .editor-field input:focus-visible,
  .editor-field select:focus-visible,
  .deck-slot select:focus-visible,
  .editor-dialog__frame > header button:focus-visible {
    outline: 4px solid Highlight;
  }

  .balance-score progress {
    forced-color-adjust: auto;
  }
}

/* Branching exploration map */
.exploration-screen {
  position: fixed;
  z-index: 27;
  inset: 0;
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: 68px auto minmax(0, 1fr) 54px;
  overflow: hidden;
  color: #f5e5b4;
  background: #0a1017;
  isolation: isolate;
  image-rendering: pixelated;
}

.exploration-cavern { position: absolute; z-index: -2; inset: 0; overflow: hidden; background: repeating-linear-gradient(0deg, #111a23 0 48px, #1b2630 48px 52px, #0b1219 52px 96px); }
.exploration-cavern::before { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(3,7,10,.9), transparent 16% 84%, rgba(3,7,10,.9)), radial-gradient(circle at 50% 30%, rgba(70,203,228,.12), transparent 36%); content: ""; }
.exploration-cavern__beam { position: absolute; top: 0; bottom: 0; width: 26px; background: #443426; border-inline: 6px solid #120d0a; box-shadow: inset 6px 0 #76563a, inset -6px 0 #241a13; }
.exploration-cavern__beam--left { left: 5%; transform: rotate(-2deg); }
.exploration-cavern__beam--right { right: 5%; transform: rotate(2deg); }
.exploration-cavern__rail { position: absolute; right: -4%; bottom: 18%; left: -4%; height: 13px; background: #49535b; border-block: 4px solid #070a0d; box-shadow: 0 14px #30251b, 0 18px #080a0c; transform: rotate(-1deg); }
.exploration-cavern__crystal { position: absolute; width: 28px; height: 64px; background: #48d8ec; border: 5px solid #07141a; box-shadow: inset 7px 0 #9af5ff, inset -7px 0 #176b88, 0 0 18px rgba(70,220,242,.45); clip-path: polygon(50% 0,100% 28%,82% 100%,18% 100%,0 28%); }
.exploration-cavern__crystal--one { bottom: 13%; left: 9%; transform: rotate(-12deg); }
.exploration-cavern__crystal--two { right: 8%; bottom: 25%; filter: hue-rotate(78deg); transform: rotate(14deg) scale(.8); }

.exploration-header { display: grid; min-width: 0; grid-template-columns: minmax(120px,1fr) auto minmax(120px,1fr); align-items: center; gap: 12px; padding: max(7px,env(safe-area-inset-top)) max(18px,env(safe-area-inset-right)) 7px max(18px,env(safe-area-inset-left)); background: #141c24; border-bottom: 5px solid #070a0d; box-shadow: inset 0 -3px #354550; }
.exploration-back-button { min-height: 44px; justify-self: start; padding: 7px 14px; color: #d8f8ff; background: #202b34; border: 3px solid #070b0f; box-shadow: inset 0 3px #4b5d69,4px 4px #07090c; font: inherit; font-size: .67rem; font-weight: 900; cursor: pointer; }
.exploration-heading { min-width: 0; text-align: center; }
.exploration-heading p { margin: 0 0 2px; color: #7beeff; font-size: .46rem; letter-spacing: .2em; }
.exploration-heading h1 { margin: 0; color: #ffe6a2; font-size: clamp(.92rem,2vw,1.28rem); letter-spacing: .1em; text-shadow: 3px 3px #56301d; }
.exploration-depth { display: grid; min-width: 64px; justify-self: end; grid-template-columns: auto auto; align-items: center; gap: 7px; padding: 5px 9px; color: #caf7ff; background: #08131a; border: 3px solid #2d414d; }
.exploration-depth small { font-size: .43rem; }
.exploration-depth strong { color: #fff0a9; font-size: 1.15rem; }

.exploration-status { display: grid; grid-template-columns: repeat(5,minmax(92px,1fr)); gap: 7px; padding: 7px max(18px,env(safe-area-inset-right)) 7px max(18px,env(safe-area-inset-left)); background: rgba(10,16,22,.96); border-bottom: 4px solid #070a0d; }
.exploration-status > div { display: grid; min-width: 0; min-height: 48px; grid-template-columns: 34px minmax(0,1fr); align-items: center; gap: 7px; padding: 5px 8px; background: #1e2932; border: 3px solid #080c0f; box-shadow: inset 0 3px #495a65; }
.exploration-status > div > span { display: grid; width: 30px; height: 34px; place-items: center; color: #10212a; background: #62dff1; border: 3px solid #c9faff; font-weight: 900; clip-path: polygon(50% 0,100% 26%,86% 100%,14% 100%,0 26%); }
.exploration-status p { min-width: 0; margin: 0; }
.exploration-status small { display: block; color: #9eafb7; font-size: .4rem; }
.exploration-status strong { display: block; overflow: hidden; color: #ffe8a9; font-size: .66rem; text-overflow: ellipsis; white-space: nowrap; }
.exploration-hp > span { color: #fff; background: #cf4d58 !important; border-color: #ffadb0 !important; }
.exploration-hp strong { color: #ffb5b2; }

.exploration-scroll { min-width: 0; min-height: 0; overflow-x: hidden; overflow-y: auto; padding: 14px max(20px,env(safe-area-inset-right)) 22px max(20px,env(safe-area-inset-left)); }
.route-progress { width: min(100%,980px); margin: 0 auto 14px; padding: 11px 14px; color: #e9dcad; background: rgba(24,31,38,.96); }
.route-progress header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.route-progress header p,.route-progress header h2 { margin: 0; }
.route-progress header p { color: #79e9fa; font-size: .45rem; letter-spacing: .15em; }
.route-progress header h2 { margin-top: 3px; font-size: .76rem; }
.route-progress header > span { padding: 5px 8px; color: #a9bbc2; background: #0b1218; border: 2px solid #40505a; font-size: .54rem; }
.route-progress header > span b { color: #ffe6a0; }
.route-track { display: flex; min-width: 0; align-items: center; gap: 18px; overflow-x: auto; padding: 9px 3px 2px; }
.route-node { position: relative; flex: 0 0 auto; padding: 6px 9px; color: #c9d7dc; background: #28333b; border: 2px solid #52616b; font-size: .48rem; }
.route-node:not(:last-child)::after { position: absolute; top: 50%; left: calc(100% + 3px); width: 12px; height: 3px; background: #58d7e9; content: ""; }
.route-node[data-type="combat"] { color: #ffd0ba; border-color: #b55d4c; }
.route-node--entrance { color: #b8f6ff; border-color: #4fc9de; }

.branch-selection { width: min(100%,1100px); margin: 0 auto; }
.branch-selection__heading { margin-bottom: 10px; text-align: center; }
.branch-selection__heading p,.branch-selection__heading h2,.branch-selection__heading span { margin: 0; }
.branch-selection__heading p { color: #79eafa; font-size: .45rem; letter-spacing: .18em; }
.branch-selection__heading h2 { margin-top: 3px; color: #ffe5a1; font-size: .94rem; text-shadow: 2px 2px #53301f; }
.branch-selection__heading span { display: block; margin-top: 4px; color: #a9b7bd; font-size: .5rem; }
.branch-list { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 13px; }
.branch-list[data-mode="boss"] { grid-template-columns: minmax(0,620px); justify-content: center; }
.branch-card { position: relative; display: grid; width: 100%; min-height: 300px; grid-template-rows: auto 88px auto auto auto 38px; padding: 9px; overflow: hidden; color: #eadfb8; background: #1d2730; border: 5px solid #080b0e; outline: 3px solid #52616b; box-shadow: inset 0 0 0 3px #33414b,7px 8px rgba(0,0,0,.55); font: inherit; text-align: left; cursor: pointer; touch-action: manipulation; }
.branch-card:hover,.branch-card:focus-visible { filter: brightness(1.08); outline: 4px solid #70edff; outline-offset: 3px; transform: translateY(-3px); }
.branch-card[data-danger="high"] { outline-color: #a44e47; }
.branch-card[data-boss-kind] { background: #2b2023; outline-color: #cb7a52; box-shadow: inset 0 0 0 3px #684134,7px 8px rgba(0,0,0,.62),0 0 20px rgba(220,91,68,.2); }
.branch-card[data-boss-kind="final"] { background: #261b2d; outline-color: #bd72cf; box-shadow: inset 0 0 0 3px #603b6c,7px 8px rgba(0,0,0,.68),0 0 24px rgba(198,83,226,.28); }
.branch-card[data-boss-kind] .branch-card__route { color: #ffb47f; }
.branch-card[data-boss-kind="final"] .branch-card__route { color: #e6a1ff; }
.branch-card[data-boss-kind] .branch-card__art i { color: #fff1c4; background: #bd493f; border-color: #ffc17f; }
.branch-card[data-boss-kind="final"] .branch-card__art i { background: #893da2; border-color: #f0b5ff; }
.branch-card[data-boss-kind] .branch-card__action { color: #fff2ce; background: #a54437; border-color: #ffb77a; box-shadow: inset 0 -4px #61221f; }
.branch-card[data-boss-kind="final"] .branch-card__action { background: #743886; border-color: #dfa0ef; box-shadow: inset 0 -4px #401b4d; }
.exploration-dialog__frame[data-result="defeat"] { border-color: #160d19; box-shadow: inset 0 0 0 4px #79526f,9px 10px rgba(0,0,0,.66); }
.exploration-dialog__frame[data-result="defeat"] .exploration-event-icon { color: #e4c8df; background: #5b344f; border-color: #a87899; }
.branch-card__route { color: #7cecff; font-size: .43rem; letter-spacing: .14em; }
.branch-card__art { position: relative; display: grid; margin: 6px 0; place-items: center; overflow: hidden; background: #101820; border: 4px solid #354650; box-shadow: inset 0 0 0 4px #070c10; }
.branch-card__art::before,.branch-card__art::after { position: absolute; width: 26px; height: 56px; background: #3cd0e7; border: 4px solid #8df4ff; content: ""; clip-path: polygon(50% 0,100% 28%,82% 100%,18% 100%,0 28%); }
.branch-card__art::before { left: 16%; bottom: -17px; transform: rotate(-13deg); }
.branch-card__art::after { right: 14%; bottom: -22px; filter: hue-rotate(78deg); transform: rotate(15deg) scale(.8); }
.branch-card__art i { position: relative; z-index: 2; display: grid; width: 52px; height: 58px; place-items: center; color: #28140d; background: #e7bd60; border: 5px solid #fff0a6; box-shadow: 5px 5px #06090c; font-size: 1.15rem; font-style: normal; font-weight: 900; clip-path: polygon(50% 0,100% 25%,88% 100%,12% 100%,0 25%); }
.branch-card[data-event-type="combat"] .branch-card__art i { color: #320e0c; background: #e35f52; border-color: #ffc09d; }
.branch-card[data-event-type="mine"] .branch-card__art i { background: #61daef; border-color: #caffff; }
.branch-card[data-event-type="rest"] .branch-card__art i { background: #71d77f; border-color: #c9ffd0; }
.branch-card[data-event-type="special"] .branch-card__art i { background: #bd6ed3; border-color: #efc1ff; }
.branch-card__copy small { color: #84eafb; font-size: .43rem; }
.branch-card__copy strong { display: block; margin-top: 2px; color: #ffe7a7; font-size: .78rem; }
.branch-card__copy em { display: -webkit-box; margin-top: 5px; overflow: hidden; color: #b6c4ca; font-size: .48rem; font-style: normal; line-height: 1.55; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.branch-card__facts { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 4px; margin-top: 8px; }
.branch-card__facts > span { min-width: 0; padding: 5px; background: #10171d; border: 2px solid #3d4b54; text-align: center; }
.branch-card__facts small,.branch-card__facts b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.branch-card__facts small { color: #81939b; font-size: .35rem; }
.branch-card__facts b { margin-top: 3px; color: #f6d997; font-size: .43rem; }
.branch-card__condition { align-self: center; margin-top: 7px; padding: 5px 7px; color: #c8b5d3; background: #271d2d; border-left: 3px solid #a961bd; font-size: .43rem; }
.branch-card__action { align-self: end; padding: 9px; color: #162027; background: #dfbb68; border: 3px solid #fff0ac; box-shadow: inset 0 -4px #9a6635; font-size: .55rem; font-weight: 900; text-align: center; }

.exploration-note { display: flex; min-width: 0; align-items: center; justify-content: center; gap: 9px; padding: 6px max(14px,env(safe-area-inset-right)) max(6px,env(safe-area-inset-bottom)) max(14px,env(safe-area-inset-left)); background: #111920; border-top: 4px solid #070a0d; }
.exploration-note > span { color: #71e8fa; font-size: 1.15rem; }
.exploration-note p { margin: 0; }
.exploration-note strong,.exploration-note small { display: block; }
.exploration-note strong { color: #ffe6a5; font-size: .54rem; }
.exploration-note small { color: #9fadb4; font-size: .43rem; }

.exploration-dialog { max-width: none; padding: 0; color: #f6e6b4; background: transparent; border: 0; }
.exploration-dialog::backdrop { background: rgba(2,5,9,.84); }
.exploration-dialog__frame { width: min(92vw,560px); max-height: 90vh; padding: 22px; overflow-y: auto; background: #182129; border: 5px solid #070b0e; box-shadow: inset 0 0 0 4px #52616b,9px 10px rgba(0,0,0,.6); text-align: center; }
.exploration-dialog__eyebrow { margin: 0 0 6px; color: #7bedff; font-size: .48rem; letter-spacing: .16em; }
.exploration-dialog h2 { margin: 0 0 10px; color: #ffe5a1; font-size: 1.05rem; text-shadow: 3px 3px #57311e; }
.exploration-dialog p:not(.exploration-dialog__eyebrow) { color: #c6d1d5; font-size: .66rem; line-height: 1.7; }
.exploration-event-icon { display: grid; width: 52px; height: 60px; margin: 0 auto 10px; place-items: center; color: #25150d; background: #dcb95f; border: 5px solid #fff0aa; box-shadow: 4px 5px #07090c; font-size: 1rem; font-weight: 900; clip-path: polygon(50% 0,100% 26%,86% 100%,14% 100%,0 26%); }
.exploration-event-facts { display: grid; grid-template-columns: repeat(3,1fr); gap: 7px; margin: 13px 0; }
.exploration-event-facts div { padding: 7px; background: #0d151b; border: 2px solid #3e4d56; }
.exploration-event-facts dt { color: #8fa1a9; font-size: .4rem; }
.exploration-event-facts dd { margin: 4px 0 0; color: #ffe19a; font-size: .53rem; }
.exploration-event-note { padding: 8px; color: #d0bbda !important; background: #2c2031; border: 2px solid #6d4778; }
.event-choice-list,.merchant-inventory { display: grid; gap: 8px; margin: 13px 0; }
.event-choice-button,.merchant-offer { display: grid; min-height: 58px; gap: 4px; padding: 9px 12px; color: #eee2ba; background: #222e37; border: 3px solid #080c0f; box-shadow: inset 0 3px #52636e,3px 4px #07090b; font: inherit; text-align: left; cursor: pointer; }
.event-choice-button strong,.merchant-offer strong { color: #ffe4a0; font-size: .62rem; }
.event-choice-button small,.merchant-offer small { color: #b3c2c7; font-size: .47rem; line-height: 1.5; }
.event-choice-button:hover,.event-choice-button:focus-visible,.merchant-offer:hover,.merchant-offer:focus-visible { outline: 4px solid #70eaff; outline-offset: 2px; }
.merchant-inventory { grid-template-columns: repeat(3,minmax(0,1fr)); }
.merchant-offer b { justify-self: end; color: #182026; background: #dfbb62; padding: 4px 6px; font-size: .5rem; }
.merchant-offer:disabled { cursor: not-allowed; filter: grayscale(.7) brightness(.65); }
.exploration-dialog__actions { display: flex; justify-content: center; gap: 9px; margin-top: 16px; }

@media (max-width: 760px) {
  .exploration-screen { grid-template-rows: 60px auto minmax(0,1fr) 48px; }
  .exploration-header { grid-template-columns: 86px minmax(0,1fr) 52px; gap: 5px; padding-inline: max(7px,env(safe-area-inset-left)); }
  .exploration-back-button { padding: 5px 7px; font-size: .55rem; }
  .exploration-heading p { display: none; }
  .exploration-heading h1 { overflow: hidden; font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
  .exploration-depth { min-width: 46px; grid-template-columns: 1fr; gap: 0; padding: 2px 4px; text-align: center; }
  .exploration-depth small { font-size: .34rem; }
  .exploration-depth strong { font-size: .85rem; }
  .exploration-status { grid-template-columns: repeat(5,minmax(58px,1fr)); gap: 3px; padding: 4px 6px; overflow-x: auto; }
  .exploration-status > div { min-height: 42px; grid-template-columns: 23px minmax(0,1fr); gap: 3px; padding: 3px; }
  .exploration-status > div > span { width: 22px; height: 28px; border-width: 2px; font-size: .6rem; }
  .exploration-status small { font-size: .31rem; }
  .exploration-status strong { font-size: .48rem; }
  .exploration-scroll { padding: 9px 8px 18px; }
  .route-progress { padding: 8px 9px; }
  .branch-list { grid-template-columns: 1fr; gap: 11px; }
  .branch-card { min-height: 244px; grid-template-columns: 92px minmax(0,1fr); grid-template-rows: auto 88px auto auto 34px; }
  .branch-card__route { grid-column: 1 / -1; }
  .branch-card__art { grid-column: 1; grid-row: 2 / 5; margin-right: 7px; }
  .branch-card__copy { grid-column: 2; grid-row: 2; }
  .branch-card__facts { grid-column: 2; grid-row: 3; }
  .branch-card__condition { grid-column: 2; grid-row: 4; }
  .branch-card__action { grid-column: 1 / -1; grid-row: 5; }
  .exploration-note small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .exploration-dialog__actions { flex-direction: column; }
  .exploration-dialog__actions button { width: 100%; }
  .merchant-inventory { grid-template-columns: 1fr; }
}

@media (max-height: 540px) and (orientation: landscape) {
  .exploration-screen { grid-template-rows: 48px 44px minmax(0,1fr); }
  .exploration-header { padding-block: 3px; }
  .exploration-status { grid-template-columns: repeat(5,minmax(70px,1fr)); padding-block: 2px; }
  .exploration-status > div { min-height: 37px; }
  .exploration-scroll { padding: 6px 9px 8px; }
  .route-progress { display: none; }
  .branch-selection__heading { margin-bottom: 5px; }
  .branch-selection__heading span { display: none; }
  .branch-list { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; }
  .branch-card { min-height: 190px; grid-template-columns: 62px minmax(0,1fr); grid-template-rows: auto 62px auto 31px; padding: 5px; border-width: 4px; }
  .branch-card__route { grid-column: 1 / -1; }
  .branch-card__art { grid-column: 1; grid-row: 2 / 4; margin: 3px 5px 3px 0; }
  .branch-card__art i { width: 38px; height: 44px; border-width: 3px; }
  .branch-card__copy { grid-column: 2; grid-row: 2; }
  .branch-card__copy strong { font-size: .57rem; }
  .branch-card__copy em { font-size: .37rem; -webkit-line-clamp: 1; }
  .branch-card__facts { grid-column: 2; grid-row: 3; margin-top: 2px; }
  .branch-card__condition { display: none; }
  .branch-card__action { grid-column: 1 / -1; grid-row: 4; padding: 5px; }
  .exploration-note { display: none; }
}

/* Battle build 01 */
.battle-screen {
  position: fixed;
  z-index: 28;
  inset: 0;
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: 64px minmax(210px, 1fr) auto minmax(190px, 30vh);
  overflow: hidden;
  color: #f7e6b0;
  background: #0b1017;
  isolation: isolate;
}

.battle-cavern {
  position: absolute;
  z-index: -2;
  inset: 0;
  overflow: hidden;
  background:
    linear-gradient(90deg, transparent 0 8%, #25303b 8% 9%, transparent 9% 91%, #25303b 91% 92%, transparent 92%),
    linear-gradient(#17202a 0 10%, #0e151e 10% 74%, #080d13 74%);
}

.battle-cavern::before,
.battle-cavern::after {
  position: absolute;
  content: "";
  background: #26323e;
  border: 5px solid #090d12;
  box-shadow: inset 0 0 0 4px #17202a, 0 7px #05080c;
}

.battle-cavern::before {
  top: 18%;
  left: -4%;
  width: 108%;
  height: 24px;
  transform: rotate(-1deg);
}

.battle-cavern::after {
  right: 18%;
  bottom: 26%;
  width: 18px;
  height: 68%;
  transform: rotate(5deg);
}

.battle-cavern__strata {
  position: absolute;
  left: 0;
  width: 100%;
  height: 7px;
  background: #303944;
  border-block: 2px solid #080b10;
  opacity: 0.62;
}

.battle-cavern__strata--one { top: 37%; }
.battle-cavern__strata--two { top: 57%; }

.battle-cavern__crystal {
  position: absolute;
  width: 34px;
  height: 84px;
  background: #36cde7;
  border: 5px solid #071219;
  box-shadow: inset 8px 0 #8af3ff, inset -8px 0 #126a8d, 0 0 0 5px #111a22, 0 0 24px rgba(55, 220, 255, 0.34);
  clip-path: polygon(50% 0, 100% 28%, 82% 100%, 18% 100%, 0 28%);
}

.battle-cavern__crystal--left { bottom: 30%; left: 8%; transform: rotate(-13deg); }
.battle-cavern__crystal--right { right: 9%; bottom: 31%; transform: rotate(15deg) scale(0.78); filter: hue-rotate(82deg); }

.battle-cavern__rail {
  position: absolute;
  right: -5%;
  bottom: 23%;
  left: -5%;
  height: 15px;
  background: #4d5660;
  border-block: 4px solid #070a0e;
  box-shadow: 0 13px #251d17, 0 17px #080a0c;
  transform: perspective(160px) rotateX(13deg);
}

.battle-header {
  position: relative;
  z-index: 20;
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(100px, 1fr) auto minmax(100px, 1fr);
  align-items: center;
  gap: 12px;
  padding: max(7px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 7px max(16px, env(safe-area-inset-left));
  background: #131a23;
  border-bottom: 5px solid #070a0e;
  box-shadow: inset 0 -3px #34414e;
}

.battle-back-button,
.end-turn-button {
  min-height: 44px;
  color: #d8f8ff;
  background: #202a34;
  border: 3px solid #070b0f;
  box-shadow: inset 0 3px #4b5b68, 4px 4px #07090c;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
}

.battle-back-button { justify-self: start; padding: 7px 16px; }

.battle-heading { min-width: 0; text-align: center; }
.battle-heading p { margin: 0 0 2px; color: var(--cyan-light); font-size: 0.49rem; letter-spacing: 0.2em; }
.battle-heading h1 { margin: 0; color: var(--gold-light); font-size: clamp(0.92rem, 2vw, 1.3rem); letter-spacing: 0.09em; text-shadow: 3px 3px #5b2e19; }

.battle-turn {
  display: grid;
  min-width: 60px;
  justify-self: end;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 7px;
  padding: 5px 9px;
  color: #c9f8ff;
  background: #08121a;
  border: 3px solid #263844;
}
.battle-turn small { font-size: 0.48rem; }
.battle-turn strong { color: #fff1b0; font-size: 1.2rem; }

.battle-arena {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  overflow: hidden;
  padding: 10px 16px 4px;
}

.enemy-intent {
  position: absolute;
  z-index: 4;
  top: 12px;
  left: 50%;
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 6px;
  color: #ffe6c3;
  background: #171c23;
  border: 3px solid #090c10;
  box-shadow: inset 0 0 0 2px #6f3c2d, 4px 4px rgba(0, 0, 0, 0.55);
  transform: translateX(-50%);
}

.enemy-intent__icon {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  color: #210d09;
  background: #ff7355;
  border: 3px solid #ffb07d;
  font-size: 1rem;
  font-weight: 900;
}
.enemy-intent[data-intent="defend"] .enemy-intent__icon { background: #63dcef; border-color: #c3fbff; }
.enemy-intent[data-intent="debuff"] .enemy-intent__icon { background: #bc6bd4; border-color: #efb8ff; }
.enemy-intent[data-intent="buff"] .enemy-intent__icon { background: #efc94f; border-color: #fff0a6; }
.enemy-intent p { margin: 0; }
.enemy-intent small { display: block; color: #dd9577; font-size: 0.45rem; letter-spacing: 0.12em; }
.enemy-intent strong { display: block; margin-top: 2px; font-size: 0.75rem; }

.battle-enemy {
  position: relative;
  z-index: 2;
  display: grid;
  width: min(310px, 66vw);
  justify-items: center;
  gap: 5px;
  margin-top: 42px;
}

.battle-enemy__nameplate {
  display: flex;
  width: 100%;
  align-items: end;
  justify-content: center;
  gap: 7px;
  text-align: center;
}
.battle-enemy__nameplate p { margin: 0; }
.battle-enemy__nameplate strong { display: block; color: #fff0b9; font-size: 0.88rem; text-shadow: 2px 2px #2b111d; }
.battle-enemy__nameplate p > span { color: var(--enemy-element-color, #c79be8); font-size: 0.56rem; }

.battle-enemy[data-element="dark"] { --enemy-element-color: #d494ef; --enemy-element-glow: rgba(181, 91, 213, 0.55); }
.battle-enemy[data-element="water"] { --enemy-element-color: #80e9ff; --enemy-element-glow: rgba(60, 195, 232, 0.55); }
.battle-enemy[data-element="electric"] { --enemy-element-color: #fff079; --enemy-element-glow: rgba(245, 215, 60, 0.55); }
.battle-enemy[data-element="earth"] { --enemy-element-color: #e8bd7c; --enemy-element-glow: rgba(180, 125, 65, 0.55); }
.battle-enemy[data-tier="elite"] .battle-enemy__nameplate strong::after { margin-left: 6px; color: #ff9b76; content: "◆"; font-size: 0.58rem; }
.battle-enemy[data-tier="mid_boss"] .battle-enemy__nameplate strong::after { margin-left: 6px; color: #ffbd69; content: "◆◆"; font-size: 0.58rem; }
.battle-enemy[data-tier="boss"] .battle-enemy__nameplate strong::after { margin-left: 6px; color: #e893ff; content: "◆◆◆"; font-size: 0.58rem; }

.battle-status-list {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.battle-status-chip {
  padding: 3px 5px;
  color: #f1c8ff;
  background: #3e214d;
  border: 2px solid #9f63b8;
  font-size: 0.53rem;
}
.battle-status-chip[data-status="vulnerable"] { color: #ffd2bd; background: #5c2825; border-color: #e77955; }
.battle-status-chip[data-status="poison"] { color: #d9ffc4; background: #234923; border-color: #6fc85b; }
.battle-status-chip[data-status="strength"] { color: #fff1ad; background: #57411c; border-color: #d9aa43; }

.battle-enemy__sprite {
  position: relative;
  width: 174px;
  height: 102px;
  image-rendering: pixelated;
  filter: drop-shadow(7px 9px #05070a) drop-shadow(0 0 9px var(--enemy-element-glow, rgba(181, 91, 213, 0.45)));
}

.bat-pixel {
  position: absolute;
  top: 28px;
  height: 52px;
  background: #743f9b;
  border: 6px solid #14101c;
  box-shadow: inset 0 8px #b877da, inset 0 -8px #3a2459;
}
.bat-pixel--left { left: 2px; width: 72px; clip-path: polygon(0 0, 100% 30%, 88% 100%, 52% 66%, 24% 92%); transform: rotate(-9deg); }
.bat-pixel--right { right: 2px; width: 72px; clip-path: polygon(100% 0, 0 30%, 12% 100%, 48% 66%, 76% 92%); transform: rotate(9deg); }
.bat-pixel--body { z-index: 2; top: 35px; left: 64px; width: 46px; height: 58px; background: #3d294c; clip-path: polygon(22% 0, 50% 16%, 78% 0, 100% 48%, 70% 100%, 30% 100%, 0 48%); }
.battle-enemy__sprite i { position: absolute; z-index: 3; top: 57px; width: 7px; height: 7px; background: #72f2ff; box-shadow: 0 0 8px #72f2ff; }
.battle-enemy__sprite i:nth-of-type(1) { left: 78px; }
.battle-enemy__sprite i:nth-of-type(2) { right: 78px; }

.battle-enemy[data-enemy="crystal_slime"] .bat-pixel--left,
.battle-enemy[data-enemy="crystal_slime"] .bat-pixel--right { display: none; }
.battle-enemy[data-enemy="crystal_slime"] .bat-pixel--body { top: 29px; left: 39px; width: 96px; height: 66px; background: #398cad; border-color: #0e2531; box-shadow: inset 0 10px #72d9eb, inset 0 -10px #24536d; clip-path: polygon(24% 0, 76% 0, 100% 58%, 86% 100%, 14% 100%, 0 58%); }
.battle-enemy[data-enemy="crystal_slime"] .battle-enemy__sprite i:nth-of-type(1) { top: 59px; left: 68px; }
.battle-enemy[data-enemy="crystal_slime"] .battle-enemy__sprite i:nth-of-type(2) { top: 59px; right: 68px; }

.battle-enemy[data-enemy="ore_golem"] .bat-pixel { background: #665847; border-color: #17130f; box-shadow: inset 0 8px #a58a61, inset 0 -8px #3d342b; }
.battle-enemy[data-enemy="ore_golem"] .bat-pixel--left { top: 44px; left: 6px; width: 58px; height: 48px; clip-path: polygon(16% 0,100% 10%,84% 100%,0 78%); transform: rotate(6deg); }
.battle-enemy[data-enemy="ore_golem"] .bat-pixel--right { top: 44px; right: 6px; width: 58px; height: 48px; clip-path: polygon(0 10%,84% 0,100% 78%,16% 100%); transform: rotate(-6deg); }
.battle-enemy[data-enemy="ore_golem"] .bat-pixel--body { top: 10px; left: 52px; width: 70px; height: 88px; background: #4d4a43; clip-path: polygon(18% 0,82% 0,100% 22%,90% 100%,10% 100%,0 22%); }
.battle-enemy[data-enemy="ore_golem"] .battle-enemy__sprite i:nth-of-type(1) { top: 42px; left: 75px; background: #f0b94d; }
.battle-enemy[data-enemy="ore_golem"] .battle-enemy__sprite i:nth-of-type(2) { top: 42px; right: 75px; background: #f0b94d; }

.battle-enemy[data-enemy="charged_bug"] .bat-pixel { background: #caa62e; border-color: #17150a; box-shadow: inset 0 7px #f6de5a, inset 0 -7px #795c1d; }
.battle-enemy[data-enemy="charged_bug"] .bat-pixel--left { top: 34px; left: 20px; width: 62px; height: 44px; clip-path: polygon(0 22%,100% 0,84% 100%,18% 78%); }
.battle-enemy[data-enemy="charged_bug"] .bat-pixel--right { top: 34px; right: 20px; width: 62px; height: 44px; clip-path: polygon(0 0,100% 22%,82% 78%,16% 100%); }
.battle-enemy[data-enemy="charged_bug"] .bat-pixel--body { top: 24px; left: 65px; width: 44px; height: 72px; background: #286276; clip-path: polygon(50% 0,90% 17%,100% 76%,50% 100%,0 76%,10% 17%); }

.battle-enemy[data-enemy="corrupted_prospector"] .bat-pixel--left { top: 39px; left: 26px; width: 54px; height: 18px; background: #705038; clip-path: polygon(0 20%,100% 0,100% 100%,0 80%); transform: rotate(-20deg); }
.battle-enemy[data-enemy="corrupted_prospector"] .bat-pixel--right { top: 41px; right: 21px; width: 59px; height: 18px; background: #684077; clip-path: polygon(0 0,100% 25%,100% 75%,0 100%); transform: rotate(25deg); }
.battle-enemy[data-enemy="corrupted_prospector"] .bat-pixel--body { top: 6px; left: 61px; width: 52px; height: 94px; background: #55483e; clip-path: polygon(24% 0,76% 0,88% 28%,100% 100%,0 100%,12% 28%); }
.battle-enemy[data-enemy="corrupted_prospector"] .battle-enemy__sprite i:nth-of-type(1) { top: 34px; left: 77px; background: #dd6aff; }
.battle-enemy[data-enemy="corrupted_prospector"] .battle-enemy__sprite i:nth-of-type(2) { top: 34px; right: 77px; background: #dd6aff; }

.battle-enemy[data-enemy="crystal_warden"] .bat-pixel { background: #9b7b45; border-color: #17120c; box-shadow: inset 0 8px #e4bd68, inset 0 -8px #574126; }
.battle-enemy[data-enemy="crystal_warden"] .bat-pixel--left { top: 40px; left: 0; width: 70px; height: 54px; clip-path: polygon(0 25%,80% 0,100% 65%,48% 100%,8% 76%); transform: rotate(-8deg); }
.battle-enemy[data-enemy="crystal_warden"] .bat-pixel--right { top: 40px; right: 0; width: 70px; height: 54px; clip-path: polygon(20% 0,100% 25%,92% 76%,52% 100%,0 65%); transform: rotate(8deg); }
.battle-enemy[data-enemy="crystal_warden"] .bat-pixel--body { top: 3px; left: 48px; width: 78px; height: 96px; background: #397f91; border-color: #10262d; box-shadow: inset 0 10px #78e5f1,inset 0 -10px #22505d; clip-path: polygon(22% 0,78% 0,100% 32%,88% 100%,12% 100%,0 32%); }
.battle-enemy[data-enemy="crystal_warden"] .battle-enemy__sprite i:nth-of-type(1) { top: 41px; left: 70px; background: #fff18e; }
.battle-enemy[data-enemy="crystal_warden"] .battle-enemy__sprite i:nth-of-type(2) { top: 41px; right: 70px; background: #fff18e; }

.battle-enemy[data-enemy="abyss_crown_dragon"] .battle-enemy__sprite { transform: scale(1.12); }
.battle-enemy[data-enemy="abyss_crown_dragon"] .bat-pixel { background: #71358b; border-color: #130b18; box-shadow: inset 0 8px #c66fe0,inset 0 -8px #3a1d49; }
.battle-enemy[data-enemy="abyss_crown_dragon"] .bat-pixel--left { top: 16px; left: -5px; width: 78px; height: 76px; clip-path: polygon(0 0,100% 25%,82% 100%,52% 68%,18% 94%); transform: rotate(-6deg); }
.battle-enemy[data-enemy="abyss_crown_dragon"] .bat-pixel--right { top: 16px; right: -5px; width: 78px; height: 76px; clip-path: polygon(100% 0,0 25%,18% 100%,48% 68%,82% 94%); transform: rotate(6deg); }
.battle-enemy[data-enemy="abyss_crown_dragon"] .bat-pixel--body { top: 18px; left: 58px; width: 58px; height: 82px; background: #261d31; clip-path: polygon(18% 0,36% 13%,50% 0,64% 13%,82% 0,100% 48%,72% 100%,28% 100%,0 48%); }
.battle-enemy[data-enemy="abyss_crown_dragon"] .battle-enemy__sprite i { top: 49px; background: #ffdc61; box-shadow: 0 0 9px #ffca43; }
.battle-enemy[data-enemy="abyss_crown_dragon"] .battle-enemy__sprite::after { position: absolute; z-index: 4; top: 3px; left: 62px; width: 50px; height: 28px; background: linear-gradient(90deg,#e85b62 0 20%,#65dff1 20% 40%,#f1d75b 40% 60%,#72dc8a 60% 80%,#c876dc 80%); border: 4px solid #ffe7a0; content: ""; clip-path: polygon(0 100%,8% 0,28% 55%,50% 0,72% 55%,92% 0,100% 100%); }

.battle-health { position: relative; min-width: 0; }
.battle-health progress {
  display: block;
  width: 100%;
  height: 18px;
  overflow: hidden;
  appearance: none;
  background: #171b20;
  border: 3px solid #080b0e;
}
.battle-health progress::-webkit-progress-bar { background: #171b20; }
.battle-health progress::-webkit-progress-value { background: #d94c54; }
.battle-health progress::-moz-progress-bar { background: #d94c54; }
.battle-health--enemy { width: min(270px, 62vw); }
.battle-health--enemy p { position: absolute; inset: 0; display: flex; height: 18px; align-items: center; justify-content: center; gap: 3px; margin: 0; color: white; font-size: 0.58rem; line-height: 1; text-shadow: 2px 2px #3e1115; pointer-events: none; }
.battle-health--enemy p b { margin-left: 9px; color: #86ebff; }

.battle-effect {
  --effect-main: #ff5c42;
  --effect-light: #fff2a8;
  --effect-shadow: #7a2438;
  --effect-scale: 1;
  --effect-duration: 300ms;
  position: absolute;
  z-index: 5;
  top: 45%;
  left: 50%;
  width: 180px;
  height: 100px;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(var(--effect-scale));
}
.battle-effect[data-intensity="low"] { --effect-scale: 0.78; --effect-duration: 220ms; }
.battle-effect[data-intensity="medium"] { --effect-scale: 1; --effect-duration: 300ms; }
.battle-effect[data-intensity="high"] { --effect-scale: 1.18; --effect-duration: 420ms; }
.battle-effect[data-element="fire"] { --effect-main: #ff5b32; --effect-light: #ffe17b; --effect-shadow: #a3232c; }
.battle-effect[data-element="water"] { --effect-main: #32bde4; --effect-light: #c6fbff; --effect-shadow: #145d91; }
.battle-effect[data-element="wood"] { --effect-main: #56b84f; --effect-light: #d3f18a; --effect-shadow: #245b32; }
.battle-effect[data-element="electric"] { --effect-main: #ffe34f; --effect-light: #8ff7ff; --effect-shadow: #936e1b; }
.battle-effect[data-element="dark"] { --effect-main: #7d3b99; --effect-light: #d998ef; --effect-shadow: #16131d; }
.battle-effect[data-element="ice"] { --effect-main: #9aefff; --effect-light: #f2ffff; --effect-shadow: #387da5; }
.battle-effect[data-element="earth"] { --effect-main: #a87845; --effect-light: #e6ca8b; --effect-shadow: #493321; }
.battle-effect[data-element="neutral"] { --effect-main: #8e9ba5; --effect-light: #eff8f8; --effect-shadow: #3a4651; }
.battle-effect span,
.battle-effect i { display: none; position: absolute; }
.battle-effect[data-effect="attack"] span {
  display: block;
  top: 35px;
  left: 12px;
  width: 155px;
  height: 18px;
  background: var(--effect-light);
  border: 5px solid var(--effect-main);
  box-shadow: 12px -16px var(--effect-shadow), -12px 18px var(--effect-main);
  transform: rotate(-24deg);
  animation: battle-slash var(--effect-duration) steps(4) both;
}
.battle-effect[data-effect="block"] span,
.battle-effect[data-effect="heal"] span,
.battle-effect[data-effect="skill"] span,
.battle-effect[data-effect="status"] span {
  display: block;
  inset: 10px 35px;
  background: var(--effect-main);
  border: 7px solid var(--effect-light);
  box-shadow: 0 0 0 8px var(--effect-shadow);
  clip-path: polygon(50% 0, 100% 27%, 85% 100%, 15% 100%, 0 27%);
  animation: battle-pulse var(--effect-duration) steps(4) both;
}
.battle-effect[data-effect="enemy"] span {
  display: block;
  inset: 25px 20px;
  background: var(--effect-main);
  border: 6px solid var(--effect-light);
  box-shadow: 20px 0 var(--effect-shadow), -20px 0 var(--effect-shadow);
  animation: battle-enemy-hit var(--effect-duration) steps(4) both;
}
.battle-effect:not([data-effect="none"]) i {
  display: block;
  width: 11px;
  height: 11px;
  background: var(--effect-main);
  border: 3px solid var(--effect-light);
  box-shadow: 4px 4px var(--effect-shadow);
  animation: battle-particle var(--effect-duration) steps(4) both;
}
.battle-effect i:nth-of-type(1) { top: 44px; left: 72px; --particle-x: -58px; --particle-y: -38px; }
.battle-effect i:nth-of-type(2) { top: 48px; right: 72px; --particle-x: 62px; --particle-y: -30px; animation-delay: 35ms; }
.battle-effect i:nth-of-type(3) { bottom: 35px; left: 76px; --particle-x: -48px; --particle-y: 42px; animation-delay: 70ms; }
.battle-effect i:nth-of-type(4) { right: 76px; bottom: 35px; --particle-x: 52px; --particle-y: 45px; animation-delay: 105ms; }
.battle-effect[data-hits="1"] i:nth-of-type(n+2),
.battle-effect[data-hits="2"] i:nth-of-type(n+3),
.battle-effect[data-hits="3"] i:nth-of-type(n+4) { display: none; }
.battle-effect[data-element="water"] i { clip-path: polygon(50% 0, 100% 65%, 74% 100%, 26% 100%, 0 65%); }
.battle-effect[data-element="wood"] i { width: 15px; height: 8px; clip-path: polygon(0 50%, 45% 0, 100% 50%, 45% 100%); }
.battle-effect[data-element="electric"] i { width: 9px; height: 24px; clip-path: polygon(55% 0, 100% 0, 67% 38%, 100% 38%, 25% 100%, 43% 55%, 0 55%); }
.battle-effect[data-element="dark"] i { border-color: #231829; }
.battle-effect[data-element="ice"] i { width: 12px; height: 22px; clip-path: polygon(50% 0, 100% 100%, 0 72%); }

.battle-message {
  position: absolute;
  right: 16px;
  bottom: 8px;
  left: 16px;
  margin: 0;
  overflow: hidden;
  color: #c8f5ff;
  font-size: 0.58rem;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.battle-message:empty { display: none; }

.battle-dashboard {
  position: relative;
  z-index: 12;
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(250px, 1fr) auto minmax(210px, 1fr);
  align-items: center;
  gap: 10px;
  padding: 7px max(16px, env(safe-area-inset-right)) 7px max(16px, env(safe-area-inset-left));
  background: #131a22;
  border-block: 4px solid #080b0f;
  box-shadow: inset 0 3px #3a4651;
}

.player-vitals { display: grid; min-width: 0; grid-template-columns: 44px minmax(120px, 260px) 58px; align-items: center; gap: 8px; }
.player-emblem { display: grid; width: 42px; height: 42px; place-items: center; color: #11202a; background: #50d8ec; border: 4px solid #d1fbff; box-shadow: 3px 3px #07090c; font-size: 1.1rem; font-weight: 900; }
.player-vitals > div:nth-child(2) > p { display: flex; align-items: center; gap: 7px; margin: 0 0 3px; color: #ffeab1; font-size: 0.63rem; }
.battle-health--player { display: grid; grid-template-columns: minmax(90px, 220px) auto; align-items: center; gap: 6px; }
.battle-health--player progress { height: 16px; }
.battle-health--player span { color: #ffb1ad; font-size: 0.62rem; }
.player-block { display: grid; min-width: 52px; min-height: 44px; place-items: center; padding: 3px; color: #7f8a92; background: #1c252d; border: 3px solid #0a0d11; clip-path: polygon(50% 0, 100% 18%, 88% 100%, 12% 100%, 0 18%); }
.player-block[data-active="true"] { color: #bff8ff; background: #23566b; border-color: #73e8f6; }
.player-block small { font-size: 0.4rem; }
.player-block strong { font-size: 0.9rem; }

.battle-piles { display: flex; gap: 7px; }
.battle-piles > div { display: grid; min-width: 54px; grid-template-columns: auto auto; align-items: center; gap: 5px; padding: 4px 6px; background: #202832; border: 3px solid #090c10; }
.battle-piles > div > span { color: var(--cyan-light); font-size: 1rem; }
.battle-piles p { margin: 0; text-align: center; }
.battle-piles strong { display: block; color: #ffe6a2; font-size: 0.72rem; }
.battle-piles small { display: block; color: #9daab4; font-size: 0.43rem; }

.battle-controls { display: flex; min-width: 0; align-items: center; justify-content: end; gap: 10px; }
.battle-energy { display: flex; min-width: 72px; height: 52px; align-items: center; justify-content: center; gap: 4px; color: #0b1a21; background: #62dff1; border: 4px solid #d3fbff; box-shadow: 4px 4px #070a0d; clip-path: polygon(12% 0, 88% 0, 100% 50%, 88% 100%, 12% 100%, 0 50%); }
.battle-energy span { color: #fff0a7; text-shadow: 2px 2px #246176; }
.battle-energy strong { font-size: 1.25rem; }
.battle-energy small { font-size: 0.5rem; }
.end-turn-button { min-width: 148px; padding: 6px 12px; color: #28170a; background: #e4bd68; border-color: #fff0ac; box-shadow: inset 0 -5px #9c6335, 4px 4px #07090c; }
.end-turn-button span { display: block; }
.end-turn-button small { display: block; margin-top: 2px; font-size: 0.42rem; letter-spacing: 0.08em; }

.battle-hand-area {
  position: relative;
  z-index: 13;
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 5px max(10px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  background: #090e14;
  box-shadow: inset 0 5px #2c3741;
}

.battle-hand-heading { display: flex; min-width: 0; align-items: center; justify-content: center; gap: 14px; padding: 2px 8px 4px; }
.battle-hand-heading h2 { margin: 0; color: #ffe6a5; font-size: 0.62rem; white-space: nowrap; }
.battle-hand-heading h2 span { color: var(--cyan-light); }
.battle-hand-heading p { min-width: 0; max-width: 56%; margin: 0; overflow: hidden; color: #9fb1bc; font-size: 0.5rem; text-overflow: ellipsis; white-space: nowrap; }
.battle-shortcuts { margin-left: auto; color: #75c8d4; font-size: 0.42rem; white-space: nowrap; }

.battle-hand {
  display: flex;
  min-width: 0;
  min-height: 0;
  align-items: start;
  justify-content: center;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 3px 8px 8px;
  scrollbar-color: #3ecce3 #111820;
  scrollbar-width: thin;
  scroll-snap-type: x proximity;
}

.battle-card-slot { flex: 0 0 146px; scroll-snap-align: center; }
.battle-card {
  position: relative;
  display: grid;
  width: 146px;
  height: 174px;
  grid-template-rows: 32px 74px minmax(42px, 1fr) 19px;
  padding: 5px;
  overflow: visible;
  color: #28190e;
  background: #e6c274;
  border: 4px solid #fff0ae;
  box-shadow: inset 0 0 0 3px #9a632f, 5px 6px #05080a;
  font: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 90ms steps(2), filter 90ms steps(2);
}
.battle-screen button { touch-action: manipulation; }
.battle-card::after { position: absolute; inset: 3px; border: 2px solid var(--card-accent, #d6533f); content: ""; pointer-events: none; }
.battle-card[data-color="blue"] { --card-accent: #36a9d8; }
.battle-card[data-color="green"] { --card-accent: #4eaf62; }
.battle-card[data-color="yellow"] { --card-accent: #d8a928; }
.battle-card[data-color="purple"] { --card-accent: #9957b5; }
.battle-card:hover:not(:disabled), .battle-card:focus-visible { z-index: 5; filter: brightness(1.08); transform: translateY(-8px); }
.battle-card:focus-visible { outline: 4px solid #75efff; outline-offset: 4px; }
.battle-card:disabled { cursor: not-allowed; filter: grayscale(0.72) brightness(0.66); }
.battle-card__cost { position: absolute; z-index: 3; top: -8px; right: -8px; display: grid; width: 34px; height: 39px; place-items: center; color: #09202a; background: #62e4f3; border: 4px solid #e1fdff; box-shadow: 3px 3px #0c2d3c; clip-path: polygon(50% 0, 100% 18%, 100% 78%, 50% 100%, 0 78%, 0 18%); font-size: 0.95rem; font-weight: 900; }
.battle-card__header { display: block; min-width: 0; padding: 2px 28px 2px 5px; border-bottom: 3px solid #8a582c; }
.battle-card__header strong { display: block; overflow: hidden; font-size: 0.63rem; text-overflow: ellipsis; white-space: nowrap; }
.battle-card__header small { display: block; margin-top: 2px; font-size: 0.39rem; }
.battle-card__art { position: relative; display: grid; margin: 4px 3px; place-items: center; overflow: hidden; background: #18232d; border: 4px solid #5e3b22; box-shadow: inset 0 0 0 3px #0b1117; }
.battle-card__art::before { position: absolute; width: 86px; height: 9px; background: var(--card-accent, #d6533f); box-shadow: 0 0 0 5px rgba(255,255,255,0.22); content: ""; transform: rotate(-42deg); }
.battle-card__art b { position: absolute; right: 3px; bottom: 2px; padding: 2px 3px; color: #fff0c0; background: #17212a; border: 2px solid var(--card-accent, #d6533f); font-size: 0.39rem; }
.battle-card__sigil { position: relative; z-index: 2; display: block; width: 38px; height: 38px; background: var(--card-accent, #d6533f); border: 4px solid #ffe9b3; clip-path: polygon(50% 0, 100% 28%, 82% 100%, 18% 100%, 0 28%); }
.battle-card__description { display: -webkit-box; margin: 0 3px; padding: 5px 4px; overflow: hidden; background: #f4d991; border: 2px solid #9a682f; font-size: 0.46rem; line-height: 1.55; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.battle-card__footer { display: flex; align-items: end; justify-content: space-between; padding: 2px 4px 0; font-size: 0.38rem; }
.battle-card__footer small:last-child { max-width: 68px; overflow: hidden; text-align: right; text-overflow: ellipsis; white-space: nowrap; }

.battle-dialog { max-width: none; padding: 0; color: #f7e6b0; background: transparent; border: 0; }
.battle-dialog::backdrop { background: rgba(2, 5, 9, 0.82); }
.battle-dialog__frame { width: min(92vw, 520px); padding: 22px; background: #171e26; border: 5px solid #080b0f; box-shadow: inset 0 0 0 4px #53606b, 9px 10px rgba(0,0,0,0.6); text-align: center; }
.battle-dialog__frame--encounter { width: min(94vw, 760px); max-height: min(90vh, 720px); overflow-y: auto; }
.battle-dialog__frame--reward { width: min(96vw, 780px); max-height: min(94vh, 760px); overflow-y: auto; }
.battle-dialog__eyebrow { margin: 0 0 6px; color: var(--cyan-light); font-size: 0.52rem; letter-spacing: 0.18em; }
.battle-dialog h2 { margin: 0 0 12px; color: var(--gold-light); font-size: 1.15rem; text-shadow: 3px 3px #5b2f1d; }
.battle-dialog p:not(.battle-dialog__eyebrow) { color: #c8d2d7; font-size: 0.7rem; line-height: 1.8; }
.battle-dialog__actions { display: flex; justify-content: center; gap: 10px; margin-top: 18px; }
.battle-result-gem { display: block; width: 56px; height: 70px; margin: 0 auto 10px; background: #52dff2; border: 5px solid #d8fdff; box-shadow: inset 10px 0 #8ff5ff, inset -10px 0 #207f9d, 0 0 22px rgba(72,225,247,0.45); clip-path: polygon(50% 0,100% 28%,82% 100%,18% 100%,0 28%); }
.battle-dialog__frame[data-result="defeat"] .battle-result-gem { background: #65456d; border-color: #9b7aa1; box-shadow: inset 10px 0 #87608d, inset -10px 0 #38263d; }
.battle-dialog__frame[data-result="run-victory"] { border-color: #160d1c; box-shadow: inset 0 0 0 4px #a15cb4,9px 10px rgba(0,0,0,.66),0 0 34px rgba(213,96,235,.28); }
.battle-dialog__frame[data-result="run-victory"] .battle-result-gem { background: linear-gradient(135deg,#52dff2 0 30%,#f2d75c 30% 55%,#d56cec 55%); border-color: #fff0a6; box-shadow: inset 10px 0 rgba(255,255,255,.24),inset -10px 0 rgba(48,18,62,.42),0 0 28px rgba(229,135,255,.62); }
.battle-dialog__frame[data-result="test"] { border-color: #102027; box-shadow: inset 0 0 0 4px #3f8896,9px 10px rgba(0,0,0,.62),0 0 28px rgba(82,223,242,.2); }
.battle-result-stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.battle-result-stats span { padding: 7px 10px; color: #b9c8ce; background: #0d141b; border: 2px solid #3c4b56; font-size: 0.58rem; }
.battle-result-stats b { color: #fff0ad; }
.battle-card-performance { display: grid; gap: 5px; margin-top: 12px; }
.battle-card-performance[hidden] { display: none; }
.battle-card-performance span { padding: 7px 9px; color: #d9f8ff; background: #12272d; border-left: 4px solid #62dced; font-size: .53rem; line-height: 1.5; }

.card-usage-summary { display: block; margin-top: 5px; color: #82dfea; font-size: .42rem; line-height: 1.5; }
.archive-action--test { color: #d5fbff; background: #1f4f59; border-color: #55baca; }
.card-test-dialog__frame { width: min(92vw,600px); }
.card-test-dialog__frame > h2 { margin: 0 0 8px; color: #ffe3a0; }
.card-test-settings { display: grid; grid-template-columns: minmax(0,2fr) minmax(120px,1fr); gap: 12px; margin-top: 16px; text-align: left; }

.compendium-screen { position: fixed; z-index: 12; inset: 0; display: grid; grid-template-rows: auto auto minmax(0,1fr) auto; overflow: hidden; color: #eee2bc; background: #111920; isolation: isolate; }
.compendium-screen[hidden] { display: none; }
.compendium-backdrop { position: absolute; z-index: -1; inset: 0; overflow: hidden; background: linear-gradient(#17242c 0 44%,#0b1117 44%); }
.compendium-backdrop::before { position: absolute; inset: 8% 4% 15%; border: 10px solid #30251d; box-shadow: inset 0 0 0 6px #17120f; content: ""; }
.compendium-backdrop span,.compendium-backdrop i,.compendium-backdrop b { position: absolute; bottom: 8%; width: 34px; height: 72px; background: #3ccce1; border: 5px solid #8af2ff; clip-path: polygon(50% 0,100% 30%,82% 100%,18% 100%,0 30%); }
.compendium-backdrop span { left: 5%; }
.compendium-backdrop i { right: 7%; filter: hue-rotate(80deg); }
.compendium-backdrop i:nth-of-type(2) { right: 14%; bottom: 18%; transform: scale(.62); filter: hue-rotate(230deg); }
.compendium-backdrop b { left: 15%; bottom: 22%; transform: scale(.54); filter: hue-rotate(150deg); }
.compendium-header { position: relative; display: grid; min-width: 0; grid-template-columns: 140px minmax(0,1fr) 100px; align-items: center; padding: max(12px,env(safe-area-inset-top)) max(16px,env(safe-area-inset-right)) 10px max(16px,env(safe-area-inset-left)); background: #151d22; border-bottom: 5px solid #070a0d; box-shadow: inset 0 -3px #3e4a4e; text-align: center; }
.compendium-header > div p,.compendium-header > div h1,.compendium-header > div span,.compendium-counter { margin: 0; }
.compendium-header > div p { color: #6de6f3; font-size: .45rem; letter-spacing: .18em; }
.compendium-header h1 { color: #ffe3a0; font-size: 1.08rem; text-shadow: 3px 3px #56321e; }
.compendium-header > div span { color: #a9bac0; font-size: .48rem; }
.compendium-counter { color: #f2d478; font-size: .86rem; }
.compendium-counter small { display: block; color: #90a1a7; font-size: .4rem; }
.compendium-tabs { display: flex; min-width: 0; gap: 6px; padding: 8px max(14px,env(safe-area-inset-right)) 8px max(14px,env(safe-area-inset-left)); overflow-x: auto; background: #0d1419; border-bottom: 4px solid #070a0d; scrollbar-width: thin; }
.compendium-tabs button { flex: 0 0 auto; min-width: 104px; min-height: 46px; padding: 6px 9px; color: #aebdc2; background: #202c32; border: 3px solid #080c0f; box-shadow: inset 0 0 0 2px #42535b; font: inherit; cursor: pointer; }
.compendium-tabs button[aria-pressed="true"] { color: #102128; background: #68dce9; box-shadow: inset 0 -5px #2e93a2; }
.compendium-tabs strong,.compendium-tabs small { display: block; }
.compendium-tabs strong { font-size: .52rem; }
.compendium-tabs small { margin-top: 3px; font-size: .38rem; }
.compendium-scroll { min-height: 0; padding: 14px max(18px,env(safe-area-inset-right)) 18px max(18px,env(safe-area-inset-left)); overflow-y: auto; }
.compendium-panel { width: min(1120px,100%); margin: 0 auto; padding: 15px; }
.compendium-panel > header { margin-bottom: 12px; text-align: center; }
.compendium-panel > header p,.compendium-panel > header h2 { margin: 0; }
.compendium-panel > header p { color: #63d9e8; font-size: .42rem; letter-spacing: .16em; }
.compendium-panel > header h2 { margin-top: 3px; color: #ffe5a7; font-size: .95rem; }
.compendium-list { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; }
.compendium-entry { display: grid; min-width: 0; min-height: 132px; grid-template-columns: 48px minmax(0,1fr); gap: 10px; align-items: start; padding: 10px; background: #1a242b; border: 4px solid #090d10; outline: 2px solid #46565d; box-shadow: inset 0 0 0 2px #2f3c42,5px 5px rgba(0,0,0,.4); }
.compendium-entry:focus-visible { outline: 4px solid #6ce7f4; outline-offset: 2px; }
.compendium-entry__mark { display: grid; width: 44px; height: 54px; place-items: center; color: #15242a; background: #5fdce9; border: 4px solid #b8faff; font-size: .9rem; clip-path: polygon(50% 0,100% 28%,82% 100%,18% 100%,0 28%); }
.compendium-entry[data-tone="fire"] .compendium-entry__mark,.compendium-entry[data-tone="attack"] .compendium-entry__mark { background: #df6656; border-color: #ffc092; }
.compendium-entry[data-tone="dark"] .compendium-entry__mark,.compendium-entry[data-tone="boss"] .compendium-entry__mark { background: #a256b9; border-color: #efb4ff; }
.compendium-entry small { color: #64d7e5; font-size: .39rem; }
.compendium-entry h3 { margin: 3px 0 6px; color: #ffe5a3; font-size: .68rem; }
.compendium-entry p { margin: 0; color: #b7c4c9; font-size: .46rem; line-height: 1.65; }
.compendium-entry em { display: block; margin-top: 7px; color: #87e2ed; font-size: .41rem; font-style: normal; }
.compendium-footer { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 7px max(14px,env(safe-area-inset-right)) max(7px,env(safe-area-inset-bottom)) max(14px,env(safe-area-inset-left)); background: #11191e; border-top: 4px solid #06090c; }
.compendium-footer > span { color: #65deeb; font-size: 1rem; }
.compendium-footer p { margin: 0; }
.compendium-footer strong,.compendium-footer small { display: block; }
.compendium-footer strong { color: #ffe2a0; font-size: .5rem; }
.compendium-footer small { color: #94a5aa; font-size: .4rem; }

@media (max-width:760px) {
  .card-test-settings { grid-template-columns: 1fr; }
  .compendium-header { grid-template-columns: 88px minmax(0,1fr) 58px; padding-inline: max(8px,env(safe-area-inset-left)); }
  .compendium-header h1 { font-size: .76rem; }
  .compendium-header > div span { display: none; }
  .compendium-list { grid-template-columns: 1fr; }
  .compendium-entry { min-height: 108px; }
}

@media (max-height:540px) and (orientation:landscape) {
  .compendium-header { padding-block: 5px; }
  .compendium-header > div span,.compendium-footer { display: none; }
  .compendium-tabs { padding-block: 4px; }
  .compendium-tabs button { min-height: 38px; }
  .compendium-scroll { padding-block: 7px; }
  .compendium-list { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .compendium-entry { min-height: 104px; }
}

.battle-reward-gem {
  display: block;
  width: 42px;
  height: 52px;
  margin: 0 auto 7px;
  background: #d56cec;
  border: 4px solid #ffd0ff;
  box-shadow: inset 8px 0 #ef9cff, inset -8px 0 #763c8c, 0 0 18px rgba(222, 104, 244, 0.55);
  clip-path: polygon(50% 0,100% 28%,82% 100%,18% 100%,0 28%);
}

.reward-run-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  margin: 10px 0 13px;
}
.reward-run-stats span { padding: 6px 9px; color: #b9cbd2; background: #0b131a; border: 2px solid #3b4d58; font-size: 0.54rem; }
.reward-run-stats b { color: #fff0a8; }

.reward-card-list {
  display: flex;
  min-width: 0;
  justify-content: center;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 10px 12px 14px;
  scrollbar-color: #c16bdd #171e26;
  scrollbar-width: thin;
  scroll-snap-type: x proximity;
}
.reward-card-slot { flex: 0 0 146px; scroll-snap-align: center; }
.reward-card { box-shadow: inset 0 0 0 3px #9a632f, 5px 6px #05080a, 0 0 0 3px #6c3d75; }

.reward-alternatives { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 5px; }
.reward-alternative {
  display: grid;
  min-height: 66px;
  grid-template-columns: 34px minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-items: center;
  gap: 2px 7px;
  padding: 7px 9px;
  color: #e7f4f6;
  background: #24323b;
  border: 3px solid #090d11;
  box-shadow: inset 0 3px #58707c, 3px 4px #07090b;
  font: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}
.reward-alternative > span { display: grid; grid-row: 1 / 3; width: 32px; height: 38px; place-items: center; color: #142029; background: #66dff0; border: 3px solid #c9faff; font-weight: 900; clip-path: polygon(50% 0,100% 28%,82% 100%,18% 100%,0 28%); }
.reward-alternative strong { color: #ffe7a0; font-size: 0.59rem; }
.reward-alternative small { color: #a8bbc2; font-size: 0.43rem; }
.reward-alternative:hover, .reward-alternative:focus-visible { background: #304550; outline: 4px solid #72edff; outline-offset: 2px; }
.reward-alternative--skip > span { color: #d6dde0; background: #404950; border-color: #89959b; }

.reward-confirmation { padding: 16px 8px 4px; }
.reward-confirmation__crystal { display: grid; width: 56px; height: 66px; margin: 0 auto 12px; place-items: center; color: #fff3b0; background: #bc65d7; border: 5px solid #f1bdff; box-shadow: inset 9px 0 #df91f2, inset -9px 0 #714184, 0 0 22px rgba(205, 100, 231, 0.5); clip-path: polygon(50% 0,100% 28%,82% 100%,18% 100%,0 28%); }
.reward-confirmation h3 { margin: 0; color: #ffe7a2; font-size: 0.9rem; }
.reward-confirmation p { margin: 7px 0 0; }

.encounter-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin: 16px 0; }
.encounter-option { position: relative; display: grid; min-height: 86px; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 9px; color: #e8eef0; background: #222b34; border: 3px solid #090c10; box-shadow: inset 0 3px #52616c, 4px 4px rgba(0,0,0,0.5); font: inherit; text-align: left; cursor: pointer; touch-action: manipulation; }
.encounter-option:hover, .encounter-option:focus-visible { background: #2c3943; outline: 4px solid #72edff; outline-offset: 2px; }
.encounter-option[data-tier="elite"] { background: #32252b; box-shadow: inset 0 3px #754955, 4px 4px rgba(0,0,0,0.5); }
.encounter-option__crystal { display: grid; width: 38px; height: 48px; place-items: center; color: #d693ef; background: #4a285d; border: 3px solid #bf7bd8; clip-path: polygon(50% 0,100% 28%,82% 100%,18% 100%,0 28%); }
.encounter-option[data-element="water"] .encounter-option__crystal { color: #b8f5ff; background: #276a89; border-color: #69dff0; }
.encounter-option[data-element="electric"] .encounter-option__crystal { color: #fff3a8; background: #74651e; border-color: #e8cf4d; }
.encounter-option[data-element="earth"] .encounter-option__crystal { color: #e2bd84; background: #665039; border-color: #b99162; }
.encounter-option__copy { min-width: 0; }
.encounter-option__copy strong, .encounter-option__copy small, .encounter-option__copy em { display: block; }
.encounter-option__copy strong { overflow: hidden; color: #ffe7a5; font-size: 0.72rem; text-overflow: ellipsis; white-space: nowrap; }
.encounter-option__copy small { margin-top: 4px; color: #aebdc4; font-size: 0.48rem; }
.encounter-option__copy em { margin-top: 5px; color: #8eeeff; font-size: 0.47rem; font-style: normal; }
.encounter-option__badge { padding: 4px 5px; color: #b9f5ff; background: #142d37; border: 2px solid #397d8d; font-size: 0.45rem; }
.encounter-option[data-tier="elite"] .encounter-option__badge { color: #ffd0bc; background: #4d2725; border-color: #a95a4b; }

@keyframes battle-slash { 0% { opacity: 0; transform: translate(-80px, 30px) rotate(-24deg) scaleX(0.2); } 50% { opacity: 1; } 100% { opacity: 0; transform: translate(75px, -25px) rotate(-24deg) scaleX(1); } }
@keyframes battle-pulse { 0% { opacity: 0; transform: scale(0.25); } 60% { opacity: 1; } 100% { opacity: 0; transform: scale(1.2); } }
@keyframes battle-enemy-hit { 0% { opacity: 0; transform: translate(70px, -30px) scale(0.4); } 55% { opacity: 1; } 100% { opacity: 0; transform: translate(-70px, 25px) scale(1); } }
@keyframes battle-particle { 0% { opacity: 0; transform: translate(0, 0) scale(0.5); } 30% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--particle-x), var(--particle-y)) scale(1); } }

html[data-reduced-motion="true"] .battle-effect span,
html[data-reduced-motion="true"] .battle-effect i,
html[data-reduced-motion="true"] .battle-card { animation: none !important; transition: none !important; }
html[data-reduced-motion="true"] .battle-effect { visibility: hidden; }

html[data-large-text="true"] .battle-card { font-size: 1.1em; }
html[data-large-text="true"] .battle-message,
html[data-large-text="true"] .battle-hand-heading p { font-size: 0.62rem; }
html[data-large-text="true"] .battle-shortcuts,
html[data-large-text="true"] .battle-status-chip,
html[data-large-text="true"] .enemy-intent small { font-size: 0.54rem; }

@media (max-width: 760px) {
  .battle-screen { grid-template-rows: 60px minmax(220px, 1fr) auto 245px; }
  .battle-header { grid-template-columns: 78px minmax(0, 1fr) 52px; gap: 5px; padding-inline: max(7px, env(safe-area-inset-left)); }
  .battle-back-button { padding: 6px 8px; font-size: 0.62rem; }
  .battle-heading p { display: none; }
  .battle-heading h1 { overflow: hidden; font-size: clamp(0.72rem, 3.4vw, 0.9rem); text-overflow: ellipsis; white-space: nowrap; }
  .battle-shortcuts { display: none; }
  .battle-turn { min-width: 48px; grid-template-columns: 1fr; gap: 0; padding: 2px 5px; text-align: center; }
  .battle-turn small { font-size: 0.38rem; }
  .battle-turn strong { font-size: 0.9rem; }
  .battle-arena { padding-inline: 7px; }
  .enemy-intent { top: 7px; min-height: 40px; }
  .enemy-intent__icon { width: 27px; height: 27px; }
  .battle-enemy { margin-top: 38px; }
  .battle-enemy__sprite { width: 150px; height: 90px; transform: scale(0.88); }
  .battle-dashboard { grid-template-columns: minmax(0, 1fr) auto; gap: 6px; padding: 5px max(7px, env(safe-area-inset-right)) 5px max(7px, env(safe-area-inset-left)); }
  .player-vitals { grid-template-columns: minmax(72px, 1fr) 45px; gap: 5px; }
  .player-emblem { display: none; }
  .player-vitals > div:nth-child(2) > p { margin-bottom: 2px; font-size: 0.52rem; }
  .battle-health--player { grid-template-columns: minmax(64px, 1fr) auto; gap: 3px; }
  .player-block { min-width: 42px; min-height: 38px; }
  .battle-piles { grid-column: 1 / -1; grid-row: 2; justify-content: center; }
  .battle-piles > div { min-width: 48px; padding-block: 2px; }
  .battle-controls { grid-column: 2; grid-row: 1; gap: 4px; }
  .battle-energy { min-width: 53px; height: 44px; }
  .battle-energy strong { font-size: 1rem; }
  .battle-energy small { display: none; }
  .end-turn-button { min-width: 94px; padding-inline: 7px; font-size: 0.59rem; }
  .end-turn-button small { font-size: 0.34rem; }
  .battle-hand { justify-content: start; }
  .battle-card-slot { flex-basis: 138px; }
  .battle-card { width: 138px; height: 202px; grid-template-rows: 34px 88px minmax(52px,1fr) 18px; }
  .battle-dialog__actions { flex-direction: column; }
  .battle-dialog__actions button { width: 100%; }
  .encounter-list { grid-template-columns: 1fr; }
  .encounter-option { min-height: 78px; }
  .reward-card-list { justify-content: start; }
  .reward-card-slot { flex-basis: 138px; }
  .reward-alternatives { grid-template-columns: 1fr; }
}

@media (max-width: 390px) {
  .battle-screen { grid-template-rows: 56px minmax(205px, 1fr) auto 235px; }
  .battle-header { grid-template-columns: 64px minmax(0, 1fr) 43px; }
  .battle-back-button { padding-inline: 5px; }
  .battle-heading h1 { font-size: 0.68rem; }
  .battle-turn { min-width: 41px; padding-inline: 2px; }
  .battle-turn small { display: none; }
  .battle-dashboard { gap: 3px; }
  .player-vitals { grid-template-columns: minmax(64px, 1fr) 40px; gap: 3px; }
  .battle-energy { min-width: 48px; }
  .end-turn-button { min-width: 86px; padding-inline: 4px; }
  .battle-piles > div { min-width: 43px; }
  .battle-piles > div > span { display: none; }
  .battle-card-slot { flex-basis: 132px; }
  .battle-card { width: 132px; }
  .reward-card-slot { flex-basis: 132px; }
}

@media (max-height: 540px) and (orientation: landscape) {
  .battle-screen { grid-template-columns: minmax(210px, 43vw) minmax(0, 1fr); grid-template-rows: 48px 70px minmax(0, 1fr); }
  .battle-header { grid-column: 1 / -1; grid-row: 1; padding-block: 3px; }
  .battle-arena { grid-column: 1; grid-row: 2 / 4; border-right: 4px solid #080b0f; }
  .enemy-intent { top: 4px; min-height: 36px; padding: 3px 7px 3px 4px; }
  .enemy-intent__icon { width: 25px; height: 25px; border-width: 2px; }
  .enemy-intent small { display: none; }
  .enemy-intent strong { font-size: 0.56rem; }
  .battle-enemy { width: 95%; margin-top: 35px; }
  .battle-enemy__nameplate strong { font-size: 0.62rem; }
  .battle-enemy__sprite { width: 130px; height: 75px; transform: scale(0.7); }
  .battle-health--enemy { width: min(190px, 86%); }
  .battle-message { right: 5px; bottom: 4px; left: 5px; font-size: 0.43rem; }
  .battle-dashboard { grid-column: 2; grid-row: 2; grid-template-columns: minmax(0, 1fr) auto; padding: 3px 6px; border-top: 0; }
  .player-vitals { grid-template-columns: 28px minmax(70px, 1fr) 38px; }
  .player-emblem { display: grid; width: 27px; height: 27px; }
  .player-vitals > div:nth-child(2) > p { font-size: 0.42rem; }
  .battle-health--player progress { height: 13px; border-width: 2px; }
  .player-block { min-width: 35px; min-height: 33px; }
  .battle-piles { display: none; }
  .battle-energy { min-width: 45px; height: 38px; border-width: 3px; }
  .end-turn-button { min-width: 83px; min-height: 44px; font-size: 0.51rem; }
  .battle-hand-area { grid-column: 2; grid-row: 3; padding: 2px 4px max(3px, env(safe-area-inset-bottom)); }
  .battle-hand-heading { justify-content: start; padding-block: 1px; }
  .battle-hand-heading p { max-width: 78%; font-size: 0.4rem; }
  .battle-hand { gap: 5px; padding: 2px 5px 5px; }
  .battle-card-slot { flex-basis: 94px; }
  .battle-card { width: 94px; height: 142px; grid-template-rows: 25px 52px minmax(43px,1fr) 14px; padding: 3px; border-width: 3px; }
  .battle-dialog__frame--reward { padding: 12px; }
  .battle-reward-gem { display: none; }
  .reward-run-stats { margin: 5px 0; }
  .reward-card-list { gap: 7px; padding-block: 5px 8px; }
  .reward-card-slot { flex-basis: 94px; }
  .reward-alternatives { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .reward-alternative { min-height: 48px; grid-template-columns: 24px minmax(0,1fr); padding: 4px; }
  .reward-alternative > span { width: 24px; height: 30px; }
  .reward-alternative small { display: none; }
  .battle-card__cost { top: -4px; right: -4px; width: 25px; height: 29px; border-width: 3px; font-size: 0.65rem; }
  .battle-card__header { padding-right: 20px; }
  .battle-card__header strong { font-size: 0.43rem; }
  .battle-card__header small, .battle-card__footer { font-size: 0.3rem; }
  .battle-card__art { margin: 2px; border-width: 2px; }
  .battle-card__sigil { width: 25px; height: 25px; border-width: 3px; }
  .battle-card__description { margin-inline: 2px; padding: 3px; font-size: 0.34rem; line-height: 1.35; }
}

@media (forced-colors: active) {
  .battle-screen,
  .battle-header,
  .battle-back-button,
  .enemy-intent,
  .battle-dashboard,
  .battle-card,
  .end-turn-button,
  .battle-dialog__frame {
    border: 3px solid ButtonText;
    forced-color-adjust: auto;
  }
  .battle-cavern { display: none; }
  .battle-effect { color: HighlightText; background: Highlight; }
}
