:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c2430;
  --line: #2b3648;
  --text: #e6edf3;
  --muted: #8b98a9;
  --accent: #e8b04b;
  --accent-2: #6ea8ff;
  --danger: #ef6b73;
  --green: #54c08a;
  --white-side: #d9e2ef;
  --black-side: #b8a4ff;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(110, 168, 255, 0.12), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(232, 176, 75, 0.1), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}

#app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 18px 60px;
}

.hidden {
  display: none !important;
}

.screen {
  animation: fade 0.25s ease;
}

@keyframes fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

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

.logo {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: 1px;
  color: #111;
  background: linear-gradient(135deg, #f2c96b, #d18a2a);
  box-shadow: 0 12px 30px rgba(232, 176, 75, 0.25);
}

.logo.small {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  font-size: 12px;
}

h1, h2, h3 {
  margin: 0 0 8px;
  font-weight: 700;
}

h1 {
  font-size: 26px;
}

h2 {
  font-size: 20px;
}

h3 {
  font-size: 15px;
  color: var(--muted);
  margin-top: 20px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.card {
  margin-top: 26px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent), var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 10px 0 6px;
  letter-spacing: 0.04em;
}

input {
  width: 100%;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0b1017;
  color: var(--text);
  font-size: 15px;
  outline: none;
}

input:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(110, 168, 255, 0.15);
}

hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 20px 0;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: #46587a;
  background: #223047;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button.primary {
  background: linear-gradient(135deg, #f2c96b, #d18a2a);
  border-color: transparent;
  color: #181008;
}

button.primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #ffd77a, #e39a34);
}

button.danger {
  color: #ffb4b8;
  border-color: #5a2a30;
}

.msg {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.footnote {
  margin-top: 18px;
  color: #61708a;
  font-size: 12px;
  line-height: 1.7;
}

.code {
  font-family: "Cascadia Mono", Consolas, monospace;
  color: var(--accent);
  letter-spacing: 0.12em;
}

.players {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.player {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #0f151e;
  font-size: 13px;
}

.player.ready {
  border-color: rgba(84, 192, 138, 0.5);
  color: var(--green);
}

.roster {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.roster-card {
  border: 1px solid var(--line);
  background: #0f151e;
  border-radius: 12px;
  padding: 12px;
}

.roster-card b {
  display: block;
  margin-bottom: 4px;
}

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

/* ---------- game ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
}

.room {
  font-size: 14px;
}

.round {
  font-size: 15px;
  color: var(--muted);
  white-space: nowrap;
}

.turn-info {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}

.team {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 12px;
}

.team.white {
  box-shadow: inset 0 2px 0 rgba(217, 226, 239, 0.2);
}

.team.black {
  box-shadow: inset 0 2px 0 rgba(184, 164, 255, 0.25);
}

.team-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--muted);
}

.team.white .team-title b { color: var(--white-side); }
.team.black .team-title b { color: var(--black-side); }

.char {
  position: relative;
  border: 1px solid var(--line);
  background: #0f151e;
  border-radius: 12px;
  padding: 10px 11px;
  margin-bottom: 9px;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.char:last-child {
  margin-bottom: 0;
}

.char.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(232, 176, 75, 0.18);
  background: #151a21;
}

.char.dead {
  opacity: 0.42;
  filter: grayscale(0.7);
}

.char.targetable {
  cursor: pointer;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 2px rgba(110, 168, 255, 0.25);
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(110, 168, 255, 0.2); }
  50% { box-shadow: 0 0 0 4px rgba(110, 168, 255, 0.35); }
}

.char-head {
  display: flex;
  align-items: center;
  gap: 9px;
}

.portrait {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: #0b1017;
  flex: 0 0 auto;
}

.char-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.char-head .name {
  font-weight: 700;
  font-size: 14px;
  min-width: 0;
}

.char-head .name small {
  color: var(--muted);
  font-weight: 400;
  font-size: 11px;
  margin-left: 6px;
}

.char-head .speed {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.float-text {
  position: absolute;
  right: 12px;
  top: 10px;
  font-weight: 800;
  font-size: 18px;
  pointer-events: none;
  animation: floatUp 1s ease-out forwards;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.65);
  z-index: 5;
}

.float-text.damage { color: #ff8a8a; }
.float-text.heal { color: #8ef0b4; }
.float-text.death { color: #ffd479; font-size: 14px; }

@keyframes floatUp {
  0% { opacity: 0; transform: translateY(6px) scale(0.9); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-28px) scale(1.05); }
}

@keyframes hitShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}

.char.hit { animation: hitShake 0.32s ease; }

.hpbar {
  height: 7px;
  border-radius: 999px;
  background: #080c12;
  overflow: hidden;
  margin: 7px 0 4px;
}

.hpbar > div {
  height: 100%;
  background: linear-gradient(90deg, #4bc58a, #9be15d);
  transition: width 0.25s ease;
}

.hpbar > div.low {
  background: linear-gradient(90deg, #e05d66, #ff9a6b);
}

.hp-text {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
}

.statuses {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 7px;
  min-height: 4px;
}

.chip {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #121a25;
  color: #b9c6d8;
}

.chip.buff {
  border-color: rgba(84, 192, 138, 0.35);
  color: #9fe0bd;
}

.chip.debuff {
  border-color: rgba(239, 107, 115, 0.4);
  color: #ffb0b4;
}

.skills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 7px;
}

.skill-pill {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 6px;
  background: #0b1017;
  border: 1px solid #223047;
  color: #8fa4c2;
}

.skill-pill.cd {
  color: #6b7890;
  border-color: #1b2636;
}

.tactical {
  margin-top: 7px;
  font-size: 11px;
  color: var(--accent);
}

.charging {
  margin-top: 6px;
  font-size: 11px;
  color: var(--accent-2);
}

.turn-order {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.order-label {
  font-size: 12px;
  color: var(--muted);
  margin-right: 4px;
  align-self: center;
}

.order-chip {
  font-size: 12px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #0f151e;
}

.order-chip.active {
  border-color: var(--accent);
  color: var(--accent);
}

.order-chip.dead {
  opacity: 0.35;
  text-decoration: line-through;
}

.actions {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  min-height: 76px;
}

.action-title {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}

.action-title b {
  color: var(--accent);
}

.action-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.action-btn {
  text-align: left;
  padding: 9px 12px;
  border-radius: 10px;
  line-height: 1.35;
}

.action-btn .sub {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  margin-top: 2px;
}

.action-btn.charge {
  border-color: #5a4a22;
  color: #e8c887;
}

.action-btn.ultimate {
  border-color: #5a4a22;
  background: #1d1a12;
  color: #f2d28a;
}

.action-btn.tactical {
  border-color: #2f4a66;
  color: #a9c8ee;
}

.waiting {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-2);
  animation: blink 1s infinite;
}

@keyframes blink {
  50% { opacity: 0.3; }
}

.log {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0b1017;
  max-height: 220px;
  overflow: auto;
  font-size: 12px;
  line-height: 1.7;
  color: #9fb0c6;
}

.log-line {
  border-bottom: 1px dashed rgba(43, 54, 72, 0.6);
  padding: 2px 0;
}

.log-line:last-child {
  border-bottom: none;
}

.winner {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: #2a1520;
  border: 1px solid #5a2a30;
  color: #ffb4b8;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4);
  z-index: 50;
}

@media (max-width: 860px) {
  .board {
    grid-template-columns: 1fr;
  }
  .topbar {
    flex-wrap: wrap;
  }
  .turn-info {
    width: 100%;
  }
}

/* ---------------- BP ---------------- */

.bp-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 14px;
  margin-top: 14px;
}

.bp-main,
.bp-log-card {
  margin-top: 0;
}

.bp-selected {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 12px 0;
}

.bp-selected-col h3 {
  margin: 8px 0 4px;
  font-size: 12px;
  color: var(--muted);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 22px;
}

.bp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  max-height: 420px;
  overflow: auto;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0b1017;
}

.bp-card {
  border: 1px solid var(--line);
  background: #0f151e;
  border-radius: 10px;
  padding: 9px;
}

.bp-card.selected-ban {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px rgba(239, 107, 115, 0.3);
}

.bp-card.selected-pick {
  border-color: var(--green);
  box-shadow: 0 0 0 1px rgba(84, 192, 138, 0.3);
}

.bp-card-top {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  align-items: baseline;
}

.bp-card-top b {
  font-size: 13px;
}

.bp-card-top span {
  font-size: 10px;
  color: var(--muted);
}

.bp-card-sub {
  font-size: 10px;
  color: var(--muted);
  margin: 4px 0 6px;
}

.bp-card-actions {
  display: flex;
  gap: 4px;
}

.bp-card-actions button {
  flex: 1;
  padding: 4px 6px;
  font-size: 11px;
}

.bp-card-actions button[data-bp="ban"] {
  color: #ffb4b8;
  border-color: #5a2a30;
}

.bp-card-actions button[data-bp="pick"] {
  color: #9fe0bd;
  border-color: #2c5a42;
}

.bp-card-actions button:disabled {
  opacity: 0.3;
}

/* ---------------- positions ---------------- */

.position-slots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.position-slot {
  border: 1px solid var(--line);
  background: #0f151e;
  border-radius: 12px;
  padding: 12px;
}

.slot-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

.slot-title span {
  color: var(--muted);
  font-weight: 400;
  font-size: 11px;
  margin-left: 6px;
}

.position-slot select {
  width: 100%;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0b1017;
  color: var(--text);
  font-size: 14px;
}

.position-row {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
}

@media (max-width: 860px) {
  .bp-layout {
    grid-template-columns: 1fr;
  }
  .bp-selected {
    grid-template-columns: 1fr;
  }
}

/* ---------------- eyes / free tactical ---------------- */

.skill-pill.eye-pill {
  border-color: #6b5a2a;
  color: #f2d58a;
}

.action-btn.eye {
  border-color: #6b5a2a;
  background: linear-gradient(180deg, #2a2314, #17130b);
}

.action-btn.eye .sub {
  color: #c9b27a;
}

.action-hint {
  font-size: 11px;
  color: var(--muted);
  margin: -2px 0 8px;
}

/* ---------------- preparation ---------------- */

.prep-list {
  display: grid;
  gap: 8px;
}

.prep-char {
  border: 1px solid var(--line);
  background: #0f151e;
  border-radius: 10px;
  padding: 10px;
}

.prep-char-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  margin-bottom: 6px;
}

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

.prep-btns button {
  padding: 6px 8px;
  font-size: 11px;
}

/* ---------------- admin / dev ---------------- */

select {
  width: 100%;
  padding: 10px 11px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0b1017;
  color: var(--text);
  font-size: 14px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 10px 0;
}

.admin-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}

.admin-skill {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 110px;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  padding: 8px;
  border-radius: 8px;
  margin: 6px 0;
}

.admin-skill b {
  font-size: 13px;
}

.admin-skill label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 10px;
  color: var(--muted);
}

.dev-link {
  color: var(--muted);
  font-size: 11px;
}

/* ---------------- prediction ---------------- */

.prediction-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin: 10px 0;
}

.prediction-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}

/* ---------------- training ---------------- */

.training-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 12px 0;
}

.training-columns h3 {
  margin: 0 0 6px;
  font-size: 13px;
}

.training-columns .chips {
  min-height: 34px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b1017;
}

.chip button {
  margin-left: 4px;
  padding: 0 4px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.training-stats {
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(17, 24, 33, 0.9);
}

.training-stats-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.training-stats-head b {
  color: var(--text);
  font-size: 13px;
}

.training-stats table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.training-stats th,
.training-stats td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--line);
  text-align: right;
}

.training-stats th:first-child,
.training-stats td:first-child {
  text-align: left;
  color: var(--muted);
}

@media (max-width: 720px) {
  .training-columns {
    grid-template-columns: 1fr;
  }
}
