/* Explicit grid areas prevent status messages from creating implicit battle rows. */
#screenGame.active { overflow-y: auto !important; overflow-x: hidden !important; }
#screenGame { --battle-width: 1240px; }
#screenGame.active .game-wrapper,
#screenGame.active .game-wrapper.with-mechanics {
  grid-template-columns: minmax(0, 1fr);
  max-width: min(var(--battle-width), 100vw) !important;
  grid-template-areas: 'header' 'enemy-hero' 'enemy-board' 'divider' 'player-board' 'player-hero' 'hand';
  grid-template-rows: auto auto minmax(96px, 1fr) 18px minmax(96px, 1fr) auto minmax(110px, 1.1fr);
  min-height: 720px;
  max-height: none !important;
  height: max(100%, 720px) !important;
  gap: 4px !important;
  padding: 6px 10px !important;
  overflow: hidden !important;
}
#screenGame .game-header { grid-area: header; min-width: 0; }
#screenGame .enemy-hero-zone { grid-area: enemy-hero; }
#screenGame .enemy-board { grid-area: enemy-board; }
#screenGame .board-divider { grid-area: divider; }
#screenGame .player-board { grid-area: player-board; }
#screenGame .player-hero-zone { grid-area: player-hero; }
#screenGame .hand-zone { grid-area: hand; }
#screenGame.active .game-wrapper.with-tutorial-info {
  grid-template-areas: 'header' 'info' 'enemy-hero' 'enemy-board' 'divider' 'player-board' 'player-hero' 'hand';
  grid-template-rows: auto 68px auto minmax(96px, 1fr) 18px minmax(96px, 1fr) auto minmax(110px, 1.1fr);
}
#screenGame .battle-info {
  grid-area: info; min-width: 0; min-height: 0;
  overflow: auto; scrollbar-width: thin;
  border: 1px solid #c9a66b40; border-radius: 10px;
  padding: 5px 10px; background: #160f0ce8;
  display: none !important; flex-direction: column; justify-content: flex-start; gap: 3px;
}
#screenGame .with-tutorial-info .battle-info { display: flex !important; }
#screenGame .battle-info .battle-hint,
#screenGame .battle-info .target-hint,
#screenGame .battle-info .tutorial-coach,
#screenGame .battle-info .turn-banner,
#screenGame .battle-info .toast-layer {
  position: static !important; inset: auto !important;
  width: 100% !important; max-width: none !important;
  transform: none !important; margin: 0 !important;
  padding: 0 !important; border: 0 !important; border-radius: 0;
  background: none !important; box-shadow: none !important;
  animation: none !important; font-size: .76rem; line-height: 1.35;
  flex-shrink: 0; white-space: normal; text-align: left;
}
#screenGame .battle-info .turn-banner { display: none !important; }
#screenGame .battle-info .hidden { display: none !important; }
#screenGame .battle-info .tutorial-coach-bubble {
  background: none !important; border: 0 !important; padding: 0 !important;
  box-shadow: none !important; border-radius: 0; color: var(--cream) !important;
}
#screenGame .battle-info .tutorial-coach-icon { display: none; }
#screenGame .battle-info .tutorial-coach-body { text-align: left; }
#screenGame .battle-info #tutorialCoachText { font-size: .78rem !important; line-height: 1.3 !important; color: var(--cream) !important; }
#screenGame .battle-info .tutorial-step-label { display: inline; margin: 0 !important; font-size: .65rem !important; color: #edc581 !important; }
#screenGame .battle-info .mechanics-status { padding: 0; border: 0; background: none; font-size: .68rem; text-align: left; }
#screenGame .battle-info .card-details { font-size: .76rem; line-height: 1.35; color: #ffe3ac; flex-shrink: 0; }
#screenGame .battle-info:has(.card-details:not(.hidden)) .battle-hint { display: none; }
#screenGame .battle-info:has(.target-hint:not(.hidden)) .battle-hint { display: none; }
#screenGame .battle-info .game-toast { padding: 0; background: none; border: 0; box-shadow: none; text-align: left; font-size: .74rem; }
#screenGame .hero-zone { min-width: 0; gap: 8px; flex-wrap: nowrap; padding: 0 4px; }
#screenGame .hero-portrait {
  display: grid; grid-template-columns: 48px minmax(32px, auto);
  grid-template-rows: auto auto; column-gap: 6px; row-gap: 0;
  min-width: 112px; max-width: 190px; padding: 5px 8px;
}
#screenGame .hero-avatar { grid-column: 1; grid-row: 1 / 3; }
#screenGame .hero-ring { display: none; }
#screenGame .hero-avatar-image { width: 48px; height: 48px; }
#screenGame .hero-name { grid-column: 2; grid-row: 1; font-size: .65rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 110px; }
#screenGame .hero-hp { grid-column: 2; grid-row: 2; justify-self: center; width: 30px; height: 30px; margin-top: 0; font-size: .9rem; }
#screenGame .deck-stack { width: 34px; height: 44px; }
#screenGame .deck-label { font-size: .58rem; }
#screenGame .mana-label { display: none; }
#screenGame .mana-bar { padding: 5px 7px; gap: 5px; }
#screenGame .mana-crystals { max-width: 100px; gap: 2px; }
#screenGame .hero-power-wrap { flex-shrink: 0; flex-direction: row; gap: 3px; }
#screenGame .hero-power-btn { width: 48px; height: 48px; padding: 3px; min-width: 0; }
#screenGame .hero-power-btn .hp-label { font-size: .65rem; }
#screenGame .end-turn-btn { padding: 8px 10px !important; font-size: .72rem !important; }
#screenGame.active .board,
#screenGame.active .hand-zone {
  min-width: 0; min-height: 0 !important; max-height: none !important;
  padding: 12px !important; overflow-x: auto !important; overflow-y: hidden !important;
  overscroll-behavior-x: contain; scrollbar-width: thin;
}
#screenGame .board { flex-wrap: nowrap; gap: 14px; justify-content: safe center; align-items: center; }
#screenGame .hand { flex-wrap: nowrap; align-items: center; justify-content: safe center; gap: 8px; width: 100%; height: 100%; min-height: 0; max-width: none; padding: 0; }
#screenGame .board .card,
#screenGame .hand .card {
  flex: 0 0 var(--card-w); margin: 0 !important;
  transform: none !important; animation: none !important;
}
#screenGame .board .card:hover, #screenGame .board .card.selected,
#screenGame .hand .card:hover, #screenGame .hand .card.selected,
#screenGame .hand .card.can-play, #screenGame .hand .card.mana-ready {
  transform: none !important; animation: none !important;
}
#screenGame .card.card-death { opacity: 0; transition: opacity 150ms ease-out; pointer-events: none; }
#screenGame .board .card .card-cost, #screenGame .hand .card .card-cost,
#screenGame .board .card .stat, #screenGame .hand .card .stat { min-width: 18px !important; font-size: clamp(10px, calc(var(--card-w) * .14), 20px) !important; }
.battle-attack-ghost.card { animation: none !important; transition: none !important; will-change: transform; transform-origin: center; }
.battle-attack-target { outline: 2px solid #edba6a !important; outline-offset: 2px; }
#screenGame .battle-impact { animation: battleImpact 160ms ease-out !important; }
@keyframes battleImpact { 45% { filter: brightness(1.4); } }
.combat-claws { position: fixed; width: 62px; height: 62px; z-index: 2147483001; pointer-events: none; transform: translate(-50%, -50%) rotate(-24deg); }
.combat-claws i { position: absolute; top: 0; width: 3px; height: 58px; border-radius: 50%; background: #ffe5ac; box-shadow: 0 0 5px #eaa248; animation: clawStrike 220ms ease-out both; }
.combat-claws i:nth-child(1) { left: 17px; }
.combat-claws i:nth-child(2) { left: 29px; top: -4px; }
.combat-claws i:nth-child(3) { left: 41px; }
@keyframes clawStrike { from { opacity: 0; transform: scaleY(.1); } 35% { opacity: 1; transform: scaleY(1); } to { opacity: 0; transform: scaleY(1.15); } }
@media (max-width: 900px) {
  #screenGame.active .game-wrapper { padding-right: 10px !important; }
}
@media (max-width: 640px) {
  #screenGame.active .game-wrapper { min-height: 820px; height: max(100%, 820px) !important; }
  #screenGame .hero-zone { gap: 4px; flex-wrap: wrap; }
  #screenGame .hero-portrait { min-width: 98px; padding: 4px; }
  #screenGame .hero-name { max-width: 75px; }
  #screenGame .player-mana { margin-left: auto; }
  #screenGame .end-turn-btn { margin-left: auto; }
  #screenGame .game-header { gap: 5px; }
  #screenGame .logo { font-size: .9rem; }
  #screenGame .turn-info { font-size: .65rem; padding: 4px 6px; gap: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  #screenGame .battle-impact, .combat-claws i { animation: none !important; }
}

/* One brief notice at the divider; it never catches card clicks. */
#screenGame #turnBanner {
  display: flex; position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%); z-index: 110; pointer-events: none;
  max-width: calc(100% - 24px); padding: 14px 24px;
  border: 2px solid #edc47e !important; border-radius: 16px;
  background: linear-gradient(135deg, #51341af5, #23150ef5) !important;
  box-shadow: 0 8px 25px #0009, 0 0 24px #e7b56755 !important;
  gap: 12px; text-align: center;
}
#screenGame #turnBanner.hidden { display: none !important; }
#screenGame #turnBanner.pulse { animation: turnNoticeIn 200ms ease-out both; }
#screenGame #turnBanner .turn-banner-text {
  font-size: clamp(18px, 2.8vw, 28px); letter-spacing: .03em; overflow-wrap: anywhere;
}
@keyframes turnNoticeIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(.94); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
#screenGame #playerHero.hero-turn-active:not(.targetable):not(.battle-attack-target),
#screenGame #enemyHero.hero-turn-active:not(.targetable):not(.battle-attack-target) {
  border-color: #ffe2a0 !important;
  box-shadow: 0 0 0 2px #e6b965a6, 0 0 22px #efbc6080, inset 0 0 12px #d5a45c33 !important;
}
#screenGame .hero-turn-active .hero-avatar-image { border-color: #ffe3a4; filter: brightness(1.12); }
@media (prefers-reduced-motion: reduce) { #screenGame #turnBanner.pulse { animation: none; } }

/* The log lives outside the board. Opening it never changes board geometry. */
#screenGame .game-header { padding-right: 4px; }
#screenGame .battle-log {
  position: relative; margin: 12px auto; z-index: 45;
  width: 140px; border: 1px solid #b88e504d; border-radius: 10px;
  background: #21160ff2; color: var(--cream); overflow: hidden;
}
#screenGame .battle-log summary {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; cursor: var(--cursor-action, pointer); user-select: none;
  list-style: none; font-size: .74rem; font-weight: 800;
}
#screenGame .battle-log summary::-webkit-details-marker { display: none; }
#screenGame .battle-log summary:focus-visible { outline: 2px solid #ffd486; outline-offset: -3px; }
#screenGame .battle-log-arrow { font-size: 1rem; line-height: 1; }
#screenGame .battle-log[open] { width: 288px; box-shadow: 0 8px 20px #0008; }
#screenGame .battle-log[open] .battle-log-arrow { transform: rotate(180deg); }
#screenGame .battle-log .game-log, #screenGame .battle-log .game-log:hover {
  display: block !important; position: static !important; inset: auto !important;
  width: 100% !important; max-width: none !important; height: auto !important;
  max-height: min(340px, 65dvh) !important; margin: 0;
  border: 0; border-top: 1px solid #b88e5033; border-radius: 0;
  padding: 8px 10px; font-size: .72rem; line-height: 1.45;
  overflow-y: auto; overscroll-behavior: contain;
}
#screenGame .battle-log:not([open]) .game-log { display: none !important; }
@media (min-width: 1600px) {
  #screenGame .battle-log {
    position: fixed; top: 10px; left: calc(50% + var(--battle-width) / 2 + 12px);
    margin: 0;
  }
  #screenGame .battle-log[open] { width: min(288px, calc((100vw - var(--battle-width)) / 2 - 24px)); }
}
