@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700&family=Inter:wght@400;500;600&display=swap');

:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --surface2: #0f3460;
  --accent: #e94560;
  --accent2: #533483;
  --gold: #f0c040;
  --text: #eee;
  --text-dim: #8899aa;
  --hp-green: #4caf50;
  --hp-yellow: #ff9800;
  --hp-red: #f44336;
  --radius: 12px;
  --danger: #c62828;
  --danger-hover: #a02020;
  --accent-hover: #d13a52;
  --gold-hover: #e0b030;
  --surface2-hover: #1a4a7a;
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

h1, h2, h3 { font-family: 'Cinzel', serif; }

/* ── Landing Screen ── */
#landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  text-align: center;
}
#landing h1 {
  font-size: 2.5em;
  color: var(--gold);
  margin-bottom: 8px;
  text-shadow: 0 2px 12px rgba(240,192,64,0.3);
}
#landing p { color: var(--text-dim); margin-bottom: 32px; font-size: 1.05em; }

.role-cards {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 700px;
}
.role-card {
  background: var(--surface);
  border: 2px solid var(--surface2);
  border-radius: var(--radius);
  padding: 32px 28px;
  width: 280px;
  cursor: pointer;
  transition: all 0.25s;
}
.role-card:hover {
  border-color: var(--gold);
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.role-card .icon { font-size: 2.5em; margin-bottom: 12px; }
.role-card h3 { color: var(--gold); margin-bottom: 8px; font-size: 1.2em; }
.role-card p { color: var(--text-dim); font-size: 0.9em; line-height: 1.5; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 400px;
}
.modal-wide {
  max-width: 480px;
}
.modal-scrollable {
  max-height: 90vh;
  overflow-y: auto;
}
.modal h2 { color: var(--gold); margin-bottom: 16px; font-size: 1.3em; }
.modal label { display: block; color: var(--text-dim); font-size: 0.85em; margin-bottom: 4px; margin-top: 12px; }
.modal input, .modal select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--surface2);
  background: var(--bg);
  color: var(--text);
  font-size: 1em;
  outline: none;
}
.modal input:focus { border-color: var(--gold); }

.setup-desc {
  color: var(--text-dim);
  font-size: 0.9em;
  margin-bottom: 12px;
}

.hint-text {
  font-size: 0.8em;
  color: var(--text-dim);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.ability-label-spacer {
  margin-top: 12px;
}

.note-textarea {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--surface2);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95em;
  resize: vertical;
  font-family: inherit;
}

.hp-mode-buttons {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.hp-mode-buttons .btn {
  flex: 1;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 0.95em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  color: #fff;
}
.btn-primary { background: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-gold { background: var(--gold); color: var(--bg); }
.btn-gold:hover { background: var(--gold-hover); }
.btn-secondary { background: var(--surface2); }
.btn-secondary:hover { background: var(--surface2-hover); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: var(--danger-hover); }
.btn-sm { padding: 6px 14px; font-size: 0.85em; }
.btn-block { width: 100%; justify-content: center; margin-top: 16px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.error-msg { color: var(--accent); font-size: 0.85em; margin-top: 8px; }

/* ── App Header ── */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--surface2);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.app-header h2 { color: var(--gold); font-size: 1.1em; }
.app-header .subtitle { color: var(--text-dim); font-size: 0.85em; }

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

/* ── DM Dashboard ── */
.dm-container { padding: 20px; max-width: 1000px; margin: 0 auto; }

.section-title {
  font-family: 'Cinzel', serif;
  color: var(--gold);
  font-size: 1.1em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.player-card {
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
}
.player-card.unassigned { border-style: dashed; opacity: 0.7; }
.player-card .pc-name {
  font-family: 'Cinzel', serif;
  font-size: 1.15em;
  color: var(--gold);
}
.player-card .player-name { color: var(--text-dim); font-size: 0.85em; margin-bottom: 12px; }

.hp-bar-container {
  background: #111;
  border-radius: 8px;
  height: 24px;
  overflow: hidden;
  position: relative;
  margin: 8px 0;
}
.hp-bar-large {
  height: 32px;
}
.hp-bar-fill {
  height: 100%;
  border-radius: 8px;
  transition: width 0.5s ease, background 0.5s;
}
.hp-bar-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8em;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}
.hp-bar-text-large {
  font-size: 1em;
}

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.stat-row-center {
  justify-content: center;
  margin-top: 14px;
}
.stat-badge {
  background: var(--bg);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.8em;
  font-weight: 500;
}
.stat-badge .label { color: var(--text-dim); }
.stat-badge .val { color: var(--gold); margin-left: 4px; }

.ability-scores {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-top: 10px;
}
.ability-scores-spaced {
  margin-top: 16px;
}
.ability-box {
  background: var(--bg);
  border-radius: 8px;
  text-align: center;
  padding: 6px 2px;
}
.ability-box .ab-label { font-size: 0.65em; color: var(--text-dim); text-transform: uppercase; }
.ability-box .ab-val { font-size: 1.05em; font-weight: 700; color: var(--text); }
.ability-box .ab-mod { font-size: 0.75em; color: var(--gold); }

.card-actions {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* ── Player View ── */
.player-container {
  padding: 20px;
  max-width: 500px;
  margin: 0 auto;
}
.player-sheet {
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  padding: 24px;
}
.player-sheet .pc-name {
  font-family: 'Cinzel', serif;
  font-size: 1.6em;
  color: var(--gold);
  text-align: center;
  margin-bottom: 16px;
}

.notes-section {
  margin-top: 20px;
  background: var(--bg);
  border-radius: 8px;
  padding: 14px;
}
.notes-section h4 { color: var(--accent); font-size: 0.9em; margin-bottom: 8px; }
.note-item {
  background: var(--surface);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 6px;
  font-size: 0.9em;
  line-height: 1.5;
  border-left: 3px solid var(--accent2);
}
.note-item .note-time { color: var(--text-dim); font-size: 0.75em; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.9em;
  z-index: 200;
  animation: fadeInUp 0.3s;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--text-dim);
}
.empty-state .icon { font-size: 2em; margin-bottom: 8px; }

@media (max-width: 600px) {
  .ability-scores { grid-template-columns: repeat(3, 1fr); }
  .player-grid { grid-template-columns: 1fr; }
  #landing h1 { font-size: 1.8em; }
  .role-cards { flex-direction: column; align-items: center; }
}