/* ================================================================
   PUBG Damage Sim — Dark Theme · animejs.com inspired
   ================================================================ */
:root {
  --bg-root: #08090c;
  --bg-surface: #111318;
  --bg-card: #181a1f;
  --bg-input: #1a1c22;
  --bg-hover: #1f2128;
  --border: #252830;
  --border-focus: #4c3aed;
  --text-primary: #f1f1f3;
  --text-secondary: #9899a0;
  --text-muted: #5f6068;
  --accent: #7c3aed;
  --accent-2: #3b82f6;
  --accent-grad: linear-gradient(135deg, #7c3aed 0%, #3b82f6 100%);
  --red: #ef4444;
  --green: #22c55e;
  --amber: #f59e0b;
  --cyan: #06b6d4;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-lg: 0 20px 60px rgba(0,0,0,0.5);
  --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-root);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

/* ---- Header ---- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(8,9,12,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1280px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 56px;
}
.logo {
  display: flex; align-items: center; gap: 8px;
  text-decoration: none;
  font-weight: 700; font-size: 1.05rem; color: var(--text-primary);
  letter-spacing: -0.01em;
}
.header-nav { display: flex; gap: 4px; }
.nav-link {
  padding: 6px 16px; border-radius: 20px;
  text-decoration: none; font-size: 0.88rem; font-weight: 500;
  color: var(--text-secondary); transition: var(--transition);
}
.nav-link:hover { color: var(--text-primary); background: var(--bg-hover); }
.nav-link.active { color: #fff; background: var(--accent-grad); }

/* ---- Main Layout ---- */
.main-content { max-width: 1280px; margin: 0 auto; padding: 24px; }
.app-layout { display: flex; gap: 24px; align-items: flex-start; }

/* ---- Config Panel ---- */
.config-panel {
  width: 340px; flex-shrink: 0;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius);
  position: sticky; top: 80px; max-height: calc(100vh - 100px);
  overflow: hidden;
}
.panel-scroll { padding: 20px; overflow-y: auto; max-height: calc(100vh - 100px); }

.cfg-section {
  border: none; margin-bottom: 18px;
}
.section-title {
  font-size: 0.8rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted);
  margin-bottom: 10px; display: block;
}

.field-row { margin-bottom: 10px; }
.field-label {
  display: block; font-size: 0.82rem; font-weight: 500;
  color: var(--text-secondary); margin-bottom: 4px;
}

.input, .select {
  width: 100%; padding: 8px 12px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-size: 0.9rem; font-family: inherit;
  transition: var(--transition);
  outline: none;
}
.input:focus, .select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.15);
}
.input::placeholder { color: var(--text-muted); }
.select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239899a0' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }

.field-hint { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 8px; }

.prob-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.prob-item label { display: block; font-size: 0.78rem; color: var(--text-secondary); margin-bottom: 2px; }
.prob-input { text-align: center; }

.checkbox-row {
  display: flex; align-items: center; gap: 8px; margin-top: 6px;
  font-size: 0.82rem; color: var(--text-secondary); cursor: pointer;
}
.checkbox-row input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

/* ---- Button ---- */
.btn-calc {
  width: 100%; margin-top: 16px; padding: 12px;
  background: var(--accent-grad); border: none; border-radius: var(--radius-sm);
  color: #fff; font-size: 1rem; font-weight: 600; font-family: inherit;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: var(--transition);
}
.btn-calc:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(124,58,237,0.35); }
.btn-calc:active { transform: translateY(0); }
.btn-icon { transition: transform 200ms; }
.btn-calc:hover .btn-icon { transform: translateX(3px); }

/* ---- Result Panel ---- */
.result-panel {
  flex: 1; min-width: 0;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius); min-height: 500px;
}

/* Empty / Loading states */
.empty-state, .loading-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 80px 20px; text-align: center; color: var(--text-muted);
}
.empty-icon { margin-bottom: 16px; color: var(--text-muted); }
.empty-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 6px; color: var(--text-secondary); }
.empty-desc { font-size: 0.85rem; max-width: 320px; }

.spinner {
  width: 36px; height: 36px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.7s linear infinite; margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Result content */
.result-content { padding: 24px; }

/* Damage cards */
.damage-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.dmg-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 10px; text-align: center;
}
.dmg-card.head { border-top: 3px solid var(--red); }
.dmg-card.body { border-top: 3px solid var(--amber); }
.dmg-card.limb { border-top: 3px solid var(--cyan); }
.dmg-card.foot { border-top: 3px solid var(--text-muted); }
.dmg-part { display: block; font-size: 0.75rem; color: var(--text-muted); margin-bottom: 4px; }
.dmg-val { display: block; font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.armor-tag {
  display: inline-block; padding: 4px 12px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 20px; font-size: 0.8rem; color: var(--text-secondary);
  margin-bottom: 18px;
}

/* KPI Grid */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.kpi-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px 14px; text-align: center;
}
.kpi-label { display: block; font-size: 0.73rem; color: var(--text-muted); margin-bottom: 6px; }
.kpi-value {
  display: block; font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em;
  color: var(--text-primary); font-variant-numeric: tabular-nums;
}
.kpi-card.hits .kpi-value { color: #60a5fa; }
.kpi-card.shots .kpi-value { color: #f87171; }
.kpi-card.ttk .kpi-value { color: #4ade80; }
.kpi-card.combos .kpi-value { color: var(--text-secondary); font-size: 1.2rem; }
.kpi-note { display: block; font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }

/* Pen info */
.pen-info {
  display: flex; gap: 24px; flex-wrap: wrap;
  font-size: 0.78rem; color: var(--text-muted); margin-bottom: 20px;
  padding: 10px 14px; background: var(--bg-card); border-radius: var(--radius-sm);
}

/* Combo table */
.table-wrap { margin-top: 4px; }
.table-title { font-size: 0.9rem; font-weight: 600; margin-bottom: 10px; }
.table-sub { font-weight: 400; font-size: 0.78rem; color: var(--text-muted); }
.table-scroll { max-height: 340px; overflow-y: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.combo-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.combo-table thead { position: sticky; top: 0; z-index: 2; }
.combo-table th {
  background: #1e2030; padding: 10px 8px; text-align: center;
  font-weight: 600; font-size: 0.75rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.03em;
}
.combo-table td {
  padding: 8px; text-align: center; border-top: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.combo-table tbody tr { transition: background 120ms; }
.combo-table tbody tr:hover { background: var(--bg-hover); }
.combo-table .weight-bar {
  display: inline-block; height: 4px; border-radius: 2px;
  background: var(--accent-grad); vertical-align: middle; margin-left: 6px;
}

/* ---- Footer ---- */
.site-footer {
  text-align: center; padding: 20px;
  color: var(--text-muted); font-size: 0.75rem;
  border-top: 1px solid var(--border); margin-top: 32px;
}

/* ---- Responsive ---- */
@media (max-width: 860px) {
  .app-layout { flex-direction: column; }
  .config-panel { width: 100%; position: static; max-height: none; }
  .panel-scroll { max-height: none; }
  .damage-cards { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
