@charset "UTF-8";

:root {
  color-scheme: dark;
  --bg: #0b121a;
  --panel: #131e29;
  --line: #304250;
  --text: #f1f6fa;
  --muted: #bccad5;
  --mint: #b4f5bf;
  --wood: #8cdda8;
  --fire: #ffab8f;
  --earth: #f4ca82;
  --metal: #e0d3ff;
  --water: #9ce5ff;
  font: 16px/1.5 "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: radial-gradient(ellipse at 42% 0, #1a302f, transparent 880px), var(--bg);
  color: var(--text);
}

button, input, select { font: inherit; }
button {
  cursor: pointer;
  color: inherit;
  border: 1px solid transparent;
}
button:disabled { cursor: not-allowed; opacity: .53; }
button:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 3px;
}
input, select {
  width: 100%;
  color: var(--text);
  background: #0f1822;
  border: 1px solid #405766;
  border-radius: 9px;
  padding: 10px 12px;
}
h1, h2, h3, p { margin: 0; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.app-shell { width: min(100%, 1540px); padding: 0 clamp(12px, 3vw, 42px) 26px; margin: auto; }
.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}
.brand, .top-tools, .mode-nav, .online-indicator, .round-counter, .arena-tools, .room-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand h1 { font-size: clamp(20px, 2.4vw, 28px); white-space: nowrap; letter-spacing: .055em; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  border-radius: 12px;
  color: #102522;
  background: linear-gradient(150deg, #e3ffe5, #8de8aa);
  box-shadow: 0 0 28px #77dfa930;
  font-size: 25px;
  font-weight: 800;
}
.nav-button, .small-button, .secondary-button {
  min-height: 42px;
  border-radius: 9px;
  background: #182735;
  padding: 8px 14px;
  font-weight: 650;
}
.nav-button { background: transparent; color: var(--muted); }
.nav-button.active, .command-tabs button.active {
  color: var(--mint);
  background: #294437;
  border-color: #5e8872;
}
.small-button, .secondary-button { border-color: var(--line); font-size: 14px; white-space: nowrap; }
.small-button:hover:not(:disabled), .nav-button:hover:not(:disabled), .secondary-button:hover:not(:disabled) { border-color: #90b4b2; }
.mint { background: var(--mint); color: #142822; border-color: var(--mint); }
.subtle { background: transparent; }
.online-indicator { color: var(--muted); font-size: 14px; }
.live-dot, .online-indicator i, .ready-dots i {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background: var(--mint);
  box-shadow: 0 0 9px #b4f5bf70;
}
.room-strip {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  background: #152925;
  border: 1px solid #3e6658;
  border-radius: 12px;
  padding: 11px 14px;
  margin-bottom: 14px;
}
.room-identity { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
#room-code { color: var(--mint); letter-spacing: .11em; font-size: 23px; }
#room-hint { color: var(--muted); font-size: 14px; }
.room-buttons { flex-wrap: wrap; }

.battle-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(222px, 23%, 300px);
  grid-template-areas: "arena side" "commands side";
  align-items: start;
  gap: 14px;
}
.arena-panel, .command-panel, .roster-panel, .log-panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 13px;
}
.arena-panel { grid-area: arena; overflow: hidden; }
.arena-toolbar, .arena-statusbar {
  min-height: 48px;
  padding: 8px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px 14px;
  background: #17232d;
}
.arena-statusbar { min-height: 44px; border-top: 1px solid var(--line); }
.round-counter { color: var(--muted); font-size: 15px; white-space: nowrap; }
.round-counter strong { color: var(--mint); font-size: 24px; line-height: 1; font-variant-numeric: tabular-nums; }
#round-phase { border-left: 1px solid var(--line); padding-left: 10px; }
.battle-arena {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  height: clamp(258px, calc(100dvh - 431px), 490px);
  background: #111d23;
  scroll-margin-top: 10px;
}
.battle-arena::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: url("assets/moonlit-arena.jpg") center 32% / cover no-repeat;
  pointer-events: none;
}
.battle-arena.is-resolving .arena-vignette {
  background: radial-gradient(ellipse at 50% 55%, transparent 25%, #03091790 100%);
}
.arena-vignette, .arena-players, #battle-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.arena-vignette { z-index: 2; background: linear-gradient(#07121b25, transparent 30%, transparent 62%, #080f2077); }
.arena-status, .ready-progress { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 14px; }
.ready-dots { display: flex; gap: 4px; }
.ready-dots i { width: 6px; height: 6px; flex-basis: 6px; background: #485968; box-shadow: none; }
.ready-dots i.on { background: var(--mint); }

.sidebar { grid-area: side; min-width: 0; display: grid; gap: 14px; }
.roster-panel, .log-panel { overflow: hidden; }
.panel-heading { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { font-size: 18px; }
#living-count { color: var(--mint); margin-left: 5px; font-size: 15px; }
.player-roster, .battle-log { max-height: 294px; overflow: auto; scrollbar-width: thin; scrollbar-color: #5a7479 transparent; }
.player-roster { padding: 2px 12px; }
.roster-player { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid #ffffff13; }
.roster-player:last-child { border-bottom: none; }
.roster-player.eliminated { opacity: .58; }
.roster-element {
  flex: 0 0 35px;
  width: 35px;
  height: 35px;
  border: 1px solid color-mix(in srgb, var(--element-color) 55%, #182735);
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 750;
  color: var(--element-color);
  background: color-mix(in srgb, var(--element-color) 12%, #182735);
}
.roster-body { min-width: 0; flex: 1; }
.roster-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 700; }
.you-label { color: var(--mint); font-size: 12px; margin-left: 6px; }
.roster-meta, .roster-energy small { font-size: 13px; color: var(--muted); }
.roster-energy { text-align: right; color: var(--mint); flex-shrink: 0; }
.roster-energy small { display: block; }
.element-cycle { padding: 10px 13px 13px; background: #0f1a24; border-top: 1px solid var(--line); }
.element-cycle p { color: var(--muted); font-size: 14px; margin-bottom: 6px; }
.element-cycle div { display: flex; align-items: baseline; justify-content: space-between; gap: 4px; }
.element-cycle i { font-style: normal; color: #9aadb8; }
.wood { color: var(--wood); } .fire { color: var(--fire); } .earth { color: var(--earth); }
.metal { color: var(--metal); } .water { color: var(--water); }
.battle-log { padding: 10px 13px; min-height: 83px; }
.log-entry { color: var(--text); border-left: 2px solid #5f8296; padding-left: 8px; margin-bottom: 9px; font-size: 14px; overflow-wrap: anywhere; }
.log-entry time { display: block; font-size: 12px; color: var(--muted); }
.log-entry.death { color: #ffd0c2; border-color: #ff997d; }
.log-entry.gain { color: #ccfdd0; border-color: var(--mint); }

.command-panel { grid-area: commands; padding: 13px; }
.command-heading, .command-options-row, .command-footer, .command-player, .command-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.command-heading { flex-wrap: wrap; }
.command-player { justify-content: start; min-width: 0; }
.command-player h2 { font-size: clamp(17px, 1.8vw, 22px); overflow-wrap: anywhere; }
.command-sigil { display: grid; place-items: center; min-width: 35px; height: 35px; border-radius: 9px; background: #233844; font-weight: 750; }
.energy-display { color: var(--muted); white-space: nowrap; }
.energy-display b { font-size: 24px; color: var(--mint); margin-left: 4px; }
.command-options-row { flex-wrap: wrap; margin: 10px 0; }
.command-tabs, .level-control { display: flex; align-items: center; gap: 5px; }
.command-tabs button, .level-control button {
  background: #20313e;
  border-color: #344959;
  border-radius: 8px;
  min-width: 48px;
  min-height: 43px;
  padding: 4px 12px;
  font-size: 16px;
  font-weight: 650;
}
.level-control { color: var(--muted); }
.level-control button { min-width: 42px; padding: 4px 8px; }
.level-control input { width: 60px; min-height: 43px; padding: 4px; text-align: center; appearance: textfield; }
.level-control input::-webkit-inner-spin-button { appearance: none; }

.skill-cards { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.skill-card {
  text-align: left;
  min-width: 0;
  min-height: 112px;
  border-radius: 10px;
  padding: 10px 9px;
  color: var(--text);
  border-color: color-mix(in srgb, var(--element-color) 28%, #273641);
  background: radial-gradient(ellipse at 80% 0, color-mix(in srgb, var(--element-color) 21%, #16232d), #17242f 82%);
  transition: box-shadow .17s ease, border-color .17s ease, background .17s ease;
}
.skill-card:hover:not(:disabled), .skill-card.selected { border-color: var(--element-color); }
.skill-card.selected { box-shadow: inset 0 0 0 1px var(--element-color), 0 0 14px color-mix(in srgb, var(--element-color) 22%, transparent); }
.skill-top, .skill-bottom { display: flex; align-items: center; justify-content: space-between; gap: 4px; color: var(--element-color); }
.skill-icon { display: grid; place-items: center; font-size: 21px; line-height: 1; min-width: 28px; height: 28px; border-radius: 7px; background: #0c1725a0; }
.skill-rank, .skill-bottom { font-size: 13px; line-height: 1.3; font-weight: 600; }
.skill-card h3 { font-size: 17px; line-height: 1.35; margin: 7px 0 7px; overflow-wrap: anywhere; }
.skill-card p { display: none; }
.skill-bottom { flex-wrap: wrap; }
.skill-cost { color: var(--text); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.gather-card { grid-column: 1 / -1; min-height: 95px; display: flex; align-items: center; gap: 12px; padding: 12px; }
.gather-card .skill-top { flex-direction: column; gap: 5px; }
.gather-card .skill-icon { width: 37px; height: 37px; }
.gather-card h3 { margin-top: 0; }
.gather-card p { display: block; color: var(--muted); font-size: 14px; }
.gather-card .skill-bottom { margin-left: auto; justify-content: flex-end; }
.command-footer { flex-wrap: wrap; margin-top: 10px; }
#selection-hint { flex: 1 1 195px; font-size: 15px; color: var(--muted); overflow-wrap: anywhere; }
#selection-hint span { color: var(--mint); margin-right: 8px; }
.command-actions { margin-left: auto; }
.turn-timer { font-weight: 750; color: #fcdb9a; font-variant-numeric: tabular-nums; white-space: nowrap; }
.turn-timer.urgent { color: #ffab91; }
.lock-button {
  min-height: 46px;
  padding: 9px 17px;
  border-radius: 9px;
  color: #13251c;
  background: linear-gradient(120deg, #e5ffd0, #93eab9);
  box-shadow: 0 3px 18px #8ef2b72b;
  font-size: 17px;
  font-weight: 800;
}
.lock-button:hover:not(:disabled) { background: #d8ffcd; }
.lock-button span { margin-left: 12px; }
.online-link { display: block; text-align: center; text-decoration: none; }

.modal {
  width: min(485px, calc(100vw - 24px));
  max-height: calc(100dvh - 26px);
  overflow: auto;
  position: fixed;
  border: 1px solid #526f7b;
  border-radius: 17px;
  background: #16232f;
  color: var(--text);
  padding: clamp(20px, 4vw, 30px);
  box-shadow: 0 18px 70px #0009;
}
.modal::backdrop { background: #030812c9; backdrop-filter: blur(5px); }
.modal h2 { margin: 0 35px 10px 0; font-size: 25px; }
.modal p { color: var(--muted); font-size: 16px; }
.modal label { display: block; margin: 13px 0; }
.modal label input, .modal label select { display: block; margin-top: 5px; }
.modal-close { position: absolute; top: 7px; right: 7px; width: 42px; height: 42px; font-size: 27px; background: transparent; border-radius: 8px; }
.modal-close:hover { background: #ffffff14; }
.full { width: 100%; margin-top: 9px; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.form-error:not(:empty), .form-feedback:not(:empty) { margin-top: 12px; color: #ffd0b8; }
.form-feedback:not(:empty) { color: var(--mint); }
.wide-modal { width: min(850px, calc(100vw - 24px)); }
.rules-grid, .catalog-content { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 18px; }
.rules-grid article, .catalog-column { padding: 12px; border-radius: 9px; background: #101c27; }
.rules-grid h3 { font-size: 18px; margin-bottom: 5px; }
.rule-note { margin-top: 12px; }
.catalog-content { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.catalog-column { border-top: 3px solid var(--element-color); }
.catalog-column h3, .catalog-group-title { color: var(--element-color); }
.catalog-group-title { margin: 10px 0 5px; font-size: 14px; }
.catalog-item { margin: 5px 0 8px; }
.catalog-item strong { display: block; font-size: 16px; }
.catalog-item span { font-size: 14px; color: var(--muted); }
.handoff-modal { text-align: center; }
.handoff-modal h2 { margin-right: 0; }
.toast {
  position: fixed;
  z-index: 90;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 28px);
  border: 1px solid #71968c;
  padding: 10px 15px;
  border-radius: 9px;
  color: var(--text);
  background: #203b35;
  box-shadow: 0 10px 35px #0008;
}

@media (min-width: 941px) and (max-height: 780px) {
  .topbar { min-height: 63px; margin-bottom: 13px; }
  .battle-layout { gap: 11px; }
  .skill-card { min-height: 100px; }
}
@media (max-width: 940px) {
  .online-indicator { display: none; }
  .battle-layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "arena" "commands" "side"; }
  .sidebar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .battle-arena { height: clamp(270px, 42vw, 410px); }
  .topbar { margin-bottom: 12px; }
}
@media (max-width: 580px) {
  .topbar { flex-wrap: wrap; justify-content: space-between; gap: 7px 9px; padding: 10px 0 8px; }
  .brand-mark { width: 34px; height: 34px; font-size: 21px; border-radius: 9px; }
  .brand { gap: 7px; }
  .top-tools { gap: 5px; }
  .top-tools button { padding: 6px 9px; }
  .mode-nav { order: 3; width: 100%; }
  .mode-nav button { flex: 1; }
  .arena-toolbar, .arena-statusbar { padding: 6px 8px; gap: 5px; }
  .arena-tools, .round-counter { gap: 5px; }
  .round-counter { font-size: 13px; }
  #round-phase { padding-left: 5px; }
  .arena-tools button { min-height: 36px; padding: 5px 7px; font-size: 13px; }
  .battle-arena { height: 267px; }
  .arena-status, .ready-progress { font-size: 13px; }
  .ready-dots { display: none; }
  .skill-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
  .skill-card { min-height: 94px; }
  .skill-card h3 { font-size: 16px; }
  .command-tabs button { padding: 4px 9px; min-width: 43px; }
  .level-control input { width: 43px; }
  .level-control button { min-width: 35px; }
  .command-panel { padding: 10px; }
  .sidebar { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .player-roster { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 10px; }
  .roster-player { gap: 6px; }
  .roster-element { flex-basis: 26px; width: 26px; height: 28px; }
  .roster-name, .roster-energy { font-size: 14px; }
  .roster-meta, .roster-energy small { font-size: 12px; }
  .rules-grid { grid-template-columns: minmax(0, 1fr); }
  .catalog-content { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
