:root {
  color-scheme: dark;
  --ink: #f5f0df;
  --muted: #aeb8b5;
  --line: rgba(245, 240, 223, 0.16);
  --panel: rgba(18, 24, 28, 0.91);
  --blue: #4b8cff;
  --red: #ff5b68;
  --gold: #f0c15b;
  --community: #5865f2;
  --mint: #70d7b4;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #0c1115;
  color: var(--ink);
  font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
  user-select: none;
}

button {
  font: inherit;
  cursor: pointer;
}

.battle-shell {
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-columns: minmax(560px, 1fr) 410px;
  gap: 14px;
  padding: 14px;
  background:
    radial-gradient(circle at 20% 17%, rgba(88, 101, 242, 0.22), transparent 29%),
    linear-gradient(90deg, rgba(75, 140, 255, 0.12), transparent 36%),
    linear-gradient(270deg, rgba(255, 91, 104, 0.11), transparent 36%),
    #0c1115;
}

.arena-wrap,
.side-panel {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.arena-wrap {
  position: relative;
  overflow: hidden;
}

#arena {
  display: block;
  width: 100%;
  height: 100%;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(8px);
  max-width: calc(100% - 48px);
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(10, 14, 17, 0.9);
  color: var(--ink);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 150ms ease,
    transform 150ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.side-panel {
  padding: 14px;
  display: grid;
  grid-template-rows: auto auto auto auto auto auto auto auto minmax(0, 1fr);
  gap: 12px;
  overflow: auto;
}

.build-badge {
  width: fit-content;
  margin-bottom: 8px;
  padding: 5px 8px;
  border: 1px solid rgba(88, 101, 242, 0.55);
  border-radius: 7px;
  background: rgba(88, 101, 242, 0.16);
  color: #d9ddff;
  font-size: 11px;
  font-weight: 700;
}

.title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
}

.title-block h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 23px;
  letter-spacing: 0;
}

.title-block p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.language-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, 44px);
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
}

.language-switch button {
  min-width: 0;
  height: 44px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
}

.language-switch button[data-active="true"] {
  background: var(--community);
  color: #fff;
}

.share-card {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 8px;
  border: 1px solid rgba(112, 215, 180, 0.24);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(112, 215, 180, 0.12), transparent),
    rgba(255, 255, 255, 0.045);
}

.share-card div {
  min-width: 0;
}

.share-card span {
  display: block;
  color: var(--muted);
  font-size: 10px;
}

.share-card strong {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-size: 12px;
}

.player-panel {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.038);
}

.compact-panel {
  padding-top: 7px;
  padding-bottom: 7px;
}

.ally-panel {
  border-color: rgba(75, 140, 255, 0.38);
  background:
    linear-gradient(90deg, rgba(75, 140, 255, 0.13), transparent 72%),
    rgba(255, 255, 255, 0.038);
}

.enemy-panel {
  border-color: rgba(255, 91, 104, 0.4);
  background:
    linear-gradient(90deg, rgba(255, 91, 104, 0.14), transparent 72%),
    rgba(255, 255, 255, 0.038);
}

.control-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.control-row button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
}

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

.metric {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.055);
  padding: 7px 8px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.metric strong {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.status-line {
  min-height: 34px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.18);
  color: #ddd7c7;
  font-size: 12px;
  line-height: 1.45;
}

.section-label,
.hand-title {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.hand-title[data-side="blue"] b {
  color: #8bb6ff;
  text-shadow: 0 0 14px rgba(75, 140, 255, 0.35);
}

.hand-title[data-side="red"] b {
  color: #ff9aa4;
  text-shadow: 0 0 14px rgba(255, 91, 104, 0.35);
}

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

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

.card-button {
  position: relative;
  min-width: 0;
  height: 84px;
  border: 1px solid rgba(75, 140, 255, 0.26);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.065);
  color: var(--ink);
  padding: 9px;
  text-align: left;
  transition:
    border-color 120ms ease,
    transform 120ms ease,
    background 120ms ease;
}

.card-button:hover:not(:disabled),
.card-button[data-selected="true"] {
  border-color: rgba(75, 140, 255, 0.95);
  background:
    linear-gradient(90deg, rgba(75, 140, 255, 0.18), transparent),
    rgba(240, 193, 91, 0.12);
  box-shadow: inset 0 0 0 1px rgba(158, 197, 255, 0.28);
  transform: translateY(-1px);
}

.card-button:disabled {
  color: rgba(245, 240, 223, 0.42);
  cursor: not-allowed;
}

.card-cost {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #6540d8;
  color: #fff;
  font-weight: 800;
  font-size: 13px;
}

.card-glyph {
  position: relative;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 2px solid rgba(12, 18, 22, 0.74);
  border-radius: 8px;
  background: var(--card-color);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.2),
    inset 0 -4px 0 rgba(0, 0, 0, 0.12);
  overflow: hidden;
}

.card-icon--small {
  width: 24px;
  height: 24px;
  border-radius: 6px;
}

.card-icon--tiny {
  width: 18px;
  height: 18px;
  border-radius: 5px;
}

.card-icon--tank {
  width: 34px;
  height: 28px;
  border-radius: 5px;
}

.card-icon--tank.card-icon--small {
  width: 28px;
  height: 24px;
}

.card-icon--tank.card-icon--tiny {
  width: 21px;
  height: 17px;
}

.card-glyph-text {
  color: #11181d;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
}

.card-icon--small .card-glyph-text {
  font-size: 12px;
}

.card-icon--tiny .card-glyph-text {
  font-size: 10px;
}

.card-icon--bruiser {
  border-radius: 6px 6px 10px 10px;
  clip-path: polygon(0 100%, 11% 13%, 34% 35%, 50% 0, 66% 35%, 89% 13%, 100% 100%);
}

.card-icon--swarm {
  border-radius: 45% 55% 42% 58%;
}

.card-icon--rifleDuo {
  border-radius: 50%;
  box-shadow:
    inset 0 0 0 2px rgba(12, 18, 22, 0.28),
    inset 0 -4px 0 rgba(0, 0, 0, 0.12);
}

.card-icon--bomber {
  border-radius: 55% 45% 60% 40%;
  clip-path: polygon(50% 0, 82% 35%, 72% 100%, 28% 100%, 6% 55%);
}

.card-icon--runner {
  border-radius: 4px;
  clip-path: polygon(50% 0, 100% 78%, 50% 100%, 0 78%);
}

.card-icon--turret {
  border-radius: 4px;
  clip-path: polygon(8% 0, 92% 0, 100% 100%, 0 100%);
}

.card-icon--airstrike {
  border-radius: 4px;
  clip-path: polygon(50% 0, 62% 30%, 95% 15%, 75% 45%, 100% 56%, 68% 62%, 80% 100%, 50% 76%, 20% 100%, 32% 62%, 0 56%, 25% 45%, 5% 15%, 38% 30%);
}

.card-name,
.card-role {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-name {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 700;
}

.card-role {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.hand-card {
  min-width: 0;
  height: 54px;
  border: 1px solid rgba(255, 91, 104, 0.34);
  border-radius: 7px;
  background:
    linear-gradient(90deg, rgba(255, 91, 104, 0.13), transparent),
    rgba(255, 255, 255, 0.055);
  padding: 6px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 5px;
  align-items: center;
}

.hand-cost {
  grid-row: span 2;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #6540d8;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.hand-card .card-icon {
  align-self: center;
}

.hand-card em {
  grid-column: 1 / -1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-style: normal;
  font-size: 10px;
}

.queue {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.queue-chip {
  min-height: 28px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.queue-cost {
  min-width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: #6540d8;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
}

.check-list {
  display: grid;
  gap: 5px;
}

.check-row {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  padding: 5px 7px;
  border: 1px solid rgba(245, 240, 223, 0.1);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.045);
  font-size: 12px;
}

.check-row span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(174, 184, 181, 0.5);
}

.check-row b {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.check-row em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.check-row[data-status="pass"] {
  border-color: rgba(116, 218, 138, 0.35);
  background: rgba(116, 218, 138, 0.08);
}

.check-row[data-status="pass"] span {
  background: #74da8a;
  box-shadow: 0 0 12px rgba(116, 218, 138, 0.5);
}

.log-list {
  min-height: 0;
  overflow: hidden;
  display: grid;
  align-content: start;
  gap: 6px;
}

.log-line {
  min-height: 25px;
  padding: 6px 8px;
  border-left: 2px solid var(--gold);
  background: rgba(255, 255, 255, 0.045);
  color: #ddd7c7;
  font-size: 12px;
}

@media (max-width: 980px) {
  .battle-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(420px, 1fr) auto;
    overflow: auto;
  }

  body {
    overflow: auto;
  }
}
