:root {
  color-scheme: light;
  --paper: #f5efdf;
  --paper-dark: #e7dfc9;
  --ink: #29423d;
  --muted: #687369;
  --line: #a9ae98;
  --red: #ad4437;
  --jade: #dce5cd;
  --purple: #715b79;
  --serif: "KaiTi", "STKaiti", "Kaiti SC", "Songti SC", "Noto Serif CJK SC", "SimSun", serif;
  --ui: "Microsoft YaHei", "PingFang SC", sans-serif;
}
* { box-sizing: border-box; }
html { min-height: 100%; background: #e4e5d7; }
body {
  margin: 0;
  min-height: 100svh;
  color: var(--ink);
  font-family: var(--serif);
  background: linear-gradient(90deg, #e6e7d8a8, #e6e7d833, #e6e7d8a8), url("assets/background.webp") center 26% / cover fixed;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 28px;
}
button, a { -webkit-tap-highlight-color: transparent; }
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  touch-action: manipulation;
}
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 4px; }
img { display: block; }
b, strong { font-weight: 500; }
.game-shell {
  position: relative;
  width: min(100%, 1040px);
  margin: 0 auto;
  padding: 16px 24px 10px;
  border: 1px solid #929e885c;
  background: linear-gradient(#f5efdfbf, #f5efdfeb), url("assets/background.webp") center / cover;
  box-shadow: 0 18px 70px #3344371a;
}
.game-shell::before, .game-shell::after {
  content: "";
  pointer-events: none;
  position: absolute;
  inset: 5px;
  border: 1px solid #89978438;
}
.game-shell::after { inset: 8px; border-color: #89978418; }
.game-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 72px;
  margin-bottom: 15px;
  padding-bottom: 11px;
  border-bottom: 1px solid #a4ac943d;
}
.heading-group { position: relative; min-width: 0; padding-left: 13px; border-left: 3px solid #38554c; }
h1 { font-size: 31px; font-weight: 400; line-height: 1.12; letter-spacing: .11em; margin: 0 0 2px; }
.progress-button { min-height: 27px; display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--muted); }
.progress-button::after { content: ""; position: absolute; inset: 0; }
.progress-button .dot { color: #999f8d; }
.progress-chevron { font-family: var(--ui); opacity: .6; margin-left: 1px; }
.tools { display: flex; gap: 8px; flex-shrink: 0; }
.tool-button {
  width: 48px; height: 47px;
  font-size: 16px;
  background: linear-gradient(115deg, #f5efdfc9, #ecebd5a3);
  border: 1px solid #83958088;
  border-radius: 2px 5px 3px 6px;
  box-shadow: inset 0 0 0 3px #f5efdf, inset 0 0 0 4px #aeb69a70;
  transform: rotate(-1deg);
}
.tool-button:nth-child(2) { transform: rotate(1deg); }
.tool-button:hover { background-color: #e0e8d0; }
.battle-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 450px);
  grid-template-areas: "arena board" "resources board" "spells board" "commands board";
  column-gap: 32px;
  row-gap: 12px;
  align-items: start;
}
.arena {
  grid-area: arena;
  position: relative;
  background: linear-gradient(to bottom, #f5efdf00 60%, #f5efdfcc), url("assets/scene.webp") center / cover;
  min-width: 0;
  overflow: hidden;
  isolation: isolate;
}
.combatants { position: relative; display: flex; justify-content: space-between; height: 236px; padding: 5px 7px 0; }
.fighter { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; position: relative; width: 46%; min-width: 44px; }
.portrait { height: 183px; width: 100%; object-fit: contain; object-position: center bottom; pointer-events: none; }
.player-portrait { object-position: 56% bottom; }
.enemy-portrait { max-width: 230px; }
.fighter-status { width: 100%; padding-top: 1px; }
.bloodline { display: flex; gap: 5px; align-items: center; }
.status-heart { width: 18px; height: 18px; }
.health-track { display: block; width: 100%; height: 8px; background: #9f98802e; border-radius: 1px; overflow: hidden; }
.health-fill { display: block; height: 100%; background: #b7493c; box-shadow: inset 0 1px 1px #fbc9a930; transition: width .22s ease; }
.combat-metrics { display: flex; justify-content: center; gap: 17px; font: 14px var(--ui); line-height: 24px; }
.combat-metrics > span { display: flex; align-items: center; gap: 4px; }
.combat-metrics img { width: 18px; height: 18px; }
.crossing-mark { position: absolute; top: 96px; left: 46%; opacity: .38; font-size: 32px; transform: rotate(-18deg); }
.intent-button { position: relative; display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 34px; width: 100%; font-size: 14px; background: #f5efdfc4; }
.intent-button::after { content: ""; position: absolute; left: 25%; right: 25%; top: -5px; bottom: -5px; }
.intent-label { color: var(--muted); font-size: 12px; }
#intent { color: var(--red); }
.intent-chevron { font-family: var(--ui); color: #7a8574; }
.resources { grid-area: resources; display: flex; min-height: 40px; }
.paper-strip { border: 1px solid #acb2998a; background: #f4efdfd4; }
.resource { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 0; position: relative; font-size: 20px; line-height: 38px; }
.resource + .resource::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 1px; background: #aeb69b77; }
.resource-label { font-size: 15px; }
.steps-resource { color: var(--red); }
.mana-resource { color: var(--purple); }
.resource small { font: 12px var(--ui); padding-left: 3px; }
.board-panel { grid-area: board; width: 100%; min-width: 0; align-self: start; }
.board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
  width: 100%;
  aspect-ratio: 1;
  padding: 7px;
  border: 1px solid #476454;
  background: #e8e1cecc;
  box-shadow: 0 0 0 3px #f5efdf, 0 0 0 4px #627a5e66;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.tile {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  aspect-ratio: 1;
  border: 1px solid #c2c6ac;
  border-radius: 2px;
  background: #f9f6e9;
  position: relative;
  padding: 2px;
  transform: translateZ(0);
  transition: transform .16s ease, box-shadow .15s ease;
}
.tile-art, .tile img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.tile:hover { z-index: 1; border-color: #476454; }
.tile.selected, .tile[aria-selected="true"] { z-index: 2; box-shadow: 0 0 0 3px #294e42, inset 0 0 0 1px #fff; transform: scale(.94); }
.tile.hinted { z-index: 1; box-shadow: inset 0 0 0 2px #d39b35, 0 0 0 2px #d39b35; animation: hint-pulse 1s ease-in-out infinite; }
.tile.clearing, .tile.matched { animation: tile-clear .28s ease both; }
.tile.falling, .tile.new { animation: tile-drop .23s ease both; }
.tile:disabled { opacity: 1; }
.board-instruction { margin: 12px 0 0; color: var(--muted); font-size: 14px; text-align: center; line-height: 20px; }
.spell-panel { grid-area: spells; min-width: 0; }
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.skill-card {
  position: relative;
  display: grid;
  grid-template-columns: 43px 1fr;
  grid-template-rows: 24px auto;
  min-height: 100px;
  padding: 7px 7px 8px;
  text-align: left;
  border: 1px solid #939f848c;
  border-radius: 3px 2px 5px 2px;
  background: linear-gradient(120deg, #f5efdf, #eee9d4);
  box-shadow: inset 0 0 0 3px #eee9d4, inset 0 0 0 4px #a0ac906b;
}
.skill-name { grid-column: 1 / -1; line-height: 23px; font-size: 17px; white-space: nowrap; padding-right: 24px; }
.skill-cost { position: absolute; right: 6px; top: 6px; width: 22px; height: 22px; display: grid; place-items: center; background: #e8dfebc9; border: 1px solid #ac9cb2; color: var(--purple); font: 13px var(--ui); }
.skill-art { width: 42px; height: 48px; object-fit: contain; grid-row: 2; }
.skill-description { grid-column: 2; font-size: 12px; line-height: 1.65; align-self: center; padding-left: 3px; }
.skill-cost > span { display: none; }
.skill-key { position: absolute; bottom: 6px; right: 7px; font: 10px var(--ui); color: #8d9684; }
.skill-description small, .skill-status { display: block; font-size: 11px; color: var(--muted); }
.skill-card.selected, .skill-card[aria-pressed="true"] { border-color: #a63f32; background: #f3e6d4; box-shadow: inset 0 0 0 3px #f3e6d4, inset 0 0 0 4px #ad443773; }
.skill-card.selected::after { content: ""; position: absolute; height: 2px; bottom: 5px; left: 7px; right: 7px; background: var(--red); }
.skill-card.unavailable, .skill-card:disabled { color: #6d7468; }
.skill-card.unavailable .skill-art, .skill-card:disabled .skill-art { opacity: .52; }
.card-detail { min-height: 21px; margin: 8px 0 0; font-size: 13px; line-height: 21px; color: var(--muted); }
.link-status { font-size: 12px; line-height: 18px; color: #3e6648; margin: 4px 0 0; padding: 2px 6px; background: #dce5cdb8; border-left: 2px solid #7d9670; }
.link-status[hidden] { display: none; }
.command-panel { grid-area: commands; min-width: 0; }
.feedback { margin: 0 0 7px; min-height: 20px; font-size: 13px; line-height: 20px; color: #466357; }
.feedback.error { color: var(--red); }
.commands { display: grid; grid-template-columns: 50px 1fr 1fr; gap: 8px; }
.action-button, .hint-button {
  min-height: 49px;
  border: 1px solid #89977c;
  border-radius: 2px 4px 2px 5px;
  box-shadow: inset 0 0 0 3px #f5efdf, inset 0 0 0 4px #a9b29570;
  font-size: 21px;
  background: #f0ead8;
  white-space: nowrap;
}
.hint-button { font-size: 15px; background: #f2eddf; }
.cast-button { border-color: #b9765c; color: #984b3b; background: #f1e0c8; }
.end-button { background: #dce6cd; color: #304d40; }
.action-button:disabled { color: #909383; border-color: #b6bba6; background: #e9e5d7; }
.action-button:not(:disabled):hover, .hint-button:not(:disabled):hover { filter: brightness(.98); }
.action-button:not(:disabled):active, .hint-button:not(:disabled):active { transform: translateY(1px); }
.game-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 45px; margin-top: 15px; border-top: 1px solid #a4ac943d; font-size: 13px; color: var(--muted); }
.game-footer a { display: flex; align-items: center; min-height: 44px; white-space: nowrap; font-size: 14px; color: #3c5b4f; }
.effects { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 8; }
.float-text, .floating-number { position: absolute; font-size: 30px; color: var(--red); text-shadow: 0 1px 2px var(--paper); animation: float-up .72s ease-out both; white-space: nowrap; }
.combat-number { position: absolute; font: 28px var(--ui); color: var(--red); text-shadow: 0 1px 2px var(--paper); animation: float-up .72s ease-out both; white-space: nowrap; }
.combat-number.heal { color: #39704e; }
.combat-number.guard { color: #477292; }
.hit { animation: impact .2s ease-out; }
.entering { animation: enter .3s ease-out; }
.defeated { animation: disappear .3s ease-in both; }
.enraged-flash { animation: rage-flash .5s ease-out; }
.cast-flash { animation: cast-flash .4s ease-out; }
.float-text.heal, .floating-number.heal { color: #39704e; }
.effect-banner { position: absolute; top: 90px; left: 50%; transform: translateX(-50%); background: #f5efdfec; border: 1px solid #9da88c; padding: 9px 20px; font-size: 21px; animation: banner-in .45s ease both; }
.shake { animation: impact .2s ease-out; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.noscript { background: var(--paper); padding: 20px; }

/* Native dialogs keep the game behind them, with safe scroll on short screens. */
dialog {
  border: 1px solid #768b72;
  border-radius: 2px;
  width: min(90vw, 530px);
  max-height: min(86dvh, 780px);
  padding: 24px;
  color: var(--ink);
  background: linear-gradient(#f6efdedf, #f6efdeed), url("assets/background.webp") center / cover;
  font: 16px/1.6 var(--serif);
  box-shadow: 0 18px 80px #23362e33, inset 0 0 0 5px #f5efdf, inset 0 0 0 6px #a1ad9477;
  overflow-y: auto;
}
dialog::backdrop { background: #283e36a3; backdrop-filter: blur(2px); }
dialog h2, .dialog-title { font-size: 25px; font-weight: 400; margin: 0 0 14px; letter-spacing: .08em; }
dialog h3 { font-size: 19px; font-weight: 400; margin: 20px 0 8px; }
dialog p { margin: 8px 0; }
dialog ul, dialog ol { padding-left: 22px; }
dialog li { margin: 6px 0; }
dialog button, .dialog-button { min-height: 44px; border: 1px solid #909d83; padding: 7px 16px; background: #e6ead5; margin-top: 8px; }
dialog a { color: #3f6453; }
.dialog-header, .modal-head { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.modal-head { position: sticky; top: -24px; z-index: 2; background: #f5efdf; padding: 6px 0; box-shadow: 0 6px 8px #f5efdf; }
.modal-head h2 { margin-bottom: 6px; }
.dialog-body { min-height: 0; }
.dialog-close { font: 20px var(--ui); width: 44px; padding: 0; margin: -8px -8px 0 0; flex-shrink: 0; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; margin-top: 16px; }
.dialog-actions button { margin: 0; }
.loadout-options, .preset-list { display: grid; gap: 10px; margin: 15px 0; }
.loadout-option, .preset { display: block; width: 100%; text-align: left; padding: 12px; min-height: 64px; background: #f3eddb; }
.loadout-option.selected, .preset.selected, .loadout-option[aria-pressed="true"] { border-color: #45674f; background: #dde6ce; }
.preset-option { display: block; width: 100%; text-align: left; padding: 10px 13px; margin: 0; min-height: 78px; background: #f3eddb; }
.preset-option.selected { border-color: #45674f; background: #dde6ce; }
.preset-option strong { display: block; font-size: 20px; }
.preset-option span { display: block; font-size: 14px; line-height: 1.6; }
.preset-option small { display: block; color: var(--muted); font-size: 12px; line-height: 1.5; }
.same-seed { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: 14px; }
.same-seed input { width: 19px; height: 19px; accent-color: #436d52; }
.primary-button { background: #dce6cd; border-color: #698663; }
.secondary-button { background: #eee8d5; display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 7px 16px; text-decoration: none; border: 1px solid #909d83; }
.text-button { border-color: transparent; background: transparent; }
.dialog-lead { font-size: 16px; line-height: 1.8; }
.fine-print { color: var(--muted); font-size: 13px; line-height: 1.7; }
.legend-list { display: grid; gap: 8px; margin: 16px 0; }
.legend-list > div { display: grid; grid-template-columns: 34px 68px 1fr; align-items: center; gap: 8px; font-size: 14px; }
.legend-list img { width: 31px; height: 31px; }
.legend-list strong { font-size: 16px; }
.rules-list { padding-left: 22px; font-size: 15px; line-height: 1.8; }
.detail-list { margin: 15px 0; }
.detail-list > div { display: flex; justify-content: space-between; align-items: center; gap: 16px; min-height: 34px; border-bottom: 1px solid #a4ac943d; }
.detail-list dt { color: var(--muted); font-size: 14px; }
.detail-list dd { margin: 0; text-align: right; font: 15px var(--ui); }
.result-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 18px 0; }
.result-grid > div { display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 79px; background: #e8e6d499; padding: 8px; }
.result-grid strong { font: 26px var(--ui); }
.result-grid span { color: var(--muted); font-size: 12px; margin-top: 5px; }
.wave-list { display: grid; gap: 5px; margin: 15px 0; }
.wave-row { display: grid; grid-template-columns: 59px minmax(0, 1fr) 56px; gap: 8px; align-items: center; min-height: 58px; padding: 7px 9px; background: #e9e7d5; }
.wave-row.current { background: #dce6ce; border-left: 2px solid #698663; }
.wave-row strong { font-size: 17px; }
.wave-row span { font-size: 13px; line-height: 1.7; }
.wave-row small { color: var(--muted); font-size: 12px; text-align: right; }
.recap-fact { padding: 10px 12px; background: #e0e7d2; border-left: 2px solid #637d5f; font-size: 14px; }
.recap-details { margin: 15px 0; }
.recap-details summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: #426651; }
.recap-details summary::before { content: "›"; font: 20px var(--ui); margin-right: 7px; }
.recap-details[open] summary::before { transform: rotate(90deg); }
.loadout-option strong, .preset strong { display: block; font-size: 19px; }
.loadout-option small, .preset small { display: block; color: var(--muted); font-size: 13px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; min-height: 52px; border-bottom: 1px solid #a4ac943d; }
.setting-row input { width: 20px; height: 20px; accent-color: #436d52; }
.setting-row label { flex: 1; min-height: 44px; display: flex; align-items: center; }
.setting-row > span { flex: 1; padding: 8px 0; }
.setting-row > span strong { display: block; font-size: 17px; }
.setting-row > span small { display: block; color: var(--muted); font-size: 12px; line-height: 1.7; margin-top: 2px; }
.stat-grid, .result-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 12px 0; }
.stat-grid > div, .result-stats > div { background: #e8e6d499; padding: 9px 12px; }
.stat-grid small, .result-stats small { display: block; font-size: 12px; color: var(--muted); }
.stat-grid b, .result-stats b { display: block; font: 23px var(--ui); }
.tip, .fact-tip { padding: 10px 12px; background: #e0e7d2; border-left: 2px solid #637d5f; margin: 12px 0; font-size: 14px; }
.tile-legend { display: flex; flex-wrap: wrap; gap: 8px 15px; }
.tile-legend > span { display: flex; align-items: center; gap: 6px; min-height: 30px; }
.tile-legend img { width: 26px; height: 26px; }
.muted { color: var(--muted); }

@keyframes hint-pulse { 50% { filter: brightness(1.13); } }
@keyframes tile-clear { to { opacity: 0; transform: scale(.45); } }
@keyframes tile-drop { from { opacity: .35; transform: translateY(-10px); } }
@keyframes float-up { 0% { opacity: 0; transform: translateY(3px); } 15% { opacity: 1; } 100% { opacity: 0; transform: translateY(-45px); } }
@keyframes banner-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes impact { 30% { transform: translateX(-5px); } 70% { transform: translateX(4px); } }
@keyframes enter { from { opacity: 0; transform: translateX(14px); } }
@keyframes disappear { to { opacity: 0; transform: translateX(10px); } }
@keyframes rage-flash { 40% { filter: sepia(.5) drop-shadow(0 0 8px #bf5039); } }
@keyframes cast-flash { 40% { filter: brightness(1.16); } }

@media (max-width: 700px) and (orientation: portrait) {
  body { padding: 0; display: block; background-attachment: scroll; }
  .game-shell { width: min(100%, 480px); min-height: 100svh; border: none; box-shadow: none; padding: max(8px, env(safe-area-inset-top)) 13px max(0px, env(safe-area-inset-bottom)); background: linear-gradient(#f5efdfda 0 70px, #f5efdf88 70px 250px, #f5efdfd5 280px), url("assets/background.webp") center top / cover; }
  .game-shell::before, .game-shell::after { display: none; }
  .game-header { height: 56px; min-height: 56px; margin-bottom: 4px; padding: 0 0 3px; border-bottom: none; gap: 6px; }
  .heading-group { padding-left: 8px; border-left-width: 2px; }
  h1 { font-size: 24px; letter-spacing: .05em; }
  .progress-button { min-height: 25px; font-size: 12px; gap: 7px; }
  .tools { gap: 5px; }
  .tool-button { width: 44px; height: 44px; font-size: 14px; }
  .battle-layout { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
  .combatants { height: 128px; padding: 0 2px; }
  .portrait { height: 86px; }
  .fighter { width: 46%; }
  .enemy-portrait { max-width: 180px; }
  .fighter-status { padding: 0; }
  .combat-metrics { line-height: 22px; font-size: 13px; gap: 16px; }
  .combat-metrics img { width: 17px; height: 17px; }
  .status-heart { height: 16px; width: 16px; }
  .health-track { height: 7px; }
  .crossing-mark { top: 55px; font-size: 25px; }
  .intent-button { min-height: 26px; font-size: 13px; gap: 8px; }
  .intent-label { font-size: 11px; }
  .resources { min-height: 33px; }
  .resource { line-height: 31px; font-size: 19px; gap: 7px; }
  .resource-label { font-size: 14px; }
  .resource small { font-size: 11px; }
  .board-panel { margin-top: 2px; }
  .board { gap: 3px; padding: 5px; }
  .tile { padding: 1px; }
  .board-instruction { display: none; }
  .cards { gap: 7px; }
  .skill-card { min-height: 72px; padding: 4px 5px 6px; grid-template-columns: 36px 1fr; grid-template-rows: 22px auto; }
  .skill-name { font-size: 15px; line-height: 22px; padding-right: 21px; }
  .skill-cost { width: 20px; height: 20px; top: 4px; right: 4px; font-size: 12px; }
  .skill-art { width: 35px; height: 39px; }
  .skill-description { font-size: 11px; padding-left: 2px; line-height: 1.65; }
  .skill-description small, .skill-status { font-size: 10px; }
  .skill-key { display: none; }
  .card-detail { min-height: 18px; margin: 0; font-size: 12px; line-height: 18px; }
  .feedback { min-height: 18px; font-size: 12px; line-height: 18px; margin: 0 0 3px; }
  .commands { grid-template-columns: 44px 1fr 1fr; gap: 7px; }
  .action-button, .hint-button { min-height: 44px; font-size: 19px; }
  .hint-button { font-size: 13px; }
  .game-footer { min-height: 30px; margin-top: 5px; font-size: 11px; border-top: none; }
  .game-footer a { position: relative; min-height: 30px; font-size: 12px; }
  .game-footer a::after { content: ""; position: absolute; inset: -14px 0 0; }
  dialog { padding: 19px; font-size: 15px; }
  .modal-head { top: -19px; }
  .legend-list > div { grid-template-columns: 30px 56px 1fr; font-size: 12px; gap: 6px; }
  .legend-list strong { font-size: 14px; }
  .wave-row { grid-template-columns: 52px minmax(0, 1fr) 43px; gap: 5px; }
  .wave-row span { font-size: 12px; }
}
@media (max-width: 360px) and (orientation: portrait) {
  .game-shell { padding-left: 10px; padding-right: 10px; }
  h1 { font-size: 21px; letter-spacing: .01em; }
  .heading-group { padding-left: 6px; }
  .tools { gap: 3px; }
  .tool-button { width: 44px; height: 44px; font-size: 13px; }
  .battle-layout { gap: 7px; }
  .combatants { height: 138px; }
  .portrait { height: 96px; }
  .skill-name { font-size: 14px; }
  .skill-description { font-size: 10px; }
  .skill-art { width: 32px; }
  .skill-card { grid-template-columns: 32px 1fr; }
  .card-detail, .feedback { font-size: 11px; }
  .action-button { font-size: 17px; }
}
@media (min-width: 701px) and (max-width: 1100px) and (min-height: 581px) {
  body { padding: 20px; }
  .game-shell { padding: 15px 21px 8px; }
  .battle-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 44%); column-gap: 22px; }
  .combatants { height: 209px; }
  .portrait { height: 163px; }
  .skill-card { min-height: 88px; grid-template-columns: 36px 1fr; }
  .skill-name { font-size: 15px; }
  .skill-art { width: 34px; height: 42px; }
  .skill-description { font-size: 11px; }
}
@media (orientation: landscape) and (max-height: 580px) {
  body { padding: 0 12px; display: block; background-attachment: scroll; }
  .game-shell { max-width: 1020px; min-height: 100svh; padding: max(5px, env(safe-area-inset-top)) 13px max(0px, env(safe-area-inset-bottom)); border: none; box-shadow: none; }
  .game-shell::before, .game-shell::after { display: none; }
  .game-header { min-height: 45px; height: 45px; margin-bottom: 5px; padding: 0; border-bottom: none; }
  h1 { font-size: 22px; line-height: 24px; margin: 0; }
  .heading-group { display: flex; align-items: center; gap: 14px; padding-left: 8px; }
  .progress-button { font-size: 12px; gap: 5px; min-height: 44px; }
  .tool-button { width: 44px; height: 44px; font-size: 13px; }
  .tools { gap: 6px; }
  .battle-layout { grid-template-columns: minmax(0, 1fr) minmax(250px, min(39vw, calc(100svh - 83px))); grid-template-areas: "arena board" "resources board" "spells board" "commands board"; column-gap: 22px; row-gap: 5px; }
  .combatants { height: 108px; }
  .portrait { height: 76px; }
  .fighter { width: 43%; }
  .bloodline { gap: 4px; }
  .health-track { height: 6px; }
  .status-heart { width: 13px; height: 13px; }
  .combat-metrics { font-size: 11px; line-height: 18px; gap: 14px; }
  .combat-metrics img { height: 15px; width: 15px; }
  .crossing-mark { top: 38px; font-size: 24px; }
  .intent-button { min-height: 22px; font-size: 12px; }
  .intent-label { font-size: 10px; }
  .resources { min-height: 29px; }
  .resource { font-size: 16px; line-height: 27px; gap: 6px; }
  .resource-label { font-size: 12px; }
  .resource small { font-size: 10px; }
  .resource + .resource::before { top: 6px; bottom: 6px; }
  .board { gap: 2px; padding: 4px; }
  .tile { padding: 1px; }
  .board-instruction { display: none; }
  .cards { gap: 6px; }
  .skill-card { min-height: 53px; padding: 3px 5px 4px; grid-template-columns: 28px 1fr; grid-template-rows: 21px auto; }
  .skill-name { font-size: 14px; line-height: 21px; }
  .skill-art { width: 26px; height: 23px; }
  .skill-description { font-size: 10px; line-height: 1.4; }
  .skill-description small, .skill-status { display: none; }
  .skill-key { display: none; }
  .skill-cost { width: 18px; height: 18px; top: 4px; right: 5px; font-size: 11px; }
  .card-detail { min-height: 15px; margin-top: 1px; line-height: 15px; font-size: 10px; }
  .feedback { line-height: 15px; min-height: 15px; margin: 0 0 2px; font-size: 10px; }
  .commands { grid-template-columns: 44px 1fr 1fr; gap: 6px; }
  .action-button, .hint-button { min-height: 44px; font-size: 17px; }
  .hint-button { font-size: 12px; }
  .game-footer { min-height: 24px; margin-top: 3px; font-size: 10px; border-top: none; }
  .game-footer a { min-height: 24px; font-size: 11px; }
}
@media (orientation: landscape) and (max-height: 355px) {
  .combatants { height: 88px; }
  .portrait { height: 57px; }
  .battle-layout { grid-template-columns: minmax(0, 1fr) minmax(220px, calc(100svh - 76px)); column-gap: 16px; row-gap: 3px; }
  .heading-group { gap: 8px; }
  h1 { font-size: 19px; letter-spacing: .02em; }
  .progress-button { font-size: 10px; gap: 3px; }
  .skill-name { font-size: 12px; }
  .skill-description { font-size: 9px; }
  .skill-card { padding-left: 4px; padding-right: 4px; grid-template-columns: 22px 1fr; }
  .skill-art { width: 22px; }
  .card-detail, .feedback { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
body.reduced-motion *, body.reduced-motion *::before, body.reduced-motion *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
