/* ========== RESET & BASE ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: linear-gradient(145deg, #0a0e17 0%, #111827 50%, #0f1629 100%);
  color: #e2e8f0;
  min-height: 100vh;
}

/* ========== APP CONTAINER ========== */
.app-container { max-width: 99%; margin: 0 auto; padding: 1rem 1.25rem 2rem; }

/* ========== HEADER ========== */
.app-header {
  text-align: center; padding: 2rem 1rem 1.5rem; position: relative;
  background: linear-gradient(135deg, rgba(139,92,246,.12), rgba(236,72,153,.08));
  border-radius: 16px; margin-bottom: 1.5rem;
  border: 1px solid rgba(139,92,246,.2);
}
.header-glow {
  position: absolute; top: -40px; left: 50%; transform: translateX(-50%);
  width: 300px; height: 80px; background: radial-gradient(ellipse, rgba(139,92,246,.35), transparent 70%);
  pointer-events: none;
}
.app-title {
  font-family: 'Cinzel', serif; font-size: 2.2rem; font-weight: 700;
  background: linear-gradient(135deg, #c084fc, #f472b6, #fb923c);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; letter-spacing: 1px;
}
.app-subtitle { color: #94a3b8; font-size: .9rem; margin-top: .3rem; letter-spacing: 2px; text-transform: uppercase; }

/* ========== TABS ========== */
.tab-nav {
  display: flex; gap: .5rem; margin-bottom: 1.25rem; overflow-x: auto; padding-bottom: .25rem;
  border-bottom: 1px solid rgba(139,92,246,.15);
}
.tab-btn {
  padding: .65rem 1.1rem; border: none; border-radius: 10px 10px 0 0;
  background: rgba(30,41,59,.6); color: #94a3b8; font-size: .85rem; font-weight: 500;
  cursor: pointer; white-space: nowrap; transition: all .25s;
  border: 1px solid transparent; border-bottom: none;
}
.tab-btn:hover { background: rgba(139,92,246,.15); color: #c084fc; }
.tab-btn.active {
  background: rgba(139,92,246,.2); color: #e0c3fc;
  border-color: rgba(139,92,246,.3); border-bottom-color: transparent;
}

/* ========== TAB CONTENT ========== */
.tab-content { display: none; animation: fadeIn .3s ease; }
.tab-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ========== CARDS ========== */
.card {
  background: rgba(30,41,59,.55); border: 1px solid rgba(139,92,246,.12);
  border-radius: 14px; padding: 1.25rem; margin-bottom: 1.25rem;
  backdrop-filter: blur(12px);
}
.card-title {
  font-family: 'Cinzel', serif; font-size: 1.15rem; font-weight: 600;
  color: #c084fc; margin-bottom: 1rem; padding-bottom: .5rem;
  border-bottom: 1px solid rgba(139,92,246,.15);
}

/* ========== FORMS ========== */
.form-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .75rem; align-items: end;
}
.form-group { display: flex; flex-direction: column; gap: .25rem; }
.form-group.full-width { grid-column: 1 / -1; }
.form-group label { font-size: .75rem; color: #94a3b8; text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
input, select, textarea {
  padding: .55rem .75rem; border-radius: 8px;
  border: 1px solid rgba(139,92,246,.2); background: rgba(15,22,41,.7);
  color: #e2e8f0; font-size: .9rem; font-family: inherit; transition: border-color .2s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #8b5cf6; box-shadow: 0 0 0 3px rgba(139,92,246,.15); }
textarea { resize: vertical; }

/* ========== BUTTONS ========== */
.btn {
  padding: .55rem 1.1rem; border: none; border-radius: 8px;
  font-size: .85rem; font-weight: 600; cursor: pointer;
  transition: all .2s; font-family: inherit; text-decoration: none;
}
.btn-primary {
  background: linear-gradient(135deg, #7c3aed, #a855f7); color: #fff;
  box-shadow: 0 2px 10px rgba(139,92,246,.25);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 15px rgba(139,92,246,.4); }
.btn-accent { background: linear-gradient(135deg, #f59e0b, #f97316); color: #fff; }
.btn-accent:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(245,158,11,.35); }
.btn-secondary { background: rgba(51,65,85,.7); color: #cbd5e1; border: 1px solid rgba(100,116,139,.3); }
.btn-secondary:hover { background: rgba(71,85,105,.7); }
.btn-danger { background: rgba(239,68,68,.2); color: #fca5a5; border: 1px solid rgba(239,68,68,.25); font-size: .75rem; padding: .3rem .6rem; }
.btn-danger:hover { background: rgba(239,68,68,.35); }
.btn-sm { font-size: .75rem; padding: .3rem .6rem; }
.btn-heal { background: rgba(34,197,94,.2); color: #86efac; border: 1px solid rgba(34,197,94,.25); font-size: .75rem; padding: .3rem .6rem; }
.btn-heal:hover { background: rgba(34,197,94,.35); }
.btn-dmg { background: rgba(239,68,68,.2); color: #fca5a5; border: 1px solid rgba(239,68,68,.25); font-size: .75rem; padding: .3rem .6rem; }
.btn-dmg:hover { background: rgba(239,68,68,.35); }
.btn-repair { background: rgba(59,130,246,.2); color: #93c5fd; border: 1px solid rgba(59,130,246,.25); font-size: .75rem; padding: .3rem .6rem; }
.btn-repair:hover { background: rgba(59,130,246,.35); }

/* ========== TABLES ========== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
thead th {
  background: rgba(139,92,246,.1); color: #c084fc; padding: .6rem .75rem;
  text-align: left; font-weight: 600; text-transform: uppercase; font-size: .72rem;
  letter-spacing: .5px; border-bottom: 1px solid rgba(139,92,246,.2); white-space: nowrap;
}
tbody td {
  padding: .55rem .75rem; border-bottom: 1px solid rgba(51,65,85,.5);
  vertical-align: middle;
}
tbody tr { transition: background .15s; }
tbody tr:hover { background: rgba(139,92,246,.05); }
tbody tr.current-turn { background: rgba(245,158,11,.12) !important; border-left: 3px solid #f59e0b; }
.hp-display { font-weight: 600; }
.hp-healthy { color: #86efac; }
.hp-hurt { color: #fbbf24; }
.hp-critical { color: #f87171; }
.hp-dead { color: #6b7280; text-decoration: line-through; }

/* ========== ACTION CELLS ========== */
.action-cell { display: flex; gap: .35rem; align-items: center; flex-wrap: nowrap !important; min-width: 320px; }
.action-cell input[type="number"] {
  width: 55px; padding: .25rem .35rem; font-size: .8rem;
  text-align: center; border-radius: 6px;
}

/* ========== TURN BAR ========== */
.turn-bar { display: flex; gap: .75rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.turn-counter {
  background: rgba(245,158,11,.15); color: #fbbf24; padding: .35rem .75rem;
  border-radius: 8px; font-weight: 700; font-size: .9rem; min-width: 50px; text-align: center;
}
.turn-info-input { flex: 1; min-width: 180px; }

#notesArea {
  width: 100%;
  min-height: 70vh;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(139,92,246,0.15);
  color: #e2e8f0;
  padding: 1.5rem;
  font-size: 1.1rem;
  line-height: 1.6;
  border-radius: 12px;
  resize: vertical;
}

#notesArea:focus {
  outline: none;
  border-color: rgba(139,92,246,0.4);
  background: rgba(255,255,255,0.05);
}

/* ========== FOOTER ========== */
.footer-actions { display: flex; gap: .75rem; margin: 1.5rem 0 1rem; flex-wrap: wrap; }
.file-label { display: inline-flex; align-items: center; }
.app-footer {
  text-align: center; padding: 1rem; color: #64748b; font-size: .8rem;
  border-top: 1px solid rgba(100,116,139,.15); margin-top: .5rem;
}

/* ========== EDITABLE CELLS ========== */
td[contenteditable="true"] { cursor: text; border-radius: 4px; outline: none; }
td[contenteditable="true"]:focus { background: rgba(139,92,246,.1); box-shadow: inset 0 0 0 1px rgba(139,92,246,.3); }

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  .app-title { font-size: 1.6rem; }
  .form-grid { grid-template-columns: 1fr; }
  .tab-nav { gap: .25rem; }
  .tab-btn { font-size: .75rem; padding: .5rem .7rem; }
}

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: rgba(15,23,42,.5); }
::-webkit-scrollbar-thumb { background: rgba(139,92,246,.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(139,92,246,.5); }

/* ========== EDITABLE TABLE INPUTS ========== */
.table-input {
  background: rgba(255,255,255,0.03);
  border: 1px solid transparent;
  color: #e2e8f0;
  font-family: inherit;
  font-size: 0.85rem;
  padding: 4px 6px;
  border-radius: 6px;
  width: 100%;
  transition: all 0.2s;
  min-width: 40px;
}

.table-input:hover, .table-input:focus {
  background: rgba(139,92,246,0.1);
  border-color: rgba(139,92,246,0.4);
  outline: none;
}

.hp-in {
  width: 45px !important;
  display: inline-block;
  text-align: center;
  padding: 2px !important;
}

.hp-display {
  white-space: nowrap;
}

select.table-input {
  appearance: none;
  cursor: pointer;
}

.col-clickable {
  cursor: pointer;
  color: #c084fc;
  transition: color 0.2s;
  font-weight: 500;
}

.col-clickable:hover {
  color: #fbbf24;
  text-decoration: underline;
}
