:root {
  color-scheme: light;
  --ink: #23170f;
  --paper: #fff2bd;
  --paper-deep: #ffd875;
  --orange: #ff782c;
  --red: #e43d35;
  --blue: #2c7eea;
  --green: #2e9f59;
  --purple: #8a45c6;
  font-family: "Gaegu", "Nanum Pen Script", "Comic Sans MS", cursive;
}

* { box-sizing: border-box; }
html { touch-action: manipulation; }
button, a, input, select, textarea { touch-action: manipulation; }
button,
button * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  color: var(--ink);
  background:
    repeating-linear-gradient(0deg, transparent 0 27px, #77a8dd44 28px 29px),
    linear-gradient(90deg, transparent 0 55px, #f06f6f55 56px 58px, transparent 59px),
    #fff8d9;
}

button, input { font: inherit; }
button {
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform .08s ease, box-shadow .08s ease, filter .08s ease;
}
button:active:not(:disabled) { transform: translateY(3px) scale(.98); box-shadow: 0 1px 0 #17100c; filter: saturate(1.15); }
button:disabled { cursor: not-allowed; filter: grayscale(.7); opacity: .55; }

.game-shell {
  width: min(1180px, 100%);
  min-height: 100dvh;
  margin: auto;
  padding: 12px;
}

.game-layout {
  display: grid;
  gap: 15px;
  grid-template-rows: minmax(510px, 58dvh) auto;
}

.battle-field {
  position: relative;
  overflow: hidden;
  padding: 80px 32px 25px;
  border: 6px solid #17100c;
  border-radius: 17px 9px 21px 12px;
  background: #f4dfae url("../assets/doodle/forge-dungeon-bg.png") center / cover no-repeat;
  box-shadow: 7px 8px 0 #17100c;
}

.battle-field::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #fff7d255, transparent 30%, #fff4c466);
  pointer-events: none;
}

.battle-mobile-ad,
.game-desktop-ad { display: none; }

@media (min-width: 981px) {
  .game-shell { padding-block: 11px; }
  .game-layout {
    grid-template-columns: minmax(0, 1fr) 300px;
    grid-template-rows: minmax(500px, 56dvh) auto;
    align-items: start;
  }
  .battle-field { grid-column: 1 / -1; }
  .forge-panel {
    grid-column: 1;
    grid-row: 2;
    padding: 14px 16px 14px;
  }
  .game-layout:not(:has(.game-desktop-ad:not([hidden]))) .forge-panel { grid-column: 1 / -1; }
  .forge-panel .forge-heading { margin-bottom: 8px; }
  .forge-panel .forge-heading h2 { font-size: 27px; }
  .forge-panel .forge-grid {
    grid-template-columns: minmax(165px, .9fr) minmax(260px, 1.4fr) minmax(125px, .72fr);
    gap: 10px;
  }
  .forge-panel .weapon-summary,
  .forge-panel .enhance-card,
  .forge-panel .forge-quick-info {
    min-height: 185px;
    padding: 10px;
    border-width: 3px;
    box-shadow: 3px 3px 0 #17100c;
  }
  .forge-panel .weapon-summary { gap: 8px; }
  .forge-panel .level-seal {
    flex-basis: 58px;
    border-width: 4px;
  }
  .forge-panel .level-seal span { font-size: 12px; }
  .forge-panel .level-seal strong { font-size: 24px; }
  .forge-panel .weapon-summary > div:last-child { min-width: 0; }
  .forge-panel .weapon-summary h3 { font-size: 18px; }
  .forge-panel .weapon-summary p { font-size: 12px; line-height: 1.2; }
  .forge-panel .chance-row { font-size: 14px; }
  .forge-panel .chance-row strong { font-size: 22px; }
  .forge-panel .chance-track { margin: 2px 0 5px; }
  .forge-panel #destroy-warning { margin-bottom: 5px !important; font-size: 10px !important; }
  .forge-panel .battle-actions { gap: 4px; margin: 4px 0; }
  .forge-panel .battle-actions button { min-height: 42px; border-width: 3px; }
  .forge-panel .battle-actions b { font-size: 15px; }
  .forge-panel .enhance-button { min-height: 48px; padding-inline: 16px; font-size: 19px; }
  .forge-panel .sell-button { margin-top: 4px; font-size: 12px; }
  .forge-panel .forge-quick-info {
    grid-column: auto;
    display: grid;
    align-content: center;
    gap: 8px;
    font-size: 14px;
  }
  .forge-panel .forge-quick-info span {
    padding-bottom: 6px;
    border: 0;
    border-bottom: 2px dashed #17100c77;
  }
  .forge-panel .forge-quick-info span:last-child { border: 0; }
  .forge-panel .forge-quick-info strong { font-size: 18px; }
  .forge-panel .game-message { margin-top: 7px; font-size: 15px; }
  .forge-panel .save-status { margin-top: 2px; }
  .forge-panel::before { display: none; }
  .game-desktop-ad:not([hidden]) {
    position: relative;
    grid-column: 2;
    grid-row: 2;
    width: 300px;
    height: 250px;
    display: grid;
    place-items: center;
    justify-self: end;
    align-self: start;
    overflow: hidden;
    background: #fff;
  }
  .game-desktop-ad .adfit-label {
    position: absolute;
    z-index: 1;
    top: 2px;
    left: 4px;
    color: #8b92a2;
    font-family: system-ui, sans-serif;
    font-size: 9px;
  }
}

.scribble-title {
  position: absolute;
  z-index: 4;
  top: 9px;
  left: 50%;
  min-width: 250px;
  padding: 5px 25px 7px;
  border: 4px solid #17100c;
  border-radius: 48% 38% 46% 35%;
  background: #fff06f;
  text-align: center;
  transform: translateX(-50%) rotate(-1.5deg);
  box-shadow: 4px 4px 0 #17100c;
}

.scribble-title h1 {
  margin: 0;
  font-size: clamp(23px, 4vw, 37px);
  line-height: .9;
  letter-spacing: -.05em;
}

.scribble-title span {
  display: block;
  margin-top: 4px;
  color: #d13e32;
  font-size: 13px;
  font-weight: 700;
}

.battle-topline {
  position: relative;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: start;
}

.battle-topline > div:first-child {
  display: grid;
  gap: 1px;
  padding: 7px 12px;
  border: 3px solid #17100c;
  border-radius: 8px 13px 7px 11px;
  background: #fff5cde6;
  transform: rotate(-1deg);
}

.label {
  color: var(--red);
  font-size: 12px;
  font-weight: 700;
}

.battle-topline strong { font-size: 21px; }

.gold-display {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  border: 4px solid #17100c;
  border-radius: 45% 55% 48% 52%;
  background: #ffd73f;
  transform: rotate(1.5deg);
  box-shadow: 3px 4px 0 #17100c;
}

.coin-icon,
.mini-coin {
  display: inline-block;
  flex: 0 0 auto;
  background: url("../assets/doodle/yeopjeon.png") center / contain no-repeat;
}
.coin-icon { width: 27px; height: 27px; }
.mini-coin { width: 20px; height: 20px; vertical-align: -5px; }
.gold-display strong { font-size: 24px; }
.gold-display small { font-size: 13px; font-weight: 700; }

.battle-actions {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin: 8px 0;
}

.battle-actions button {
  position: relative;
  width: auto;
  min-width: 0;
  min-height: 48px;
  padding: 3px;
  border: 4px solid #17100c;
  border-radius: 14px 7px 12px 8px;
  background: #83d9ff;
  box-shadow: 3px 3px 0 #17100c;
  font-weight: 700;
}
.battle-actions button:nth-child(2) { background: #b8f37d; transform: rotate(-1deg); }
.battle-actions button:nth-child(3) { background: #efb8ff; transform: rotate(1deg); }
.battle-actions button:nth-child(4) { background: #ffb989; transform: rotate(-.6deg); }
.battle-actions button:active:not(:disabled) { box-shadow: none; transform: translate(3px, 3px); }
.battle-actions b { display: block; font-size: 17px; line-height: 1; }
.battle-actions em {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 21px;
  padding: 1px 4px;
  border: 2px solid #17100c;
  border-radius: 50%;
  background: #ffe849;
  font-size: 12px;
  font-style: normal;
}

.battle-scene {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr 150px 1fr;
  align-items: center;
  min-height: 305px;
  margin-top: -7px;
}

.fighter-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.armor-side { flex-direction: row-reverse; }

.fighter-copy {
  min-width: 155px;
  padding: 8px 11px;
  border: 3px solid #17100c;
  border-radius: 9px 5px 12px 6px;
  background: #fff8d9e8;
  box-shadow: 3px 3px 0 #17100c;
  transform: rotate(-1deg);
}

.armor-side .fighter-copy { transform: rotate(1.3deg); }
.fighter-copy > span { color: var(--blue); font-size: 12px; font-weight: 700; }
.fighter-copy h2 { margin: 1px 0; font-size: clamp(19px, 2.2vw, 28px); line-height: 1; }
.fighter-copy h2 b { color: var(--red); }
.fighter-copy p { margin: 4px 0 0; font-size: 14px; font-weight: 700; }
.fighter-copy p strong { color: var(--purple); }

.fighter-visual {
  position: relative;
  flex: 0 0 auto;
  width: 150px;
  height: 200px;
  filter: drop-shadow(5px 7px 0 #17100c88);
}

.hero-visual { width: 190px; height: 220px; }

.hero-character {
  position: absolute;
  inset: 3px 47px 3px 0;
  background: url("../assets/doodle/hero-v2.png") center / contain no-repeat;
  filter: drop-shadow(3px 4px 0 #17100c66);
}
.hero-character.windup-frame { background-image: url("../assets/doodle/hero-windup-v3.png"); }
.hero-character.strike-frame { background-image: url("../assets/doodle/hero-strike-v3.png"); }

.hero-head {
  position: absolute;
  top: 30px;
  left: 15px;
  width: 50px;
  height: 49px;
  border: 5px solid #17100c;
  border-radius: 51% 44% 47% 52%;
  background: #ffc78f;
  transform: rotate(-7deg);
}

.hero-head::before {
  content: "•  ◡  •";
  position: absolute;
  top: 9px;
  left: 5px;
  white-space: pre;
  font-size: 15px;
  font-weight: 700;
}

.hero-head::after {
  content: "";
  position: absolute;
  top: -11px;
  left: -6px;
  width: 51px;
  height: 20px;
  border: 5px solid #17100c;
  border-bottom: 0;
  border-radius: 50% 60% 0 0;
  background: #5a351f;
  transform: rotate(4deg);
}

.hero-body {
  position: absolute;
  bottom: 10px;
  left: 8px;
  width: 68px;
  height: 130px;
  border: 6px solid #17100c;
  border-radius: 45% 35% 12px 9px;
  background: repeating-linear-gradient(85deg, #63b9ff 0 14px, #ffed69 15px 27px);
  transform: rotate(3deg);
}

.hero-body::after {
  content: "용사";
  position: absolute;
  top: 35px;
  left: 10px;
  color: #d93632;
  font-size: 18px;
  font-weight: 700;
  transform: rotate(-6deg);
}

.sword-visual,
.armor-visual,
.collection-weapon,
.impact-art,
.enhancement-art {
  display: block;
  background-repeat: no-repeat;
}

.weapon-rig {
  position: absolute;
  z-index: 4;
  top: -53px;
  right: -18px;
  width: 125px;
  height: 167px;
  transform: rotate(-18deg);
  transform-origin: 50% 90%;
}

.weapon-rig::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 2% 24% 25%;
  border-radius: 50%;
  background: var(--element-color, transparent);
  box-shadow: 0 0 18px 8px var(--element-glow, transparent);
  opacity: .28;
  filter: blur(7px);
  animation: weapon-aura 1.1s ease-in-out infinite alternate;
}
.weapon-side[data-element="wood"] .weapon-rig::after { display: none; }
.weapon-side[data-element="steel"] .weapon-rig::after { opacity: .12; }

.sword-visual {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background-image: url("../assets/doodle/weapons-atlas.png");
  background-size: 700% 300%;
  filter: drop-shadow(3px 4px 0 #17100c66);
}

.sword-trail {
  position: absolute;
  z-index: -1;
  inset: -28% -48% -12% -35%;
  display: block;
  border: 13px solid transparent;
  border-right-color: var(--element-color, #fff);
  border-bottom-color: var(--element-glow, #fff);
  border-radius: 50%;
  opacity: 0;
  filter: drop-shadow(0 0 8px var(--element-glow, #fff));
}

.armor-visual {
  width: 145px;
  height: 240px;
  background-image: url("../assets/doodle/armors-atlas.png");
  background-size: 500% 200%;
}

.impact-zone {
  --pop-rotation: -8deg;
  position: relative;
  width: 145px;
  height: 145px;
}

.impact-art {
  position: absolute;
  inset: 0;
  background-image: url("../assets/doodle/effects-atlas.png");
  background-size: 300% 100%;
  opacity: .72;
}

.impact-zone > span {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 31px;
  font-weight: 700;
  -webkit-text-stroke: 5px #17100c;
  paint-order: stroke fill;
  text-shadow: 4px 4px 0 #e13d2e;
  transform: rotate(var(--pop-rotation));
}

.armor-health {
  position: relative;
  z-index: 3;
  width: min(690px, 90%);
  margin: -2px auto 0;
  padding: 8px 12px 10px;
  border: 4px solid #17100c;
  border-radius: 13px 8px 15px 7px;
  background: #fff7dbe8;
  box-shadow: 4px 5px 0 #17100c;
  transform: rotate(-.3deg);
}

@media (min-width: 881px) {
  .speed-buff {
    position: absolute;
    z-index: 4;
    top: 145px;
    left: 32px;
    width: max-content;
    max-width: 190px;
  }

  .battle-scene {
    grid-template-columns: minmax(300px, 1fr) 130px minmax(300px, 1fr);
    min-height: 310px;
    margin-top: -10px;
  }

  .weapon-side {
    justify-content: flex-end;
  }

  .weapon-side .fighter-copy {
    order: -1;
  }

  .armor-side {
    flex-direction: row;
    justify-content: flex-start;
  }

  .fighter-copy {
    min-width: 150px;
    max-width: 180px;
  }

  .fighter-copy h2 {
    font-size: clamp(19px, 1.8vw, 25px);
  }

  .hero-visual {
    width: 175px;
  }

  .armor-visual {
    width: 135px;
    height: 225px;
  }
}

.health-copy { display: flex; justify-content: space-between; font-size: 15px; font-weight: 700; }
.health-copy span { color: var(--red); }
.health-track {
  height: 19px;
  padding: 2px;
  border: 3px solid #17100c;
  border-radius: 9px 5px 8px 4px;
  background: #fff;
  overflow: hidden;
}
.health-track i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 5px 2px 6px 3px;
  background: repeating-linear-gradient(-45deg, #ff4f45 0 11px, #ff9a3f 12px 21px);
  transition: width .24s ease;
}
.combat-verdict { margin: 5px 0 0; text-align: center; color: var(--green); font-size: 14px; font-weight: 700; }
.combat-verdict.blocked { color: var(--red); }

.battle-effects { position: absolute; z-index: 5; inset: 0; overflow: hidden; pointer-events: none; }
.float-effect {
  position: absolute;
  z-index: 9;
  left: 52%;
  top: 40%;
  color: #ff5548;
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 700;
  -webkit-text-stroke: 6px #17100c;
  paint-order: stroke fill;
  text-shadow: 4px 5px 0 #fff09a;
  transform: rotate(-7deg);
  animation: float-up .9s ease forwards;
}

.coin-drop {
  position: absolute;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 2px;
  color: #ffdb2d;
  font-size: 21px;
  font-style: normal;
  font-weight: 700;
  -webkit-text-stroke: 3px #17100c;
  paint-order: stroke fill;
  filter: drop-shadow(2px 3px 0 #17100c88);
  animation: coin-fall .92s cubic-bezier(.25,.7,.28,1) forwards;
}
.coin-drop .coin-icon { width: 31px; height: 31px; }
.coin-drop::before,
.coin-drop::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  background: url("../assets/doodle/yeopjeon.png") center / contain no-repeat;
  animation: loose-coin .75s ease-out forwards;
}
.coin-drop::before { --coin-x: -42px; --coin-rotate: -140deg; }
.coin-drop::after { --coin-x: 48px; --coin-rotate: 170deg; animation-delay: .05s; }

.element-burst {
  position: absolute;
  z-index: 8;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  pointer-events: none;
}
.element-burst::before {
  content: "";
  position: absolute;
  width: 34px;
  height: 34px;
  border: 7px solid var(--element-color);
  border-radius: 50%;
  box-shadow: 0 0 16px 5px var(--element-glow);
  transform: translate(-50%, -50%);
  animation: element-ring .5s ease-out forwards;
}
.element-burst.armor-break::before { border-width: 11px; animation-duration: .68s; }
.element-burst b {
  position: absolute;
  top: -13px;
  left: -9px;
  color: var(--element-color);
  font-family: "Gaegu", cursive;
  font-size: 25px;
  font-style: normal;
  line-height: 1;
  text-shadow: 0 0 7px var(--element-glow), 2px 2px 0 #17100c;
  animation: element-particle .62s cubic-bezier(.12,.72,.24,1) var(--particle-delay) forwards;
}
.element-flame b { font-size: 29px; text-shadow: 0 0 9px #ffdf32, 2px 2px 0 #8b1b0d; }
.element-thunder b { font-size: 34px; transform: skewX(-15deg); }
.element-frost b { color: #eaffff; text-shadow: 0 0 8px #28c7ff, 2px 2px 0 #23699f; }
.element-shadow b,
.element-abyss b { filter: blur(.4px); }
.element-holy b,
.element-origin b { text-shadow: 0 0 11px #fff, 0 0 18px var(--element-glow), 2px 2px 0 #8e5b00; }
.element-dimension::before,
.element-time::before { border-style: double; border-radius: 42% 58% 47% 53%; }

.forge-panel {
  position: relative;
  padding: 22px 28px 25px;
  border: 6px solid #17100c;
  border-radius: 9px 20px 8px 17px;
  background:
    repeating-linear-gradient(0deg, transparent 0 27px, #63a5d93d 28px 29px),
    #ffe7a3;
  box-shadow: 7px 8px 0 #17100c;
}

.forge-panel::before {
  content: "낙서 금지 (이미 늦음)";
  position: absolute;
  right: 27px;
  bottom: 12px;
  color: #db493f88;
  font-size: 18px;
  font-weight: 700;
  transform: rotate(-8deg);
}

.forge-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; }
.forge-heading span { color: var(--red); font-size: 14px; font-weight: 700; }
.forge-heading h2 { margin: -2px 0 0; font-size: 31px; line-height: 1; transform: rotate(-1deg); }
.speed-buff {
  padding: 7px 11px;
  border: 3px solid #17100c;
  border-radius: 12px 6px 11px 5px;
  background: #85eaff;
  font-size: 15px;
  font-weight: 700;
  transform: rotate(2deg);
}

.forge-grid { display: grid; grid-template-columns: 1.05fr 1.2fr .9fr; gap: 15px; }
.weapon-summary,
.enhance-card,
.consumables,
.forge-quick-info,
.forge-actions {
  min-height: 160px;
  padding: 14px;
  border: 4px solid #17100c;
  background: #fff7d7;
  box-shadow: 5px 5px 0 #17100c;
}
.weapon-summary { display: flex; align-items: center; gap: 12px; border-radius: 13px 7px 15px 6px; transform: rotate(-.7deg); }
.enhance-card { border-radius: 7px 15px 6px 12px; transform: rotate(.5deg); }
.consumables { margin: 0; border-radius: 16px 6px 13px 8px; transform: rotate(-.4deg); }
.forge-quick-info {
  display: grid;
  align-content: center;
  gap: 12px;
  border-radius: 16px 6px 13px 8px;
  background: #dff3ff;
  font-size: 17px;
  font-weight: 700;
  text-align: center;
  transform: rotate(-.4deg);
}
.forge-quick-info span { padding-bottom: 7px; border-bottom: 3px dashed #17100c77; }
.forge-quick-info span:last-child { padding: 0; border: 0; }
.forge-quick-info strong { color: var(--purple); font-size: 22px; }
.forge-actions { border-radius: 7px 13px 6px 17px; transform: rotate(.7deg); }

.level-seal {
  flex: 0 0 76px;
  aspect-ratio: 1;
  display: grid;
  place-content: center;
  border: 5px solid #17100c;
  border-radius: 53% 44% 49% 40%;
  background: #ffeb55;
  text-align: center;
  transform: rotate(-4deg);
}
.level-seal span { color: var(--red); font-size: 13px; font-weight: 700; }
.level-seal strong { color: var(--blue); font-size: 28px; line-height: .9; }
.weapon-summary h3 { margin: 0 0 5px; font-size: 22px; line-height: 1; }
.weapon-summary p { margin: 0; font-size: 14px; font-weight: 700; line-height: 1.35; }

.chance-row { display: flex; justify-content: space-between; font-size: 15px; font-weight: 700; }
.chance-row strong { color: var(--purple); font-size: 25px; }
.chance-track {
  height: 12px;
  margin: 4px 0 8px;
  border: 3px solid #17100c;
  border-radius: 6px 3px 7px 4px;
  background: #fff;
  overflow: hidden;
}
.chance-track i { display: block; width: 100%; height: 100%; background: repeating-linear-gradient(90deg, #ff7436 0 15px, #ffe447 16px 29px); transition: width .2s; }

#destroy-warning { color: var(--red) !important; font-family: inherit; font-size: 12px !important; font-weight: 700; }

.enhance-button {
  width: 100%;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  border: 0;
  background: transparent url("../assets/doodle/enhance-button.png") center / 100% 100% no-repeat;
  color: #17100c;
  font-size: 21px;
  font-weight: 700;
  transform: rotate(-.5deg);
  filter: drop-shadow(3px 4px 0 #17100c);
}
.enhance-button:hover:not(:disabled) { transform: rotate(.7deg) scale(1.025); }
.enhance-button:active:not(:disabled) { transform: translate(3px, 4px) rotate(.7deg); filter: none; }
.enhance-button strong { color: #7d1e1d; font-size: 16px; }
.sell-button { width: 100%; margin-top: 7px; border: 0; background: none; color: #6d4d3b; font-size: 13px; font-weight: 700; text-decoration: wavy underline; }

.consumables legend { padding: 0 5px; color: var(--blue); font-size: 14px; font-weight: 700; }
.consumables label {
  display: grid;
  grid-template-columns: 21px 34px 1fr auto;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  border-bottom: 3px dashed #17100c77;
  font-size: 14px;
  font-weight: 700;
}
.consumables label:last-child { border: 0; }
.consumables input { width: 18px; height: 18px; accent-color: var(--orange); }
.consumable-icon,
.shop-item-icon {
  display: block;
  background-image: url("../assets/doodle/shop-items-atlas.png");
  background-repeat: no-repeat;
  background-size: 200% 200%;
}
.consumable-icon { width: 32px; height: 32px; }
.lucky-icon { background-position: 0 0; }
.protection-icon { background-position: 100% 0; }
.hammer-icon { background-position: 0 100%; }
.consumables b,
.forge-actions b { min-width: 24px; padding: 1px 6px; border: 2px solid #17100c; border-radius: 50%; background: #ffeb50; text-align: center; font-size: 13px; }

.forge-actions { display: grid; gap: 8px; }
.forge-actions button,
.primary,
.secondary,
.shop-list button,
.save-card button {
  min-height: 40px;
  border: 3px solid #17100c;
  border-radius: 10px 5px 12px 6px;
  background: #8ed9ff;
  box-shadow: 3px 3px 0 #17100c;
  font-weight: 700;
}
.forge-actions button { padding: 2px 8px; text-align: left; font-size: 14px; }
.forge-actions button:nth-child(2) { background: #b8f37d; transform: rotate(-1deg); }
.forge-actions button:nth-child(3) { background: #efb8ff; transform: rotate(1deg); }
.forge-actions button:nth-child(4) { background: #ffb989; transform: rotate(-.6deg); }
.forge-actions span { display: inline-grid; width: 24px; color: var(--red); font-size: 18px; }
.forge-actions button:active:not(:disabled),
.primary:active:not(:disabled),
.secondary:active:not(:disabled),
.shop-list button:active:not(:disabled) { box-shadow: none; transform: translate(3px, 3px); }

.game-message,
.save-status { position: relative; margin: 14px 0 0; text-align: center; font-weight: 700; }
.game-message { color: #4d2e20; font-size: 17px; }
.game-message[data-tone="success"] { color: var(--green); }
.game-message[data-tone="danger"] { color: var(--red); }
.save-status { color: #75594a; font-size: 12px; }

.forge-effects { position: absolute; z-index: 12; inset: 0; display: grid; place-items: center; overflow: hidden; pointer-events: none; }
.enhancement-effect {
  position: relative;
  width: min(390px, 88%);
  aspect-ratio: 2 / 1;
  animation: enhancement-pop 1.3s ease forwards;
}
.enhancement-art {
  position: absolute;
  inset: -40%;
  background-image: url("../assets/doodle/effects-atlas.png");
  background-size: 300% 100%;
}
.enhancement-effect strong {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: clamp(28px, 5vw, 48px);
  text-align: center;
  white-space: pre-line;
  -webkit-text-stroke: 7px #17100c;
  paint-order: stroke fill;
  text-shadow: 5px 5px 0 var(--red);
  transform: rotate(-4deg);
}
.enhancement-effect.destroyed strong { color: #aeeaff; text-shadow: 5px 5px 0 #2767c9; }

.forge-sequence {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background:
    linear-gradient(#211008d9, #2c1309e3),
    url("../assets/doodle/forge-dungeon-bg.png") center / cover no-repeat;
  backdrop-filter: blur(3px);
}

.forge-stage {
  position: relative;
  width: min(390px, 94vw);
  height: min(430px, 78dvh);
  min-height: 330px;
  overflow: hidden;
  border: 7px solid #17100c;
  border-radius: 20px 9px 17px 11px;
  background:
    linear-gradient(180deg, #2c140022, #e8620055),
    url("../assets/doodle/forge-dungeon-bg.png") 16% center / auto 100% no-repeat,
    #e8ad5c;
  box-shadow: 10px 11px 0 #17100c;
}

.forge-stage > span {
  position: absolute;
  z-index: 5;
  top: 18px;
  left: 50%;
  width: max-content;
  max-width: 90%;
  padding: 6px 16px;
  border: 4px solid #17100c;
  border-radius: 50%;
  background: #fff36d;
  font-size: 23px;
  font-weight: 700;
  text-align: center;
  transform: translateX(-50%) rotate(-2deg);
}

.forge-light {
  position: absolute;
  z-index: 6;
  inset: -25%;
  display: block;
  background: radial-gradient(circle, #fff 0 9%, #fff77c 18%, #ff9e32 34%, transparent 67%);
  opacity: 0;
  transform: scale(.15);
}

.forge-anvil,
.forge-hammer {
  position: absolute;
  display: block;
  width: 210px;
  height: 210px;
  background-image: url("../assets/doodle/forge-kit.png");
  background-repeat: no-repeat;
  background-size: 200% 100%;
}
.forge-anvil { left: 50%; bottom: 4px; background-position: 0 0; transform: translateX(-58%); }
.forge-hammer {
  z-index: 4;
  top: 60px;
  right: 7px;
  background-position: 100% 0;
  transform: rotate(-25deg);
  transform-origin: 68% 76%;
}
.forge-preview {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 92px;
  display: block;
  width: 105px;
  height: 140px;
  background-image: url("../assets/doodle/weapons-atlas.png");
  background-repeat: no-repeat;
  background-size: 700% 300%;
  transform: translateX(-65%) rotate(82deg);
  filter: drop-shadow(3px 3px 0 #17100c88);
}
.forge-hit-sparks {
  position: absolute;
  z-index: 6;
  left: 50%;
  bottom: 142px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  opacity: 0;
  transform: translateX(-50%);
}
.forge-stage > strong {
  position: absolute;
  z-index: 7;
  inset: 75px 10px auto;
  color: #fff;
  font-size: clamp(31px, 9vw, 48px);
  text-align: center;
  -webkit-text-stroke: 7px #17100c;
  paint-order: stroke fill;
  text-shadow: 5px 5px 0 var(--red);
  transform: rotate(-5deg);
  opacity: 0;
}
.forge-sequence.hammer-hit .forge-hammer { animation: forge-hammering .16s ease-in-out 1; }
.forge-sequence.hammer-hit .forge-preview { animation: forge-rattle .16s ease-in-out 1; }
.forge-sequence.hammer-hit .forge-hit-sparks { animation: forge-spark-pop .17s ease-out 1; }
.forge-sequence.revealing .forge-light { animation: forge-light-reveal .54s ease-out forwards; }
.forge-sequence.revealing .forge-stage { animation: forge-stage-reveal .54s ease-out; }
.forge-sequence.resolved .forge-hammer { animation: hammer-bounce .5s ease forwards; }
.forge-sequence.resolved .forge-stage > strong { animation: forge-result-pop .5s cubic-bezier(.2,1.5,.4,1) forwards; }
.forge-sequence.resolved.success .forge-stage { animation: rainbow-stage .9s ease; }
.forge-sequence.resolved.protected .forge-stage > strong { color: #c9f6ff; text-shadow: 5px 5px 0 #2470bd; }
.forge-sequence.resolved.destroyed .forge-stage > strong { color: #ffd1c7; text-shadow: 5px 5px 0 #a51e1e; }
.forge-sequence.destroyed .forge-preview { animation: forged-weapon-break .9s ease forwards; }
.forge-sequence.protected .forge-preview { animation: protected-wobble .6s ease; }

.modal {
  width: min(470px, calc(100% - 30px));
  padding: 26px;
  border: 6px solid #17100c;
  border-radius: 17px 8px 21px 11px;
  background:
    repeating-linear-gradient(0deg, transparent 0 27px, #63a5d93d 28px 29px),
    #fff1b9;
  color: var(--ink);
  box-shadow: 8px 9px 0 #17100c;
  transform: rotate(-.4deg);
}
.modal::backdrop { background: #291b15c7; backdrop-filter: blur(3px); }
.game-modal::before {
  content: attr(data-gold) " 엽전";
  position: sticky;
  z-index: 8;
  top: 0;
  float: right;
  min-height: 34px;
  margin: 0 8px 8px 0;
  padding: 4px 10px 4px 37px;
  border: 3px solid #17100c;
  border-radius: 48% 52% 46% 54%;
  background: #ffd73f url("../assets/doodle/yeopjeon.png") 7px center / 24px 24px no-repeat;
  box-shadow: 2px 2px 0 #17100c;
  font-size: 17px;
  font-weight: 700;
  line-height: 20px;
  white-space: nowrap;
}
.modal h2 { margin: 4px 0 8px; font-size: 31px; line-height: 1; }
.modal p, .modal small { color: #62493c; font-size: 15px; font-weight: 700; line-height: 1.35; }
.genre-note {
  margin: 10px 0;
  padding: 8px 10px;
  border: 3px dashed #17100c;
  border-radius: 8px 13px 7px 11px;
  background: #fff36d;
  color: #3e291e !important;
  transform: rotate(-.7deg);
}
.genre-note strong { color: var(--red); font-size: 19px; }
.forge-modal { width: min(780px, calc(100% - 22px)); }
.forge-workbench { display: grid; grid-template-columns: 1fr 1.2fr; gap: 12px; margin: 14px 0; }
.forge-equipped,
.probability-sheet,
.sacrifice-picker,
.equipped-strip {
  border: 4px solid #17100c;
  border-radius: 12px 7px 14px 8px;
  background: #fff8d9;
  box-shadow: 3px 3px 0 #17100c;
}
.forge-equipped { display: flex; align-items: center; gap: 10px; padding: 9px; }
.forge-equipped .collection-weapon { flex: 0 0 62px; }
.forge-equipped span { color: var(--blue); font-size: 13px; font-weight: 700; }
.forge-equipped h3 { margin: 2px 0 0; font-size: 21px; }
.probability-sheet { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 12px; padding: 10px 13px; }
.probability-sheet > div { display: flex; justify-content: space-between; font-weight: 700; }
.probability-sheet > div strong { color: var(--green); }
.probability-sheet .probability-total { grid-column: 1 / -1; margin-top: 3px; padding-top: 4px; border-top: 3px dashed #17100c88; font-size: 19px; }
.probability-sheet .probability-total strong { color: var(--red); font-size: 26px; }
.probability-sheet .chance-track { grid-column: 1 / -1; width: 100%; }
.sacrifice-picker { margin-bottom: 12px; padding: 10px; }
.forge-target-picker {
  padding: 9px 10px;
  border: 4px solid #17100c;
  border-radius: 10px 6px 12px 8px;
  background: #ffe59a;
  box-shadow: 3px 3px 0 #17100c;
}
.forge-target-picker .section-heading strong { color: var(--red); font-size: 15px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.section-heading h3 { margin: 0; font-size: 20px; }
.section-heading button { min-height: 30px; border: 2px solid #17100c; border-radius: 8px 4px 9px 5px; background: #ffb989; font-weight: 700; }
#sacrifice-help { margin: 5px 0 7px; font-size: 13px; }
.forge-icon-list {
  display: flex;
  gap: 8px;
  max-width: 100%;
  padding: 5px 3px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}
.forge-list-row { display: flex; align-items: center; gap: 4px; min-width: 0; }
.forge-list-row > .forge-icon-list { flex: 1; min-width: 0; }
.forge-page-button { display: none; }
.forge-weapon-icon {
  position: relative;
  flex: 0 0 70px;
  width: 70px;
  height: 88px;
  padding: 4px;
  border: 3px solid #17100c;
  border-radius: 10px 6px 12px 7px;
  background: #fffdf2;
  box-shadow: 3px 3px 0 #17100c;
  touch-action: none;
}
#forge-target-list .forge-weapon-icon { touch-action: pan-x; }
.forge-weapon-icon:nth-child(even) { transform: rotate(1deg); }
.forge-weapon-icon .collection-weapon { width: 45px; height: 61px; margin: -2px auto 0; }
.forge-weapon-icon > strong {
  position: absolute;
  right: 4px;
  bottom: 2px;
  padding: 0 4px;
  border: 2px solid #17100c;
  border-radius: 50%;
  background: #fff16d;
  color: var(--red);
  font-size: 15px;
  line-height: 20px;
}
.forge-weapon-icon > small {
  position: absolute;
  top: 2px;
  left: 2px;
  min-width: 27px;
  padding: 0 3px;
  border: 2px solid #17100c;
  border-radius: 7px 4px 8px 5px;
  background: #9dec7e;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
}
.forge-weapon-icon.selected { background: #fff16d; box-shadow: 0 0 0 4px #ff7b32, 3px 3px 0 4px #17100c; transform: rotate(-1deg) translateY(-2px); }
.forge-weapon-icon.dragging { opacity: .42; }
.material-list { min-height: 96px; max-height: 108px; }
.sacrifice-slot {
  min-height: 82px;
  display: grid;
  grid-template-columns: 62px 1fr;
  align-items: center;
  gap: 7px;
  margin-top: 7px;
  padding: 6px 9px;
  border: 4px dashed #8f5b34;
  border-radius: 14px 8px 15px 9px;
  background: #f4cf8f88;
  transition: transform .12s ease, background .12s ease, box-shadow .12s ease;
}
.sacrifice-slot > span { color: #7d1e1d; font-size: 17px; font-weight: 700; text-align: center; }
#sacrifice-slot-content { min-height: 62px; display: flex; align-items: center; justify-content: center; gap: 8px; border-left: 3px dashed #17100c55; }
#sacrifice-slot-content .collection-weapon { width: 44px; height: 59px; }
#sacrifice-slot-content strong { color: var(--red); font-size: 22px; }
.sacrifice-slot.filled { border-style: solid; background: #fff16d; box-shadow: inset 0 0 0 3px #ff963f; }
.sacrifice-slot.drag-active { transform: scale(1.015); background: #d8f7c8; }
.sacrifice-slot.drop-ready { box-shadow: 0 0 0 5px #42b85f, inset 0 0 18px #fff; transform: scale(1.035) rotate(-.5deg); }
.forge-drag-ghost {
  position: fixed;
  z-index: 9999;
  width: 72px;
  height: 90px;
  margin: -45px 0 0 -36px;
  opacity: .9;
  pointer-events: none;
  transform: rotate(7deg) scale(1.08);
  filter: drop-shadow(7px 9px 2px #17100c66);
}
.material-card {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  min-width: 0;
  padding: 5px;
  border: 3px solid #17100c;
  border-radius: 9px 5px 11px 6px;
  background: #fff;
  text-align: left;
}
.material-card.selected { background: #fff16d; box-shadow: 0 0 0 4px #ff7b32; transform: rotate(-1deg); }
.material-card .collection-weapon { width: 43px; height: 58px; }
.material-card span { min-width: 0; }
.material-card strong,
.material-card small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.material-card strong { font-size: 13px; }
.material-card small { color: var(--green); font-size: 11px; }
.empty-inventory { grid-column: 1 / -1; margin: 0; padding: 13px; border: 3px dashed #17100c88; background: #fff; text-align: center; }
.forge-consumables { min-height: 0; display: grid; grid-template-columns: repeat(3, 1fr); padding: 7px 12px; }
.forge-consumables label { padding: 0 8px; border: 0; border-right: 3px dashed #17100c66; }
.forge-consumables label:last-child { border-right: 0; }
.forge-confirm-row { display: grid; grid-template-columns: auto minmax(220px, 1fr); align-items: center; gap: 13px; margin-top: 14px; }
.forge-confirm-row > div { display: grid; padding: 5px 12px; border: 3px solid #17100c; border-radius: 50%; background: #ffea53; text-align: center; }
.forge-confirm-row > div strong { display: flex; align-items: center; gap: 4px; font-size: 20px; }
.forge-confirm-row .primary { min-height: 54px; background: #ff824b; font-size: 22px; }

.inventory-modal { width: min(720px, calc(100% - 22px)); }
.equipped-strip { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 9px; margin: 12px 0; padding: 9px 12px; }
.equipped-strip span { color: var(--blue); font-weight: 700; }
.equipped-strip strong { font-size: 20px; }
.equipped-strip button,
.inventory-actions button,
.inventory-card > button { min-height: 34px; border: 2px solid #17100c; border-radius: 8px 4px 9px 5px; background: #9dec7e; font-weight: 700; }
.inventory-subtitle { margin: 15px 0 5px; color: var(--red); font-size: 20px; }
.inventory-list { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; max-height: 260px; padding: 3px; overflow: auto; }
.inventory-card { display: grid; grid-template-columns: 55px 1fr; align-items: center; gap: 5px 9px; padding: 8px; border: 3px solid #17100c; border-radius: 10px 5px 12px 6px; background: #fff9df; box-shadow: 2px 2px 0 #17100c; }
.inventory-card .collection-weapon { grid-row: 1 / 3; width: 50px; height: 67px; }
.inventory-card h3,
.inventory-card p { margin: 0; }
.inventory-card h3 { font-size: 16px; line-height: 1; }
.inventory-card h3 b { color: var(--red); }
.inventory-card p { font-size: 12px; }
.inventory-actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.inventory-actions button:last-child { background: #ffb989; }
.inventory-card.compact { grid-template-columns: 48px 1fr auto; }
.inventory-card.compact .shop-item-icon { width: 45px; height: 45px; margin: 0; }
.item-inventory-list { max-height: 180px; }
.speed-upgrade-card { background: #fff0a8; }
.modal-eyebrow { color: var(--red); font-size: 14px; font-weight: 700; }
.modal-actions { display: grid; gap: 10px; margin: 20px 0 12px; }
.modal-actions.inline { grid-template-columns: 1fr 1fr; margin-bottom: 0; }
.primary { background: #ff9e4f; }
.secondary { background: #8fd9ff; }
.save-count { display: inline-block; margin: 5px 0 12px; padding: 3px 10px; border: 3px solid #17100c; border-radius: 50%; background: #ffea53; font-weight: 700; }
.save-list { display: grid; gap: 10px; margin-bottom: 15px; }
.save-card { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 12px; border: 4px solid #17100c; border-radius: 12px 6px 13px 7px; background: #fff9df; box-shadow: 3px 3px 0 #17100c; }
.save-card h3, .save-card p { margin: 0; }
.save-card h3 { font-size: 20px; }
.save-card p, .save-card small { grid-column: 1; font-size: 13px; }
.save-card button { grid-column: 2; min-width: 80px; background: #9dec7e; }
.save-card button.danger { grid-row: 2 / 4; background: #ff9d8e; }
.save-name-label { display: block; font-size: 14px; font-weight: 700; }
.library-modal input { width: 100%; height: 43px; margin: 5px 0 9px; padding: 0 12px; border: 4px solid #17100c; border-radius: 7px 11px 6px 9px; background: #fff; color: var(--ink); }
.library-modal > .primary { width: 100%; }
.error { color: var(--red) !important; }
.wide-modal { width: min(740px, calc(100% - 30px)); }
.dialog-close { float: right; border: 4px solid #17100c; border-radius: 50%; background: #ff8c77; font-size: 25px; font-weight: 700; line-height: 27px; }

.shop-list,
.weapon-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 13px; margin-top: 18px; }
.collection-pages { display: none; }
.shop-card,
.weapon-entry { padding: 13px; border: 4px solid #17100c; border-radius: 12px 6px 15px 7px; background: #fff9df; box-shadow: 4px 4px 0 #17100c; }
.shop-card:nth-child(even),
.weapon-entry:nth-child(even) { transform: rotate(.6deg); }
.shop-card:nth-child(odd),
.weapon-entry:nth-child(odd) { transform: rotate(-.6deg); }
.shop-card h3, .weapon-entry h3 { margin: 0 0 3px; font-size: 19px; line-height: 1; }
.shop-card p, .weapon-entry p { margin: 0 0 8px; font-size: 14px; }
.shop-card button { width: 100%; display: flex; justify-content: space-between; padding: 0 12px; background: #9dec7e; }
.shop-card button strong { display: flex; align-items: center; gap: 3px; }
.shop-item-icon { float: left; width: 76px; height: 76px; margin: -2px 10px 4px -2px; }
.base-weapon-shop-icon {
  grid-row: auto;
  background-image: url("../assets/doodle/weapons-atlas.png");
  background-size: 700% 300%;
  background-repeat: no-repeat;
}
.inventory-actions.single-action { grid-template-columns: 1fr; }
.weapon-entry { display: grid; grid-template-columns: 64px 1fr; align-items: center; column-gap: 9px; min-height: 100px; }
.weapon-entry h3, .weapon-entry p { grid-column: 2; }
.weapon-entry p { margin: 0; }
.collection-weapon {
  grid-row: 1 / 3;
  width: 60px;
  height: 80px;
  background-image: url("../assets/doodle/weapons-atlas.png");
  background-size: 700% 300%;
}
.weapon-entry.locked { filter: grayscale(1); opacity: .45; }
.weapon-entry strong { color: var(--red); }
.victory-modal { text-align: center; }
.victory-modal .primary { width: 100%; margin-top: 10px; }

.weapon-side.strike .weapon-rig { animation: sword-hit .46s cubic-bezier(.35,.02,.22,1); }
.weapon-side.strike .hero-character { animation: hero-swing .46s cubic-bezier(.35,.02,.22,1); }
.weapon-side.strike .sword-trail { animation: sword-trail .46s ease-out; }
.weapon-side.speed-up .hero-character { animation: hero-speed-up .8s ease 2; }
.armor-side.hit .armor-visual { animation: armor-hit .32s ease; }
.impact-zone.flash .impact-art { animation: impact-art .36s ease; }
.impact-zone.flash > span { animation: impact-word .48s ease; }
.weapon-side.weapon-celebrate .weapon-rig { animation: weapon-celebrate 1.2s ease; }
.weapon-side.weapon-drop .weapon-rig { animation: weapon-drop 1.2s ease forwards; }
.weapon-side.weapon-wobble .weapon-rig { animation: weapon-wobble .55s ease 2; }

@keyframes sword-hit {
  0%, 100% { transform: translate(0, 0) rotate(-18deg); }
  18%, 38% { transform: translate(-8px, -29px) rotate(-56deg) scale(1.02); }
  54% { transform: translate(12px, 8px) rotate(96deg) scale(1.08); }
  72% { transform: translate(9px, 5px) rotate(80deg) scale(1.03); }
}
@keyframes hero-swing {
  0%, 100% { transform: translateX(0) rotate(0); }
  18%, 40% { transform: translate(-4px, -1px) rotate(-2deg); }
  48%, 72% { transform: translateX(13px) rotate(3deg); }
  82% { transform: translateX(7px) rotate(1deg); }
}
@keyframes sword-trail {
  0%, 22% { opacity: 0; transform: rotate(-20deg) scale(.55); }
  48% { opacity: .92; transform: rotate(6deg) scale(1); }
  78%, 100% { opacity: 0; transform: rotate(25deg) scale(1.2); }
}
@keyframes weapon-aura {
  to { opacity: .48; transform: scale(1.12); }
}
@keyframes armor-hit {
  35% { transform: translateX(14px) rotate(6deg); filter: brightness(1.8) saturate(1.5); }
  70% { transform: translateX(-8px) rotate(-4deg); }
}
@keyframes impact-art {
  0% { opacity: 0; transform: scale(.25) rotate(-25deg); }
  60% { opacity: 1; transform: scale(1.35) rotate(8deg); }
}
@keyframes impact-word {
  0% { opacity: 0; transform: scale(.2) rotate(var(--pop-rotation)); }
  55% { opacity: 1; transform: scale(1.35) rotate(var(--pop-rotation)); }
}
@keyframes float-up {
  0% { opacity: 0; transform: translateY(20px) rotate(-12deg) scale(.45); }
  28% { opacity: 1; transform: translateY(-8px) rotate(5deg) scale(1.2); }
  100% { transform: translateY(-105px) rotate(-8deg) scale(.9); opacity: 0; }
}
@keyframes coin-fall {
  0% { opacity: 0; transform: translate(-50%, -35px) rotate(-12deg) scale(.45); }
  22% { opacity: 1; transform: translate(-50%, -6px) rotate(8deg) scale(1.15); }
  72% { opacity: 1; transform: translate(-50%, 72px) rotate(-8deg) scale(1); }
  100% { opacity: 0; transform: translate(-50%, 88px) rotate(4deg) scale(.8); }
}
@keyframes loose-coin {
  from { opacity: 1; transform: translate(0, 0) rotate(0) scale(.6); }
  to { opacity: 0; transform: translate(var(--coin-x), 75px) rotate(var(--coin-rotate)) scale(1); }
}
@keyframes hero-speed-up {
  0%, 100% { transform: translateX(0); filter: none; }
  25% { transform: translateX(-8px) rotate(-3deg); filter: brightness(1.5) drop-shadow(0 0 8px #4ceaff); }
  50% { transform: translateX(9px) rotate(4deg); filter: brightness(1.8) drop-shadow(0 0 13px #fff34c); }
  75% { transform: translateX(-5px) rotate(-2deg); filter: brightness(1.4) drop-shadow(0 0 8px #4ceaff); }
}
@keyframes element-particle {
  0% { opacity: 0; transform: rotate(var(--particle-angle)) translateX(6px) scale(.2); }
  24% { opacity: 1; }
  100% { opacity: 0; transform: rotate(var(--particle-angle)) translateX(var(--particle-distance)) scale(1.15); }
}
@keyframes element-ring {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(.15) rotate(-12deg); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(3.2) rotate(18deg); }
}
@keyframes enhancement-pop {
  0% { opacity: 0; transform: scale(.1) rotate(-18deg); }
  35% { opacity: 1; transform: scale(1.08) rotate(4deg); }
  80% { opacity: 1; transform: scale(.98) rotate(-2deg); }
  100% { opacity: 0; transform: scale(1.25) rotate(3deg); }
}
@keyframes weapon-celebrate {
  0%, 100% { transform: rotate(-18deg); filter: drop-shadow(3px 4px 0 #17100c66); }
  25% { transform: rotate(-8deg) translateY(-18px) scale(1.15); filter: hue-rotate(80deg) drop-shadow(0 0 12px #ff25ef); }
  55% { transform: rotate(-48deg) translateY(-8px) scale(1.1); filter: hue-rotate(200deg) drop-shadow(0 0 15px #31dfff); }
}
@keyframes weapon-drop {
  0% { transform: rotate(-18deg) translateY(-20px); opacity: 1; }
  35% { transform: rotate(35deg) translateY(5px); }
  100% { transform: rotate(120deg) translate(80px, 210px); opacity: 0; }
}
@keyframes weapon-wobble {
  0%, 100% { transform: rotate(-18deg); }
  30% { transform: rotate(-41deg) translateX(-7px); }
  70% { transform: rotate(-13deg) translateX(7px); }
}
@keyframes forge-hammering {
  0%, 100% { transform: rotate(-25deg); }
  50% { transform: rotate(-78deg) translate(-13px, 13px); }
}
@keyframes forge-rattle {
  0%, 100% { transform: translateX(-65%) rotate(82deg); }
  50% { transform: translateX(-61%) rotate(76deg) scale(1.04); filter: brightness(1.8) drop-shadow(0 0 13px #ff641e); }
}
@keyframes forge-spark-pop {
  0% { opacity: 1; box-shadow: 0 0 0 0 #fff, 0 0 0 0 #ffea35; transform: translateX(-50%) scale(.2); }
  45% { opacity: 1; box-shadow: -42px -25px 0 -8px #fff, 38px -30px 0 -7px #ffea35, -30px 27px 0 -9px #ff6b2f, 44px 22px 0 -8px #fff; transform: translateX(-50%) scale(1); }
  100% { opacity: 0; box-shadow: -64px -42px 0 -11px #fff, 61px -49px 0 -10px #ffea35, -50px 45px 0 -12px #ff6b2f, 67px 39px 0 -11px #fff; transform: translateX(-50%) scale(.5); }
}
@keyframes forge-light-reveal {
  0% { opacity: 0; transform: scale(.12); }
  38% { opacity: 1; transform: scale(.72); }
  100% { opacity: 0; transform: scale(1.8); }
}
@keyframes forge-stage-reveal {
  35% { filter: brightness(2.6) saturate(1.6); transform: scale(1.025) rotate(.8deg); }
}
@keyframes forge-result-pop {
  from { opacity: 0; transform: scale(.15) rotate(-12deg); }
  to { opacity: 1; transform: scale(1) rotate(-5deg); }
}
@keyframes hammer-bounce {
  to { transform: rotate(12deg) translate(45px, -35px); }
}
@keyframes rainbow-stage {
  0%, 100% { filter: none; }
  30% { filter: hue-rotate(80deg) brightness(1.25); }
  60% { filter: hue-rotate(230deg) brightness(1.35); }
}
@keyframes forged-weapon-break {
  0% { transform: translateX(-65%) rotate(82deg); opacity: 1; }
  35% { transform: translateX(-65%) rotate(102deg) scale(.85); filter: grayscale(1); }
  100% { transform: translate(-40%, 180px) rotate(190deg) scale(.55); opacity: 0; }
}
@keyframes protected-wobble {
  0%, 100% { transform: translateX(-65%) rotate(82deg); }
  25% { transform: translateX(-75%) rotate(70deg); }
  75% { transform: translateX(-55%) rotate(94deg); }
}

@media (max-width: 880px) {
  .game-layout { grid-template-rows: minmax(540px, 58dvh) auto; }
  .battle-field { padding: 82px 17px 23px; }
  .battle-scene { grid-template-columns: 1fr 100px 1fr; min-height: 330px; }
  .fighter-card { display: grid; justify-items: center; gap: 4px; }
  .armor-side { display: grid; }
  .fighter-copy { min-width: 0; text-align: center; }
  .fighter-copy h2 { font-size: 19px; }
  .fighter-visual { transform: scale(.84); }
  .impact-zone { width: 105px; height: 105px; }
  .impact-zone > span { font-size: 25px; }
  .forge-grid { grid-template-columns: 1fr 1fr; }
  .forge-actions { grid-column: 1 / -1; grid-template-columns: repeat(4, 1fr); min-height: 85px; }
  .forge-actions button { text-align: center; }
  .forge-actions span { display: block; margin: auto; }
}

@media (max-width: 580px) {
  .game-shell { padding: 7px; }
  .game-layout { gap: 10px; grid-template-rows: minmax(560px, 68dvh) auto; }
  .battle-field { padding: 78px 8px 18px; border-width: 5px; box-shadow: 4px 5px 0 #17100c; background-position: 51% center; }
  .scribble-title { top: 8px; min-width: 215px; padding-inline: 15px; }
  .scribble-title h1 { font-size: 27px; }
  .scribble-title span { font-size: 11px; }
  .battle-topline > div:first-child { padding: 5px 8px; }
  .battle-topline strong { font-size: 17px; }
  .gold-display { padding: 4px 8px; }
  .gold-display strong { font-size: 19px; }
  .gold-display small { font-size: 11px; }
  .battle-scene { grid-template-columns: 1fr 44px 1fr; min-height: 345px; margin-top: -15px; }
  .fighter-card { gap: 0; }
  .hero-visual { width: 143px; height: 178px; transform: scale(.78); }
  .hero-head { left: 2px; }
  .hero-body { left: -4px; }
  .weapon-rig { width: 120px; height: 160px; right: -3px; }
  .armor-visual { width: 108px; height: 180px; transform: scale(.9); }
  .fighter-copy { width: 132px; padding: 6px; }
  .fighter-copy > span { font-size: 10px; }
  .fighter-copy h2 { font-size: 16px; }
  .fighter-copy p { font-size: 11px; }
  .impact-zone { width: 68px; height: 68px; margin-left: -12px; }
  .impact-zone > span { font-size: 20px; -webkit-text-stroke-width: 4px; }
  .armor-health { width: 97%; padding: 7px 8px; }
  .health-copy, .combat-verdict { font-size: 12px; }
  .forge-panel { padding: 17px 12px 21px; border-width: 5px; box-shadow: 4px 5px 0 #17100c; }
  .forge-heading h2 { font-size: 27px; }
  .speed-buff { max-width: 145px; font-size: 12px; }
  .forge-grid { grid-template-columns: 1fr; }
  .weapon-summary, .enhance-card, .consumables { min-height: auto; }
  .forge-actions { grid-column: auto; grid-template-columns: 1fr 1fr; min-height: auto; }
  .forge-actions button { min-height: 58px; }
  .shop-list, .weapon-list { grid-template-columns: 1fr; }
  .modal { padding: 20px; }
  .enhancement-effect strong { -webkit-text-stroke-width: 5px; }
}

@media (max-width: 580px) {
  html, body { height: 100%; overflow: hidden; }
  body { min-height: 0; overscroll-behavior: none; }

  .game-shell {
    width: 100%;
    height: 100dvh;
    min-height: 0;
    padding: 3px;
    overflow: hidden;
  }

  .game-layout {
    height: 100%;
    min-height: 0;
    grid-template-rows: minmax(0, 1fr) 232px;
    gap: 4px;
  }
  .game-layout:has(.battle-mobile-ad:not([hidden])) { grid-template-rows: 100px minmax(0, 1fr) 232px; }

  .battle-field {
    min-height: 0;
    padding: 0;
    border-width: 4px;
    border-radius: 10px 6px 11px 7px;
    background-position: 50% center;
    box-shadow: 2px 3px 0 #17100c;
  }

  .battle-mobile-ad:not([hidden]) {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100px;
    display: grid;
    place-items: center;
    justify-self: center;
    overflow: hidden;
    background: #fff;
  }
  .battle-mobile-ad[data-adfit-fluid] .kakao_ad_area { width: 100% !important; max-width: 100%; }
  .battle-mobile-ad .adfit-label {
    position: absolute;
    z-index: 1;
    top: 1px;
    left: 3px;
    color: #8b92a2;
    font-family: system-ui, sans-serif;
    font-size: 8px;
  }

  .scribble-title {
    top: 3px;
    min-width: 188px;
    padding: 3px 12px 4px;
    border-width: 3px;
    box-shadow: 2px 2px 0 #17100c;
  }
  .scribble-title h1 { font-size: 25px; }
  .scribble-title span { margin-top: 1px; font-size: 11px; }

  .battle-topline {
    position: absolute;
    top: 52px;
    right: 5px;
    left: 5px;
  }
  .battle-topline > div:first-child { padding: 2px 6px; border-width: 2px; }
  .label { font-size: 10px; }
  .battle-topline strong { font-size: 16px; line-height: 1; }
  .gold-display { gap: 3px; padding: 2px 6px; border-width: 3px; box-shadow: 2px 2px 0 #17100c; }
  .coin-icon { width: 21px; height: 21px; }
  .gold-display strong { max-width: 126px; overflow: hidden; font-size: 19px; text-overflow: ellipsis; }
  .gold-display small { font-size: 10px; }

  .speed-buff {
    position: absolute;
    z-index: 9;
    top: 86px;
    left: 6px;
    max-width: none;
    padding: 2px 6px;
    border-width: 2px;
    font-size: 11px;
  }

  .battle-actions { grid-row: 3; gap: 3px; margin: 0; }
  .battle-actions button {
    width: auto;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 2px;
    border-width: 2px;
    box-shadow: 1px 2px 0 #17100c;
    line-height: 1;
  }
  .battle-actions b { display: inline; font-size: 12px; }
  .battle-actions em { top: -5px; right: -5px; min-width: 17px; padding: 0 3px; font-size: 10px; }

  .battle-scene {
    position: absolute;
    top: 101px;
    right: 2px;
    bottom: 72px;
    left: 2px;
    min-height: 0;
    margin: 0;
    grid-template-columns: minmax(0, 1fr) 42px minmax(0, 1fr);
  }

  .fighter-card,
  .armor-side {
    display: flex;
    min-width: 0;
    height: 100%;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
  }

  .fighter-visual,
  .hero-visual { transform: none; }
  .hero-visual { width: 135px; height: 185px; }
  .hero-character { inset: 0 32px 0 0; }
  .weapon-rig {
    top: -23px;
    right: -26px;
    width: 91px;
    height: 122px;
    transform: rotate(-18deg);
  }
  .armor-visual { width: 100px; height: 166px; transform: none; }

  .fighter-copy,
  .armor-side .fighter-copy {
    width: min(126px, 100%);
    min-width: 0;
    padding: 3px 4px;
    border-width: 2px;
    box-shadow: 2px 2px 0 #17100c;
    text-align: center;
  }
  .fighter-copy > span { display: none; }
  .fighter-copy h2 { margin: 0; overflow: hidden; font-size: 16px; line-height: 1; text-overflow: ellipsis; white-space: nowrap; }
  .fighter-copy p { margin-top: 2px; font-size: 11px; line-height: 1; }

  .impact-zone { width: 58px; height: 58px; margin: 0 0 42px -8px; }
  .impact-zone > span { font-size: 17px; -webkit-text-stroke-width: 3px; text-shadow: 2px 2px 0 #e13d2e; }

  .armor-health {
    position: absolute;
    right: 5px;
    bottom: 4px;
    left: 5px;
    width: auto;
    height: 63px;
    margin: 0;
    padding: 4px 7px;
    border-width: 3px;
    box-shadow: 2px 2px 0 #17100c;
  }
  .health-copy { font-size: 12px; line-height: 1; }
  .health-track { height: 14px; margin-top: 2px; border-width: 2px; }
  .combat-verdict { margin-top: 2px; overflow: hidden; font-size: 11px; line-height: 1.1; text-overflow: ellipsis; white-space: nowrap; }
  .float-effect { left: 48%; top: 43%; font-size: 28px; -webkit-text-stroke-width: 4px; text-shadow: 2px 3px 0 #fff09a; }
  .coin-drop { font-size: 15px; -webkit-text-stroke-width: 2px; }
  .coin-drop .coin-icon { width: 23px; height: 23px; }
  .coin-drop::before, .coin-drop::after { width: 17px; height: 17px; }
  .mini-coin { width: 16px; height: 16px; vertical-align: -4px; }

  .forge-panel {
    min-height: 0;
    height: auto;
    padding: 7px;
    border-width: 4px;
    border-radius: 7px 11px 6px 9px;
    box-shadow: 2px 3px 0 #17100c;
    overflow: hidden;
  }
  .forge-panel::before,
  .forge-heading,
  .game-message,
  .save-status,
  .forge-effects { display: none; }

  .forge-grid {
    height: 100%;
    grid-template-columns: 94px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) 51px;
    gap: 4px;
  }
  .weapon-summary,
  .enhance-card,
  .consumables,
  .forge-quick-info {
    min-height: 0;
    padding: 4px;
    border-width: 3px;
    box-shadow: 2px 2px 0 #17100c;
    transform: none;
  }
  .weapon-summary {
    grid-column: 1;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    text-align: center;
  }
  .level-seal { flex: 0 0 43px; width: 43px; border-width: 3px; }
  .level-seal span { font-size: 10px; }
  .level-seal strong { font-size: 22px; }
  .weapon-summary h3 { width: 82px; margin: 0; overflow: hidden; font-size: 15px; line-height: 1; text-overflow: ellipsis; white-space: nowrap; }
  .weapon-summary p { display: none; }

  .enhance-card {
    grid-column: 2;
    grid-row: 1;
    display: grid;
    grid-template-rows: 18px 8px 36px minmax(0, 1fr);
    gap: 2px;
  }
  .chance-row { font-size: 13px; line-height: 1; }
  .chance-row strong { font-size: 19px; }
  .chance-track { height: 8px; margin: 0; border-width: 2px; }
  #destroy-warning,
  .sell-button { display: none !important; }
  .enhance-button {
    min-height: 0;
    height: 100%;
    flex-direction: column;
    justify-content: center;
    gap: 1px;
    padding: 0 12px;
    font-size: 20px;
    line-height: 1;
    filter: drop-shadow(2px 2px 0 #17100c);
  }
  .enhance-button span,
  .enhance-button strong { white-space: nowrap; }
  .enhance-button strong { font-size: 15px; }
  .enhance-button strong::before { width: 17px; height: 17px; vertical-align: -4px; }

  .forge-quick-info {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    align-items: center;
    justify-content: space-around;
    gap: 3px;
    padding: 2px 5px;
    font-size: 12px;
  }
  .forge-quick-info span { padding: 0 8px 0 0; border: 0; border-right: 2px dashed #17100c77; }
  .forge-quick-info span:last-child { padding: 0; border: 0; }
  .forge-quick-info strong { font-size: 16px; }

  .consumables {
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-radius: 8px 5px 9px 6px;
  }
  .consumables legend { display: none; }
  .consumables label {
    min-width: 0;
    min-height: 0;
    grid-template-columns: 14px 25px minmax(0, 1fr) 18px;
    gap: 2px;
    padding: 0 3px;
    border: 0;
    border-right: 2px dashed #17100c77;
  }
  .consumables label:last-child { border-right: 0; }
  .consumables input { width: 13px; height: 13px; }
  .consumable-icon { width: 25px; height: 25px; }
  .consumables label span { overflow: hidden; font-size: 0; white-space: nowrap; }
  .consumables label span::after { content: attr(data-short); font-size: 11px; }
  .consumables b { min-width: 17px; padding: 0 2px; border-width: 1px; font-size: 10px; }

  .forge-sequence { padding: 7px; }
  .forge-stage { width: min(350px, 94vw); height: min(400px, 70dvh); min-height: 320px; border-width: 5px; box-shadow: 5px 6px 0 #17100c; }
  .forge-stage > span { top: 12px; padding: 4px 11px; border-width: 3px; font-size: 20px; }
  .forge-anvil, .forge-hammer { width: 180px; height: 180px; }
  .forge-hammer { top: 54px; right: -2px; }
  .forge-preview { bottom: 78px; width: 90px; height: 120px; }
  .forge-stage > strong { top: 69px; font-size: 36px; -webkit-text-stroke-width: 5px; }

  .modal,
  .wide-modal {
    width: calc(100% - 12px);
    max-height: none;
    padding: 15px;
    border-width: 4px;
    overflow: hidden;
    box-shadow: 4px 5px 0 #17100c;
  }
  .modal[open],
  .wide-modal[open] {
    height: calc(100dvh - 12px);
    display: flex;
    flex-direction: column;
  }
  .game-modal::before { flex: 0 0 auto; align-self: flex-end; }
  .dialog-close { position: absolute; z-index: 12; top: 8px; right: 8px; float: none; }
  .modal h2 { font-size: 27px; }
  .modal p, .modal small { font-size: 14px; }
  .modal-eyebrow { font-size: 15px; }
  .game-modal::before { min-height: 31px; padding: 3px 8px 3px 32px; background-position-x: 5px; background-size: 22px 22px; font-size: 15px; }
  .forge-modal[open] { height: min(540px, calc(100dvh - 12px)); padding: 9px; }
  .forge-modal > p { display: none; }
  .forge-modal .modal-eyebrow { font-size: 12px; line-height: 1; }
  .forge-modal h2 { margin-block: 1px 4px; font-size: 23px; }
  .forge-workbench { grid-template-columns: .9fr 1.1fr; gap: 4px; margin: 4px 0; }
  .forge-equipped { min-height: 64px; padding: 4px; gap: 4px; }
  .forge-equipped .collection-weapon { width: 38px; height: 51px; flex-basis: 38px; }
  .forge-equipped span { font-size: 10px; }
  .forge-equipped h3 { font-size: 15px; }
  .probability-sheet { gap: 1px 5px; padding: 4px; font-size: 11px; }
  .probability-sheet .probability-total { margin-top: 1px; padding-top: 1px; font-size: 13px; }
  .probability-sheet .probability-total strong { font-size: 18px; }
  .probability-sheet .chance-track { height: 8px; margin: 0; border-width: 2px; }
  .forge-target-picker { padding: 4px; border-width: 3px; }
  .forge-target-picker .section-heading h3 { font-size: 15px; }
  .forge-target-picker .section-heading strong { font-size: 12px; }
  .forge-icon-list { gap: 5px; padding: 3px 2px; }
  .forge-list-row > .forge-icon-list { overflow: hidden; }
  .forge-page-button { display: block; flex: 0 0 24px; width: 24px; height: 44px; padding: 0; border: 2px solid #17100c; border-radius: 6px; background: #fff16d; font-size: 23px; font-weight: 800; }
  .forge-page-button:disabled { opacity: .35; }
  .forge-weapon-icon { flex-basis: 50px; width: 50px; height: 60px; border-width: 2px; box-shadow: 2px 2px 0 #17100c; }
  .forge-weapon-icon .collection-weapon { width: 29px; height: 39px; }
  .forge-weapon-icon > strong { font-size: 14px; line-height: 18px; }
  .forge-weapon-icon > small { min-width: 22px; font-size: 9px; line-height: 14px; }
  .sacrifice-picker {
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr);
    grid-template-areas: "heading heading" "slot materials";
    gap: 4px;
    margin-bottom: 4px;
    padding: 4px;
  }
  .sacrifice-picker .section-heading { grid-area: heading; }
  .sacrifice-picker .section-heading h3 { font-size: 15px; }
  .sacrifice-picker .section-heading button { min-height: 23px; font-size: 11px; }
  #sacrifice-help { display: none; }
  .sacrifice-slot { grid-area: slot; min-height: 64px; grid-template-columns: 1fr; gap: 1px; margin: 0; padding: 2px; border-width: 2px; }
  .sacrifice-slot > span { font-size: 11px; }
  #sacrifice-slot-content { min-height: 38px; border: 0; border-top: 2px dashed #17100c55; }
  #sacrifice-slot-content small { font-size: 9px; text-align: center; }
  #sacrifice-slot-content .collection-weapon { width: 28px; height: 38px; }
  .material-list-row { grid-area: materials; }
  .material-list { grid-area: auto; min-height: 64px; max-height: 64px; }
  .material-card { grid-template-columns: 38px minmax(0, 1fr); }
  .material-card .collection-weapon { width: 35px; height: 47px; }
  .forge-consumables { min-height: 42px; padding: 3px; }
  .forge-confirm-row { grid-template-columns: auto 1fr; gap: 5px; margin-top: 4px; }
  .forge-confirm-row > div { padding: 2px 5px; }
  .forge-confirm-row > div small { font-size: 10px; }
  .forge-confirm-row > div strong { font-size: 15px; }
  .forge-confirm-row .primary { min-height: 42px; font-size: 18px; }
  .inventory-modal[open] { height: min(540px, calc(100dvh - 12px)); padding: 10px; }
  .inventory-modal .equipped-strip { margin: 5px 0; padding: 5px 7px; }
  .inventory-modal .inventory-subtitle { margin: 6px 0 2px; font-size: 16px; }
  .inventory-list { min-height: 0; max-height: min(34dvh, 250px); flex: 0 1 auto; grid-template-columns: 1fr; align-content: start; overflow: auto; }
  .base-inventory-card { grid-template-columns: 40px minmax(0, 1fr) 105px; gap: 4px; padding: 5px; }
  .base-inventory-card .collection-weapon { grid-row: 1; width: 38px; height: 52px; }
  .base-inventory-card h3 { font-size: 13px; }
  .base-inventory-card p { font-size: 10px; }
  .base-inventory-card .inventory-actions { grid-column: 3; grid-row: 1; }
  .base-inventory-card .inventory-actions button { padding: 2px; font-size: 11px; }
  .item-inventory-list { max-height: min(27dvh, 180px); }
  .inventory-card.compact { grid-template-columns: 32px minmax(0, 1fr) 70px; gap: 3px; padding: 3px; border-width: 2px; }
  .inventory-card.compact .shop-item-icon { width: 30px; height: 30px; }
  .inventory-card.compact h3 { font-size: 12px; }
  .inventory-card.compact p { font-size: 10px; }
  .inventory-card.compact button { min-height: 28px; padding: 2px; font-size: 10px; }
  .equipped-strip { grid-template-columns: 1fr auto; }
  .equipped-strip span { grid-column: 1 / -1; }
  #shop > p { margin: 2px 0; font-size: 12px; }
  #shop[open] { height: min(560px, calc(100dvh - 12px)); }
  .shop-list { min-height: 0; flex: 0 1 auto; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(3, auto); gap: 6px; margin-top: 5px; overflow: hidden; }
  .shop-card { min-height: 0; display: grid; grid-template-rows: auto auto auto 32px; justify-items: center; padding: 5px; border-width: 3px; overflow: hidden; text-align: center; }
  .shop-item-icon { float: none; width: min(42px, 7dvh); height: min(42px, 7dvh); margin: 0; }
  .shop-card h3 { font-size: 14px; }
  .shop-card p { min-height: 0; margin-bottom: 3px; font-size: 10px; line-height: 1.05; }
  .shop-card button { min-height: 32px; padding: 0 5px; font-size: 12px; }
  .speed-upgrade-card { grid-column: 1 / -1; grid-template-columns: 40px minmax(0, 1fr) minmax(0, 1fr) 94px; grid-template-rows: auto auto; align-content: center; align-items: center; gap: 0 5px; justify-items: start; text-align: left; }
  .speed-upgrade-card .shop-item-icon { grid-row: 1 / 3; width: 39px; height: 39px; }
  .speed-upgrade-card h3 { grid-column: 2 / 4; }
  .speed-upgrade-card p { grid-column: 2 / 4; grid-row: 2; margin: 0; }
  .speed-upgrade-card button { grid-column: 4; grid-row: 1 / 3; min-width: 0; }
  #collection .weapon-list { min-height: 0; flex: 1; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 5px; overflow: hidden; }
  #collection .weapon-entry { min-height: 0; grid-template-columns: 36px minmax(0, 1fr); gap: 2px; padding: 4px; border-width: 2px; box-shadow: 2px 2px 0 #17100c; }
  #collection .collection-weapon { width: 34px; height: 46px; }
  #collection .weapon-entry h3 { font-size: 13px; }
  #collection .weapon-entry p { font-size: 10px; line-height: 1.1; }
  .collection-pages { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 5px; font-weight: 800; }
  .collection-pages button { width: 34px; height: 30px; border: 2px solid #17100c; border-radius: 6px; background: #fff16d; font-size: 22px; line-height: 1; }
  .collection-pages button:disabled { opacity: .35; }
  .library-modal .save-list { min-height: 0; flex: 1; overflow: auto; }
}

@media (max-width: 580px) and (max-height: 700px) {
  .game-layout { grid-template-rows: minmax(0, 1fr) 212px; }
  .game-layout:has(.battle-mobile-ad:not([hidden])) { grid-template-rows: 100px minmax(0, 1fr) 212px; }
  .battle-scene { top: 91px; bottom: 62px; }
  .battle-actions button { min-height: 34px; }
  .hero-visual { width: 115px; height: 150px; }
  .weapon-rig { top: -16px; right: 0; width: 76px; height: 102px; }
  .armor-visual { width: 86px; height: 143px; }
  .fighter-copy h2 { font-size: 12px; }
  .armor-health { height: 55px; }
}

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