:root {
  color-scheme: dark;
  --bg: #0b1020;
  --panel: rgba(14, 20, 38, 0.82);
  --line: rgba(255, 255, 255, 0.1);
  --text: #e8ecf6;
  --muted: #9ea8c6;
  --accent: #7ee0ff;
  --accent-2: #b59dff;
  --danger: #ff9c9c;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --radius-xl: 18px;
  --radius-lg: 13px;
  --radius-md: 10px;
  --radius-sm: 7px;
  --card-width: 180px;
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun", serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(126, 224, 255, 0.18), transparent 30%),
    radial-gradient(circle at 85% 12%, rgba(181, 157, 255, 0.16), transparent 24%),
    radial-gradient(circle at 50% 100%, rgba(124, 240, 176, 0.1), transparent 22%),
    linear-gradient(180deg, #090d19 0%, #0b1020 54%, #090d17 100%);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent 88%);
  opacity: 0.35;
}
button, input, select, textarea { font: inherit; }
select option { background: #101827; color: #eef6ff; }
.app-shell { position: relative; width: min(1460px, calc(100vw - 18px)); margin: 0 auto; padding: 22px 7px 16px; }
.app-toolbar { position: relative; z-index: 20; }
.page-auth-actions {
  position: absolute;
  top: 0;
  right: 7px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  z-index: 30;
}
.app-toolbar,
.frontline-panel,
.turn-panel,
.control-panel,
.detail-panel,
.modal,
.picker-card,
.skill-item {
  backdrop-filter: blur(18px);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.app-toolbar,
.frontline-panel,
.turn-panel,
.workspace-shell { margin-bottom: 6px; }
.plan-bar {
  display: grid;
  grid-template-columns: minmax(420px, 0.95fr) minmax(520px, 1.05fr);
  gap: 6px;
  align-items: start;
  padding: 8px;
  border-radius: var(--radius-xl);
  background: rgba(14, 20, 38, 0.72);
}

.plan-section-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(6, 10, 20, 0.18));
}

.plan-section-grid {
  display: grid;
  gap: 6px;
  min-width: 0;
  align-items: start;
}

.plan-section-grid-plan {
  grid-template-columns:
    minmax(150px, 1fr)
    minmax(150px, 1fr)
    auto;
}

.plan-section-grid-boss {
  grid-template-columns:
    minmax(120px, 1fr)
    minmax(120px, 1fr)
    74px
    minmax(150px, 1.1fr);
}

.plan-field,
.panel-section,
.field { display: grid; gap: 4px; min-width: 0; }

.plan-actions { display: flex; align-items: end; gap: 4px; min-width: 0; padding-top: 14px; }

.plan-field label,
.plan-actions-label,
.field label {
  font-size: 10px;
  line-height: 1;
  color: var(--muted);
  font-weight: 700;
}

.plan-actions-label { display: none; }

.input,
.select {
  width: 100%;
  min-width: 0;
  height: 32px;
  padding: 0 9px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(9, 14, 28, 0.9);
  color: var(--text);
  outline: none;
  font-size: 11px;
}

.input:focus,
.select:focus {
  border-color: rgba(126, 224, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(126, 224, 255, 0.12);
}

.card-actions,
.picker-meta-row,
.effect-row,
.frontline-skill-buffs,
.turn-skill-buffs,
.turn-skill-effects {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}

.picker-chip-row { display: flex; align-items: center; gap: 4px; min-width: 0; overflow: hidden; white-space: nowrap; }

.plan-actions > button { align-self: end; height: 32px; white-space: nowrap; }
.plan-bar .plan-actions > button { height: 26px; min-height: 26px; padding: 0 6px; border-radius: 7px; font-size: 11px; line-height: 1; }

.turn-total,
.modal-summary-chip,
.picker-chip,
.tag,
.turn-skill-cost,
.turn-skill-bp,
.turn-hp-select,
.turn-skill-power,
.turn-skill-hit-inline,
.turn-skill-damage,
.turn-skill-effect,
.skill-flag {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 8px;
  line-height: 1.2;
  white-space: nowrap;
}

.tag,
.picker-chip,
.skill-flag,
.turn-skill-effect {
  background: rgba(126, 224, 255, 0.12);
  border: 1px solid rgba(126, 224, 255, 0.18);
  color: #dffbff;
}

.picker-job-chip {
  min-height: 20px;
  padding: 0 7px;
  border-radius: 5px;
  background: linear-gradient(180deg, rgba(255, 193, 107, 0.22), rgba(255, 193, 107, 0.1));
  border-color: rgba(255, 193, 107, 0.42);
  color: #ffe7bd;
  font-size: 9px;
  font-weight: 800;
}

.turn-skill-bp,
.turn-hp-select { background: rgba(181, 157, 255, 0.12); border: 1px solid rgba(181, 157, 255, 0.22); color: #d7ccff; }

.turn-skill-cost {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e8ecf6;
}

.turn-skill-power {
  background: rgba(255, 193, 107, 0.12);
  border: 1px solid rgba(255, 193, 107, 0.22);
  color: #ffe5b8;
}

.turn-skill-hit-inline {
  background: rgba(255, 168, 168, 0.12);
  border: 1px solid rgba(255, 168, 168, 0.22);
  color: #ffd6d6;
}

.turn-skill-damage,
.damage-tag {
  background: rgba(255, 156, 126, 0.14);
  border: 1px solid rgba(255, 156, 126, 0.22);
  color: #ffd5c8;
}

.turn-skill-formula-tag,
.skill-tag {
  background: rgba(181, 157, 255, 0.12);
  border-color: rgba(181, 157, 255, 0.22);
  color: #e9e2ff;
}
.turn-skill-formula-tag { cursor: pointer; }

.muted,
.current-character-label,
.toolbar {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.tiny-btn,
.action-btn,
.ghost-btn,
.picker-confirm,
.main-close {
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
}

.tiny-btn,
.action-btn,
.ghost-btn {
  min-height: 24px;
  padding: 0 7px;
  border-radius: 8px;
}

.tiny-btn,
.ghost-btn,
.main-close {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.action-btn {
  background: linear-gradient(135deg, rgba(126, 224, 255, 0.28), rgba(181, 157, 255, 0.24));
  color: #f7fbff;
  border-color: rgba(126, 224, 255, 0.26);
}

.danger-btn {
  color: #ffd6d6;
  border-color: rgba(255, 156, 156, 0.22);
  background: rgba(255, 156, 156, 0.08);
}

.auth-mini-btn {
  min-height: 18px;
  padding: 0 2px;
  font-size: 10px;
  border: 0;
  background: transparent;
  color: #d9e5ff;
  border-radius: 0;
}

.auth-mini-btn:hover {
  color: #ffffff;
  text-decoration: underline;
  background: transparent;
}

.toolbar-weaknesses { position: relative; z-index: 21; min-height: 32px; align-content: center; width: 100%; }

.frontline-panel,
.turn-panel {
  padding: 6px;
  border-radius: var(--radius-xl);
  background: rgba(14, 20, 38, 0.72);
  overflow-x: auto;
}

.frontline-table,
.turn-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}

.frontline-table th,
.frontline-table td,
.turn-table th,
.turn-table td {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  padding: 2px;
  text-align: left;
  vertical-align: top;
  font-size: 10px;
  overflow: hidden;
}

.frontline-table th,
.turn-table th {
  background: rgba(126, 224, 255, 0.08);
  color: #e7fbff;
  font-weight: 700;
}

.frontline-card {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  min-width: 0;
}

.frontline-portrait,
.turn-slot-portrait,
.picker-portrait {
  object-fit: cover;
  image-rendering: pixelated;
  display: block;
  flex: none;
}

.frontline-portrait { width: 20px; height: 20px; border-radius: 4px; }
.frontline-name,
.turn-slot-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.frontline-name { font-size: 9px; line-height: 1.1; color: #f3f7ff; }
.frontline-empty,
.turn-empty-text { color: rgba(223, 251, 255, 0.42); font-size: 9px; }

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

.frontline-buff-zone,
.formula-box,
.picker-stat-item,
.picker-detail,
.skill-item {
  padding: 6px 7px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

.frontline-buff-zone strong {
  display: block;
  margin-bottom: 2px;
  font-size: 9px;
  color: #e7fbff;
}

.turn-table-toolbar,
.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}

.turn-table-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 10px;
  margin-bottom: 6px;
  padding: 5px 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 14px;
}

.turn-table-turn-control {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  flex: 0 0 auto;
  flex-wrap: nowrap;
}

.turn-table-turn-control > span { color: var(--muted); font-size: 10px; font-weight: 700; white-space: nowrap; }

.turn-total {
  min-height: 24px;
  padding: 0 7px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #dffbff;
  font-size: 10px;
  white-space: nowrap;
}

.turn-damage-panel {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
}

.turn-damage-lines {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
}

.turn-damage-line {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  min-height: 24px;
  font-size: 10px;
  line-height: 1;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(10, 15, 28, 0.55);
}

.turn-damage-line-total {
  color: #eef6ff;
  font-weight: 700;
}

.turn-damage-operator {
  color: var(--muted);
  font-weight: 500;
}

.turn-damage-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  border: 1px solid rgba(181, 157, 255, 0.22);
  background: rgba(181, 157, 255, 0.12);
  color: #e9e2ff;
  font: inherit;
  cursor: pointer;
}

.damage-tooltip-panel {
  display: grid;
  grid-template-columns: minmax(300px, 1.05fr) minmax(260px, 0.95fr);
  gap: 6px;
  width: min(760px, calc(100vw - 24px));
  max-width: 760px;
  font-size: 10px;
}

.damage-tooltip-main { display: grid; gap: 4px; min-width: 0; }

.damage-tooltip-side { display: grid; align-content: start; gap: 4px; min-width: 0; }

.damage-tooltip-box-title {
  color: #f3f7ff;
  font-weight: 700;
}

.damage-tooltip-box {
  display: grid;
  gap: 3px;
  padding: 5px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

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

.damage-tooltip-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.damage-tooltip-row span {
  color: #9fb0cf;
}

.damage-tooltip-row strong,
.damage-tooltip-result {
  color: #f3f7ff;
  font-weight: 700;
}

.damage-tooltip-text {
  color: #d7e3f8;
  line-height: 1.25;
}

.damage-tooltip-center {
  text-align: center;
  font-weight: 700;
}

.damage-tooltip-result {
  padding: 5px 7px;
  border-radius: 8px;
  border: 1px solid rgba(126, 224, 255, 0.16);
  background: linear-gradient(180deg, rgba(9, 15, 27, 0.98), rgba(16, 24, 42, 0.96));
  text-align: center;
  font-size: 13px;
}

.damage-tooltip-formula-result {
  padding: 5px 7px;
  color: #d7e3f8;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 10px;
  line-height: 1.25;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
}

.damage-tooltip-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
}

.damage-tooltip-table th,
.damage-tooltip-table td {
  padding: 2px 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
}

.damage-tooltip-table th {
  color: #e7fbff;
  background: rgba(126, 224, 255, 0.08);
}

.damage-tooltip-flow {
  align-content: start;
  min-width: 0;
}

.damage-flow-list {
  display: grid;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
}

.damage-flow-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: baseline;
  padding: 5px 7px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.damage-flow-row:last-child {
  border-bottom: 0;
}

.damage-flow-row span {
  color: #d7e3f8;
  min-width: 0;
}

.damage-flow-row strong {
  color: #f3f7ff;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

#app-tooltip.rich-tooltip {
  max-width: min(780px, calc(100vw - 18px)) !important;
  max-height: calc(100vh - 24px);
  white-space: normal !important;
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  overflow: auto;
  padding: 28px 10px 10px;
}

@media (max-width: 860px) {
  .damage-tooltip-panel {
    grid-template-columns: 1fr;
    width: min(520px, calc(100vw - 24px));
  }
}

.turn-select { height: 24px; }

.turn-table thead th { text-align: center; }

.turn-subhead-row th {
  text-align: center;
  padding: 4px 6px;
  font-size: 11px;
  font-weight: 700;
  color: #d8f5ef;
  background: rgba(16, 185, 129, 0.08);
}

.turn-cell {
  width: 102px;
  min-width: 102px;
  height: 112px;
  padding: 2px;
  cursor: pointer;
}

.turn-front-row .turn-cell { background: rgba(59, 130, 246, 0.12); }

.turn-back-row .turn-cell { background: rgba(16, 185, 129, 0.12); }

.turn-cell.pos-front { background: rgba(59, 130, 246, 0.22); box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.34); }
.turn-cell.pos-back { background: rgba(16, 185, 129, 0.22); box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.34); }
.turn-cell.pos-front-to-back { background: linear-gradient(135deg, rgba(59, 130, 246, 0.24), rgba(16, 185, 129, 0.24)); box-shadow: inset 0 0 0 1px rgba(255, 215, 153, 0.4); }
.turn-cell.pos-back-to-front { background: linear-gradient(135deg, rgba(16, 185, 129, 0.24), rgba(59, 130, 246, 0.24)); box-shadow: inset 0 0 0 1px rgba(255, 215, 153, 0.4); }

.turn-unit-cell {
  width: 100%;
  height: 100%;
  border-radius: 0;
  border: 1px dashed rgba(126, 224, 255, 0.28);
  background: rgba(255, 255, 255, 0.03);
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 5px;
  padding: 4px;
}

.turn-slot-frame {
  position: relative;
  width: 86px;
  height: 78px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 2px;
  border: 1px solid rgba(126, 224, 255, 0.34);
  background: linear-gradient(135deg, rgba(126, 224, 255, 0.14), rgba(181, 157, 255, 0.08));
  box-shadow: inset 0 0 0 2px rgba(9, 14, 28, 0.92), 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.turn-slot-frame.empty {
  display: grid;
  align-content: center;
  color: rgba(223, 251, 255, 0.5);
}

.turn-slot-portrait { width: 72px; height: 72px; border-radius: 2px; }
.turn-slot-name { max-width: 100%; font-size: 8px; line-height: 1.1; color: #e8ecf6; font-weight: 700; }

.turn-skill-bp,
.turn-hp-select {
  height: 18px;
  max-width: 58px;
  cursor: pointer;
}

.turn-unit-left,
.turn-unit-right {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.turn-unit-left {
  align-items: center;
  gap: 3px;
}

.turn-unit-right {
  justify-content: center;
  gap: 3px;
}

.turn-skill-head {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.turn-skill-controls {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 4px;
}

.skill-top,
.skill-name {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  flex-wrap: wrap;
}

.turn-skill-name,
.picker-card-name,
.detail-heading {
  color: #f3f7ff;
  font-weight: 800;
}

.turn-skill-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-xl);
  background: rgba(14, 20, 38, 0.72);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.control-panel, .detail-panel {
  border-radius: var(--radius-xl);
  padding: 10px;
}

.panel-title {
  margin: 0;
  color: #eef8ff;
  font-size: 14px;
}

.sticky-detail { display: grid; gap: 12px; }
