/* Battle Cockpit — compact, readable play surface for phone and tablet screens. */
#screen-battle.battle-cockpit {
  --cockpit-bg: #071123;
  --cockpit-panel: #101d36;
  --cockpit-panel-2: #162947;
  --cockpit-line: rgb(150 190 245 / .24);
  --cockpit-cyan: #55e6f4;
  --cockpit-gold: #ffd35a;
  --cockpit-coral: #ff8e84;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "opponent"
    "arena"
    "player";
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 5px;
  width: 100%;
  height: calc(100dvh - 85px);
  min-height: 0;
  overflow: hidden;
  padding: 6px clamp(6px, 1.5vw, 16px) 8px;
  background:
    radial-gradient(circle at 50% 38%, rgb(55 111 181 / .16), transparent 45%),
    linear-gradient(160deg, #050b18, var(--cockpit-bg));
}

#screen-battle.battle-cockpit > .opponent-zone {
  grid-area: opponent;
  min-width: 0;
  min-height: 0;
  padding: 5px 8px;
  overflow: hidden;
  border: 1px solid var(--cockpit-line);
  border-radius: 14px;
  background: linear-gradient(160deg, rgb(87 39 73 / .38), var(--cockpit-panel));
}

#screen-battle.battle-cockpit > .battle-arena {
  grid-area: arena;
  min-width: 0;
  min-height: 0;
}

#screen-battle.battle-cockpit .turn-banner {
  display: grid;
  grid-template-columns: auto minmax(0, auto) minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 38px;
  margin: 0 0 4px;
  padding: 5px 10px;
  overflow: hidden;
  border: 2px solid var(--cockpit-cyan);
  border-radius: 11px;
  background: linear-gradient(100deg, rgb(34 153 178 / .34), rgb(10 27 55 / .96));
  box-shadow: 0 0 15px rgb(85 230 244 / .18), inset 0 1px 0 rgb(255 255 255 / .12);
}

#screen-battle.battle-cockpit .turn-banner.is-opponent-turn {
  border-color: var(--cockpit-coral);
  background: linear-gradient(100deg, rgb(160 62 82 / .42), rgb(28 18 45 / .96));
  box-shadow: 0 0 15px rgb(255 142 132 / .2), inset 0 1px 0 rgb(255 255 255 / .1);
}

#screen-battle.battle-cockpit .turn-banner.is-defense {
  border-color: var(--cockpit-gold);
  background: linear-gradient(100deg, rgb(177 113 24 / .42), rgb(37 27 41 / .96));
}

#screen-battle.battle-cockpit .turn-banner-label {
  color: #d4e9ff;
  font: 900 .58rem/1 Outfit, sans-serif;
  letter-spacing: .14em;
}

#screen-battle.battle-cockpit .turn-banner-text {
  overflow: hidden;
  color: #fff7d1;
  font: 900 clamp(.82rem, 2.4vw, 1.08rem)/1 Outfit, sans-serif;
  letter-spacing: .06em;
  text-overflow: ellipsis;
  text-shadow: 0 1px 5px rgb(0 0 0 / .7);
  white-space: nowrap;
}

#screen-battle.battle-cockpit .turn-banner-detail {
  min-width: 0;
  overflow: hidden;
  color: #e8f5ff;
  font: 700 .68rem/1.2 Outfit, sans-serif;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#screen-battle.battle-cockpit > .player-zone-main {
  grid-area: player;
  min-width: 0;
  min-height: 0;
  padding: 5px 8px;
  overflow: hidden;
  border: 1px solid var(--cockpit-line);
  border-radius: 14px;
  background: linear-gradient(160deg, rgb(21 84 108 / .3), var(--cockpit-panel));
}

#screen-battle.battle-cockpit .battlefield-row,
#screen-battle.battle-cockpit .ki-zone-row,
#screen-battle.battle-cockpit .battle-hand-dock {
  min-width: 0;
  scrollbar-width: thin;
  scrollbar-color: #3a6897 transparent;
}

#screen-battle.battle-cockpit .battlefield-row {
  min-height: 0;
  align-items: stretch;
  gap: 7px;
  padding: 4px 2px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

#screen-battle.battle-cockpit .battle-opponent-field {
  border-top: 1px solid rgb(255 142 132 / .2);
}

#screen-battle.battle-cockpit .battle-player-field {
  border-top: 1px solid rgb(85 230 244 / .2);
}

#screen-battle.battle-cockpit .player-hud,
#screen-battle.battle-cockpit .ki-zone-row {
  min-width: 0;
}

#screen-battle.battle-cockpit .player-hud {
  min-height: 34px;
  gap: 6px;
}

#screen-battle.battle-cockpit .hud-avatar {
  width: 32px;
  height: 32px;
  font-size: 1.35rem;
}

#screen-battle.battle-cockpit .hud-name {
  font-size: .82rem;
}

#screen-battle.battle-cockpit .hud-faction {
  max-width: 110px;
  overflow: hidden;
  font-size: .58rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#screen-battle.battle-cockpit .hud-center {
  min-width: 0;
  max-width: 230px;
}

#screen-battle.battle-cockpit .life-container {
  min-width: 0;
  gap: 4px;
}

#screen-battle.battle-cockpit .life-label {
  font-size: .68rem;
}

#screen-battle.battle-cockpit .life-value {
  min-width: 39px;
  font-size: .78rem;
}

#screen-battle.battle-cockpit .life-bar-bg {
  height: 10px;
}

#screen-battle.battle-cockpit .hud-right {
  gap: 4px;
}

#screen-battle.battle-cockpit .ki-counter-badge,
#screen-battle.battle-cockpit .deck-count-badge {
  padding: 3px 5px;
  font-size: .68rem;
  white-space: nowrap;
}

#screen-battle.battle-cockpit .dragon-radar-meter {
  display: none;
}

#screen-battle.battle-cockpit .ki-zone-row {
  min-height: 24px;
  gap: 5px;
  padding: 2px 0;
  overflow-x: auto;
}

#screen-battle.battle-cockpit .ki-land-pill {
  min-height: 25px;
  padding: 2px 7px;
  font-size: .64rem;
  white-space: nowrap;
}

#screen-battle.battle-cockpit .battle-arena {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid var(--cockpit-line);
  border-radius: 12px;
  background: rgb(5 12 27 / .9);
}

#screen-battle.battle-cockpit .battle-coach {
  min-width: 0;
  flex: 1;
  font-size: .72rem;
  line-height: 1.2;
}

#screen-battle.battle-cockpit .coach-tip {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

#screen-battle.battle-cockpit .battle-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 5px;
}

#screen-battle.battle-cockpit .battle-actions .action-btn {
  min-height: 40px;
  padding: 7px 10px;
  font-size: .72rem;
  white-space: nowrap;
}

#screen-battle.battle-cockpit .draw-btn {
  border-color: rgb(255 211 90 / .85);
  color: #fff4b6;
  background: linear-gradient(135deg, #8d4b0b, #e39a21);
  box-shadow: 0 0 18px rgb(255 196 62 / .34);
  animation: draw-button-pulse 1.8s ease-in-out infinite;
}

@keyframes draw-button-pulse {
  0%, 100% { transform: translateY(0); box-shadow: 0 0 14px rgb(255 196 62 / .28); }
  50% { transform: translateY(-2px); box-shadow: 0 0 24px rgb(255 223 98 / .58); }
}

#screen-battle.battle-cockpit .draw-btn:disabled {
  animation: none;
  opacity: .5;
}

#screen-battle.battle-cockpit #btn-draw-card {
  display: none !important;
}

#screen-battle.battle-cockpit .battle-hand-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  width: 100%;
  min-width: 0;
  min-height: 0;
  position: relative;
}

#screen-battle.battle-cockpit .battle-hand-dock {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  min-height: 0;
  width: 100%;
  padding: 5px 2px 7px;
  overflow-x: auto;
  overflow-y: hidden;
  touch-action: pan-x;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
}

/* Compact image-backed floating deck pile */
.player-deck-pile {
  position: fixed;
  width: clamp(48px, 12vw, 64px);
  height: clamp(68px, 11dvh, 84px);
  right: clamp(10px, 2vw, 24px);
  bottom: calc(max(10px, env(safe-area-inset-bottom)) + 96px);
  cursor: pointer;
  user-select: none;
  touch-action: none;
  outline: none;
  border-radius: 10px;
  perspective: 700px;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.2s ease;
  z-index: 30;
}

.player-deck-pile.is-dragging {
  cursor: grabbing;
  filter: brightness(1.15) saturate(1.15);
  transition: none;
  z-index: 40;
}

.player-deck-pile:focus-visible {
  outline: 2px solid #ffd35a;
  outline-offset: 3px;
}

.player-deck-pile .deck-card-stack {
  position: relative;
  width: 100%;
  height: 100%;
}

.player-deck-pile .deck-layer {
  position: absolute;
  inset: 0;
  border-radius: 9px;
  border: 1px solid rgba(255, 170, 0, 0.25);
  background: #091224;
  pointer-events: none;
}

.player-deck-pile .deck-layer.layer-3 {
  transform: translate(3px, 3px);
  background: #050b18;
  border-color: rgba(255, 150, 0, 0.15);
}

.player-deck-pile .deck-layer.layer-2 {
  transform: translate(2px, 2px);
  background: #081121;
  border-color: rgba(255, 160, 0, 0.2);
}

.player-deck-pile .deck-top-card {
  position: absolute;
  inset: 0;
  border-radius: 9px;
  border: 1.5px solid rgba(255, 196, 62, 0.55);
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 170, 0, 0.22), transparent 70%),
    linear-gradient(145deg, #132240, #0a1326);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 3px;
  text-align: center;
  transition: all 0.25s ease;
  overflow: hidden;
}

.player-deck-pile .deck-float-grip {
  position: absolute;
  top: 4px;
  right: 6px;
  color: rgb(255 244 182 / .8);
  font: 900 .68rem/1 Outfit, sans-serif;
  letter-spacing: -.18em;
  opacity: .8;
}

.player-deck-pile .deck-back-image {
  display: block;
  width: 72%;
  height: 72%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 2px 3px rgb(0 0 0 / .65));
}

.player-deck-pile .deck-count-num {
  position: absolute;
  top: 5px;
  left: 5px;
  min-width: 16px;
  padding: 1px 3px;
  border-radius: 8px;
  background: rgb(3 11 27 / .82);
  border: 1px solid rgb(255 211 90 / .7);
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: clamp(0.56rem, 1.7vw, 0.68rem);
  color: #ffffff;
  line-height: 1.1;
}

.player-deck-pile .deck-prompt-pill {
  position: absolute;
  right: 3px;
  bottom: 3px;
  margin: 0;
  padding: 2px 3px;
  border-radius: 10px;
  background: rgba(255, 170, 0, 0.2);
  border: 1px solid rgba(255, 211, 90, 0.4);
  font-size: 0.42rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #fff4b6;
  opacity: 0.7;
  transition: all 0.2s ease;
}

/* DRAW PHASE ACTIVE - Ki Aura, Pulsing & Hover */
.player-deck-pile.deck-draw-ready {
  cursor: pointer;
}

.player-deck-pile.deck-draw-ready .deck-top-card {
  border-color: #ffd35a;
  box-shadow:
    0 0 16px rgba(255, 196, 62, 0.6),
    0 0 32px rgba(255, 140, 0, 0.4),
    inset 0 0 12px rgba(255, 211, 90, 0.28);
  animation: deckAuraPulse 1.6s ease-in-out infinite;
}

.player-deck-pile.deck-draw-ready .deck-prompt-pill {
  opacity: 1;
  background: linear-gradient(135deg, #c76707, #ff9f1c);
  border-color: #ffe066;
  color: #ffffff;
  box-shadow: 0 0 10px rgba(255, 196, 62, 0.75);
  animation: promptPillBounce 1.2s ease-in-out infinite alternate;
}

.player-deck-pile.deck-draw-ready:hover {
  transform: translateY(-4px) scale(1.05);
}

.player-deck-pile.deck-draw-ready:hover .deck-top-card {
  box-shadow:
    0 0 24px rgba(255, 211, 90, 0.85),
    0 0 46px rgba(255, 140, 0, 0.55),
    inset 0 0 16px rgba(255, 211, 90, 0.35);
}

.player-deck-pile.deck-draw-ready:active {
  transform: translateY(1px) scale(0.97);
}

@keyframes deckAuraPulse {
  0%, 100% {
    box-shadow: 0 0 14px rgba(255, 196, 62, 0.5), 0 0 26px rgba(255, 140, 0, 0.3), inset 0 0 10px rgba(255, 211, 90, 0.2);
  }
  50% {
    box-shadow: 0 0 24px rgba(255, 211, 90, 0.85), 0 0 44px rgba(255, 140, 0, 0.6), inset 0 0 18px rgba(255, 211, 90, 0.4);
  }
}

@keyframes promptPillBounce {
  0% { transform: scale(0.95); }
  100% { transform: scale(1.06); }
}

#screen-battle.battle-cockpit .battle-hand-dock::before {
  content: 'YOUR HAND';
  position: sticky;
  left: 0;
  z-index: 3;
  align-self: stretch;
  display: flex;
  min-width: 28px;
  align-items: center;
  justify-content: center;
  padding: 2px;
  color: var(--cockpit-gold);
  background: linear-gradient(90deg, var(--cockpit-panel) 72%, transparent);
  font: 900 .55rem/1 Outfit, sans-serif;
  letter-spacing: .08em;
  writing-mode: vertical-rl;
}

#screen-battle.battle-cockpit .battle-hand-dock .card,
#screen-battle.battle-cockpit .battlefield-row .card {
  box-sizing: border-box;
  flex: 0 0 auto;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 4px;
  border-radius: 9px;
  scroll-snap-align: start;
}

#screen-battle.battle-cockpit .battlefield-row .card {
  width: clamp(76px, 12vw, 108px);
  height: 100%;
  max-height: 112px;
  border-color: rgb(255 142 132 / .5);
}

#screen-battle.battle-cockpit .battle-player-field .card {
  border-color: rgb(85 230 244 / .62);
}

#screen-battle.battle-cockpit .battle-hand-dock .card {
  width: clamp(86px, 24vw, 108px);
  height: clamp(118px, 18dvh, 136px);
  border-color: rgb(255 211 90 / .55);
  scroll-snap-align: center;
}

#screen-battle.battle-cockpit .card-inner {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

#screen-battle.battle-cockpit .card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2px;
}

#screen-battle.battle-cockpit .card-name {
  min-width: 0;
  font-size: clamp(.58rem, 1.7vw, .72rem);
  text-align: left;
}

#screen-battle.battle-cockpit .card-cost {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  font-size: .68rem;
}

#screen-battle.battle-cockpit .card-art {
  height: clamp(48px, 8dvh, 70px);
  margin: 2px 0;
  overflow: hidden;
  border-radius: 5px;
  background: #0b1428;
}

#screen-battle.battle-cockpit .card-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

#screen-battle.battle-cockpit .card-desc {
  display: -webkit-box;
  overflow: hidden;
  color: #c9d9f2;
  font-size: .55rem;
  line-height: 1.08;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

#screen-battle.battle-cockpit .card-stats {
  font-size: .68rem;
}

#screen-battle.battle-cockpit .battle-hand-dock .card-desc {
  display: none;
}

#screen-battle.battle-cockpit .battle-hand-dock .card:hover,
#screen-battle.battle-cockpit .battle-hand-dock .card:focus-visible {
  z-index: 4;
  transform: translateY(-5px);
}

/* Portrait phone cockpit: every essential region participates in one bounded grid. */
@media (max-width: 600px) {
  .app-container.battle-active .game-header {
    min-height: 48px;
    padding: 4px 8px;
  }

  .app-container.battle-active .game-title {
    font-size: 1.15rem;
  }

  .app-container.battle-active .subtitle,
  .app-container.battle-active .dragon-ball-icon,
  .app-container.battle-active #btn-bgm,
  .app-container.battle-active #btn-wiki {
    display: none;
  }

  .app-container.battle-active .header-controls {
    gap: 4px;
  }

  .app-container.battle-active .btn-icon {
    min-width: 40px;
    min-height: 40px;
    padding: 5px;
    font-size: .95rem;
  }

  .app-container.battle-active + * { box-sizing: border-box; }

  #screen-battle.battle-cockpit {
    grid-template-areas:
      "opp-hud"
      "opp-ki"
      "opp-field"
      "player-field"
      "player-hud"
      "player-ki"
      "hand"
      "coach"
      "actions";
    grid-template-rows: auto 25px minmax(72px, 13dvh) minmax(82px, 15dvh) auto 27px minmax(132px, 20dvh) auto auto;
    height: auto;
    min-height: calc(100dvh - 78px);
    max-height: none;
    overflow: visible;
    gap: 4px;
    padding: 4px 6px max(7px, env(safe-area-inset-bottom));
  }

  #screen-battle.battle-cockpit > .opponent-zone,
  #screen-battle.battle-cockpit > .player-zone-main,
  #screen-battle.battle-cockpit > .battle-arena {
    display: contents;
  }

  #screen-battle.battle-cockpit .battle-opponent-hud { grid-area: opp-hud; }
  #screen-battle.battle-cockpit .battle-opponent-ki { grid-area: opp-ki; }
  #screen-battle.battle-cockpit .battle-opponent-field { grid-area: opp-field; }
  #screen-battle.battle-cockpit .battle-player-field { grid-area: player-field; }
  #screen-battle.battle-cockpit .battle-player-hud { grid-area: player-hud; }
  #screen-battle.battle-cockpit .battle-player-ki { grid-area: player-ki; }
  #screen-battle.battle-cockpit .battle-hand-dock,
  #screen-battle.battle-cockpit .battle-hand-row { grid-area: hand; }
  #screen-battle.battle-cockpit .battle-coach { grid-area: coach; }
  #screen-battle.battle-cockpit .battle-actions { grid-area: actions; }

  #screen-battle.battle-cockpit .battle-opponent-hud,
  #screen-battle.battle-cockpit .battle-player-hud,
  #screen-battle.battle-cockpit .battle-opponent-ki,
  #screen-battle.battle-cockpit .battle-player-ki,
  #screen-battle.battle-cockpit .battlefield-row,
  #screen-battle.battle-cockpit .battle-hand-dock,
  #screen-battle.battle-cockpit .battle-hand-row,
  #screen-battle.battle-cockpit .battle-coach,
  #screen-battle.battle-cockpit .battle-actions {
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
  }

  #screen-battle.battle-cockpit .battle-opponent-hud,
  #screen-battle.battle-cockpit .battle-player-hud {
    padding: 2px 5px;
    border: 1px solid var(--cockpit-line);
    border-radius: 9px;
    background: rgb(16 29 54 / .86);
  }

  #screen-battle.battle-cockpit .battle-opponent-field,
  #screen-battle.battle-cockpit .battle-player-field {
    min-height: 0;
    height: 100%;
    border: 1px solid var(--cockpit-line);
    border-radius: 9px;
    background: rgb(8 19 38 / .72);
  }

  #screen-battle.battle-cockpit .battle-opponent-ki,
  #screen-battle.battle-cockpit .battle-player-ki {
    padding: 1px 5px;
    border-radius: 7px;
    background: rgb(15 31 58 / .72);
  }

  #screen-battle.battle-cockpit .battle-hand-dock {
    min-height: 0;
    height: clamp(132px, 20dvh, 158px);
    padding: 4px 2px 6px;
    border: 1px solid rgb(255 211 90 / .38);
    border-radius: 10px;
    background: linear-gradient(180deg, rgb(38 42 67 / .88), rgb(12 22 43 / .94));
  }

  #screen-battle.battle-cockpit .battle-hand-dock::before {
    min-width: 22px;
    font-size: .5rem;
  }

  #screen-battle.battle-cockpit .battle-hand-dock .card {
    width: clamp(84px, 23vw, 102px);
    height: clamp(116px, 18dvh, 138px);
  }

  #screen-battle.battle-cockpit .battlefield-row .card {
    width: clamp(70px, 19vw, 92px);
    max-height: 104px;
  }

  #screen-battle.battle-cockpit .card-art {
    height: clamp(42px, 7dvh, 62px);
  }

  #screen-battle.battle-cockpit .card-name {
    font-size: .62rem;
  }

  #screen-battle.battle-cockpit .card-stats {
    font-size: .62rem;
  }

  #screen-battle.battle-cockpit .battle-coach {
    min-height: 32px;
    padding: 4px 6px;
    border: 1px solid rgb(85 230 244 / .24);
    border-radius: 8px;
    background: rgb(8 24 47 / .92);
    font-size: .68rem;
  }

  #screen-battle.battle-cockpit .battle-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
  }

  #screen-battle.battle-cockpit .battle-actions .action-btn {
    min-width: 0;
    min-height: 44px;
    padding: 7px 5px;
    overflow: hidden;
    font-size: .68rem;
    text-overflow: ellipsis;
  }

  #screen-battle.battle-cockpit .battle-actions .end-btn:last-child {
    grid-column: 1 / -1;
  }

  #screen-battle.battle-cockpit .battle-actions[data-phase="ATTACK_DECLARE"] .attack-btn:not(.hidden) {
    grid-column: 1 / -1;
    min-height: 48px;
    padding-inline: 10px;
    overflow: visible;
    font-size: .82rem;
    font-weight: 800;
    text-overflow: clip;
    white-space: normal;
  }

  #screen-battle.battle-cockpit .battle-actions .attack-btn:disabled {
    opacity: .72;
    cursor: not-allowed;
    filter: saturate(.45);
  }

  #screen-battle.battle-cockpit .battle-opponent-hud .hud-left,
  #screen-battle.battle-cockpit .battle-player-hud .hud-left {
    min-width: 0;
    flex: 1 1 auto;
  }

  #screen-battle.battle-cockpit .battle-opponent-hud .hud-right,
  #screen-battle.battle-cockpit .battle-player-hud .hud-right {
    flex: 0 0 auto;
  }

  #screen-battle.battle-cockpit .battle-opponent-hud .hud-center,
  #screen-battle.battle-cockpit .battle-player-hud .hud-center {
    flex: 0 1 34%;
  }

  #screen-battle.battle-cockpit .battle-player-hud .quick-emojis {
    display: none;
  }
}

@media (max-width: 360px), (max-height: 620px) and (max-width: 600px) {
  #screen-battle.battle-cockpit {
    grid-template-rows: auto 22px minmax(62px, 11dvh) minmax(70px, 12dvh) auto 24px minmax(118px, 18dvh) auto auto;
  }

  #screen-battle.battle-cockpit .battle-hand-dock {
    height: 122px;
  }

  #screen-battle.battle-cockpit .battle-hand-dock .card {
    width: 96px;
    height: 138px;
  }

  #screen-battle.battle-cockpit .battlefield-row .card {
    width: 72px;
  }

  #screen-battle.battle-cockpit .card-art {
    height: 44px;
  }

  #screen-battle.battle-cockpit .card-name,
  #screen-battle.battle-cockpit .card-stats {
    font-size: .7rem;
  }

  #screen-battle.battle-cockpit .battle-coach {
    display: none;
  }
}

/* Landscape phones/tablets: keep the hand and actions in a reachable side dock. */
@media (orientation: landscape) and (max-height: 620px) and (max-width: 900px) {
  #screen-battle.battle-cockpit {
    grid-template-columns: minmax(0, 1fr) minmax(230px, 34vw);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "opponent hand"
      "player hand";
    height: calc(100dvh - 58px);
    padding: 4px;
  }

  #screen-battle.battle-cockpit > .opponent-zone,
  #screen-battle.battle-cockpit > .player-zone-main {
    display: contents;
  }

  #screen-battle.battle-cockpit > .battle-arena { grid-area: hand; display: flex; flex-direction: column; }
  #screen-battle.battle-cockpit .battle-opponent-hud { grid-area: opponent; }
  #screen-battle.battle-cockpit .battle-opponent-field { grid-area: opponent; align-self: end; }
  #screen-battle.battle-cockpit .battle-player-field { grid-area: player; }
  #screen-battle.battle-cockpit .battle-hand-dock,
  #screen-battle.battle-cockpit .battle-hand-row { grid-area: hand; height: 48%; }
  #screen-battle.battle-cockpit .battle-coach { grid-area: hand; margin-top: auto; }
  #screen-battle.battle-cockpit .battle-actions { grid-area: hand; margin-top: auto; }
}

.card-inspect-sheet {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  background: rgb(2 6 18 / .78);
  backdrop-filter: blur(7px);
}

.card-inspect-sheet.hidden { display: none !important; }

.card-inspect-panel {
  position: relative;
  width: min(100%, 760px);
  max-height: min(90dvh, 680px);
  overflow: auto;
  padding: 20px;
  color: #eef6ff;
  border: 1px solid rgb(129 199 255 / .38);
  border-radius: 20px;
  background: linear-gradient(145deg, #182d50, #0b172f 72%);
  box-shadow: 0 20px 55px rgb(0 0 0 / .55), inset 0 2px 0 rgb(255 255 255 / .13);
}

.card-inspect-close {
  position: absolute;
  top: 8px;
  right: 10px;
  z-index: 1;
  width: 44px;
  height: 44px;
  border: 1px solid rgb(255 255 255 / .24);
  border-radius: 50%;
  color: #fff;
  background: rgb(6 13 29 / .75);
  cursor: pointer;
  font-size: 1.8rem;
  line-height: 1;
}

.card-inspect-layout {
  display: grid;
  grid-template-columns: minmax(170px, 240px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.card-inspect-art-wrap {
  padding: 5px;
  border: 1px solid rgb(255 211 90 / .52);
  border-radius: 12px;
  background: #071123;
}

.card-inspect-art {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: contain;
  object-position: top center;
  border-radius: 8px;
  background: linear-gradient(180deg, #0b1428, #152743);
}

.card-inspect-copy { min-width: 0; padding-top: 8px; }
.card-inspect-kicker { color: var(--gold-primary, #ffd35a); font: 800 .72rem/1 Outfit, sans-serif; letter-spacing: .14em; }
.card-inspect-copy h2 { margin: 4px 0 9px; color: #fff; font-size: clamp(1.35rem, 4vw, 2rem); }
.card-inspect-stats { color: #8cecf8; font-weight: 800; }
.card-inspect-text { margin: 12px 0; color: #d9e5f8; line-height: 1.5; }
.card-inspect-keywords { display: flex; flex-wrap: wrap; gap: 5px; }
.card-inspect-reason { min-height: 1.2em; margin: 12px 0 8px; color: #ffcf72; font-size: .88rem; }
.card-inspect-play { min-height: 46px; width: 100%; color: #071123; background: linear-gradient(180deg, #ffe58c, #ffb52e); }
.card-inspect-play:disabled { cursor: not-allowed; opacity: .45; filter: grayscale(.4); }

.spell-target-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  flex-wrap: wrap;
  width: min(100%, 680px);
  margin: 7px auto 0;
  padding: 7px 10px;
  border: 1px solid rgb(85 230 244 / .55);
  border-radius: 10px;
  color: #eaffff;
  background: linear-gradient(135deg, rgb(5 103 133 / .82), rgb(14 31 61 / .92));
  box-shadow: 0 0 18px rgb(48 211 238 / .18);
  font-size: .72rem;
}
.spell-target-panel strong { color: #ffe58c; letter-spacing: .05em; }
.spell-target-panel span { color: #d9f7ff; }
.spell-target-panel .btn-small { min-height: 32px; padding: 5px 9px; }
.spell-target-panel.hidden { display: none; }
.spell-target-options { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.spell-target-choice { min-height: 36px; padding: 6px 10px; border: 1px solid #8cecf8; border-radius: 9px; color: #061222; background: #8cecf8; font: 800 .78rem/1.15 Outfit, sans-serif; cursor: pointer; }
.spell-target-choice:focus-visible, .keyword-help-toggle:focus-visible, .keyword-help-close:focus-visible, .keyword-badge:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

.keyword-help-row { display: flex; justify-content: center; margin: 4px auto 2px; }
.keyword-help-toggle { width: 44px; height: 44px; border: 2px solid #ffe58c; border-radius: 50%; color: #071123; background: linear-gradient(145deg, #fff1a6, #ffbd36); box-shadow: 0 3px 12px rgb(0 0 0 / .35); font: 900 1.35rem/1 Outfit, sans-serif; cursor: pointer; }
.keyword-help-toggle[aria-expanded="true"] { color: #fff; background: #155b76; }
.keyword-live-help { position: fixed; z-index: 2400; top: max(12px, env(safe-area-inset-top)); left: 50%; width: min(440px, calc(100vw - 24px)); margin: 0; padding: 10px 14px; border: 1px solid #8cecf8; border-radius: 12px; color: #f4fbff; background: #071a2eed; box-shadow: 0 8px 28px rgb(0 0 0 / .55); text-align: center; transform: translateX(-50%); }
.keyword-live-help.hidden { display: none; }
.keyword-help-dialog { position: fixed; z-index: 2500; top: max(12px, env(safe-area-inset-top)); left: 50%; width: min(520px, calc(100vw - 24px)); max-height: min(78vh, 680px); overflow: auto; padding: 17px; border: 1px solid rgb(140 236 248 / .75); border-radius: 18px; color: #edf8ff; background: linear-gradient(150deg, #101f38, #071222 78%); box-shadow: 0 18px 55px rgb(0 0 0 / .72), 0 0 28px rgb(48 211 238 / .18); transform: translateX(-50%); }
.keyword-help-dialog.hidden { display: none; }
.keyword-help-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
.keyword-help-header h2 { margin: 0; color: #ffe58c; font-size: 1.16rem; }
.keyword-help-close { min-width: 52px; min-height: 40px; border: 1px solid #8cecf8; border-radius: 10px; color: #f5fcff; background: #153049; font: 800 .88rem Outfit, sans-serif; cursor: pointer; }
.keyword-help-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin: 0; }
.keyword-help-list > div { min-width: 0; padding: 9px 10px; border: 1px solid rgb(140 236 248 / .25); border-radius: 11px; background: rgb(24 49 76 / .78); }
.keyword-help-list dt { color: #8cecf8; font-weight: 900; }
.keyword-help-list dd { margin: 3px 0 0; color: #e0eafa; font-size: .86rem; line-height: 1.4; }
.badge-keyword.keyword-badge { display: inline-flex; align-items: center; justify-content: center; min-height: 25px; padding: 3px 7px; border: 1px solid rgb(255 229 140 / .8); border-radius: 999px; color: #fff1b2; background: #33284dcc; font: 800 .62rem/1.1 Outfit, sans-serif; cursor: help; touch-action: manipulation; }
.card-type-label { display: inline-flex; align-items: center; min-height: 22px; padding: 3px 7px; border: 1px solid rgb(140 236 248 / .42); border-radius: 999px; color: #bfeff5; background: #123044c9; font: 800 .58rem/1.1 Outfit, sans-serif; }
.response-continue-btn { border-color: #8cecf8; color: #051623; background: linear-gradient(180deg, #b8f4fb, #43c9df); }
.response-continue-btn.hidden { display: none; }

#screen-battle.battle-cockpit .spell-targetable-leader {
  cursor: crosshair;
  outline: 2px solid rgb(85 230 244 / .9);
  outline-offset: 3px;
  border-radius: 10px;
  box-shadow: 0 0 20px rgb(55 216 240 / .35);
}

@media (max-width: 520px) {
  .card-inspect-panel { padding: 14px; border-radius: 16px; }
  .card-inspect-layout { grid-template-columns: 92px minmax(0, 1fr); gap: 12px; }
  .card-inspect-copy { padding-top: 2px; }
  .card-inspect-copy h2 { font-size: 1.2rem; }
  .card-inspect-text { max-height: 92px; overflow: auto; font-size: .9rem; }
  .keyword-help-list { grid-template-columns: minmax(0, 1fr); }
  .keyword-help-dialog { padding: 13px; }
  .spell-target-panel { width: calc(100% - 12px); }
}

@media (prefers-reduced-motion: reduce) {
  #screen-battle.battle-cockpit *,
  .card-inspect-sheet * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

/* Gameplay interaction pass: unavailable cards, pointer drag, and combat impact. */
#screen-battle.battle-cockpit .battle-player-field {
  position: relative;
  isolation: isolate;
}

#screen-battle.battle-cockpit .battle-drop-zone {
  position: absolute;
  inset: 8px;
  z-index: 0;
  display: grid;
  place-items: center;
  min-height: 70px;
  border: 2px dashed rgb(255 211 90 / .7);
  border-radius: 14px;
  color: #ffe58c;
  background: rgb(255 196 54 / .08);
  font-size: clamp(.7rem, 1.4vw, .95rem);
  font-weight: 900;
  letter-spacing: .12em;
  opacity: 0;
  pointer-events: none;
  transform: scale(.96);
  transition: opacity .16s ease, transform .16s ease, background .16s ease;
}

#screen-battle.battle-cockpit .battle-player-field > .card { position: relative; z-index: 1; }
#screen-battle.battle-cockpit .battle-player-field.drop-target-active .battle-drop-zone,
#screen-battle.battle-cockpit .battle-drop-zone.drag-hover {
  opacity: 1;
  transform: scale(1);
}

#screen-battle.battle-cockpit .battle-drop-zone.drag-hover {
  color: #071123;
  background: linear-gradient(135deg, #ffe58c, #ff9f1c);
  border-color: #fff;
  box-shadow: 0 0 30px rgb(255 183 48 / .55);
}

#screen-battle.battle-cockpit .hand-card {
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
  cursor: grab;
}

#screen-battle.battle-cockpit .hand-card:active,
#screen-battle.battle-cockpit .hand-card.dragging-card {
  cursor: grabbing;
}

#screen-battle.battle-cockpit .hand-card.dragging-card {
  z-index: 20;
  transform: translateY(-14px) scale(1.05) rotate(-2deg);
  border-color: #ffe58c;
  box-shadow: 0 0 0 3px rgb(255 229 140 / .3), 0 18px 35px rgb(0 0 0 / .65), 0 0 24px rgb(255 178 40 / .55);
}

#screen-battle.battle-cockpit .hand-card.cannot-play {
  opacity: .42;
  filter: grayscale(.82) saturate(.45) brightness(.78);
  border-color: rgb(168 180 201 / .45);
  box-shadow: 0 5px 10px rgb(0 0 0 / .25);
}

#screen-battle.battle-cockpit .hand-card.cannot-play::after {
  content: 'UNAVAILABLE';
  position: absolute;
  left: 5px;
  right: 5px;
  bottom: 7px;
  z-index: 4;
  padding: 3px 4px;
  border: 1px solid rgb(255 255 255 / .3);
  border-radius: 5px;
  color: #eef2f7;
  background: rgb(24 31 45 / .82);
  font-size: .52rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-align: center;
  pointer-events: none;
}

#screen-battle.battle-cockpit .hand-card.cannot-play:focus-visible {
  opacity: .7;
  filter: grayscale(.5) saturate(.6);
}

#screen-battle.battle-cockpit .action-hint,
#screen-battle.battle-cockpit .target-hint {
  position: relative;
  z-index: 4;
  outline: 2px solid rgb(255 221 105 / .9);
  outline-offset: 3px;
  animation: legal-action-hint 1.65s ease-in-out infinite;
}

#screen-battle.battle-cockpit .action-hint::before,
#screen-battle.battle-cockpit .target-hint::before {
  content: 'TAP';
  position: absolute;
  top: -9px;
  right: 5px;
  z-index: 8;
  padding: 2px 5px;
  border-radius: 5px;
  color: #071123;
  background: #ffe276;
  font: 900 .48rem/1 Outfit, sans-serif;
  letter-spacing: .08em;
  pointer-events: none;
}

#screen-battle.battle-cockpit .target-hint {
  outline-color: rgb(85 230 244 / .95);
}

#screen-battle.battle-cockpit .target-hint::before {
  content: 'TARGET';
  color: #eaffff;
  background: #087f9b;
}

@keyframes legal-action-hint {
  0%, 100% { outline-color: rgb(255 221 105 / .55); box-shadow: 0 0 8px rgb(255 208 72 / .18); }
  50% { outline-color: rgb(255 244 177 / 1); box-shadow: 0 0 24px rgb(255 217 76 / .62); }
}

.card-character-art {
  overflow: hidden;
}

.card-character-idle .character-art {
  transform-origin: 50% 88%;
  animation: card-character-idle 8s ease-in-out var(--idle-delay, 0s) infinite;
}

@keyframes card-character-idle {
  0%, 68%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  73% { transform: translate3d(1px, -2px, 0) scale(1.012); }
  78% { transform: translate3d(-1px, 0, 0) scale(1); }
  84% { transform: translate3d(1px, -1px, 0) scale(1.008); }
}

.character-attack-flight {
  position: fixed;
  z-index: 880;
  overflow: hidden;
  pointer-events: none;
  border: 2px solid #ffe36e;
  border-radius: 12px;
  box-shadow: 0 0 30px rgb(255 216 83 / .88), 0 18px 30px rgb(0 0 0 / .5);
  transform-origin: 50% 86%;
}

.character-attack-flight::after {
  position: absolute;
  right: 4px;
  bottom: 4px;
  left: 4px;
  color: #fff7c7;
  content: attr(data-signature-move);
  font: 800 .55rem/1 Outfit, sans-serif;
  text-align: center;
  text-shadow: 0 1px 3px #000;
}

.character-attack-flight img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (prefers-reduced-motion: reduce) {
  .card-character-idle .character-art { animation: none; }
}

.card-flight {
  position: fixed;
  z-index: 900;
  display: grid;
  place-items: end center;
  overflow: hidden;
  pointer-events: none;
  border: 2px solid #ffe58c;
  border-radius: 10px;
  background: linear-gradient(150deg, #192d52, #071123);
  box-shadow: 0 0 24px rgb(255 215 91 / .72), 0 16px 34px rgb(0 0 0 / .65);
  transform-origin: center;
}

.card-flight img {
  width: 100%;
  height: 82%;
  object-fit: cover;
}

.card-flight span {
  position: absolute;
  right: 3px;
  bottom: 3px;
  left: 3px;
  overflow: hidden;
  color: #fff4bd;
  font: 800 .55rem/1 Outfit, sans-serif;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-flight.card-flight-draw {
  border: 2px solid #ffd35a;
  box-shadow: 0 0 28px rgba(255, 211, 90, 0.85), 0 16px 36px rgba(0, 0, 0, 0.7);
  background: radial-gradient(circle at 50% 35%, #1f3d6d, #071123);
  perspective: 800px;
}

.card-flight.card-flight-draw .flight-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
}

.card-flight.card-flight-draw .flight-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 8px;
}

.card-flight.card-flight-draw .flight-front img {
  width: 100%;
  height: 82%;
  object-fit: cover;
}

.card-flight.card-flight-draw .flight-front span {
  position: absolute;
  right: 3px;
  bottom: 3px;
  left: 3px;
  overflow: hidden;
  color: #fff4bd;
  font: 800 .55rem/1 Outfit, sans-serif;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-flight.card-flight-draw .flight-back {
  transform: rotateY(180deg);
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 170, 0, 0.25), transparent 70%),
    linear-gradient(145deg, #182848, #0a1122);
  border: 1.5px solid rgba(255, 196, 62, 0.75);
  box-shadow: inset 0 0 10px rgba(255, 211, 90, 0.3);
  color: #ffd35a;
}

.card-flight.card-flight-draw .flight-back-emblem {
  font-size: 1.8rem;
  line-height: 1;
  filter: drop-shadow(0 0 8px rgba(255, 196, 62, 0.85));
}

.card-flight.card-flight-draw .flight-back span {
  position: static;
  margin-top: 4px;
  font: 900 0.62rem/1 Outfit, sans-serif;
  letter-spacing: 0.1em;
  color: #ffd35a;
}

.combat-strike-fx {
  position: fixed;
  z-index: 450;
  height: 9px;
  pointer-events: none;
  transform-origin: 0 50%;
  transform: translateY(-50%) rotate(var(--strike-angle)) scaleX(0);
  border-radius: 999px;
  background: linear-gradient(90deg, rgb(255 238 150 / 0), #fff 35%, #ffb21c 78%, #ff4d3d);
  box-shadow: 0 0 10px #fff, 0 0 24px #ffb21c, 0 0 42px rgb(255 73 42 / .9);
  animation: combat-strike .42s cubic-bezier(.2,.8,.2,1) forwards;
}

.combat-impact-burst {
  position: fixed;
  z-index: 451;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  pointer-events: none;
  color: #fff4bf;
  font-size: 2rem;
  transform: translate(-50%, -50%) scale(.35);
  filter: drop-shadow(0 0 10px #ffb21c);
  animation: combat-burst .65s ease-out forwards;
}

.combat-impact-burst::before,
.combat-impact-burst::after {
  content: '';
  position: absolute;
  inset: 3px;
  border: 2px solid #ffe58c;
  clip-path: polygon(50% 0, 62% 35%, 100% 20%, 70% 50%, 100% 80%, 61% 65%, 50% 100%, 38% 65%, 0 80%, 30% 50%, 0 20%, 39% 35%);
}

.combat-impact-burst::after {
  inset: -8px;
  border-color: #ff6c3b;
  animation: combat-ring .65s ease-out forwards;
}

.card.combat-target-hit {
  z-index: 8;
  animation: combat-target-hit .58s ease-out;
  box-shadow: 0 0 0 4px #fff, 0 0 24px #ff6a3d, 0 0 45px rgb(255 178 28 / .8) !important;
}

.card.combat-attacker-lunge {
  z-index: 9;
  animation: combat-attacker-lunge .52s ease-in-out;
}

@keyframes combat-strike { to { transform: translateY(-50%) rotate(var(--strike-angle)) scaleX(1); } }
@keyframes combat-burst { 35% { transform: translate(-50%, -50%) scale(1.35); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1.8); } }
@keyframes combat-ring { 100% { opacity: 0; transform: scale(1.8); } }
@keyframes combat-target-hit { 25% { transform: translateX(8px) rotate(2deg); } 55% { transform: translateX(-8px) rotate(-2deg); } 100% { transform: translateX(0) rotate(0); } }
@keyframes combat-attacker-lunge { 45% { transform: translateY(-10px) scale(1.08); } 100% { transform: translateY(0) scale(1); } }

@media (prefers-reduced-motion: reduce) {
  .combat-strike-fx,
  .combat-impact-burst,
  .combat-impact-burst::after,
  .card.combat-target-hit,
  .card.combat-attacker-lunge { animation: none !important; }
}

/* Final portrait readability pass: preserve the game rules while giving the
   phone player one clear vertical reading order and a reserved deck lane. */
@media (max-width: 600px) and (orientation: portrait) {
  body:has(.app-container.battle-active) {
    width: 100%;
    min-height: 100dvh;
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .app-container.battle-active {
    width: 100%;
    min-height: 100dvh;
    height: auto;
    overflow: visible;
  }

  #screen-battle.battle-cockpit {
    --mobile-hand-side-lane: clamp(64px, 18vw, 78px);
    grid-template-areas:
      "turn"
      "opp-hud"
      "opp-ki"
      "opp-field"
      "player-field"
      "player-hud"
      "player-ki"
      "hand"
      "coach"
      "actions";
    grid-template-rows: auto auto 25px minmax(52px, 9dvh) minmax(68px, 11dvh) auto 27px minmax(150px, 23dvh) auto auto;
    min-height: calc(100dvh - 78px);
    height: auto;
    max-height: none;
    overflow: visible;
    gap: 5px;
    padding: 5px 6px max(10px, env(safe-area-inset-bottom));
  }

  #screen-battle.battle-cockpit .turn-banner {
    grid-area: turn;
    display: grid;
    grid-template-columns: auto minmax(0, auto) minmax(0, 1fr);
    align-items: center;
    min-height: 46px;
    margin: 0;
    padding: 7px 9px;
    gap: 7px;
  }

  #screen-battle.battle-cockpit .turn-banner-label {
    font-size: .62rem;
  }

  #screen-battle.battle-cockpit .turn-banner-text {
    font-size: clamp(.9rem, 4.2vw, 1.12rem);
    white-space: nowrap;
  }

  #screen-battle.battle-cockpit .turn-banner-detail {
    max-height: 2.5em;
    font-size: .7rem;
    line-height: 1.2;
    text-overflow: clip;
    white-space: normal;
  }

  #screen-battle.battle-cockpit .battle-opponent-hud,
  #screen-battle.battle-cockpit .battle-player-hud {
    min-height: 40px;
    padding: 4px 6px;
  }

  #screen-battle.battle-cockpit .battle-opponent-field,
  #screen-battle.battle-cockpit .battle-player-field {
    min-height: 0;
    height: 100%;
  }

  #screen-battle.battle-cockpit .battlefield-row {
    min-height: 0;
    padding: 4px 3px;
    overflow-x: auto;
    touch-action: pan-x;
  }

  #screen-battle.battle-cockpit .battlefield-row .card {
    width: clamp(72px, 21vw, 92px);
    max-height: 112px;
  }

  #screen-battle.battle-cockpit .battle-hand-row.hand-side-lane {
    position: relative;
    display: flex;
    align-items: stretch;
    width: 100%;
    min-width: 0;
    min-height: 0;
    padding-right: 0;
    box-sizing: border-box;
  }

  #screen-battle.battle-cockpit .battle-hand-row,
  #screen-battle.battle-cockpit .battle-hand-dock {
    min-width: 0;
    box-sizing: border-box;
  }

  #screen-battle.battle-cockpit .battle-hand-dock {
    flex: 1 1 auto;
    width: 100%;
    height: clamp(150px, 23dvh, 182px);
    min-height: 150px;
    padding: 6px 3px 8px;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    touch-action: pan-x;
    scroll-snap-type: x proximity;
  }

  /* Keep the hand surface edge-to-edge while reserving a non-card tail for
     the floating deck. The final card can scroll into view without sitting
     underneath the deck image. */
  #screen-battle.battle-cockpit .battle-hand-dock::after {
    content: '';
    display: block;
    flex: 0 0 var(--mobile-hand-side-lane);
    width: var(--mobile-hand-side-lane);
    min-width: var(--mobile-hand-side-lane);
    height: 1px;
    pointer-events: none;
  }

  #screen-battle.battle-cockpit .battle-hand-dock::before {
    min-width: 28px;
    font-size: .54rem;
  }

  #screen-battle.battle-cockpit .battle-hand-dock .card {
    width: clamp(96px, 27vw, 108px);
    height: clamp(138px, 20dvh, 152px);
    flex: 0 0 auto;
    scroll-snap-align: start;
  }

  #screen-battle.battle-cockpit .battle-hand-dock .card-art {
    height: clamp(52px, 8dvh, 68px);
  }

  #screen-battle.battle-cockpit .battle-hand-dock .card-name {
    min-height: 2.2em;
    font-size: .72rem;
    line-height: 1.08;
    white-space: normal;
  }

  #screen-battle.battle-cockpit .battle-hand-dock .card-stats {
    font-size: .7rem;
  }

  #screen-battle.battle-cockpit .battle-coach {
    display: block;
    min-height: 34px;
    padding: 5px 7px;
    font-size: .72rem;
    line-height: 1.2;
  }

  #screen-battle.battle-cockpit .battle-coach .coach-tip {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  #screen-battle.battle-cockpit .battle-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 6px;
    padding-bottom: max(2px, env(safe-area-inset-bottom));
  }

  #screen-battle.battle-cockpit .battle-actions .action-btn {
    min-width: 0;
    min-height: 46px;
    padding: 8px 6px;
    font-size: .72rem;
    white-space: normal;
  }

  #screen-battle.battle-cockpit .battle-actions .end-btn:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 360px) and (orientation: portrait) {
  #screen-battle.battle-cockpit {
    grid-template-rows: auto auto 23px minmax(48px, 8dvh) minmax(62px, 10dvh) auto 25px minmax(150px, 23dvh) auto auto;
  }

  #screen-battle.battle-cockpit .battle-hand-dock {
    height: 154px;
    min-height: 154px;
  }

  #screen-battle.battle-cockpit .battle-hand-dock .card {
    width: 96px;
    height: 138px;
  }

  #screen-battle.battle-cockpit .battle-hand-dock .card-name,
  #screen-battle.battle-cockpit .battle-hand-dock .card-stats {
    font-size: .7rem;
  }

  #screen-battle.battle-cockpit .turn-banner {
    grid-template-columns: auto minmax(0, 1fr);
    row-gap: 2px;
  }

  #screen-battle.battle-cockpit .turn-banner-detail {
    grid-column: 1 / -1;
    text-align: left;
  }
}

/* Settings is available from both the menu and battle header. */
.settings-card {
  width: min(100%, 520px);
  max-height: min(86vh, 620px);
  overflow-y: auto;
  padding: 22px;
  color: #eef4ff;
  background: linear-gradient(145deg, #182039, #0e1425);
  border: 2px solid #3e4c73;
  border-radius: 16px;
  box-shadow: 0 22px 60px rgb(0 0 0 / .5);
}

.settings-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.settings-header h2,
.settings-item h3 {
  margin: 0;
  color: #ffe276;
}

.settings-item {
  display: grid;
  gap: 14px;
  padding: 16px;
  background: rgb(5 10 23 / .58);
  border: 1px solid rgb(98 121 168 / .55);
  border-radius: 12px;
}

.settings-item p,
.settings-status {
  margin: 7px 0 0;
  color: #cbd5e1;
  font-size: .86rem;
  line-height: 1.45;
}

.settings-item .menu-btn {
  width: 100%;
  min-height: 46px;
}

.settings-status {
  min-height: 2.8em;
  margin: 14px 2px 0;
  color: #9de9f5;
}

.selected-blocker {
  outline: 3px solid #ffe276 !important;
  outline-offset: 4px;
  box-shadow: 0 0 22px rgb(255 226 118 / .72) !important;
  transform: translateY(-5px) scale(1.035);
}

.targetable-block {
  cursor: crosshair;
}

@media (max-width: 600px) {
  .settings-card {
    padding: 16px;
  }

  .settings-item {
    padding: 13px;
  }
}

/* Mobile battle usability + arena atmosphere pass. The hand is a real horizontal
   scroll surface; the deck is a separate control and never consumes hand width. */
#screen-battle.battle-cockpit .battlefield-row {
  position: relative;
  overflow-x: auto;
  background:
    radial-gradient(ellipse at 50% 110%, rgb(46 218 172 / .2), transparent 58%),
    linear-gradient(180deg, rgb(8 20 43 / .96), rgb(6 14 31 / .98));
  box-shadow: inset 0 10px 26px rgb(0 0 0 / .22), inset 0 -1px 0 rgb(120 215 255 / .18);
}

#screen-battle.battle-cockpit .battlefield-row::before {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  color: rgb(152 235 213 / .22);
  font: 900 clamp(.7rem, 2.2vw, 1.1rem)/1 Outfit, sans-serif;
  letter-spacing: .24em;
  text-align: center;
  text-shadow: 0 0 18px rgb(54 230 186 / .24);
  content: 'CLASH ZONE';
  background:
    linear-gradient(115deg, transparent 0 48%, rgb(105 228 194 / .08) 49% 51%, transparent 52%),
    repeating-linear-gradient(90deg, transparent 0 54px, rgb(133 226 204 / .055) 55px 56px),
    radial-gradient(circle at 18% 28%, rgb(255 243 163 / .22) 0 1px, transparent 2px),
    radial-gradient(circle at 74% 24%, rgb(255 243 163 / .16) 0 1px, transparent 2px);
}

#screen-battle.battle-cockpit .battle-opponent-field::before { content: 'OPPONENT FRONTIER'; color: rgb(255 166 184 / .22); }
#screen-battle.battle-cockpit .battle-player-field::before { content: 'NAMEK CLASH ZONE'; color: rgb(108 238 198 / .26); }
#screen-battle.battle-cockpit .battlefield-row > * { position: relative; z-index: 1; }
#screen-battle.battle-cockpit .battle-player-field { border-color: rgb(95 234 204 / .42); box-shadow: inset 0 0 35px rgb(25 177 137 / .12), 0 0 18px rgb(29 199 168 / .1); }
#screen-battle.battle-cockpit .battle-opponent-field { border-color: rgb(255 126 159 / .35); }

.combat-callout {
  position: fixed;
  z-index: 452;
  pointer-events: none;
  color: #fff8cf;
  font: 900 clamp(1.05rem, 5vw, 2.1rem)/1 Bangers, Outfit, sans-serif;
  letter-spacing: .08em;
  text-shadow: 0 3px 0 #5b1d0a, 0 0 18px #ffbf32;
  transform: translate(-50%, -50%) scale(.55) rotate(-5deg);
  animation: combat-callout .72s cubic-bezier(.15,.8,.2,1) forwards;
}

.combat-callout.is-block {
  color: #eaffff;
  text-shadow: 0 3px 0 #063d66, 0 0 18px #50eaff;
}

.card.combat-block-hit {
  animation: combat-block-hit .58s ease-out;
  box-shadow: 0 0 0 4px #dffcff, 0 0 24px #32d6ff, 0 0 45px rgb(54 220 255 / .8) !important;
}

@keyframes combat-callout {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.55) rotate(-5deg); }
  22% { opacity: 1; transform: translate(-50%, -50%) scale(1.18) rotate(2deg); }
  100% { opacity: 0; transform: translate(-50%, -82%) scale(.94) rotate(0); }
}

@keyframes combat-block-hit {
  20% { transform: translateX(-7px) rotate(-2deg); }
  45% { transform: translateX(7px) rotate(2deg); }
  72% { transform: translateX(-3px) rotate(-1deg); }
  100% { transform: translateX(0) rotate(0); }
}

@media (max-width: 600px) and (orientation: portrait) {
  #screen-battle.battle-cockpit {
    --mobile-hand-side-lane: 0px;
    grid-template-rows: auto auto 25px minmax(96px, 13dvh) minmax(112px, 16dvh) auto 27px minmax(132px, 20dvh) auto auto;
  }

  #screen-battle.battle-cockpit .battle-hand-row {
    position: relative;
    z-index: 2;
    width: 100%;
    min-width: 0;
    overflow: visible;
    touch-action: pan-x;
  }

  #screen-battle.battle-cockpit .battle-hand-dock {
    width: 100%;
    min-width: 0;
    height: clamp(132px, 20dvh, 154px);
    min-height: 132px;
    padding: 7px 6px 10px;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    touch-action: pan-x;
    scroll-snap-type: none;
    scroll-padding-inline: 6px;
    scrollbar-width: auto;
  }

  #screen-battle.battle-cockpit .battle-hand-dock::before,
  #screen-battle.battle-cockpit .battle-hand-dock::after {
    display: none;
    content: none;
  }

  #screen-battle.battle-cockpit .battle-hand-dock .card {
    width: clamp(54px, 17.2vw, 80px);
    height: clamp(122px, 18.5dvh, 140px);
    flex: 0 0 clamp(54px, 17.2vw, 80px);
    scroll-snap-align: none;
  }

  #screen-battle.battle-cockpit .hand-card {
    touch-action: pan-x;
  }

  #screen-battle.battle-cockpit .battle-opponent-field,
  #screen-battle.battle-cockpit .battle-player-field {
    min-height: 0;
    height: 100%;
  }

  #screen-battle.battle-cockpit .battlefield-row .card {
    width: clamp(78px, 21vw, 94px);
    height: clamp(92px, 14dvh, 124px);
    max-height: none;
  }

  #screen-battle.battle-cockpit .player-deck-pile {
    width: 52px;
    height: 74px;
    z-index: 20;
  }
}

@media (prefers-reduced-motion: reduce) {
  .combat-callout,
  .card.combat-block-hit { animation: none !important; }
}

@media (max-width: 600px) and (orientation: portrait) {
  #screen-battle.battle-cockpit {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "turn"
      "opp-hud"
      "opp-ki"
      "opp-field"
      "player-field"
      "player-hud"
      "player-ki"
      "coach"
      "actions"
      "hand";
    grid-template-rows: auto auto 25px minmax(96px, 13dvh) minmax(112px, 16dvh) auto 27px minmax(40px, 44px) auto minmax(126px, 17dvh);
  }

  #screen-battle.battle-cockpit .battle-coach {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    max-height: 44px;
    padding: 4px 7px;
    overflow: hidden;
  }

  #screen-battle.battle-cockpit .coach-icon {
    flex: 0 0 auto;
    font-size: 1.1rem;
    line-height: 1;
  }

  #screen-battle.battle-cockpit .coach-tip {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    max-height: 2.5em;
    overflow-y: auto;
    line-height: 1.2;
    white-space: normal;
    text-overflow: clip;
  }

  #screen-battle.battle-cockpit .battle-actions {
    min-height: 0;
    align-items: stretch;
    padding: 2px 0;
  }

  #screen-battle.battle-cockpit .battle-actions .action-btn {
    min-height: 44px;
  }

  #screen-battle.battle-cockpit .battle-hand-dock {
    height: clamp(126px, 17dvh, 148px);
    min-height: 126px;
  }

  #screen-battle.battle-cockpit .battle-hand-dock .card {
    height: clamp(108px, 15.5dvh, 128px);
  }
}
