/* One responsive battle console, scoped to this game. */
body[data-game=defense] .shell {
  width:min(1480px,100%);height:100dvh;min-height:360px;
  display:grid;grid-template-columns:minmax(0,1fr) auto;
  grid-template-rows:68px minmax(0,1fr) 58px;
  padding:14px 20px;gap:12px;
}
body[data-game=defense] .top {grid-column:1;grid-row:1;padding:0;min-height:0;gap:14px}
body[data-game=defense] .top .brand {font-size:27px;line-height:1.15}
body[data-game=defense] .top .game-purpose {font-size:11px;color:#a4bed0}
body[data-game=defense] .top-actions .quiet {min-height:44px;font-size:12px}
body[data-game=defense] .stats {
  position:static;grid-column:2;grid-row:1;display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));gap:7px;
}
body[data-game=defense] .stat {min-width:98px;padding:8px 12px;border-radius:10px}
body[data-game=defense] .stat small {font-size:10px;letter-spacing:.2px}
body[data-game=defense] .stat b {font-size:24px}
body[data-game=defense] .layout,
body[data-game=defense][data-inspection-open=true] .layout {
  grid-column:1/-1;grid-row:2;min-height:0;gap:12px;
  grid-template-columns:minmax(0,1fr) 290px;grid-template-rows:minmax(0,1fr);
}
body[data-game=defense] .world-area {
  grid-template-columns:minmax(0,1fr);grid-template-rows:auto auto minmax(0,1fr) 52px;
  border-radius:16px;
}
body[data-game=defense] .world-area .stage-note,
body[data-game=defense][data-battle-phase=battle] .world-area .stage-note {
  grid-column:1;grid-row:1;grid-template-columns:auto minmax(0,1fr);
  padding:6px 12px;gap:5px 12px;min-height:42px;align-items:center;
}
body[data-game=defense] .world-area .stage-note #phase {font-size:11px;white-space:nowrap}
body[data-game=defense] .world-area .battle-guide,
body[data-game=defense][data-battle-phase=battle] .world-area .battle-guide {
  grid-column:2;grid-row:1;height:28px;min-height:28px;
}
body[data-game=defense] .world-area .battle-guide #coach {font-size:11px;line-height:1.35}
body[data-game=defense] .stage-note .coverage-key {display:none}
body[data-game=defense] .wave-stage {grid-row:2;padding:7px 12px;gap:5px 8px}
body[data-game=defense] .wave-heading strong {font-size:13px}
body[data-game=defense] .wave-hint {font-size:11px}
body[data-game=defense] .wave-next {grid-row:3;grid-column:1/-1}
body[data-game=defense] .wave-route {margin-top:3px;grid-column:1/-1}
body[data-game=defense] .world-area .field-viewport {grid-column:1;grid-row:3;min-height:0}
body[data-game=defense] .world-area .field-tools {
  grid-column:1;grid-row:4;position:relative;inset:auto;flex-wrap:nowrap;
  padding:4px 8px;gap:8px;justify-content:space-between;min-width:0;z-index:7;
}
.fusion-switch {display:flex;gap:10px;align-items:center;min-width:0}
body[data-game=defense] .field-tools #autoMerge {margin:0;min-height:42px;min-width:104px;font-size:11px}
#autoMergeState {font-size:11px;line-height:1.3;color:#9eb9ce;white-space:normal}
#autoMergeState[data-state=merging] {color:#f6d48c}
#autoMergeState[data-state=protected] {color:#a1d8c5}
.battle-options {position:relative;flex-shrink:0}
.battle-options>summary {
  display:grid;place-items:center;list-style:none;cursor:pointer;
  min-width:64px;min-height:42px;border:1px solid #48617a;
  border-radius:8px;background:#213247;color:#c6d9e9;font-size:12px;font-weight:800;
}
.battle-options>summary::-webkit-details-marker {display:none}
.battle-options[open]>summary {border-color:#e4be80;color:#ffe0a6}
.battle-options-body {
  position:absolute;bottom:calc(100% + 10px);right:0;z-index:30;
  display:grid;grid-template-columns:1fr 1fr;gap:7px;width:232px;
  padding:12px;border:1px solid #647c93;border-radius:12px;
  background:#17293df5;box-shadow:0 10px 30px #0008;
}
body[data-game=defense] .battle-options-body .quiet,
body[data-game=defense] .battle-options-body #zoom {
  position:static;min-width:0;min-height:44px;padding:7px;font-size:12px;
}
.battle-options summary:focus-visible {outline:3px solid #f4c37c;outline-offset:2px}
body[data-game=defense] .side {position:static;inset:auto;width:auto;max-height:none;overflow:hidden;gap:9px}
body[data-game=defense] .tactical-panel {min-height:0;flex:1;display:flex;flex-direction:column;border-radius:12px}
body[data-game=defense] .tactical-panel>summary {flex-shrink:0;height:48px;min-height:48px;cursor:default;padding:7px 12px}
body[data-game=defense] .tactical-panel>summary::after {display:none}
body[data-game=defense] .tactical-content {
  position:static;display:grid;grid-template-columns:minmax(0,1fr);
  min-height:0;max-height:none;overflow:auto;padding:0 8px 8px;gap:8px;
}
body[data-game=defense] .tactical-content .card {min-height:0;padding:12px}
body[data-game=defense] .unit-overview {grid-template-columns:76px minmax(0,1fr);gap:9px}
body[data-game=defense] .unit-overview #unitPortrait {width:76px;height:104px}
body[data-game=defense] .unit-overview #unitPortrait[hidden]+.unit-overview-text {grid-column:1/-1}
body[data-game=defense] .tactical-upgrade {flex-direction:column;align-items:stretch;padding:4px}
body[data-game=defense] footer.actions {grid-column:1/-1;grid-row:3;margin:0;max-width:none;width:auto}
body[data-game=defense] footer .main-btn,
body[data-game=defense] footer .quiet {min-height:54px;border-radius:10px;font-size:15px}
body[data-game=defense] footer #merge:disabled {display:none}
body[data-game=defense] .hintline {display:none}

@media(max-width:999px) and (min-height:601px) {
  body[data-game=defense] .shell {grid-template-columns:minmax(0,1fr);grid-template-rows:50px 48px minmax(0,1fr) 54px;padding:8px;gap:7px}
  body[data-game=defense] .top {grid-column:1;grid-row:1}
  body[data-game=defense] .top .brand {font-size:21px}
  body[data-game=defense] .top .edition {font-size:8px;letter-spacing:1px}
  body[data-game=defense] .top .game-purpose {display:none}
  body[data-game=defense] .top-actions .quiet {font-size:11px;min-height:42px;padding:8px 10px}
  body[data-game=defense] .stats {grid-column:1;grid-row:2}
  body[data-game=defense] .stat {min-width:0;padding:3px 12px}
  body[data-game=defense] .stat b {font-size:20px}
  body[data-game=defense] .stat small {font-size:9px}
  body[data-game=defense] .layout,
  body[data-game=defense][data-inspection-open=true] .layout {grid-row:3;grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr) 44px;gap:7px}
  body[data-game=defense] .world-area {border-radius:12px;grid-template-rows:auto auto minmax(0,1fr) 50px}
  body[data-game=defense] .side {position:relative;overflow:visible;z-index:8}
  body[data-game=defense] .tactical-panel {display:block;flex:initial}
  body[data-game=defense] .tactical-panel>summary {height:44px;min-height:44px;cursor:pointer;padding-right:32px}
  body[data-game=defense] .tactical-panel>summary::after {display:block}
  body[data-game=defense] .tactical-content {
    position:absolute;bottom:calc(100% + 7px);left:0;right:0;max-height:min(55dvh,390px);
    border:1px solid #698499;border-radius:12px;background:#17283d;
    box-shadow:0 -10px 35px #0008;padding:10px;
  }
  body[data-game=defense] .tactical-panel:not([open]) .tactical-content {display:none}
  body[data-game=defense] .world-area .stage-note,
  body[data-game=defense][data-battle-phase=battle] .world-area .stage-note {grid-template-columns:minmax(0,1fr);padding:6px 10px;gap:2px;min-height:56px}
  body[data-game=defense] .world-area .battle-guide,
  body[data-game=defense][data-battle-phase=battle] .world-area .stage-note>.battle-guide {grid-column:1;grid-row:2;height:28px;min-height:28px}
  body[data-game=defense] .world-area .stage-note>#phase {grid-column:1;grid-row:1}
  body[data-game=defense] .wave-stage {padding:6px 10px}
  body[data-game=defense] .wave-heading strong {font-size:12px}
  body[data-game=defense] .wave-stage[data-phase=prepare] .wave-heading {grid-column:1/-1}
  body[data-game=defense] .wave-preview {grid-row:2;grid-column:1/-1;justify-content:flex-start;max-width:none}
  /* The next enemy occupies row 2 on portrait phones. Keep the following
     instruction and the earned receipt below it, never in the same cells. */
  body[data-game=defense] .wave-stage[data-phase=prepare] .wave-hint {grid-row:3}
  body[data-game=defense] .wave-stage[data-phase=prepare] .wave-next {grid-row:4}
  body[data-game=defense] .wave-stage[data-round-result=true] .round-card {grid-row:3}

  body[data-game=defense] .wave-hint {grid-row:3;font-size:10px}
  body[data-game=defense] .wave-next {display:none}
  .fusion-switch {gap:7px}
  #autoMergeState {font-size:10px;max-width:150px}
  body[data-game=defense] .field-tools #autoMerge {min-width:98px;font-size:10px}
  body[data-game=defense] footer.actions {grid-row:4;gap:6px}
  body[data-game=defense] footer .main-btn,
  body[data-game=defense] footer .quiet {font-size:13px;min-height:50px;padding:8px}
}

@media(min-width:650px) and (max-height:600px) {
  body[data-game=defense] .shell {grid-template-rows:44px minmax(0,1fr) 46px;padding:6px 10px;gap:5px}
  body[data-game=defense] .top {min-height:0;padding:0}
  body[data-game=defense] .top .brand {font-size:19px}
  body[data-game=defense] .top .edition {font-size:8px;letter-spacing:1px}
  body[data-game=defense] .top .game-purpose {display:none}
  body[data-game=defense] .top-actions .quiet {font-size:10px;padding:6px;min-height:38px}
  body[data-game=defense] .stat {min-width:74px;padding:3px 9px}
  body[data-game=defense] .stat b {font-size:17px}
  body[data-game=defense] .stat small {font-size:8px}
  body[data-game=defense] .layout,
  body[data-game=defense][data-inspection-open=true] .layout {grid-template-columns:minmax(0,1fr) 210px;gap:7px;grid-template-rows:minmax(0,1fr)}
  body[data-game=defense] .world-area {grid-template-columns:minmax(0,1fr) auto;grid-template-rows:44px auto minmax(0,1fr);border-radius:10px}
  body[data-game=defense] .world-area .stage-note,
  body[data-game=defense][data-battle-phase=battle] .world-area .stage-note {grid-column:1;grid-row:1;grid-template-columns:minmax(0,1fr);gap:1px;min-height:0;padding:4px 8px}
  body[data-game=defense] .world-area .stage-note #phase {font-size:9px}
  body[data-game=defense] .world-area .battle-guide,
  body[data-game=defense][data-battle-phase=battle] .world-area .stage-note>.battle-guide {grid-column:1;grid-row:2;height:23px;min-height:23px}
  body[data-game=defense] .world-area .stage-note>#phase {grid-column:1;grid-row:1}
  body[data-game=defense] .world-area .battle-guide #coach {font-size:9px;white-space:normal;text-overflow:clip}
  body[data-game=defense] .world-area .field-tools {grid-column:2;grid-row:1;border:0;padding:1px 4px;gap:4px}
  body[data-game=defense] .field-tools #autoMerge {min-width:88px;min-height:40px;font-size:9px}
  #autoMergeState {display:none}
  .battle-options>summary {min-width:48px;min-height:40px;font-size:10px}
  .battle-options-body {bottom:auto;top:calc(100% + 7px)}
  body[data-game=defense] .wave-stage {grid-column:1/-1;grid-row:2;padding:4px 8px;gap:3px 7px}
  body[data-game=defense] .wave-heading strong {font-size:10px}
  body[data-game=defense] .wave-hint {font-size:9px;grid-column:1/-1}
  body[data-game=defense] .wave-next {display:none}
  body[data-game=defense] .world-area .field-viewport {grid-column:1/-1;grid-row:3}
  body[data-game=defense] .tactical-panel>summary {height:40px;min-height:40px;padding:5px 9px}
  body[data-game=defense] .tactical-content {max-height:none;padding:0 6px 6px}
  body[data-game=defense] .tactical-content .card {padding:8px}
  body[data-game=defense] #inspectionStats {font-size:9px}
  body[data-game=defense] footer .main-btn,
  body[data-game=defense] footer .quiet {font-size:12px;min-height:44px;padding:7px}
}
