﻿:root {
  color-scheme: dark;
  --ink: #f6ecd8;
  --muted: rgba(246, 236, 216, .68);
  --gold: #d6a94d;
  --red: #b81819;
  --blue: #2d4ea5;
  --panel: rgba(13, 18, 18, .72);
  --card-w: clamp(58px, 7.55vw, 152px);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: #101312;
  color: var(--ink);
  font-family: "Microsoft YaHei", "Noto Sans SC", "Segoe UI", sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  cursor: pointer;
}

.battle-page {
  width: min(100vw, 1920px);
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 1fr auto;
  gap: 12px;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
}

.battle-stage {
  position: relative;
  width: min(100%, calc(100vh * 16 / 9 - 20px));
  aspect-ratio: 16 / 9;
  margin: 0 auto;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(4, 9, 10, .72), rgba(8, 12, 13, .08) 30%, rgba(8, 12, 13, .08) 70%, rgba(4, 9, 10, .58)),
    url("./assets/optimized/battle-bg.webp") center / cover no-repeat;
  box-shadow: 0 20px 70px rgba(0, 0, 0, .42);
}

.battle-stage::before {
  content: "";
  position: absolute;
  inset: 17.2% 8.4% 24.2% 24.7%;
  border: 2px solid rgba(206, 194, 134, .38);
  background: rgba(214, 221, 213, .2);
  box-shadow: inset 0 0 34px rgba(255, 255, 255, .08), 0 0 22px rgba(0, 0, 0, .22);
  pointer-events: none;
}

.player-strip {
  position: absolute;
  left: 0;
  width: 23.5%;
  min-height: 6.8%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 7.5% 12%;
  align-items: center;
  gap: .55vw;
  padding-left: 4.6%;
  color: #fff7e2;
  text-shadow: 0 2px 4px rgba(0, 0, 0, .72);
  z-index: 20;
}

.opponent-strip {
  top: 28.2%;
  background: linear-gradient(90deg, rgba(141, 25, 17, .86), rgba(141, 25, 17, .42), transparent);
}

.current-strip {
  bottom: 18.2%;
  background: linear-gradient(90deg, rgba(43, 67, 169, .82), rgba(43, 67, 169, .38), transparent);
}

.player-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: clamp(12px, 1.55vw, 30px);
  font-weight: 900;
  text-align: right;
}

.avatar {
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid rgba(225, 191, 99, .8);
  background-size: cover;
  background-position: top center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .5);
}

.life-drop {
  width: 100%;
  aspect-ratio: .72 / 1;
  display: grid;
  place-items: center;
  align-self: end;
  position: relative;
  color: #fff2de;
  font-size: clamp(12px, 1.45vw, 28px);
  font-weight: 1000;
  filter: drop-shadow(0 5px 8px rgba(0, 0, 0, .5));
}

.life-vial {
  position: absolute;
  inset: -2% 0;
  width: 100%;
  height: 104%;
}

.life-vial-glass {
  fill: rgba(70, 8, 10, .34);
  stroke: rgba(255, 214, 150, .34);
  stroke-width: 2.5;
}

.life-liquid {
  transition: y 520ms cubic-bezier(.2, .8, .2, 1), height 520ms cubic-bezier(.2, .8, .2, 1);
}

.life-shine {
  fill: none;
  stroke: rgba(255, 235, 210, .38);
  stroke-width: 5;
  stroke-linecap: round;
}

.life-vial-rim {
  fill: none;
  stroke: rgba(255, 235, 186, .68);
  stroke-width: 3;
}

.life-drop b {
  position: relative;
  z-index: 2;
  color: #fff2de;
  text-shadow: 0 2px 4px #390305, 0 0 8px rgba(0, 0, 0, .56);
}

.life-drop.rolling {
  color: #fff;
  text-shadow: 0 0 10px rgba(255, 228, 128, .9), 0 2px 3px rgba(0, 0, 0, .9);
}

.avatar.hit,
.life-drop.hit {
  animation: hit-shake 480ms ease;
}

.card-row,
.public-grid {
  position: absolute;
  display: grid;
  z-index: 10;
}

.opponent-hand {
  left: 25.9%;
  right: 8.4%;
  top: -10.8%;
  grid-template-columns: repeat(8, minmax(0, var(--card-w)));
  justify-content: space-between;
}

.current-hand {
  left: 25.6%;
  right: 8.8%;
  bottom: 1.4%;
  grid-template-columns: repeat(8, minmax(0, var(--card-w)));
  justify-content: space-between;
}

.table-zone {
  position: absolute;
  inset: 22% 8.4% 24.2% 24.7%;
  z-index: 8;
}

.public-grid {
  inset: 12% 39.5% 31.2% 6.7%;
  grid-template-columns: repeat(4, minmax(0, var(--card-w)));
  grid-template-rows: repeat(2, auto);
  gap: 4.1% 4.4%;
  justify-content: start;
  align-content: center;
}

.deck-area {
  position: absolute;
  right: 9%;
  top: 25%;
  width: 19%;
  height: 45%;
  display: grid;
  place-items: center;
}

.deck-stack {
  position: relative;
  width: 53%;
  aspect-ratio: 2 / 3;
}

.deck-stack span,
.deck-stack strong {
  position: absolute;
  inset: 0;
}

.deck-stack span {
  border-radius: 5%;
  background: url("./assets/optimized/card-back.webp") center / cover no-repeat;
  box-shadow: 0 8px 16px rgba(0, 0, 0, .42);
}

.deck-stack span:nth-child(1) { transform: translate(-20%, -12%) rotate(-7deg); }
.deck-stack span:nth-child(2) { transform: translate(4%, -3%) rotate(2deg); }
.deck-stack span:nth-child(3) { transform: translate(18%, 9%) rotate(5deg); }

.battle-stage[data-phase="shuffle"] .deck-stack {
  animation: shuffle-stack 760ms ease-in-out;
}

.battle-stage[data-phase="lift"] .deck-stack span:nth-child(1) {
  animation: lift-card-a 720ms ease-in-out;
}

.battle-stage[data-phase="lift"] .deck-stack span:nth-child(2) {
  animation: lift-card-b 720ms ease-in-out;
}

.deck-stack strong {
  display: grid;
  place-items: center;
  z-index: 3;
  color: white;
  font-size: clamp(18px, 3vw, 58px);
  line-height: .9;
  text-shadow: 0 3px 7px rgba(0, 0, 0, .9);
}

.stage-status {
  display: none;
}

.turn-timer {
  position: absolute;
  left: 25.4%;
  right: 8.5%;
  top: auto;
  bottom: 26.4%;
  height: clamp(18px, 2.05vw, 34px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(74px, 8.2vw, 142px);
  align-items: center;
  gap: clamp(6px, .62vw, 10px);
  color: #fff4d6;
  z-index: 34;
  pointer-events: none;
  --timer-progress: 100%;
}

.turn-timer[hidden] {
  display: none;
}

.turn-timer-track {
  position: relative;
  height: clamp(8px, .92vw, 15px);
  overflow: hidden;
  border: 2px solid rgba(160, 122, 45, .82);
  border-radius: 999px;
  background: rgba(18, 15, 8, .86);
  box-shadow:
    0 5px 12px rgba(0, 0, 0, .42),
    inset 0 0 0 1px rgba(255, 236, 166, .18),
    inset 0 0 10px rgba(0, 0, 0, .72);
}

.turn-timer-track::before {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, .22), transparent 46%);
  z-index: 2;
}

.turn-timer-fill {
  position: absolute;
  left: 0;
  top: 2px;
  bottom: 2px;
  width: var(--timer-progress);
  border-radius: inherit;
  background:
    linear-gradient(90deg, #22791c, #3cad28 42%, #74d63a),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .18) 0 12px, transparent 12px 24px);
  box-shadow: 0 0 9px rgba(83, 210, 54, .58);
  transition: width 950ms linear, background 180ms ease, box-shadow 180ms ease;
}

.turn-timer-badge {
  height: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(2ch, 1fr);
  align-items: center;
  justify-content: center;
  gap: clamp(6px, .62vw, 10px);
  padding: 0 clamp(10px, 1.2vw, 18px);
  border: 2px solid rgba(214, 169, 77, .78);
  border-radius: 10px;
  background: rgba(16, 12, 8, .88);
  box-shadow: 0 7px 16px rgba(0, 0, 0, .45), inset 0 0 12px rgba(255, 221, 139, .08);
}

.turn-timer-icon {
  font-size: clamp(16px, 1.8vw, 30px);
  line-height: 1;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .75));
}

.turn-timer-number {
  min-width: 2ch;
  color: #fff4d6;
  font-size: clamp(22px, 2.5vw, 44px);
  font-weight: 1000;
  line-height: .9;
  text-align: center;
  text-shadow: 0 2px 4px black;
}

.turn-timer.current-turn {
  --timer-side-color: rgba(74, 141, 255, .78);
}

.turn-timer.current-turn .turn-timer-badge {
  border-color: rgba(74, 141, 255, .78);
}

.turn-timer.opponent-turn .turn-timer-badge {
  border-color: rgba(214, 169, 77, .82);
}

.turn-timer.danger .turn-timer-fill {
  background: linear-gradient(90deg, #a91813, #dc391f 48%, #ff9b38);
  box-shadow: 0 0 12px rgba(255, 74, 42, .72);
}

.turn-timer.danger .turn-timer-badge {
  background: rgba(64, 10, 8, .88);
  animation: timer-warning 900ms ease-in-out infinite;
}

.mobile-coach {
  display: none;
}

.side-buttons {
  position: absolute;
  right: max(6px, env(safe-area-inset-right));
  top: 37%;
  z-index: 80;
  display: grid;
  gap: 8px;
}

.side-tool-btn {
  min-width: 44px;
  min-height: 74px;
  padding: 8px 6px;
  border: 1px solid rgba(235, 214, 151, .66);
  border-radius: 8px 0 0 8px;
  background: rgba(16, 12, 8, .86);
  color: #fff4d6;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .42), inset 0 0 12px rgba(255, 221, 139, .08);
  font-size: clamp(13px, 1.1vw, 18px);
  font-weight: 900;
  line-height: 1.15;
  writing-mode: vertical-rl;
  letter-spacing: 0;
}

.play-card {
  position: relative;
  width: var(--card-w);
  aspect-ratio: 2 / 3;
  --drag-x: 0px;
  --drag-y: 0px;
  --selected-lift: clamp(22px, 3.2vw, 42px);
  padding: 0;
  border: 0;
  background: none;
  overflow: visible;
  touch-action: none;
  transform: translate3d(var(--drag-x), var(--drag-y), 0);
  transition: transform 160ms ease, opacity 160ms ease;
}

.play-card .card-face {
  position: absolute;
  inset: 0;
  overflow: visible;
  background: #171513;
  border-radius: 5%;
  box-shadow: 0 8px 15px rgba(0, 0, 0, .5);
}

.card-art,
.card-back-img,
.card-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 5%;
}

.card-art {
  z-index: 1;
}

.card-frame {
  z-index: 4;
  pointer-events: none;
}

.card-back-img {
  z-index: 2;
}

.card-faction-icons {
  position: absolute;
  left: -6.5%;
  top: -1.5%;
  width: 43%;
  height: 39%;
  display: grid;
  grid-template-rows: repeat(2, 1fr);
  gap: 4px;
  justify-items: center;
  align-items: center;
  z-index: 30;
  pointer-events: none;
}

.card-faction-icon {
  width: 100%;
  max-width: 70px;
  max-height: 70px;
  aspect-ratio: 1;
  object-fit: contain;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .75));
}

.card-faction-icon:nth-child(2) {
  transform: translateY(-18%);
}

.score {
  position: absolute;
  right: 5.2%;
  top: 1.8%;
  width: 20%;
  height: 15%;
  display: grid;
  place-items: center;
  z-index: 31;
  color: #fff7df;
  font-size: clamp(18px, 1.95vw, 31px);
  font-weight: 1100;
  text-shadow:
    1.6px 0 0 #b56e0b,
    -1.6px 0 0 #b56e0b,
    0 1.6px 0 #b56e0b,
    0 -1.6px 0 #b56e0b,
    1.2px 1.2px 0 #7c4305,
    -1.2px 1.2px 0 #7c4305,
    1.2px -1.2px 0 #7c4305,
    -1.2px -1.2px 0 #7c4305,
    0 2px 4px rgba(0, 0, 0, .85);
}

.play-card.selected {
  transform: translate3d(var(--drag-x), calc(var(--drag-y) - var(--selected-lift)), 0);
  z-index: 42;
}

.current-hand.replace-mode .play-card {
  --fan-rot: 0deg;
  --fan-y: 0px;
  --replace-lift: 0px;
  transform: translate3d(var(--drag-x), calc(var(--drag-y) + var(--fan-y) - var(--replace-lift)), 0) rotate(var(--fan-rot));
  transform-origin: 50% 118%;
  transition: transform 180ms cubic-bezier(.2, .8, .2, 1), opacity 160ms ease;
}

.current-hand.replace-mode .play-card:nth-child(1) { --fan-rot: -8deg; --fan-y: 14px; }
.current-hand.replace-mode .play-card:nth-child(2) { --fan-rot: -5.5deg; --fan-y: 7px; }
.current-hand.replace-mode .play-card:nth-child(3) { --fan-rot: -3deg; --fan-y: 2px; }
.current-hand.replace-mode .play-card:nth-child(4) { --fan-rot: -1deg; --fan-y: 0px; }
.current-hand.replace-mode .play-card:nth-child(5) { --fan-rot: 1deg; --fan-y: 0px; }
.current-hand.replace-mode .play-card:nth-child(6) { --fan-rot: 3deg; --fan-y: 2px; }
.current-hand.replace-mode .play-card:nth-child(7) { --fan-rot: 5.5deg; --fan-y: 7px; }
.current-hand.replace-mode .play-card:nth-child(8) { --fan-rot: 8deg; --fan-y: 14px; }

.current-hand.replace-mode .play-card.replace-selected {
  --replace-lift: var(--selected-lift);
  transform: translate3d(var(--drag-x), calc(var(--drag-y) + var(--fan-y) - var(--selected-lift)), 0) rotate(var(--fan-rot));
  z-index: 42;
}

.current-hand.replace-mode .play-card.replace-selected .card-face {
  box-shadow: 0 0 0 3px rgba(86, 190, 255, .72), 0 12px 20px rgba(0, 0, 0, .55);
}

.play-card.dragging {
  z-index: 80;
  transition: none;
}

.play-card.receiving-card {
  opacity: 0;
}

.play-card.collecting-card {
  opacity: 0;
  transform: translate3d(var(--drag-x), var(--drag-y), 0) scale(.92);
  transition: opacity 120ms ease, transform 120ms ease;
}

.play-card.received-card {
  animation: receive-card 360ms cubic-bezier(.22, 1, .36, 1);
}

.play-card.matchable .card-face {
  box-shadow: 0 0 0 3px rgba(109, 234, 157, .55), 0 8px 16px rgba(0, 0, 0, .5);
}

.play-card.blocked {
  opacity: .74;
}

.card-row:not(.active-hand) .play-card {
  pointer-events: none;
}

.active-hand .play-card .card-face {
  box-shadow: 0 0 0 2px rgba(214, 169, 77, .46), 0 10px 18px rgba(0, 0, 0, .56);
}

.effect-layer {
  position: absolute;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}

.capture-progress {
  position: absolute;
  left: 3.3%;
  width: 20.8%;
  display: grid;
  grid-template-columns: clamp(34px, 4.15vw, 78px) minmax(0, 1fr);
  gap: .55vw .65vw;
  align-items: end;
  z-index: 24;
}

.opponent-progress {
  top: 2.1%;
}

.current-progress {
  bottom: 1.4%;
}

.view-captured {
  display: grid;
  justify-items: center;
  gap: .1vw;
  border: 0;
  background: transparent;
  color: rgba(255, 249, 229, .9);
  text-shadow: 0 2px 4px rgba(0, 0, 0, .75);
  font-size: clamp(11px, 1.25vw, 24px);
  font-weight: 900;
}

.magnifier {
  width: clamp(34px, 3.7vw, 70px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 2px solid rgba(220, 201, 154, .7);
  border-radius: 50%;
  background: rgba(10, 13, 13, .38);
  font-size: clamp(28px, 3.2vw, 56px);
  line-height: 1;
}

.progress-icons {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: .45vw;
  align-items: end;
}

.progress-chip {
  width: 100%;
  aspect-ratio: .62 / 1;
  display: grid;
  justify-items: center;
  grid-template-rows: 1fr auto;
  align-content: end;
  gap: 2px;
  border: 2px solid rgba(216, 229, 224, .32);
  border-radius: 6px;
  background: rgba(8, 12, 12, .44);
  box-shadow: inset 0 0 10px rgba(255, 255, 255, .08);
  padding: 10% 4% 8%;
}

.progress-chip img {
  width: 76%;
  aspect-ratio: 1;
  object-fit: contain;
  align-self: end;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .72));
}

.progress-chip b {
  color: #41d071;
  font-size: clamp(10px, 1.08vw, 22px);
  line-height: 1;
  font-weight: 1000;
  text-shadow: 0 2px 3px rgba(0, 0, 0, .75);
}

.progress-chip[data-tier="6"] b {
  color: #52d6df;
}

.progress-chip[data-tier="9"] b {
  color: #c678ff;
}

.confirm-pop {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  padding: .45vw 1.2vw;
  border: 1px solid rgba(244, 215, 122, .6);
  background: rgba(13, 17, 16, .72);
  color: #fff2cf;
  font-size: clamp(16px, 1.8vw, 34px);
  font-weight: 900;
  text-shadow: 0 2px 5px black;
  animation: confirm-pop 700ms ease forwards;
}

.turn-banner {
  position: absolute;
  left: 50%;
  top: 48%;
  width: min(48%, 640px);
  min-height: 8%;
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%);
  border-top: 1px solid rgba(246, 219, 145, .62);
  border-bottom: 1px solid rgba(246, 219, 145, .62);
  background:
    linear-gradient(90deg, transparent, rgba(8, 12, 13, .72) 16%, rgba(141, 36, 21, .78) 50%, rgba(8, 12, 13, .72) 84%, transparent);
  color: #fff4d6;
  font-size: clamp(18px, 2.2vw, 42px);
  font-weight: 1000;
  text-shadow: 0 2px 5px rgba(0, 0, 0, .9);
  animation: turn-banner 980ms cubic-bezier(.16, 1, .3, 1) forwards;
}

.result-banner {
  position: absolute;
  left: 50%;
  top: 47%;
  width: min(58%, 780px);
  min-height: 12%;
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255, 228, 151, .82);
  background:
    linear-gradient(90deg, transparent, rgba(18, 28, 22, .88) 12%, rgba(29, 119, 69, .88) 50%, rgba(18, 28, 22, .88) 88%, transparent);
  color: #fff8dc;
  font-size: clamp(30px, 4.2vw, 82px);
  font-weight: 1000;
  letter-spacing: 0;
  text-shadow: 0 3px 8px rgba(0, 0, 0, .9), 0 0 18px rgba(255, 235, 159, .42);
  box-shadow: 0 0 34px rgba(255, 228, 151, .26);
  animation: result-banner-in 780ms cubic-bezier(.16, 1, .3, 1) forwards;
}

.result-banner.lost {
  border-color: rgba(255, 109, 93, .84);
  background:
    linear-gradient(90deg, transparent, rgba(28, 11, 10, .9) 12%, rgba(133, 18, 21, .9) 50%, rgba(28, 11, 10, .9) 88%, transparent);
  box-shadow: 0 0 34px rgba(255, 74, 57, .28);
}

.pair-reveal {
  position: absolute;
  left: 50%;
  top: 43.5%;
  width: min(43%, 700px);
  min-height: 31%;
  transform: translate(-50%, -50%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto minmax(0, 1fr);
  align-items: center;
  gap: .55vw 1vw;
  padding: clamp(10px, .95vw, 20px) clamp(14px, 1.35vw, 26px);
  border: 1px solid rgba(230, 195, 105, .66);
  background:
    linear-gradient(180deg, rgba(26, 32, 30, .94), rgba(8, 11, 11, .9)),
    radial-gradient(circle at 30% 0, rgba(214, 169, 77, .2), transparent 50%);
  box-shadow: inset 0 0 26px rgba(255, 236, 174, .08), 0 22px 56px rgba(0, 0, 0, .55);
  pointer-events: none;
  z-index: 50;
  animation: pair-reveal-in 760ms cubic-bezier(.16, 1, .3, 1) forwards;
}

.pair-reveal.leaving {
  animation: pair-reveal-out 180ms ease forwards;
}

.pair-reveal-label {
  grid-column: 1 / 2;
  justify-self: center;
  color: #ffe7a7;
  font-size: clamp(13px, 1.12vw, 23px);
  font-weight: 900;
  text-shadow: 0 2px 4px rgba(0, 0, 0, .8);
}

.pair-reveal-cards {
  grid-column: 1 / 2;
  display: flex;
  justify-content: center;
  align-items: end;
  gap: clamp(6px, .62vw, 12px);
  min-width: 0;
}

.pair-reveal-card {
  width: clamp(54px, 5.45vw, 106px);
  flex: 0 1 auto;
  animation: combo-card-rise 480ms cubic-bezier(.16, 1, .3, 1) both;
  animation-delay: calc(var(--i, 0) * 46ms);
}

.pair-link {
  align-self: center;
  color: rgba(255, 241, 199, .9);
  font-size: clamp(18px, 2.2vw, 42px);
  line-height: 1;
  font-weight: 1000;
  text-shadow: 0 2px 5px black;
}

.pair-reveal-score {
  grid-column: 2 / 3;
  grid-row: 1 / 3;
  align-self: center;
  color: #ff3129;
  font-size: clamp(34px, 4.7vw, 88px);
  line-height: .92;
  font-weight: 1000;
  text-shadow:
    0 0 2px #2d0103,
    0 2px 0 rgba(255, 227, 170, .55),
    0 8px 14px rgba(0, 0, 0, .82);
}

.combo-reveal {
  position: absolute;
  left: 50%;
  top: 43%;
  width: min(42%, 680px);
  min-height: 38%;
  transform: translate(-50%, -50%);
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: .65vw;
  padding: clamp(12px, 1.05vw, 22px) clamp(16px, 1.45vw, 28px);
  border: 1px solid rgba(230, 195, 105, .62);
  background:
    linear-gradient(180deg, rgba(24, 30, 28, .92), rgba(8, 11, 11, .88)),
    radial-gradient(circle at 50% 0, rgba(214, 169, 77, .22), transparent 48%);
  box-shadow: inset 0 0 28px rgba(255, 236, 174, .08), 0 22px 60px rgba(0, 0, 0, .55);
  pointer-events: none;
  animation: combo-reveal-in 1180ms cubic-bezier(.16, 1, .3, 1) forwards;
}

.combo-reveal.leaving {
  animation: combo-reveal-out 260ms ease forwards;
}

.combo-reveal-head {
  display: inline-flex;
  align-items: center;
  justify-self: center;
  gap: .45vw;
  color: #ffe7a7;
  font-size: clamp(13px, 1.15vw, 24px);
  font-weight: 900;
  text-shadow: 0 2px 4px rgba(0, 0, 0, .8);
}

.combo-reveal-head img {
  width: clamp(24px, 2.1vw, 42px);
  aspect-ratio: 1;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .75));
}

.combo-reveal-title {
  justify-self: center;
  max-width: 92%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: #fff8dd;
  font-size: clamp(18px, 1.9vw, 36px);
  line-height: 1.05;
  text-shadow: 0 2px 5px black;
}

.combo-reveal-cards {
  display: flex;
  justify-content: center;
  align-items: end;
  gap: clamp(6px, .7vw, 14px);
  min-width: 0;
}

.combo-reveal-card {
  width: clamp(52px, 5.6vw, 104px);
  flex: 0 1 auto;
  animation: combo-card-rise 520ms cubic-bezier(.16, 1, .3, 1) both;
  animation-delay: calc(var(--i, 0) * 48ms);
}

.combo-reveal-score {
  position: absolute;
  right: clamp(12px, 1.6vw, 30px);
  top: 45%;
  transform: translateY(-50%);
  color: #ff3129;
  font-size: clamp(30px, 4.2vw, 82px);
  line-height: 1;
  font-weight: 1000;
  text-shadow:
    0 0 2px #2d0103,
    0 2px 0 rgba(255, 227, 170, .55),
    0 8px 14px rgba(0, 0, 0, .8);
}

.flying-card {
  position: fixed;
  z-index: 200;
  pointer-events: none;
  margin: 0;
}

.deal-flight {
  will-change: transform, left, top, opacity;
  filter: drop-shadow(0 10px 12px rgba(0, 0, 0, .45));
}

.slash-effect {
  position: absolute;
  right: 1%;
  top: -20%;
  width: 62%;
  height: 145%;
  transform: rotate(0deg);
  mix-blend-mode: screen;
  pointer-events: none;
  filter: drop-shadow(0 0 6px rgba(255, 22, 32, .78));
  animation: slash-cut 420ms cubic-bezier(.16, 1, .3, 1) forwards;
  z-index: 35;
}

.slash-effect svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.slash-arc {
  fill: none;
  stroke-linecap: round;
  stroke-dasharray: 235;
  stroke-dashoffset: 235;
  animation: slash-arc-draw 360ms cubic-bezier(.16, 1, .3, 1) forwards;
}

.slash-arc-glow {
  stroke: rgba(255, 12, 28, .32);
  stroke-width: 12;
}

.slash-arc-main {
  stroke: rgba(255, 20, 34, .92);
  stroke-width: 5;
}

.slash-arc-edge {
  stroke: rgba(255, 244, 238, .96);
  stroke-width: 2;
  animation-delay: 28ms;
}

.slash-effect.combo-slash {
  filter: drop-shadow(0 0 7px rgba(255, 22, 32, .92)) saturate(1.25);
}

.damage-number {
  position: absolute;
  right: 11.5%;
  top: -56%;
  color: #cd1517;
  font-size: clamp(22px, 2.75vw, 54px);
  line-height: .9;
  font-weight: 1000;
  text-shadow:
    0 0 2px #2d0103,
    0 2px 0 rgba(255, 227, 170, .55),
    0 5px 8px rgba(0, 0, 0, .75);
  pointer-events: none;
  animation: damage-rise 820ms cubic-bezier(.16, 1, .3, 1) forwards;
  z-index: 36;
}

.damage-number.combo-damage {
  top: -84%;
}

.control-dock {
  width: min(100%, 1480px);
  margin: 12px auto 0;
  color: #1f241f;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.actions button {
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid #bfc8bb;
  border-radius: 6px;
  background: #fbfaf4;
  color: #1f241f;
  font-weight: 800;
}

.actions button:first-child {
  background: #20251f;
  color: #fbfaf4;
}

#landscapeBtn {
  background: #143323;
  color: #f7fff4;
}

.panel-grid {
  display: grid;
  grid-template-columns: .9fr 1.1fr 1.2fr;
  gap: 10px;
}

.panel-grid article {
  min-height: 118px;
  padding: 12px;
  border: 1px solid #c8d1c2;
  background: #fbfaf4;
  box-shadow: 0 8px 22px rgba(20, 24, 18, .12);
}

.panel-grid h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.strategy-panel {
  margin-top: 10px;
  padding: 14px;
  border: 1px solid #b9c5b2;
  background:
    linear-gradient(135deg, rgba(247, 243, 226, .98), rgba(224, 231, 217, .96)),
    #f4f1e5;
  box-shadow: 0 10px 28px rgba(20, 24, 18, .13);
}

.strategy-panel h2 {
  margin: 0 0 10px;
  font-size: 19px;
  letter-spacing: 0;
}

.strategy-guide {
  display: grid;
  gap: 12px;
}

.strategy-topline {
  display: grid;
  grid-template-columns: minmax(180px, .72fr) minmax(260px, 1.35fr) minmax(230px, 1fr);
  gap: 10px;
  align-items: stretch;
}

.strategy-readout,
.strategy-main,
.strategy-section {
  border: 1px solid rgba(91, 106, 86, .28);
  background: rgba(255, 252, 240, .72);
}

.strategy-readout {
  display: grid;
  align-content: center;
  gap: 7px;
  padding: 13px;
}

.strategy-label {
  color: #596457;
  font-size: 13px;
  font-weight: 800;
}

.strategy-readout strong {
  color: #182116;
  font-size: clamp(34px, 4vw, 54px);
  line-height: .9;
}

.strategy-readout small {
  color: #66705f;
  font-size: 12px;
}

.strategy-meter {
  height: 9px;
  overflow: hidden;
  border: 1px solid rgba(54, 71, 52, .32);
  background: rgba(35, 42, 33, .14);
}

.strategy-meter i {
  display: block;
  width: var(--value);
  height: 100%;
  background: linear-gradient(90deg, #9b3f2d, #d7af4a 48%, #3f895f);
  transition: width 260ms ease-out;
}

.strategy-main {
  padding: 12px 13px;
}

.strategy-main h3,
.strategy-section h3 {
  margin: 0 0 6px;
  color: #1c271a;
  font-size: 15px;
}

.strategy-main p {
  min-height: 42px;
  margin: 0;
  color: #404b3e;
  font-size: 14px;
  line-height: 1.5;
}

.strategy-tags,
.hand-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.strategy-tags span,
.hand-tags span {
  padding: 3px 7px;
  border: 1px solid rgba(62, 79, 59, .25);
  background: rgba(50, 70, 48, .08);
  color: #365034;
  font-size: 12px;
  font-weight: 800;
}

.strategy-section {
  padding: 12px;
}

.route-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.route-group > strong {
  display: block;
  margin-bottom: 7px;
  color: #273425;
  font-size: 13px;
}

.route-group > div {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.route-chip,
.route-empty {
  min-height: 42px;
  display: inline-grid;
  grid-template-columns: 26px auto;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid rgba(56, 69, 58, .3);
  background: rgba(19, 29, 23, .08);
}

.route-chip img {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.route-chip.no-icon {
  grid-template-columns: auto;
}

.route-chip b {
  max-width: 126px;
  overflow: hidden;
  color: #263223;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-chip em {
  grid-column: 2;
  color: #25875e;
  font-style: normal;
  font-size: 15px;
  font-weight: 1000;
}

.route-chip.no-icon em {
  grid-column: 1;
}

.route-empty {
  grid-template-columns: 1fr;
  color: #6d7568;
  font-size: 13px;
}

.hand-lines {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.hand-line {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 42px;
  gap: 8px;
  align-items: start;
  min-height: 118px;
  padding: 9px;
  border: 1px solid rgba(72, 80, 70, .26);
  background: rgba(255, 255, 250, .62);
}

.hand-line.playable {
  border-color: rgba(133, 111, 48, .48);
  background: linear-gradient(180deg, rgba(255, 248, 218, .82), rgba(255, 255, 250, .62));
}

.hand-line > b {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  background: #243124;
  color: #f7efd4;
  font-size: 13px;
}

.hand-line strong {
  display: block;
  overflow: hidden;
  color: #1d281c;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hand-line p {
  margin: 4px 0 0;
  color: #536052;
  font-size: 12px;
  line-height: 1.38;
}

.hand-line > em {
  color: #8e3125;
  font-style: normal;
  font-size: 17px;
  font-weight: 1000;
  text-align: right;
}

.move-preview,
.ledger,
#battleLog {
  margin: 0;
  color: #4d574c;
  font-size: 14px;
}

.ledger {
  display: grid;
  gap: 4px;
}

#battleLog {
  max-height: 120px;
  overflow: auto;
  padding-left: 20px;
}

#battleLog li {
  margin: 4px 0;
}

.captured-modal[hidden],
.combo-guide-modal[hidden],
.card-library-modal[hidden] {
  display: none;
}

.captured-modal,
.combo-guide-modal,
.card-library-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  place-items: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(5, 8, 9, .74);
  backdrop-filter: blur(2px);
}

.captured-panel {
  position: relative;
  width: min(620px, 86vw);
  max-height: 82vh;
  overflow: auto;
  padding: 24px 24px 28px;
  border: 1px solid rgba(226, 205, 139, .45);
  background: linear-gradient(180deg, rgba(27, 43, 45, .94), rgba(8, 12, 13, .96));
  box-shadow: 0 24px 80px rgba(0, 0, 0, .56);
}

.combo-guide-panel {
  position: relative;
  width: min(1120px, 94vw);
  max-height: 90vh;
  padding: clamp(10px, 1vw, 16px);
  border: 1px solid rgba(226, 205, 139, .52);
  background: rgba(8, 12, 13, .94);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .62);
}

.combo-guide-panel img {
  display: block;
  width: 100%;
  max-height: calc(90vh - 32px);
  object-fit: contain;
}

.card-library-panel {
  position: relative;
  width: min(1180px, 94vw);
  max-height: 90vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid rgba(226, 205, 139, .52);
  background: linear-gradient(180deg, rgba(24, 35, 35, .96), rgba(8, 12, 13, .97));
  box-shadow: 0 24px 80px rgba(0, 0, 0, .62);
  overflow: hidden;
}

.card-library-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 52px 12px 18px;
  border-bottom: 1px solid rgba(226, 205, 139, .22);
}

.card-library-head h2 {
  margin: 0;
  color: #f8f1df;
  font-size: clamp(18px, 2vw, 28px);
}

.library-tabs {
  display: flex;
  gap: 8px;
}

.library-tabs button {
  min-height: 34px;
  padding: 6px 14px;
  border: 1px solid rgba(235, 214, 151, .46);
  border-radius: 6px;
  background: rgba(8, 12, 12, .62);
  color: #fff4d6;
  font-weight: 900;
}

.library-tabs button.active {
  background: #d6a94d;
  color: #171513;
}

.card-library-content {
  overflow: auto;
  padding: 16px 18px 20px;
}

.library-group {
  margin-bottom: 22px;
}

.library-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  color: #ffe6a3;
  font-size: clamp(15px, 1.5vw, 20px);
}

.library-group-title img {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.library-count {
  color: rgba(248, 241, 223, .68);
  font-size: 12px;
}

.library-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(82px, 1fr));
  gap: 12px 10px;
}

.bond-pair-group {
  display: inline-grid;
  width: min(100%, 270px);
  margin-right: 14px;
  vertical-align: top;
}

.bond-pair-grid {
  grid-template-columns: repeat(2, minmax(82px, 1fr));
  padding: 10px;
  border: 1px solid rgba(226, 205, 139, .24);
  background: rgba(255, 248, 222, .06);
}

.library-card {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: #f8f1df;
}

.library-card img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 5px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, .44);
}

.library-card b,
.library-card span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: center;
}

.library-card b {
  font-size: 12px;
}

.library-card span {
  color: #ffe6a3;
  font-size: 12px;
  font-weight: 900;
}

.captured-panel h2 {
  margin: 0 0 18px;
  color: #f8f1df;
  font-size: 26px;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .1);
  color: #f8f1df;
  font-size: 24px;
}

.captured-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 118px));
  justify-content: center;
  gap: 18px 16px;
}

.captured-grid .play-card {
  width: 118px;
}

.empty-captured {
  grid-column: 1 / -1;
  margin: 20px 0;
  color: rgba(248, 241, 223, .76);
  text-align: center;
}

@keyframes shuffle-stack {
  0%, 100% { transform: translateX(0) rotate(0); }
  18% { transform: translateX(-14%) rotate(-5deg); }
  38% { transform: translateX(13%) rotate(4deg); }
  58% { transform: translateX(-9%) rotate(-3deg); }
  78% { transform: translateX(7%) rotate(2deg); }
}

@keyframes lift-card-a {
  0%, 100% { transform: translate(-20%, -12%) rotate(-7deg); }
  28% { transform: translate(-54%, -42%) rotate(-16deg); }
  58% { transform: translate(32%, -50%) rotate(13deg); }
}

@keyframes lift-card-b {
  0%, 100% { transform: translate(4%, -3%) rotate(2deg); }
  32% { transform: translate(48%, -38%) rotate(15deg); }
  64% { transform: translate(-34%, -46%) rotate(-12deg); }
}

@keyframes confirm-pop {
  0% { opacity: 0; transform: translate(-50%, -35%) scale(.86); }
  22% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -72%) scale(1.06); }
}

@keyframes turn-banner {
  0% { opacity: 0; transform: translate(-50%, -50%) scaleX(.28); }
  16% { opacity: 1; transform: translate(-50%, -50%) scaleX(1); }
  72% { opacity: 1; transform: translate(-50%, -50%) scaleX(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) translateY(-16%) scaleX(.94); }
}

@keyframes result-banner-in {
  0% { opacity: 0; transform: translate(-50%, -50%) scaleX(.48) scaleY(.9); filter: brightness(1.25); }
  20% { opacity: 1; transform: translate(-50%, -50%) scaleX(1.04) scaleY(1); }
  100% { opacity: 1; transform: translate(-50%, -50%) scaleX(1) scaleY(1); filter: brightness(1); }
}

@keyframes timer-warning {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

@keyframes pair-reveal-in {
  0% { opacity: 0; transform: translate(-50%, -42%) scale(.9); filter: brightness(1.28); }
  18% { opacity: 1; }
  72% { opacity: 1; transform: translate(-50%, -50%) scale(1); filter: brightness(1); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); filter: brightness(1); }
}

@keyframes pair-reveal-out {
  from { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  to { opacity: 0; transform: translate(-50%, -54%) scale(.94); }
}

@keyframes combo-reveal-in {
  0% { opacity: 0; transform: translate(-50%, -43%) scale(.9); filter: brightness(1.28); }
  16% { opacity: 1; }
  78% { opacity: 1; transform: translate(-50%, -50%) scale(1); filter: brightness(1); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); filter: brightness(1); }
}

@keyframes combo-reveal-out {
  from { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  to { opacity: 0; transform: translate(-50%, -54%) scale(.94); }
}

@keyframes combo-card-rise {
  from { opacity: 0; transform: translateY(14%) scale(.86); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes hit-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8%); }
  48% { transform: translateX(6%); }
  72% { transform: translateX(-3%); }
}

@keyframes receive-card {
  0% { transform: translateY(-5%) scale(.94); filter: brightness(1.45); }
  100% { transform: translateY(0) scale(1); filter: brightness(1); }
}

@keyframes slash-cut {
  0% { opacity: 0; transform: translate(-8%, -6%) rotate(0deg) scale(.96); }
  18% { opacity: 1; }
  62% { opacity: 1; transform: translate(0, 0) rotate(0deg) scale(1); }
  100% { opacity: 0; transform: translate(7%, 5%) rotate(0deg) scale(1.02); }
}

@keyframes slash-arc-draw {
  0% { stroke-dashoffset: 235; }
  72% { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: 0; }
}

@keyframes damage-rise {
  0% { opacity: 0; transform: translateY(20%) scale(.82); }
  18% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-76%) scale(1.12); }
}

@media (max-width: 900px) {
  .battle-page {
    padding: 6px;
  }

  .battle-stage {
    width: 100%;
  }

  .panel-grid {
    grid-template-columns: 1fr;
  }

  .strategy-topline,
  .route-board {
    grid-template-columns: 1fr;
  }

  .hand-lines {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .hand-lines {
    grid-template-columns: 1fr;
  }

  .strategy-panel {
    padding: 10px;
  }

  .hand-line {
    min-height: 0;
  }
}

body.landscape-mode {
  overflow: hidden;
  background: #050706;
}

body.landscape-mode .battle-page {
  width: 100vw;
  height: 100vh;
  padding: 0;
  display: grid;
  place-items: center;
}

body.landscape-mode .battle-stage {
  width: min(100vw, calc(100vh * 16 / 9));
  max-height: 100vh;
  align-self: center;
}

body.landscape-mode .control-dock {
  position: fixed;
  right: max(6px, env(safe-area-inset-right));
  top: 50%;
  bottom: auto;
  left: auto;
  transform: translateY(-50%);
  z-index: 600;
  margin: 0;
  width: auto;
  padding: 0;
  background: transparent;
  color: #f8f1df;
  pointer-events: none;
}

body.landscape-mode .actions {
  display: grid;
  justify-items: end;
  gap: 6px;
  margin: 0;
  pointer-events: auto;
}

body.landscape-mode .actions button {
  width: clamp(38px, 4.6vw, 54px);
  min-height: clamp(38px, 4.6vw, 54px);
  padding: 4px;
  border: 1px solid rgba(235, 214, 151, .62);
  border-radius: 999px;
  background: rgba(8, 12, 12, .68);
  color: #fff4d6;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .38);
  font-size: clamp(10px, 1vw, 12px);
  line-height: 1.05;
  font-weight: 900;
  text-align: center;
}

body.landscape-mode .actions button:first-child {
  background: rgba(33, 38, 32, .82);
  color: #fff4d6;
}

body.landscape-mode #fullscreenBtn {
  order: 1;
}

body.landscape-mode #newGameBtn {
  order: 2;
}

body.landscape-mode #landscapeBtn {
  order: 3;
}

body.landscape-mode #replaceBtn,
body.landscape-mode #clearBtn {
  display: none;
}

body.landscape-mode .panel-grid {
  display: none;
}

body.landscape-mode .strategy-panel {
  display: none;
}

body.landscape-mode .mobile-coach {
  position: absolute;
  left: 3.4%;
  top: 38.3%;
  width: 19.8%;
  min-height: 18.4%;
  display: grid;
  align-content: start;
  gap: .55vw;
  padding: .72vw .78vw;
  border: 1px solid rgba(224, 205, 143, .34);
  background:
    linear-gradient(180deg, rgba(16, 25, 26, .7), rgba(6, 10, 10, .54)),
    rgba(12, 17, 16, .62);
  box-shadow: inset 0 0 18px rgba(255, 255, 255, .05), 0 8px 26px rgba(0, 0, 0, .25);
  color: #f8f1df;
  text-shadow: 0 2px 4px rgba(0, 0, 0, .78);
  z-index: 26;
  pointer-events: none;
}

body.landscape-mode .coach-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .6vw;
}

body.landscape-mode .coach-head span {
  color: rgba(255, 241, 207, .84);
  font-size: clamp(9px, .95vw, 16px);
  font-weight: 900;
}

body.landscape-mode .coach-head strong {
  color: #ffe08a;
  font-size: clamp(14px, 1.55vw, 26px);
  line-height: 1;
}

body.landscape-mode .mobile-coach p {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0;
  color: rgba(255, 248, 226, .9);
  font-size: clamp(9px, .83vw, 14px);
  line-height: 1.32;
}

body.landscape-mode .coach-picks {
  display: grid;
  gap: 3px;
}

body.landscape-mode .coach-picks span {
  display: grid;
  grid-template-columns: 1.5em minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px;
  min-height: 1.55em;
  padding: 2px 4px;
  background: rgba(255, 248, 222, .08);
}

body.landscape-mode .coach-picks b {
  display: grid;
  place-items: center;
  width: 1.35em;
  height: 1.35em;
  background: rgba(227, 184, 78, .24);
  color: #ffe69d;
  font-size: clamp(8px, .78vw, 12px);
}

body.landscape-mode .coach-picks em {
  overflow: hidden;
  color: rgba(255, 248, 226, .9);
  font-style: normal;
  font-size: clamp(9px, .82vw, 13px);
  white-space: nowrap;
  text-overflow: ellipsis;
}

body.landscape-mode .coach-picks strong {
  color: #67d88c;
  font-size: clamp(9px, .88vw, 14px);
}

body.landscape-mode .mobile-coach small {
  overflow: hidden;
  color: rgba(204, 226, 213, .82);
  font-size: clamp(8px, .78vw, 12px);
  white-space: nowrap;
  text-overflow: ellipsis;
}

@media (orientation: portrait) and (max-width: 900px) {
  body.landscape-mode::before {
    content: "请横放手机";
    position: fixed;
    inset: 0;
    z-index: 900;
    display: grid;
    place-items: center;
    background: rgba(5, 7, 6, .88);
    color: #fff4d6;
    font-size: 26px;
    font-weight: 900;
    pointer-events: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ===== 剩余牌堆 ===== */
.deck-count-display {
  position: absolute;
  right: 7.2%;
  top: 50%;
  width: var(--card-w);
  aspect-ratio: 2 / 3;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  z-index: 12;
  pointer-events: none;
}

.deck-card-layer {
  position: absolute;
  inset: 0;
  border-radius: 5%;
  background: url("./assets/optimized/card-back.webp") center / cover no-repeat;
  box-shadow: 0 10px 18px rgba(0, 0, 0, .48);
  transition: opacity 180ms ease, transform 180ms ease;
}

.deck-card-shadow {
  transform: translate(-8%, 6%) rotate(-5deg);
  opacity: .82;
}

.deck-card-mid {
  transform: translate(-3%, 2.5%) rotate(-1.5deg);
  opacity: .92;
}

.deck-card-top {
  transform: translate(2%, -1%) rotate(2deg);
}

.deck-count-display.dealing .deck-card-top {
  transform: translate(8%, -8%) rotate(8deg);
  opacity: .42;
}

.deck-count-display.empty .deck-card-layer {
  opacity: .12;
}

.deck-count-display.single-card .deck-card-shadow,
.deck-count-display.single-card .deck-card-mid,
.deck-count-display.two-cards .deck-card-shadow {
  opacity: 0;
}

.deck-count-badge {
  position: absolute;
  right: -12%;
  top: -8%;
  min-width: clamp(24px, 2.7vw, 44px);
  min-height: clamp(24px, 2.7vw, 44px);
  padding: 4px;
  border-radius: 999px;
  background: linear-gradient(135deg, #f0d686, #c89435);
  border: 2px solid rgba(255, 246, 205, .72);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 5px 14px rgba(0, 0, 0, .45);
  z-index: 4;
}

.deck-count-number {
  font-size: clamp(12px, 1.5vw, 22px);
  font-weight: 900;
  color: #1a1a1a;
  line-height: 1;
}

.deck-count-label {
  font-size: clamp(7px, .72vw, 9px);
  color: rgba(26, 26, 26, 0.7);
  font-weight: 600;
  line-height: 1;
}

/* ===== 控制栏样式调整 ===== */
.control-dock {
  display: flex;
  justify-content: center;
  padding: 10px 0;
}

.actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* ===== 战斗区域样式调整 ===== */
.battle-stage {
  width: min(100%, calc((100vh - 84px) * 16 / 9));
  aspect-ratio: 16 / 9;
  margin: 0 auto;
}

@media (orientation: portrait) and (max-width: 900px) {
  :root {
    --card-w: clamp(40px, 13.2vw, 62px);
  }

  body,
  body.landscape-mode {
    min-height: 100dvh;
    overflow: hidden;
    background: #070a09;
  }

  body.landscape-mode::before {
    content: none;
  }

  .battle-page,
  body.landscape-mode .battle-page {
    width: 100vw;
    height: 100dvh;
    min-height: 100dvh;
    padding:
      max(6px, env(safe-area-inset-top))
      max(7px, env(safe-area-inset-right))
      max(6px, env(safe-area-inset-bottom))
      max(7px, env(safe-area-inset-left));
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 6px;
    place-items: stretch;
  }

  .battle-stage,
  body.landscape-mode .battle-stage {
    width: min(100%, calc((100dvh - 70px) * 9 / 16));
    max-width: 100%;
    height: auto;
    max-height: calc(100dvh - 70px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    aspect-ratio: 9 / 16;
    align-self: center;
    justify-self: center;
    border-radius: 0;
    background:
      linear-gradient(180deg, rgba(4, 9, 10, .72), rgba(8, 12, 13, .08) 24%, rgba(8, 12, 13, .08) 76%, rgba(4, 9, 10, .7)),
      url("./assets/optimized/battle-bg.webp") center / cover no-repeat;
  }

  .battle-stage::before {
    inset: 18.5% 4.5% 27%;
  }

  .player-strip {
    left: 3%;
    width: 94%;
    min-height: 7.2%;
    grid-template-columns: 13% 13% minmax(0, 1fr);
    gap: 7px;
    padding: 0 10px;
  }

  .player-strip .avatar {
    grid-column: 1;
    order: 1;
  }

  .player-strip .life-drop {
    grid-column: 2;
    order: 2;
  }

  .player-strip .player-name {
    grid-column: 3;
    order: 3;
    text-align: left;
  }

  .opponent-strip {
    top: 12.2%;
  }

  .current-strip {
    bottom: 18.8%;
  }

  .player-name {
    font-size: clamp(18px, 5.2vw, 28px);
  }

  .life-drop {
    font-size: clamp(18px, 5.4vw, 30px);
  }

  .opponent-hand {
    left: 3.5%;
    right: 3.5%;
    top: 1.2%;
    grid-template-columns: repeat(8, minmax(0, var(--card-w)));
    gap: 0;
  }

  .current-hand {
    left: 3.5%;
    right: 3.5%;
    bottom: 4.4%;
    grid-template-columns: repeat(8, minmax(0, var(--card-w)));
    gap: 0;
  }

  .capture-progress {
    left: auto;
    right: 4%;
    width: 38%;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 1px 4px;
    align-items: center;
    justify-content: end;
    z-index: 35;
    pointer-events: none;
  }

  .opponent-progress {
    top: 16.1%;
  }

  .current-progress {
    bottom: 16.4%;
  }

  .capture-progress .view-captured {
    pointer-events: auto;
  }

  .view-captured {
    gap: 0;
    font-size: 11px;
  }

  .magnifier {
    width: 26px;
    border-width: 2px;
    font-size: 21px;
  }

  .progress-icons {
    grid-template-columns: repeat(5, minmax(0, 18px));
    gap: 1px 2px;
    align-items: center;
    justify-content: end;
  }

  .progress-chip {
    width: 18px;
    border: 0;
    background: transparent;
    box-shadow: none;
    padding: 0;
    gap: 0;
  }

  .progress-chip img {
    width: 15px;
  }

  .progress-chip b {
    font-size: 10px;
    line-height: .95;
  }

  .table-zone {
    inset: 18.5% 4.5% 27%;
  }

  .public-grid {
    left: 50%;
    right: auto;
    top: 15%;
    bottom: auto;
    width: min(88%, calc((var(--card-w) * 4) + 24px));
    transform: translateX(-50%);
    grid-template-columns: repeat(4, minmax(0, var(--card-w)));
    grid-template-rows: repeat(2, auto);
    gap: 10px 8px;
    justify-content: center;
    align-content: center;
  }

  .deck-count-display {
    right: 3.8%;
    top: 78%;
    width: clamp(46px, 15vw, 68px);
  }

  .turn-timer {
    left: 4.5%;
    right: 4.5%;
    bottom: 28.4%;
    height: 26px;
    grid-template-columns: minmax(0, 1fr) 64px;
    gap: 6px;
  }

  .turn-timer-track {
    height: 10px;
    border-width: 1px;
  }

  .turn-timer-badge {
    border-radius: 7px;
    padding: 0 8px;
  }

  .turn-timer-icon {
    font-size: 14px;
  }

  .turn-timer-number {
    font-size: 21px;
  }

  body.landscape-mode .mobile-coach,
  .mobile-coach {
    display: none;
  }

  .side-buttons {
    right: 0;
    top: 34%;
    gap: 6px;
  }

  .side-tool-btn {
    min-width: 36px;
    min-height: 62px;
    padding: 7px 4px;
    border-radius: 7px 0 0 7px;
    font-size: 13px;
  }

  .combo-guide-panel {
    width: 96vw;
    max-height: 82vh;
    padding: 8px;
  }

  .combo-guide-panel img {
    max-height: calc(82vh - 16px);
  }

  .card-library-panel {
    width: 96vw;
    max-height: 86vh;
  }

  .card-library-head {
    align-items: start;
    flex-direction: column;
    padding: 12px 46px 10px 12px;
  }

  .card-library-content {
    padding: 12px;
  }

  .library-card-grid {
    grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
    gap: 10px 8px;
  }

  .bond-pair-group {
    width: min(100%, 210px);
    margin-right: 8px;
  }

  .bond-pair-grid {
    grid-template-columns: repeat(2, minmax(62px, 1fr));
    padding: 8px;
  }

  .play-card {
    touch-action: none;
  }

  .score {
    font-size: clamp(14px, 4vw, 20px);
  }

  .card-faction-icons {
    gap: 2px;
  }

  .control-dock,
  body.landscape-mode .control-dock {
    position: static;
    transform: none;
    width: min(100%, 520px);
    margin: 0 auto;
    padding: 0;
    color: #f8f1df;
    pointer-events: auto;
  }

  .actions,
  body.landscape-mode .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 0;
    justify-items: stretch;
  }

  .actions button,
  body.landscape-mode .actions button {
    width: 100%;
    min-height: 42px;
    padding: 8px 10px;
    border: 1px solid rgba(235, 214, 151, .55);
    border-radius: 7px;
    background: rgba(251, 250, 244, .95);
    color: #20251f;
    box-shadow: 0 7px 18px rgba(0, 0, 0, .26);
    font-size: clamp(12px, 3.5vw, 15px);
    line-height: 1.1;
    font-weight: 900;
    text-align: center;
  }

  .actions button:first-child,
  body.landscape-mode .actions button:first-child {
    background: #20251f;
    color: #fbfaf4;
  }

  body.landscape-mode #replaceBtn,
  body.landscape-mode #clearBtn {
    display: inline-block;
  }
}

/* ===== 手机横屏优化 (不影响桌面16:9) ===== */
@media (orientation: landscape) and (max-width: 932px) {
  :root {
    --card-w: clamp(44px, 7.8vw, 82px);
  }

  body {
    overflow: hidden;
    background: #070a09;
  }

  .battle-page {
    width: 100vw;
    height: 100dvh;
    min-height: 100dvh;
    padding:
      max(4px, env(safe-area-inset-top))
      max(4px, env(safe-area-inset-right))
      max(4px, env(safe-area-inset-bottom))
      max(4px, env(safe-area-inset-left));
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 4px;
    place-items: center;
  }

  .battle-stage {
    width: min(100%, calc(100dvh * 16 / 9 - 10px));
    max-height: 100dvh;
    margin: 0 auto;
    border-radius: 0;
  }

  .battle-stage::before {
    inset: 16.5% 5% 22.5% 8%;
  }

  /* 玩家信息条 - 更紧凑 */
  .player-strip {
    left: 1.5%;
    width: 20%;
    min-height: 5.5%;
    grid-template-columns: 18% minmax(0, 1fr);
    gap: 4px;
    padding-left: 3%;
  }

  .player-strip .life-drop {
    display: none;
  }

  .opponent-strip {
    top: 26.5%;
    background: linear-gradient(90deg, rgba(141, 25, 17, .72), rgba(141, 25, 17, .28), transparent);
  }

  .current-strip {
    bottom: 16.5%;
    background: linear-gradient(90deg, rgba(43, 67, 169, .68), rgba(43, 67, 169, .24), transparent);
  }

  .player-name {
    font-size: clamp(11px, 1.5vw, 18px);
  }

  .avatar {
    width: 100%;
    min-width: 22px;
    aspect-ratio: 1;
    border-width: 1.5px;
  }

  /* 手牌区 */
  .opponent-hand {
    left: 2%;
    right: 2%;
    top: 1%;
    grid-template-columns: repeat(8, minmax(0, var(--card-w)));
    gap: 0;
    justify-content: center;
  }

  .current-hand {
    left: 2%;
    right: 2%;
    bottom: 3.2%;
    grid-template-columns: repeat(8, minmax(0, var(--card-w)));
    gap: 0;
    justify-content: center;
  }

  /* 桌上区域 */
  .table-zone {
    inset: 17.5% 3.5% 24%;
  }

  .public-grid {
    left: 50%;
    right: auto;
    top: 12%;
    bottom: auto;
    width: min(82%, calc((var(--card-w) * 4) + 20px));
    transform: translateX(-50%);
    grid-template-columns: repeat(4, minmax(0, var(--card-w)));
    grid-template-rows: repeat(2, auto);
    gap: 8px 6px;
    justify-content: center;
    align-content: center;
  }

  /* 牌堆 */
  .deck-count-display {
    right: 4%;
    top: 50%;
    width: clamp(40px, 6.5vw, 56px);
  }

  .deck-count-badge {
    min-width: clamp(20px, 2.2vw, 30px);
    min-height: clamp(20px, 2.2vw, 30px);
    right: -6%;
    top: -6%;
    padding: 2px;
  }

  .deck-count-number {
    font-size: clamp(10px, 1.2vw, 16px);
  }

  .deck-count-label {
    font-size: clamp(6px, 0.6vw, 8px);
  }

  /* 回合计时器 */
  .turn-timer {
    left: 22%;
    right: 15%;
    bottom: 25%;
    height: 18px;
    grid-template-columns: minmax(0, 1fr) 48px;
    gap: 4px;
  }

  .turn-timer-track {
    height: 8px;
    border-width: 1px;
  }

  .turn-timer-badge {
    border-radius: 6px;
    padding: 0 6px;
  }

  .turn-timer-icon {
    font-size: 12px;
  }

  .turn-timer-number {
    font-size: 18px;
  }

  /* 捕获进度 */
  .capture-progress {
    width: 32%;
    grid-template-columns: 22px minmax(0, 1fr);
    gap: 1px 3px;
  }

  .opponent-progress {
    top: 14%;
  }

  .current-progress {
    bottom: 14%;
  }

  .progress-icons {
    grid-template-columns: repeat(5, minmax(0, 15px));
    gap: 1px;
  }

  .progress-chip {
    width: 15px;
  }

  .progress-chip img {
    width: 13px;
  }

  .progress-chip b {
    font-size: 8px;
  }

  .view-captured {
    font-size: 10px;
  }

  .magnifier {
    width: 22px;
    border-width: 1.5px;
    font-size: 18px;
  }

  /* 侧边按钮 */
  .side-buttons {
    right: 0;
    top: 35%;
    gap: 5px;
  }

  .side-tool-btn {
    min-width: 32px;
    min-height: 56px;
    padding: 6px 3px;
    border-radius: 6px 0 0 6px;
    font-size: 12px;
  }

  /* 状态文字 */
  .stage-status {
    font-size: clamp(10px, 1.2vw, 14px);
    padding: 3px 10px;
  }

  /* 底部控制 */
  .control-dock {
    padding: 4px 0;
  }

  .actions {
    gap: 8px;
  }

  .actions button {
    min-height: 36px;
    padding: 6px 16px;
    font-size: clamp(11px, 1.4vw, 14px);
  }

  /* 模态框 */
  .combo-guide-panel {
    width: 90vw;
    max-height: 78vh;
    padding: 6px;
  }

  .card-library-panel {
    width: 90vw;
    max-height: 82vh;
  }

  .library-card-grid {
    grid-template-columns: repeat(auto-fill, minmax(54px, 1fr));
    gap: 8px 6px;
  }
}

