:root {
  color-scheme: light;
  --paper: #f7faf7;
  --panel: #ffffff;
  --ink: #17211c;
  --muted: #64706b;
  --line: #d8e1db;
  --player: #c73343;
  --ai: #176ca8;
  --toxin: #2c8f57;
  --amber: #bf7d17;
  --violet: #7055ad;
  --shadow: 0 18px 42px rgba(28, 42, 35, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(44, 143, 87, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(199, 51, 67, 0.08), transparent 34%),
    repeating-linear-gradient(0deg, rgba(23, 33, 28, 0.025) 0 1px, transparent 1px 18px),
    var(--paper);
  color: var(--ink);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1440px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px 0 30px;
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  gap: 14px;
}

.match-header,
.game-board,
.action-zone,
.result-zone {
  width: 100%;
}

.match-header {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(520px, 1.6fr);
  align-items: center;
  gap: 14px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 74px;
  height: 74px;
  border: 2px solid var(--ink);
  background:
    linear-gradient(160deg, rgba(44, 143, 87, 0.16), transparent 52%),
    var(--panel);
  display: grid;
  place-items: center;
  box-shadow: 8px 8px 0 var(--toxin);
  font-weight: 900;
  letter-spacing: 0;
  transform: rotate(-3deg);
}

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: 0;
}

.brand-lockup p,
.settlement p,
.round-modal p {
  margin: 0;
}

#match-subtitle {
  color: var(--muted);
  margin-top: 6px;
}

.scoreboard {
  min-height: 88px;
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
}

.scoreboard section {
  min-width: 0;
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 10px;
}

.scoreboard section:last-child {
  justify-items: end;
  grid-template-columns: 1fr auto auto;
}

.score-label {
  color: var(--muted);
  font-size: 14px;
}

.scoreboard strong {
  font-size: 36px;
  line-height: 1;
}

.pips {
  display: flex;
  gap: 5px;
}

.pip {
  width: 18px;
  height: 18px;
  border: 1px solid var(--line);
  background: #edf4ef;
}

.pip.win.player {
  background: var(--player);
  border-color: var(--player);
}

.pip.win.ai {
  background: var(--ai);
  border-color: var(--ai);
}

.round-badge {
  min-width: 168px;
  padding: 10px 14px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  text-align: center;
  font-weight: 800;
}

.game-board {
  min-height: 360px;
  display: grid;
  grid-template-columns: minmax(210px, 0.8fr) minmax(460px, 1.8fr) minmax(210px, 0.8fr);
  gap: 14px;
  align-items: stretch;
}

.combatant,
.settlement,
.battle-log {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.combatant {
  padding: 16px;
  display: grid;
  align-content: start;
  gap: 18px;
}

.panel-title {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px 16px;
  align-items: center;
}

.stat-grid span {
  color: var(--muted);
}

.stat-grid strong {
  min-width: 66px;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  background: #f5f8f6;
  text-align: center;
}

.player-panel {
  border-top: 5px solid var(--player);
}

.enemy-panel {
  border-top: 5px solid var(--ai);
}

.arena {
  position: relative;
  overflow: hidden;
  min-height: 360px;
  border: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(199, 51, 67, 0.08), transparent 45%, rgba(23, 108, 168, 0.08)),
    radial-gradient(circle at 50% 52%, rgba(44, 143, 87, 0.1), transparent 36%),
    repeating-linear-gradient(0deg, rgba(23, 33, 28, 0.04) 0 1px, transparent 1px 18px),
    #ffffff;
  box-shadow: var(--shadow);
}

.duel-row {
  position: relative;
  z-index: 2;
  height: 100%;
  min-height: 306px;
  padding: 28px;
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto minmax(150px, 1fr);
  gap: 18px;
  align-items: center;
}

.duel-card {
  min-height: 230px;
  border: 2px solid var(--ink);
  background: var(--panel);
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: center;
  justify-items: center;
  padding: 18px;
  transform-style: preserve-3d;
  transition: transform 260ms ease, box-shadow 260ms ease, filter 260ms ease;
  box-shadow: 10px 10px 0 rgba(23, 33, 28, 0.12);
}

.duel-card.revealed {
  animation: cardFlip 520ms ease both;
}

.player-card {
  border-color: var(--player);
}

.ai-card {
  border-color: var(--ai);
}

.hidden-card {
  filter: saturate(0.28);
}

.card-owner {
  width: 100%;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.duel-card strong {
  max-width: 100%;
  overflow-wrap: anywhere;
  text-align: center;
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: 0;
}

.duel-card span:last-child {
  color: var(--muted);
  text-align: center;
}

.versus {
  min-width: 76px;
  display: grid;
  place-items: center;
  gap: 8px;
  font-weight: 900;
}

.versus > span {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border: 2px solid var(--ink);
  background: #fff;
  box-shadow: 5px 5px 0 var(--amber);
}

#turn-chip {
  padding: 6px 10px;
  border: 1px solid var(--line);
  background: #f6f9f7;
}

.status-line {
  position: absolute;
  z-index: 3;
  left: 18px;
  right: 18px;
  bottom: 16px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-weight: 800;
}

.effect-layer,
.effect-layer > div {
  pointer-events: none;
  position: absolute;
  inset: 0;
}

.slash {
  opacity: 0;
  width: 72%;
  height: 12px;
  top: 47%;
  left: 14%;
  background: var(--player);
  transform: rotate(-14deg) scaleX(0);
}

.blast {
  opacity: 0;
  width: 180px;
  height: 180px;
  top: calc(50% - 90px);
  left: calc(50% - 90px);
  border: 10px solid var(--amber);
  background: rgba(191, 125, 23, 0.18);
}

.shield-ring {
  opacity: 0;
  width: 210px;
  height: 210px;
  top: calc(50% - 105px);
  left: calc(50% - 105px);
  border: 8px solid var(--ai);
}

.gas-cloud {
  opacity: 0;
  width: 220px;
  height: 130px;
  top: calc(50% - 65px);
  left: calc(50% - 110px);
  background:
    radial-gradient(circle at 20% 50%, rgba(44, 143, 87, 0.72), transparent 38%),
    radial-gradient(circle at 52% 38%, rgba(44, 143, 87, 0.62), transparent 42%),
    radial-gradient(circle at 78% 56%, rgba(44, 143, 87, 0.68), transparent 40%);
  filter: blur(1px);
}

.serum-drop {
  opacity: 0;
  width: 74px;
  height: 110px;
  top: calc(50% - 55px);
  left: calc(50% - 37px);
  border: 8px solid var(--toxin);
  background: rgba(44, 143, 87, 0.14);
  transform: rotate(45deg) scale(0.4);
}

.bullet-trail {
  opacity: 0;
  width: 58%;
  height: 8px;
  top: 50%;
  left: 21%;
  background: var(--violet);
  transform: scaleX(0);
}

.arena.effect-knife .slash {
  animation: slashCut 780ms ease-out both;
}

.arena.effect-pistol .bullet-trail {
  animation: trailShot 720ms ease-out both;
}

.arena.effect-reflect .shield-ring,
.arena.effect-defend .shield-ring {
  animation: shieldPulse 850ms ease-out both;
}

.arena.effect-gas .gas-cloud {
  animation: gasBloom 920ms ease-out both;
}

.arena.effect-purify .serum-drop {
  animation: serumDrop 860ms ease-out both;
}

.arena.effect-load .player-card {
  animation: chargeCard 760ms ease-out both;
}

.arena.effect-burst .blast {
  animation: blastOut 850ms ease-out both;
}

.action-zone {
  padding: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}

.action-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.seed-field {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 800;
}

.seed-field input {
  width: 180px;
  min-width: 0;
  border: 1px solid var(--line);
  padding: 6px 8px;
  background: #f7faf7;
  color: var(--ink);
}

.seed-field input:disabled {
  opacity: 0.62;
}

.commit-button,
.round-modal button {
  min-height: 46px;
  padding: 0 22px;
  border: 2px solid var(--ink);
  background: var(--ink);
  color: #fff;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 5px 5px 0 var(--toxin);
}

.commit-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  box-shadow: none;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(104px, 1fr));
  gap: 8px;
}

.action-button {
  min-height: 88px;
  padding: 10px;
  border: 1px solid var(--ink);
  background: #fff;
  color: var(--ink);
  display: grid;
  align-content: space-between;
  gap: 6px;
  text-align: left;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.action-button strong {
  font-size: 18px;
  overflow-wrap: anywhere;
  letter-spacing: 0;
}

.action-button span {
  color: var(--muted);
  font-size: 12px;
}

.action-button:hover:not(:disabled),
.action-button.selected {
  transform: translateY(-2px);
  box-shadow: 5px 5px 0 rgba(23, 33, 28, 0.12);
}

.action-button.selected {
  border-color: var(--toxin);
  background: #f1fbf5;
}

.action-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.result-zone {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(360px, 1.2fr);
  gap: 14px;
}

.settlement,
.battle-log {
  min-height: 146px;
  padding: 14px;
}

#settlement-text {
  margin: 10px 0;
  line-height: 1.65;
}

.state-id {
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: #f4f8f5;
  color: var(--muted);
  font-family: Consolas, "Courier New", monospace;
  overflow-wrap: anywhere;
}

.battle-log ol {
  min-height: 96px;
  max-height: 164px;
  margin: 10px 0 0;
  padding-left: 20px;
  overflow: auto;
}

.battle-log li {
  margin: 0 0 8px;
  line-height: 1.45;
}

.modal-backdrop {
  position: fixed;
  z-index: 20;
  inset: 0;
  background: rgba(23, 33, 28, 0.32);
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal-backdrop.hidden {
  display: none;
}

.round-modal {
  width: min(460px, 100%);
  padding: 24px;
  border: 2px solid var(--ink);
  background: #fff;
  box-shadow: 12px 12px 0 rgba(23, 33, 28, 0.22);
  animation: modalPop 260ms ease-out both;
}

.round-modal h2 {
  margin: 8px 0;
  font-size: 32px;
  letter-spacing: 0;
}

#modal-kicker,
#modal-detail {
  color: var(--muted);
}

.round-modal button {
  margin-top: 18px;
}

@keyframes cardFlip {
  0% {
    transform: rotateY(0deg) scale(1);
  }
  45% {
    transform: rotateY(86deg) scale(1.04);
  }
  100% {
    transform: rotateY(0deg) scale(1);
  }
}

@keyframes slashCut {
  0% {
    opacity: 0;
    transform: rotate(-14deg) scaleX(0);
  }
  35% {
    opacity: 1;
    transform: rotate(-14deg) scaleX(1);
  }
  100% {
    opacity: 0;
    transform: rotate(-14deg) scaleX(1.08) translateX(80px);
  }
}

@keyframes blastOut {
  0% {
    opacity: 0;
    transform: scale(0.2) rotate(0deg);
  }
  45% {
    opacity: 1;
    transform: scale(1.15) rotate(12deg);
  }
  100% {
    opacity: 0;
    transform: scale(1.8) rotate(24deg);
  }
}

@keyframes shieldPulse {
  0% {
    opacity: 0;
    transform: scale(0.4);
  }
  45% {
    opacity: 0.85;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.45);
  }
}

@keyframes trailShot {
  0% {
    opacity: 0;
    transform: scaleX(0);
  }
  25% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: scaleX(1);
  }
}

@keyframes gasBloom {
  0% {
    opacity: 0;
    transform: scale(0.35) translateY(24px);
  }
  42% {
    opacity: 0.9;
    transform: scale(1.1) translateY(0);
  }
  100% {
    opacity: 0;
    transform: scale(1.55) translateY(-16px);
  }
}

@keyframes serumDrop {
  0% {
    opacity: 0;
    transform: rotate(45deg) scale(0.35) translateY(-46px);
  }
  45% {
    opacity: 0.9;
    transform: rotate(45deg) scale(1) translateY(0);
  }
  100% {
    opacity: 0;
    transform: rotate(45deg) scale(1.28) translateY(18px);
  }
}

@keyframes chargeCard {
  0% {
    transform: translateY(0);
  }
  45% {
    transform: translateY(-8px);
    box-shadow: 10px 16px 0 rgba(44, 143, 87, 0.28);
  }
  100% {
    transform: translateY(0);
  }
}

@keyframes modalPop {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 1080px) {
  .match-header,
  .game-board,
  .result-zone {
    grid-template-columns: 1fr;
  }

  .game-board {
    min-height: auto;
  }

  .duel-row {
    min-height: 320px;
  }

  .action-grid {
    grid-template-columns: repeat(4, minmax(112px, 1fr));
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 18px, 1440px);
    padding-top: 12px;
  }

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

  .scoreboard section,
  .scoreboard section:last-child {
    grid-template-columns: auto auto 1fr;
    justify-items: start;
  }

  .round-badge {
    width: 100%;
  }

  .duel-row {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .duel-card {
    min-height: 156px;
  }

  .duel-card strong {
    font-size: 24px;
  }

  .versus {
    min-width: 0;
  }

  .action-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .seed-field {
    justify-content: space-between;
  }

  .seed-field input {
    width: min(180px, 55vw);
  }

  .action-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
}
