:root {
  --bg: #08141d;
  --panel: rgba(8, 25, 36, 0.88);
  --panel-strong: rgba(12, 33, 48, 0.96);
  --line: rgba(156, 211, 233, 0.18);
  --text: #edf7fb;
  --muted: #9ab7c7;
  --accent: #79e0c8;
  --accent-strong: #d9ff70;
  --danger: #ff8c7a;
  --gold: #ffd27a;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "Malgun Gothic", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(72, 162, 191, 0.24), transparent 30%),
    linear-gradient(160deg, #08141d 0%, #0f2533 45%, #061018 100%);
}

button {
  font: inherit;
  cursor: pointer;
  border: 0;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

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

.app-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.auth-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 16px 20px;
  margin-bottom: 20px;
}

.auth-panel-copy {
  display: grid;
  gap: 6px;
}

.auth-panel-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.hero-panel,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.hero-panel {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 28px;
  margin-bottom: 20px;
  position: sticky;
  top: 12px;
  z-index: 25;
}

.eyebrow,
.label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
  color: var(--muted);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(2.5rem, 5vw, 4.5rem);
  line-height: 0.96;
}

.hero-copy {
  max-width: 680px;
  color: var(--muted);
  line-height: 1.6;
}

.hero-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  min-width: 320px;
}

.tower-heading-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-btn,
.secondary-btn,
.action-btn,
.target-btn {
  border-radius: 16px;
  padding: 14px 18px;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  color: #08222e;
  font-weight: 700;
}

.secondary-btn,
.target-btn {
  background: rgba(138, 205, 228, 0.08);
  color: var(--text);
  border: 1px solid rgba(138, 205, 228, 0.15);
}

.dashboard {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
}

.panel {
  padding: 20px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-weight: 700;
}

.section-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.section-title {
  font-size: 1.18rem;
  line-height: 1.1;
}

.badge {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(121, 224, 200, 0.12);
  color: var(--accent);
  font-size: 12px;
}

.danger-lite-btn {
  border-color: rgba(255, 140, 122, 0.18);
  background: rgba(255, 140, 122, 0.08);
}

.tower-card,
.battle-layout,
.tower-stats,
.party-grid,
.roster-grid,
.combat-grid,
.battle-overview,
.detail-grid,
.quick-stats,
.skill-list {
  display: grid;
  gap: 14px;
}

.tower-card {
  grid-template-columns: 1.2fr 0.8fr;
}

.tower-stats,
.party-grid,
.roster-grid,
.combat-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.roster-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-items: stretch;
}

.battle-overview {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  margin-bottom: 16px;
}

.battle-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: stretch;
}

.battle-main {
  min-width: 0;
  display: grid;
  gap: 18px;
}

.log-panel {
  width: 340px;
  justify-self: end;
  height: 100%;
  background: var(--panel-strong);
  border: 1px solid rgba(156, 211, 233, 0.12);
  border-radius: 20px;
  padding: 18px;
}

.detail-grid {
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
}

.skill-list {
  grid-template-columns: 1fr;
}

.party-card,
.overview-card,
.combatant-card,
.reward-card,
.command-box,
.tower-card {
  background: var(--panel-strong);
  border: 1px solid rgba(156, 211, 233, 0.12);
  border-radius: 20px;
  padding: 18px;
}

.combatant-card {
  padding: 14px 16px;
}

.party-card {
  padding: 0;
  overflow: hidden;
}

.roster-card.selected {
  box-shadow: inset 0 0 0 1px rgba(121, 224, 200, 0.45);
}

.party-card-toggle {
  display: block;
  width: 100%;
  padding: 18px;
  text-align: left;
  background: transparent;
  color: inherit;
}

.party-card h3,
.combatant-card h3 {
  margin-bottom: 0;
}

.muted {
  color: var(--muted);
}

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

.draft-toolbar .primary-btn {
  padding: 12px 16px;
}

.draft-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.stat-row,
.skill-head,
.party-card-header,
.detail-item,
.quick-stats > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.stat-row {
  font-size: 14px;
  color: var(--muted);
}

.hp-bar,
.mp-bar,
.meter {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  margin: 8px 0 10px;
}

.fill,
.meter-fill {
  height: 100%;
  border-radius: inherit;
}

.hp-fill {
  background: linear-gradient(90deg, #ff8c7a, #ffce75);
}

.mp-fill {
  background: linear-gradient(90deg, #79b8ff, #79e0c8);
}

.meter-fill {
  width: 0%;
  background: linear-gradient(90deg, #d9ff70, #79e0c8);
  transition: width 220ms ease;
}

.quick-stats {
  grid-template-columns: repeat(2, 1fr);
  margin-top: 10px;
}

.key-stat {
  color: var(--accent);
  font-weight: 700;
}

.quick-stats > div,
.detail-item {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
}

.quick-stats strong,
.detail-item strong {
  color: var(--text);
}

.party-card-details {
  padding: 0 18px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.expand-indicator {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.derived-grid {
  margin-top: 8px;
}

.skill-card {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.equipment-slot-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-top: 18px;
  margin-bottom: 18px;
}

.equipment-slot-btn {
  text-align: left;
  width: 100%;
  min-height: 88px;
  display: grid;
  align-content: start;
  gap: 8px;
  color: var(--text);
}

.equipment-slot-btn strong,
.equipment-slot-btn p {
  color: var(--text);
}

.tier-common {
  border-color: rgba(255, 255, 255, 0.08);
}

.tier-shop {
  border-color: rgba(255, 210, 122, 0.28);
  box-shadow: inset 0 0 0 1px rgba(255, 210, 122, 0.12);
}

.tier-rare {
  border-color: rgba(121, 184, 255, 0.42);
  background: linear-gradient(180deg, rgba(52, 92, 150, 0.18), rgba(255, 255, 255, 0.03));
}

.tier-heroic {
  border-color: rgba(217, 255, 112, 0.45);
  background: linear-gradient(180deg, rgba(125, 150, 33, 0.22), rgba(255, 255, 255, 0.04));
  box-shadow: 0 0 0 1px rgba(217, 255, 112, 0.12);
}

.skill-card p {
  margin-bottom: 10px;
}

.skill-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.skill-tag {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(121, 224, 200, 0.12);
  color: var(--accent);
  font-size: 12px;
}

.battle-panel {
  min-height: 460px;
}

.battle-overview {
  display: none;
}

.overview-card {
  padding: 14px 16px;
}

.overview-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1.3rem;
}

.command-box {
  margin-top: 18px;
}

.command-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.action-buttons,
.target-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.action-btn {
  min-width: 140px;
  background: linear-gradient(135deg, rgba(255, 210, 122, 0.18), rgba(121, 224, 200, 0.14));
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.target-buttons {
  margin-top: 12px;
}

.selected-skill {
  box-shadow: inset 0 0 0 1px rgba(217, 255, 112, 0.42);
}

.combat-target-anchor {
  min-height: 38px;
  display: flex;
  align-items: flex-end;
  margin-top: 10px;
}

.combat-target-chip {
  width: 100%;
  border-radius: 12px;
  padding: 7px 10px;
  font-size: 12px;
  background: rgba(121, 224, 200, 0.16);
  color: var(--text);
  border: 1px solid rgba(121, 224, 200, 0.28);
}

[data-tooltip] {
  position: relative;
}

[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  width: max-content;
  max-width: 220px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(4, 14, 21, 0.96);
  border: 1px solid rgba(156, 211, 233, 0.18);
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
  box-shadow: var(--shadow);
  z-index: 40;
  pointer-events: none;
  white-space: normal;
}

.log-list {
  display: grid;
  gap: 10px;
  max-height: 520px;
  overflow: auto;
}

.log-item {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  color: #dbeef5;
  line-height: 1.5;
}

.empty-log {
  min-height: 120px;
  display: flex;
  align-items: center;
  color: var(--muted);
}

.encounter-banner {
  margin-top: 16px;
  padding: 16px 18px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255, 140, 122, 0.16), rgba(255, 210, 122, 0.16));
  border: 1px solid rgba(255, 210, 122, 0.18);
  color: #fff0d1;
}

.progression-panel {
  margin-top: 16px;
}

.status-line {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--accent);
  line-height: 1.5;
}

.status-token {
  display: inline-block;
  margin-right: 6px;
  color: var(--accent);
}

.combat-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.combat-class-tag {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.combat-card-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 6px;
}

.combat-mini-btn {
  padding: 8px 6px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
}

.inspect-modal-card {
  width: min(660px, 100%);
}

.inspect-modal-card .modal-item-btn,
.inspect-modal-card .modal-item-btn strong,
.inspect-modal-card .modal-item-btn span {
  color: #ffffff;
}

.enemy {
  border-color: rgba(255, 140, 122, 0.16);
}

.active {
  box-shadow: inset 0 0 0 1px rgba(217, 255, 112, 0.35);
}

.ko {
  color: rgba(255, 255, 255, 0.35);
}

.hidden {
  display: none;
}

@media (max-width: 780px) {
  .auth-panel {
    flex-direction: column;
    align-items: stretch;
  }

  .auth-panel-actions {
    justify-content: flex-start;
  }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 8, 12, 0.72);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 50;
}

#inspect-modal {
  z-index: 50;
}

#equipment-modal {
  z-index: 60;
}

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

.modal-card {
  width: min(1080px, 100%);
  max-height: min(88vh, 920px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.equipment-modal-card {
  width: min(760px, 100%);
}

.equipment-modal-card .skill-card,
.equipment-modal-card .detail-item,
.equipment-modal-card .modal-item-btn {
  color: var(--text);
}

.equipment-modal-card .skill-head span,
.equipment-modal-card .detail-item span,
.equipment-modal-card p,
.equipment-modal-card .muted {
  color: #d6e7ef;
}

.equipment-modal-card strong {
  color: #ffffff;
}

.equipment-modal-layout,
.equipment-compare {
  display: grid;
  gap: 16px;
}

.equipment-modal-layout {
  grid-template-columns: 1fr;
}

.equipment-compare {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.compact-heading {
  margin-bottom: 12px;
}

.modal-item-btn {
  text-align: left;
  width: 100%;
}

.selected-modal-item {
  box-shadow: inset 0 0 0 1px rgba(121, 224, 200, 0.45);
}

.compare-grid {
  margin: 12px 0;
}

.inspect-stat-row {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 12px;
}

.delta-up {
  color: var(--accent-strong);
}

.delta-down {
  color: var(--danger);
}

@media (max-width: 980px) {
  .dashboard,
  .tower-card,
  .hero-panel {
    grid-template-columns: 1fr;
  }

  .battle-shell {
    grid-template-columns: 1fr;
  }

  .equipment-modal-layout,
  .equipment-compare {
    grid-template-columns: 1fr;
  }

  .hero-panel {
    display: grid;
    top: 8px;
  }

  .draft-toolbar,
  .command-header,
  .party-card-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

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

.roster-row {
  overflow: hidden;
}

.roster-row-header {
  display: flex;
  justify-content: flex-end;
  padding: 10px 12px 0;
}

.roster-reroll-btn {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(138, 205, 228, 0.08);
  color: var(--text);
  border: 1px solid rgba(138, 205, 228, 0.18);
  font-size: 16px;
  line-height: 1;
}

.roster-row-toggle {
  display: grid;
  grid-template-columns: 110px minmax(180px, 0.9fr) minmax(240px, 1.1fr) minmax(280px, 1.3fr) minmax(280px, 1.4fr);
  gap: 16px;
  align-items: start;
}

.roster-select,
.roster-summary,
.roster-block {
  min-width: 0;
}

.roster-select {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
}

.roster-block-label {
  display: block;
  margin-bottom: 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.roster-stat-line,
.roster-skill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.roster-stat-line span,
.roster-skill {
  padding: 9px 11px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.roster-stat-line span {
  color: var(--muted);
  font-size: 13px;
}

.roster-stat-line strong,
.roster-skill strong {
  color: var(--text);
}

.roster-skill {
  display: grid;
  gap: 4px;
}

.roster-skill span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

@media (max-width: 900px) {
  .roster-row-toggle {
    grid-template-columns: 1fr;
  }

  .roster-select {
    justify-content: flex-start;
  }
}
