/* Battle presentation. Coordinates and interactions stay in the shared layout module. */
:root {
  --field-blue: #61d8f5;
  --field-gold: #ffe593;
}
.battle-mode .workspace {
  background: #203b43;
  padding: 8px;
}
.battle-mode .topbar {
  background: #172e36;
  border-bottom: 1px solid #5d8790;
}
.battle-mode .brand-icon {
  color: #162e36;
  background: #ffe593;
  border-radius: 7px;
  font-size: 18px;
  transform: rotate(-5deg);
}
.battle-grid {
  position: relative;
  gap: 10px;
}
.map-container {
  border: 2px solid #59858c;
  border-radius: 16px;
  overflow: hidden;
  box-shadow:
    0 4px 0 #102d35,
    inset 0 0 30px #14392344;
}
.battle-hud {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
  z-index: 3;
}
.level-badge,
.wave-display {
  background: #183740ee;
  border: 1px solid #6c9b9c;
  border-radius: 12px;
  padding: 8px 11px;
  color: #f8f3d9;
  box-shadow: 0 3px 0 #13303744;
}
.level-badge {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 55%;
}
.level-badge > span {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 1.4px;
  color: #ffe593;
}
.level-badge strong {
  font-size: 13px;
}
.wave-display {
  display: grid;
  justify-items: end;
  gap: 3px;
}
.wave-display > strong {
  font-size: 13px;
  letter-spacing: 1px;
}
.wave-display > span {
  font-size: 13px;
  color: #b9e4e7;
}
.wave-dots {
  display: flex;
  gap: 4px;
}
.wave-dots i {
  width: 7px;
  height: 4px;
  background: #60858a;
  border-radius: 3px;
}
.wave-dots .filled {
  background: #ffe593;
  box-shadow: 0 0 5px #ffe59350;
}
.start-overlay {
  background: #193941ee;
  border: 1px solid #93beb6;
  border-radius: 18px;
  padding: 22px;
  top: 37%;
  width: min(330px, calc(100% - 34px));
  box-shadow:
    0 10px 0 #112b3840,
    0 24px 50px #17382e44;
  color: #fff3d2;
}
.start-overlay .start-kicker {
  display: block;
  font-size: 13px;
  letter-spacing: 1.3px;
  color: #ffe593;
  font-weight: 900;
}
.start-overlay > strong {
  font-size: 25px;
  margin: 6px 0;
  color: #fff7dc;
}
.start-overlay > span:not(.start-kicker) {
  color: #cce7e0;
  font-size: 13px;
  line-height: 1.55;
}
.start-overlay .primary,
.campaign-celebration .primary {
  width: 100%;
  background: linear-gradient(#fff1af, #eec460);
  border: 1px solid #fff0b7;
  color: #3b3d2b;
  box-shadow: 0 4px 0 #a4833e;
  font-weight: 900;
  border-radius: 10px;
  min-height: 46px;
  margin-top: 14px;
}
.hand-dock {
  background: linear-gradient(#294957, #1a343f);
  color: #def0ee;
  border: 1px solid #547a84;
  border-radius: 14px;
  padding: 8px;
  flex-basis: 178px;
  height: 178px;
  gap: 6px;
  box-shadow: 0 4px 0 #112b35;
}
.deck-heading {
  height: 30px;
  flex-basis: 30px;
}
.deck-heading > strong {
  color: #d6e9e5;
  font-size: 13px;
}
.energy-summary {
  color: #b4e9ff;
}
.dock-button {
  color: #e5f4ef;
  background: #395d69;
  border-color: #739aa0;
  min-height: 32px;
  border-radius: 8px;
}
#rally {
  width: auto;
  padding: 0 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}
#rally span {
  font-size: 13px;
}
.dock-button:disabled {
  opacity: 0.4;
}
.card {
  position: relative;
  background: linear-gradient(130deg, #dcf0eb, #afc6bb);
  border: 2px solid #80a7ae;
  border-radius: 11px;
  box-shadow: 0 4px 0 #0d2b3b;
  overflow: hidden;
  transition:
    transform 0.16s,
    border-color 0.16s,
    box-shadow 0.16s;
}
.card:not(.unaffordable) {
  border-color: #b8e1e4;
  box-shadow:
    0 4px 0 #0d2b3b,
    inset 0 0 0 1px #ecf8dd;
}
.card.selected {
  transform: translateY(-7px);
  border-color: #ffe593;
  box-shadow:
    0 5px 0 #a38337,
    0 0 18px #ffd97b55;
}
.card.dragging {
  opacity: 0.35;
  transform: translateY(-6px) scale(0.96);
}
.card.unaffordable {
  opacity: 0.65;
  filter: saturate(0.65);
}
.card.unaffordable:after {
  color: #394b4a;
  background: #f1edda;
  border-radius: 4px;
  top: 5px;
  right: 5px;
  font-size: 13px;
}
.card-energy-fill {
  background: #e8fbfc33;
}
.card .cost {
  background: linear-gradient(#619cc6, #345d86);
  color: #fff6d9;
  border: 1px solid #c5e6f2;
  border-radius: 7px;
  padding: 3px 4px;
  box-shadow: 0 2px 0 #254157;
}
.card > .troop-art {
  background: radial-gradient(ellipse at 50% 20%, #fffae380, transparent 75%);
}
.card-info {
  color: #1c3b40;
}
.card-power {
  color: #3e6163;
}
.card-stats {
  color: #335253;
}
.card-stats span {
  background: #f0f4dc;
  border-color: #9bb5a0;
}
.card-multiplier {
  background: #fbf0c5;
  border-radius: 4px;
  color: #394f49;
}
.energy-track {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 12px;
  flex: 0 0 12px;
}
.energy-track > span {
  font-size: 13px;
  letter-spacing: 1px;
  color: #9bc4d2;
  white-space: nowrap;
}
.energy-track b {
  color: #d8f2ff;
  font-size: 13px;
  letter-spacing: 0;
}
.energy-pips {
  flex: 1;
  display: flex;
  gap: 3px;
}
.energy-pips i {
  height: 7px;
  flex: 1;
  border-radius: 3px;
  background: linear-gradient(90deg, #76d4ee var(--fill), #142d3e var(--fill));
  box-shadow: inset 0 1px 1px #ffffff20;
}
.lane-buttons button {
  background: #7fd2e5;
  color: #123547;
  border-color: #bcebf3;
  border-radius: 7px;
  min-height: 34px;
}
.drag-guide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 12;
  overflow: visible;
}
.teaching-drag .card[data-card='0'] {
  border-color: #fff0a7;
  box-shadow:
    0 0 0 3px #ffe59388,
    0 0 25px #ffe59377;
  animation: card-invite 2.6s infinite;
}
@keyframes card-invite {
  0%,
  85%,
  100% {
    transform: translateY(0);
  }
  25%,
  60% {
    transform: translateY(-5px);
  }
}
.drag-tutorial {
  top: 47%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(275px, calc(100% - 32px));
  color: #f8f0ce;
  background: #173b47eb;
  border: 1px solid #96c9ce;
  border-radius: 14px;
  padding: 13px 12px;
  box-shadow: 0 5px 0 #18313b66;
  pointer-events: none;
  z-index: 4;
}
.drag-tutorial .tutorial-step {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 1.5px;
  color: #ffe593;
}
.drag-tutorial > strong {
  display: block;
  font-size: 21px;
  margin: 5px 0;
  color: #fff5d1;
}
.drag-tutorial > span:not(.tutorial-step) {
  font-size: 13px;
  color: #bce0e5;
}
.tutorial-steps {
  display: flex;
  gap: 5px;
  justify-content: center;
  margin-top: 10px;
}
.tutorial-steps b {
  border: 1px solid #6f989b;
  border-radius: 6px;
  padding: 5px;
  font-size: 13px;
  color: #e2f1e9;
}
#drag-ghost {
  width: 105px;
  height: auto;
  background: linear-gradient(#edf5dc, #a7d1cd);
  border: 2px solid #e5faff;
  border-radius: 12px;
  color: #25454d;
  padding: 6px;
  box-shadow:
    0 10px 20px #112c4777,
    0 4px 0 #386f86;
  z-index: 20;
}
#drag-ghost svg {
  width: 65px;
  height: 58px;
  display: block;
  margin: auto;
}
#drag-ghost > strong {
  display: block;
  font-size: 13px;
}
#drag-ghost > span {
  display: block;
  font-size: 13px;
  margin-top: 3px;
}
#drag-ghost.invalid {
  border-color: #f3a685;
  filter: saturate(0.5);
}
.drop-preview {
  transform: translate(-50%, -50%);
  background: #b3e9f4ee;
  color: #164d64;
  border: 2px solid #ebfcff;
  border-radius: 40px;
  padding: 9px 12px;
  font-size: 13px;
  box-shadow:
    0 0 0 8px #93e5f333,
    0 7px 0 #31576733;
  pointer-events: none;
}
.drop-preview.blocked {
  background: #f0ba9c;
  border-color: #fff0d5;
  color: #7d3e2d;
}
.battle-toast {
  top: 28%;
  background: #143841e8;
  color: #fff1bd;
  border: 1px solid #9ec1b2;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 3px 0 #18352a40;
}
.enemy-intel {
  top: 91px;
  border-radius: 7px;
  background: #943f32dc;
  color: #ffedd8;
  font-size: 13px;
}
.level-transition {
  background: #163742c9;
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.campaign-celebration {
  background: linear-gradient(#eef2d8, #cfdcc2);
  border: 2px solid #fcf2c6;
  border-radius: 22px;
  padding: 18px;
  box-shadow: 0 10px 0 #102d3755;
}
.campaign-celebration .next-lesson {
  font-size: 13px;
  font-weight: 800;
  padding: 9px;
  background: #dce9df;
  border-radius: 8px;
  color: #365d62;
  margin-top: 8px;
}
.operation:not(.locked):not(.completed) {
  border: 2px solid #68a6b7;
  box-shadow: 0 4px 0 #407381;
}
.operation .level-theme {
  display: block;
  color: #477c8a;
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 1px;
  margin-top: 5px;
}
@media (max-width: 600px) {
  .hand-dock {
    flex-basis: 178px;
    height: 178px;
  }
  .card {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
  }
  .card > .troop-art svg {
    max-height: 66px;
    width: 90px;
  }
  .card-info {
    padding: 5px;
    gap: 3px;
  }
  .card-info strong {
    font-size: 13px;
  }
  .card-power {
    font-size: 13px;
  }
  .card-stats {
    font-size: 13px;
  }
  .wave-display {
    padding: 7px 8px;
  }
  .level-badge {
    padding: 7px 9px;
  }
  .level-badge strong {
    font-size: 13px;
  }
  .battle-mode .workspace {
    padding: 6px;
  }
}
@media (max-height: 560px) and (min-width: 600px) {
  .hand-dock {
    flex-basis: 114px;
    height: 114px;
  }
  .deck-heading {
    height: 25px;
    flex-basis: 25px;
  }
  .card {
    grid-template-columns: 50px minmax(0, 1fr);
  }
  .card > .troop-art svg {
    max-height: 47px;
  }
  .card-info {
    gap: 2px;
    padding: 4px;
  }
  .card-info strong {
    font-size: 13px;
  }
  .card-power {
    font-size: 13px;
  }
  .card-stats {
    font-size: 13px;
  }
  .battle-hud {
    top: 5px;
    left: 7px;
    right: 7px;
  }
  .level-badge,
  .wave-display {
    padding: 5px 8px;
  }
  .level-badge strong {
    font-size: 13px;
  }
  .wave-dots {
    display: none;
  }
  .wave-display > span {
    font-size: 13px;
  }
  .start-overlay {
    top: 24%;
    padding: 9px 14px;
    max-width: 360px;
  }
  .start-overlay > strong {
    font-size: 20px;
  }
  .start-overlay > span:not(.start-kicker) {
    font-size: 13px;
  }
  .start-overlay .primary {
    min-height: 34px;
    margin-top: 7px;
  }
  .drag-tutorial {
    top: 49%;
    width: 240px;
    padding: 8px;
  }
  .drag-tutorial > strong {
    font-size: 16px;
    margin: 2px 0;
  }
  .tutorial-steps {
    margin-top: 4px;
  }
  .campaign-celebration {
    padding: 10px 14px;
  }
  .campaign-celebration .next-lesson {
    margin-top: 3px;
    padding: 4px;
    font-size: 13px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .teaching-drag .card[data-card='0'] {
    animation: none;
  }
  .demo-hand {
    display: none;
  }
  .card {
    transition: none;
  }
}
/* Give landscape play the full field height instead of flattening the battlefield. */
@media (max-height: 560px) and (min-width: 600px) {
  .battle-grid {
    flex-direction: row;
  }
  .hand-dock {
    flex: 0 0 205px;
    width: 205px;
    height: 100%;
  }
  .hand {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }
  .card {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
  }
  .card > .troop-art svg {
    width: 75px;
    max-height: 63px;
  }
  .deck-heading {
    flex-basis: 45px;
    height: 45px;
    flex-wrap: wrap;
    gap: 3px;
  }
  .deck-heading > strong {
    flex-basis: 100%;
    font-size: 13px;
  }
  .dock-tools {
    margin-left: auto;
  }
  .energy-summary {
    display: none;
  }
  .lane-buttons {
    gap: 3px;
  }
  .lane-buttons button {
    min-width: 40px;
    min-height: 27px;
    padding: 3px 5px;
    font-size: 13px;
  }
  .dock-button {
    min-height: 27px;
    width: 27px;
  }
  #rally {
    padding: 0 6px;
  }
  .energy-track {
    gap: 5px;
  }
  .energy-track > span {
    font-size: 13px;
    letter-spacing: 0;
  }
  .energy-pips {
    gap: 2px;
  }
}

/* Prevent native long-press selection from interrupting card placement on iOS. */
[data-card],
[data-card] *,
#arena,
#drag-ghost {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* Keep battle controls readable and easy to tap at every orientation. */
.hand-dock {
  height: 215px;
  flex-basis: 215px;
}
.deck-heading {
  height: auto;
  flex-basis: auto;
  flex-wrap: wrap;
  gap: 6px;
}
.deck-heading > strong {
  flex: 1 1 100%;
  white-space: normal;
  line-height: 1.3;
}
.dock-tools {
  width: 100%;
  justify-content: flex-end;
  gap: 8px;
}
.energy-summary {
  margin-right: auto;
}
#pause {
  width: auto;
  min-width: 104px;
  min-height: 48px;
  padding: 0 12px;
  font-size: 15px;
  white-space: nowrap;
  background: linear-gradient(#fff1af, #eec460);
  border-color: #fff0b7;
  color: #283d39;
  box-shadow: 0 3px 0 #9b7838;
}
#rally {
  min-height: 48px;
}
.battle-menu {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}
.battle-menu button {
  min-height: 48px;
  font-size: 14px;
}
#pause-resume,
#pause-reset {
  grid-column: 1 / -1;
}
@media (max-height: 560px) and (min-width: 600px) {
  .hand-dock {
    height: 100%;
    flex-basis: 205px;
  }
  .deck-heading {
    height: auto;
    flex-basis: auto;
  }
}
#restart-cancel,
#restart-confirm,
#reset-no,
#reset-yes {
  min-height: 48px;
}
