/* PP2 Battle Calculator - Paragon Pioneers 2 Theme */

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

:root {
  --bg-dark:       #1a1209;
  --bg-panel:      #241a0d;
  --bg-player:     #0f2010;
  --bg-enemy:      #1e0d0d;
  --bg-card:       #2e2015;
  --gold:          #c9a84c;
  --gold-light:    #e8cc7a;
  --gold-dim:      #7a6530;
  --text-primary:  #f0e8d0;
  --text-muted:    #a09070;
  --green-bright:  #4caf50;
  --green-dim:     #2e7d32;
  --red-bright:    #f44336;
  --red-dim:       #8B0000;
  --border:        1px solid var(--gold-dim);
  --radius:        6px;
  --font:          'Segoe UI', 'Trebuchet MS', system-ui, sans-serif;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.4;
  min-height: 100vh;
}

/* ===== HEADER ===== */

header {
  background: linear-gradient(135deg, #120d04 0%, #2a1e08 50%, #120d04 100%);
  border-bottom: 2px solid var(--gold);
  padding: 18px 24px;
  text-align: center;
}

header h1 {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--gold-light);
  letter-spacing: 0.05em;
  text-shadow: 0 0 20px rgba(201, 168, 76, 0.4);
}

header p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 4px;
}

/* ===== LAYOUT ===== */

.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px;
}

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

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

/* ===== PANELS ===== */

.panel {
  border-radius: var(--radius);
  border: 1px solid var(--gold-dim);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--gold-dim);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.04em;
}

.player-panel {
  background: var(--bg-player);
}

.player-panel .panel-header {
  background: rgba(76, 175, 80, 0.15);
  color: #81c784;
  border-bottom-color: var(--green-dim);
}

.enemy-panel {
  background: var(--bg-enemy);
}

.enemy-panel .panel-header {
  background: rgba(244, 67, 54, 0.15);
  color: #ef9a9a;
  border-bottom-color: var(--red-dim);
}

.clear-btn {
  background: transparent;
  border: 1px solid currentColor;
  border-radius: 4px;
  color: inherit;
  cursor: pointer;
  font-size: 0.75rem;
  opacity: 0.7;
  padding: 3px 8px;
  transition: opacity 0.2s;
}

.clear-btn:hover {
  opacity: 1;
}

/* ===== UNIT LIST ===== */

.unit-list {
  padding: 6px 0;
  max-height: 640px;
  overflow-y: auto;
}

.unit-list::-webkit-scrollbar {
  width: 6px;
}

.unit-list::-webkit-scrollbar-track {
  background: transparent;
}

.unit-list::-webkit-scrollbar-thumb {
  background: var(--gold-dim);
  border-radius: 3px;
}

.unit-row {
  display: grid;
  grid-template-columns: 40px 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-bottom: 1px solid rgba(201, 168, 76, 0.08);
  transition: background 0.15s;
}

.unit-row:last-child {
  border-bottom: none;
}

.unit-row:hover {
  background: rgba(201, 168, 76, 0.05);
}

/* ===== UNIT BADGE ===== */

.unit-badge {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  border: 1px solid var(--gold-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: var(--gold);
  background: rgba(201, 168, 76, 0.08);
  overflow: hidden;
  flex-shrink: 0;
  text-align: center;
  line-height: 1.1;
}

.unit-badge img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ===== UNIT NAME / LABEL ===== */

.unit-name {
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unit-name:hover {
  color: var(--gold-light);
}

/* ===== SKILL TAGS ===== */

.unit-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  justify-content: flex-end;
  max-width: 120px;
}

.skill-tag {
  border-radius: 3px;
  cursor: help;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 1px 4px;
  text-transform: uppercase;
  white-space: nowrap;
}

.skill-ranged       { background: #1a3a1a; color: #81c784; border: 1px solid #2e7d32; }
.skill-firststrike  { background: #2a1a00; color: #ffb74d; border: 1px solid #e65100; }
.skill-laststrike   { background: #1a002a; color: #ce93d8; border: 1px solid #6a1b9a; }
.skill-doublestrike { background: #2a1a00; color: #ffcc02; border: 1px solid #f57f17; }
.skill-triplestrike { background: #2a0a0a; color: #ff8a65; border: 1px solid #bf360c; }
.skill-splash       { background: #0a1a2a; color: #64b5f6; border: 1px solid #1565c0; }
.skill-flanking     { background: #2a001a; color: #f48fb1; border: 1px solid #880e4f; }
.skill-piercing     { background: #1a1a00; color: #fff176; border: 1px solid #f9a825; }
.skill-defender     { background: #001a2a; color: #81d4fa; border: 1px solid #01579b; }
.skill-spiky        { background: #1a0a00; color: #ffab91; border: 1px solid #bf360c; }
.skill-armored      { background: #1a1a1a; color: #b0bec5; border: 1px solid #546e7a; }
.skill-stalwart     { background: #0d1a0d; color: #a5d6a7; border: 1px solid #2e7d32; }
.skill-quicksilver  { background: #001a1a; color: #80deea; border: 1px solid #00838f; }
.skill-charge       { background: #2a0a00; color: #ff8a65; border: 1px solid #bf360c; }
.skill-bulletproof  { background: #1a1a1a; color: #cfd8dc; border: 1px solid #455a64; }
.skill-supporter    { background: #1a1a00; color: #ffe082; border: 1px solid #f9a825; }
.skill-armageddon   { background: #2a0000; color: #ef9a9a; border: 1px solid #b71c1c; }
.skill-lightningbolt{ background: #1a1a00; color: #fff59d; border: 1px solid #f9a825; }
.skill-confusion    { background: #1a002a; color: #b39ddb; border: 1px solid #4527a0; }
.skill-summon       { background: #002a00; color: #a5d6a7; border: 1px solid #1b5e20; }
.skill-revive       { background: #0a001a; color: #ea80fc; border: 1px solid #6a1b9a; }

/* ===== UNIT INPUT ===== */

.unit-input {
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--gold-dim);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.9rem;
  padding: 4px 6px;
  text-align: right;
  width: 64px;
  transition: border-color 0.2s;
  -moz-appearance: textfield;
}

.unit-input::-webkit-inner-spin-button,
.unit-input::-webkit-outer-spin-button {
  opacity: 0.5;
}

.unit-input:focus {
  border-color: var(--gold);
  outline: none;
}

.unit-input:not([value="0"]) {
  background: rgba(201, 168, 76, 0.08);
  border-color: var(--gold);
}

/* ===== ENEMY PANEL SPLIT ===== */

.enemy-columns {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 0;
  height: 100%;
}

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

.enemy-section-header {
  background: rgba(244, 67, 54, 0.08);
  border-bottom: 1px solid var(--red-dim);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 6px 12px;
  text-transform: uppercase;
}

.boss-section {
  border-left: 1px solid var(--gold-dim);
  overflow-y: auto;
}

.boss-list {
  padding: 4px 0;
}

.boss-row {
  align-items: flex-start;
  border-bottom: 1px solid rgba(201, 168, 76, 0.08);
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  transition: background 0.15s;
}

.boss-row:last-child {
  border-bottom: none;
}

.boss-row:hover {
  background: rgba(244, 67, 54, 0.07);
}

.boss-row input[type="radio"] {
  accent-color: var(--gold);
  cursor: pointer;
  flex-shrink: 0;
  height: 16px;
  margin-top: 2px;
  width: 16px;
}

.boss-label {
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  gap: 2px;
}

.boss-label:hover {
  color: var(--gold-light);
}

.boss-stats {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.boss-no-select {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(201, 168, 76, 0.08);
}

.boss-no-btn {
  background: transparent;
  border: 1px solid var(--gold-dim);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 4px 10px;
  transition: all 0.2s;
  width: 100%;
}

.boss-no-btn:hover {
  border-color: var(--gold);
  color: var(--text-primary);
}

/* ===== CONTROLS ===== */

.controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
  padding: 0 16px;
}

.calculate-btn {
  background: linear-gradient(135deg, #7a5200, #c9a84c, #7a5200);
  border: 2px solid var(--gold);
  border-radius: var(--radius);
  color: #1a1209;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 12px 48px;
  text-transform: uppercase;
  transition: all 0.2s;
}

.calculate-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #a07000, #e8cc7a, #a07000);
  box-shadow: 0 0 20px rgba(201, 168, 76, 0.4);
}

.calculate-btn:disabled {
  cursor: wait;
  opacity: 0.6;
}

/* ===== ERROR ===== */

.error-msg {
  background: rgba(244, 67, 54, 0.15);
  border: 1px solid var(--red-bright);
  border-radius: var(--radius);
  color: #ef9a9a;
  display: none;
  margin: 12px auto;
  max-width: 500px;
  padding: 10px 16px;
  text-align: center;
}

/* ===== RESULTS ===== */

.results {
  background: var(--bg-card);
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius);
  display: none;
  margin-top: 20px;
  padding: 20px 24px;
}

.results-header {
  align-items: center;
  border-bottom: 1px solid var(--gold-dim);
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 14px;
}

.win-display {
  align-items: baseline;
  display: flex;
  gap: 8px;
}

.win-label {
  color: var(--text-muted);
  font-size: 1rem;
}

.win-pct {
  font-size: 2.2rem;
  font-weight: 700;
}

.win-high { color: var(--green-bright); }
.win-low  { color: var(--red-bright); }

.results-meta {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: right;
}

.results-meta span {
  display: block;
}

/* ===== RESULTS TABLE ===== */

.results-table-wrapper {
  overflow-x: auto;
}

.results-table {
  border-collapse: collapse;
  width: 100%;
}

.results-table th {
  background: rgba(201, 168, 76, 0.12);
  border-bottom: 1px solid var(--gold-dim);
  color: var(--gold);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 8px 12px;
  text-align: left;
  text-transform: uppercase;
}

.results-table th:not(:first-child) {
  text-align: right;
}

.results-table td {
  border-bottom: 1px solid rgba(201, 168, 76, 0.06);
  padding: 7px 12px;
}

.results-table td:not(:first-child) {
  text-align: right;
}

.results-table tr:last-child td {
  border-bottom: none;
}

.row-player td {
  background: rgba(76, 175, 80, 0.06);
}

.row-player td.res-name {
  color: #a5d6a7;
}

.row-player td.res-survived {
  color: var(--green-bright);
}

.row-player td.res-lost {
  color: #ef9a9a;
}

.row-enemy td {
  background: rgba(244, 67, 54, 0.06);
}

.row-enemy td.res-name {
  color: #ef9a9a;
}

.row-enemy td.res-survived {
  color: var(--red-bright);
}

.row-enemy td.res-lost {
  color: var(--green-bright);
}

.row-boss td {
  font-weight: 600;
}

/* ===== DISCLAIMER ===== */

.disclaimer {
  border-top: 1px solid var(--gold-dim);
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 12px;
  padding-top: 10px;
  text-align: center;
}

/* ===== FOOTER ===== */

footer {
  border-top: 1px solid var(--gold-dim);
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 32px;
  padding: 16px;
  text-align: center;
}
