/* ============================================================
   RPG REALM — Dark Fantasy Theme
   ============================================================ */

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

:root {
  --bg:          #07090f;
  --surface:     #0d1117;
  --card:        #111722;
  --card2:       #161e2e;
  --border:      #1e2d44;
  --border-glow: #2a4070;
  --gold:        #c9a227;
  --gold-light:  #f0c040;
  --gold-dark:   #7a600a;
  --red:         #c0392b;
  --red-light:   #e74c3c;
  --green:       #27ae60;
  --green-light: #2ecc71;
  --blue:        #2980b9;
  --blue-light:  #3498db;
  --purple:      #8e44ad;
  --purple-light:#9b59b6;
  --text:        #d4c9b0;
  --text-bright: #f0e6cc;
  --text-muted:  #6b7a8d;
  --warrior:     #c0392b;
  --mage:        #8e44ad;
  --hunter:      #27ae60;
  --radius:      8px;
  --radius-lg:   14px;
  --shadow:      0 4px 24px rgba(0,0,0,0.6);
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Open Sans', sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-glow); border-radius: 3px; }

/* ---- Utility ---- */
.hidden { display: none !important; }
.text-gold   { color: var(--gold-light); }
.text-red    { color: var(--red-light); }
.text-green  { color: var(--green-light); }
.text-muted  { color: var(--text-muted); }

/* ---- Typography ---- */
h1, h2, h3, .font-cinzel {
  font-family: 'Cinzel', serif;
  letter-spacing: 0.05em;
}

/* ============================================================
   SCREEN MANAGEMENT
   ============================================================ */
.screen { min-height: 100vh; }

/* ============================================================
   AUTH SCREEN
   ============================================================ */
#screen-auth {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #0d1a2e 0%, #07090f 70%);
  padding: 20px;
}

.auth-box {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow), 0 0 60px rgba(100,150,255,0.05);
  overflow: hidden;
}

.auth-logo {
  text-align: center;
  padding: 32px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.auth-logo h1 {
  font-family: 'Cinzel Decorative', serif;
  font-size: 2rem;
  color: var(--gold-light);
  text-shadow: 0 0 20px rgba(201,162,39,0.4);
}

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

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.auth-tab {
  flex: 1;
  padding: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.08em;
}

.auth-tab.active {
  color: var(--gold-light);
  background: rgba(201,162,39,0.08);
  border-bottom: 2px solid var(--gold);
}

.auth-tab:hover:not(.active) { color: var(--text); background: rgba(255,255,255,0.03); }

.auth-form { padding: 24px; }
.auth-panel { display: none; }
.auth-panel.active { display: block; }

.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-bright);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus { border-color: var(--gold-dark); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #b8860b, #c9a227);
  color: #0a0800;
  font-weight: 700;
  box-shadow: 0 2px 12px rgba(201,162,39,0.25);
}

.btn-primary:hover { background: linear-gradient(135deg, #c9a227, #f0c040); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.auth-error {
  background: rgba(192,57,43,0.15);
  border: 1px solid rgba(192,57,43,0.4);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 16px;
  color: var(--red-light);
  font-size: 0.85rem;
  display: none;
}

/* ============================================================
   CHARACTER CREATION SCREEN
   ============================================================ */
#screen-create {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: radial-gradient(ellipse at center, #0d1a2e 0%, #07090f 70%);
}

.create-box {
  width: 100%;
  max-width: 700px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 32px;
}

.create-box h2 {
  text-align: center;
  color: var(--gold-light);
  font-size: 1.4rem;
  margin-bottom: 24px;
}

.class-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.class-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.class-card:hover { border-color: var(--border-glow); transform: translateY(-2px); }
.class-card.selected { border-color: var(--gold); background: rgba(201,162,39,0.08); }
.class-card.selected.warrior { border-color: var(--warrior); background: rgba(192,57,43,0.1); }
.class-card.selected.mage    { border-color: var(--purple);  background: rgba(142,68,173,0.1); }
.class-card.selected.hunter  { border-color: var(--hunter);  background: rgba(39,174,96,0.1); }

.class-icon { font-size: 2.5rem; margin-bottom: 8px; }

.class-card h3 {
  font-family: 'Cinzel', serif;
  font-size: 0.95rem;
  color: var(--text-bright);
  margin-bottom: 8px;
}

.class-stats { font-size: 0.75rem; color: var(--text-muted); line-height: 1.6; }
.class-stats span { display: block; }

.create-name-row { display: flex; gap: 12px; align-items: flex-end; }
.create-name-row .form-group { flex: 1; margin-bottom: 0; }

/* ============================================================
   GAME SCREEN
   ============================================================ */
#screen-game {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.game-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.game-title {
  font-family: 'Cinzel Decorative', serif;
  font-size: 1.1rem;
  color: var(--gold-light);
  text-shadow: 0 0 10px rgba(201,162,39,0.3);
}

.header-player {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.header-player strong { color: var(--text-bright); }

.btn-logout {
  padding: 6px 14px;
  background: rgba(192,57,43,0.15);
  border: 1px solid rgba(192,57,43,0.3);
  border-radius: var(--radius);
  color: var(--red-light);
  font-family: 'Cinzel', serif;
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.05em;
}

.btn-logout:hover { background: rgba(192,57,43,0.3); }

/* Main layout */
.game-main {
  flex: 1;
  display: grid;
  grid-template-columns: 220px 1fr 200px;
  gap: 0;
  overflow: hidden;
}

/* Panels */
.panel {
  padding: 16px;
  overflow-y: auto;
}

.panel-left  { background: var(--card);  border-right: 1px solid var(--border); }
.panel-right { background: var(--card);  border-left:  1px solid var(--border); }
.panel-center { background: var(--bg); }

.panel-title {
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin-bottom: 14px;
}

/* ---- Character Stats ---- */
.char-name {
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  color: var(--text-bright);
  margin-bottom: 2px;
}

.char-class {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 14px;
}

.class-warrior { color: var(--warrior); }
.class-mage    { color: var(--purple-light); }
.class-hunter  { color: var(--hunter); }

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  font-size: 0.82rem;
}

.stat-label { color: var(--text-muted); }
.stat-value { color: var(--text-bright); font-weight: 600; }
.stat-value.gold { color: var(--gold-light); }

/* Progress bars */
.bar-wrap {
  margin: 10px 0;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.bar {
  height: 8px;
  background: rgba(255,255,255,0.06);
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.bar-hp   .bar-fill { background: linear-gradient(90deg, #8b0000, var(--red-light)); }
.bar-exp  .bar-fill { background: linear-gradient(90deg, #1a6634, var(--green-light)); }
.bar-mhp  .bar-fill { background: linear-gradient(90deg, #8b0000, var(--red-light)); }

/* ============================================================
   COMBAT ARENA
   ============================================================ */
.combat-arena {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  min-height: 0;
  height: 100%;
  position: relative;
}

/* Zone background overlays */
.zone-meadow  { background: radial-gradient(ellipse at 50% 30%, #0a2010 0%, #07090f 70%); }
.zone-forest  { background: radial-gradient(ellipse at 50% 30%, #0a1020 0%, #05080f 70%); }
.zone-ruins   { background: radial-gradient(ellipse at 50% 30%, #1a1508 0%, #0a0a07 70%); }
.zone-lair    { background: radial-gradient(ellipse at 50% 30%, #200808 0%, #0f0505 70%); }

/* Monster display */
.monster-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  position: relative;
}

.monster-emoji {
  font-size: 6rem;
  line-height: 1;
  animation: float 3s ease-in-out infinite;
  display: block;
  cursor: pointer;
  user-select: none;
  transition: transform 0.1s;
  filter: drop-shadow(0 0 20px rgba(255,100,50,0.2));
}

.monster-emoji.hit {
  animation: monster-hit 0.3s ease-out;
}

.monster-emoji.dead {
  animation: monster-die 0.5s ease-out forwards;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-12px); }
}

@keyframes monster-hit {
  0%   { transform: scale(1) translateX(0); }
  25%  { transform: scale(0.9) translateX(-8px); }
  75%  { transform: scale(0.95) translateX(8px); }
  100% { transform: scale(1) translateX(0); }
}

@keyframes monster-die {
  0%   { transform: scale(1) rotate(0deg); opacity: 1; }
  50%  { transform: scale(1.3) rotate(15deg); opacity: 0.5; }
  100% { transform: scale(0) rotate(45deg); opacity: 0; }
}

.monster-name {
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  color: var(--text-bright);
  margin: 12px 0 6px;
}

.monster-hp-bar {
  width: 100%;
  max-width: 300px;
  margin-bottom: 6px;
}

.monster-hp-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

/* Damage numbers */
.damage-number {
  position: absolute;
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 1.4rem;
  pointer-events: none;
  animation: dmg-float 1.2s ease-out forwards;
  text-shadow: 0 2px 4px rgba(0,0,0,0.8);
  z-index: 100;
}

.damage-number.dmg-player { color: #ff6b35; }
.damage-number.dmg-taken  { color: #ff2244; font-size: 1.1rem; }
.damage-number.dmg-gold   { color: var(--gold-light); font-size: 1rem; }
.damage-number.dmg-exp    { color: var(--green-light); font-size: 1rem; }

@keyframes dmg-float {
  0%   { transform: translateY(0) scale(1); opacity: 1; }
  60%  { transform: translateY(-60px) scale(1.1); opacity: 1; }
  100% { transform: translateY(-90px) scale(0.8); opacity: 0; }
}

/* Attack button area */
.attack-area {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding-bottom: 8px;
}

.btn-attack {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle, #3a0808, #1a0404);
  border: 3px solid var(--red);
  color: #ff6b6b;
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 0.1s;
  box-shadow: 0 0 20px rgba(192,57,43,0.3), inset 0 0 30px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn-attack:hover:not(:disabled) {
  background: radial-gradient(circle, #5a0c0c, #2a0606);
  box-shadow: 0 0 35px rgba(192,57,43,0.5), inset 0 0 20px rgba(0,0,0,0.3);
  border-color: var(--red-light);
  color: #ffaaaa;
}

.btn-attack:active:not(:disabled) {
  transform: scale(0.94);
  box-shadow: 0 0 15px rgba(192,57,43,0.4);
}

.btn-attack:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-attack-icon { font-size: 2rem; }

.btn-attack.mage-style {
  background: radial-gradient(circle, #2a0840, #140320);
  border-color: var(--purple);
  color: #cc88ff;
  box-shadow: 0 0 20px rgba(142,68,173,0.3), inset 0 0 30px rgba(0,0,0,0.5);
}

.btn-attack.hunter-style {
  background: radial-gradient(circle, #082a10, #041408);
  border-color: var(--hunter);
  color: #88ffaa;
  box-shadow: 0 0 20px rgba(39,174,96,0.3), inset 0 0 30px rgba(0,0,0,0.5);
}

/* Auto attack toggle */
.auto-attack-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.toggle {
  position: relative;
  width: 40px;
  height: 22px;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.08);
  border-radius: 11px;
  cursor: pointer;
  transition: 0.3s;
  border: 1px solid var(--border);
}

.toggle-slider:before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  top: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: 0.3s;
}

.toggle input:checked + .toggle-slider { background: rgba(192,57,43,0.3); border-color: var(--red); }
.toggle input:checked + .toggle-slider:before { transform: translateX(18px); background: var(--red-light); }

/* Combat Log */
.combat-log {
  width: 100%;
  max-width: 500px;
  height: 100px;
  overflow-y: auto;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 0.75rem;
  font-family: monospace;
}

.log-entry {
  padding: 1px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.log-entry:last-child { border-bottom: none; }
.log-hit    { color: #e8a87c; }
.log-kill   { color: var(--gold-light); font-weight: 600; }
.log-levelup{ color: var(--green-light); font-weight: 600; }
.log-dmg    { color: #e87c7c; }
.log-death  { color: var(--red-light); font-weight: 600; }

/* ---- Zone Panel (right) ---- */
.zone-list { margin-bottom: 20px; }

.zone-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  margin-bottom: 6px;
  transition: all 0.15s;
  font-size: 0.8rem;
}

.zone-item:hover:not(.zone-locked) { background: rgba(255,255,255,0.04); border-color: var(--border); }
.zone-item.zone-active { background: rgba(201,162,39,0.1); border-color: var(--gold-dark); }
.zone-item.zone-locked { opacity: 0.4; cursor: not-allowed; }

.zone-icon { font-size: 1.1rem; }
.zone-info-name { font-family: 'Cinzel', serif; font-size: 0.75rem; color: var(--text-bright); }
.zone-info-req  { font-size: 0.68rem; color: var(--text-muted); }

/* Leaderboard */
.leaderboard { font-size: 0.75rem; }
.lb-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.lb-rank  { color: var(--text-muted); width: 18px; }
.lb-name  { color: var(--text-bright); flex: 1; font-family: 'Cinzel', serif; }
.lb-level { color: var(--gold); }

/* ============================================================
   DEATH OVERLAY
   ============================================================ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.death-box {
  background: var(--card);
  border: 2px solid var(--red);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  max-width: 360px;
  box-shadow: 0 0 60px rgba(192,57,43,0.3);
}

.death-box h2 {
  font-size: 2rem;
  color: var(--red-light);
  margin-bottom: 8px;
  text-shadow: 0 0 20px rgba(231,76,60,0.5);
}

.death-box p {
  color: var(--text-muted);
  margin-bottom: 24px;
  font-size: 0.9rem;
}

.btn-revive {
  background: linear-gradient(135deg, #8b0000, #c0392b);
  color: #ffd;
  padding: 12px 32px;
  font-size: 0.9rem;
  border-radius: var(--radius);
  border: none;
  font-family: 'Cinzel', serif;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 4px 16px rgba(192,57,43,0.3);
}

.btn-revive:hover { background: linear-gradient(135deg, #c0392b, #e74c3c); }

/* ============================================================
   LEVEL UP ANIMATION
   ============================================================ */
.levelup-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
}

.levelup-text {
  font-family: 'Cinzel Decorative', serif;
  font-size: 3rem;
  color: var(--gold-light);
  text-shadow: 0 0 30px rgba(201,162,39,0.8), 0 0 60px rgba(201,162,39,0.4);
  animation: levelup-anim 2.5s ease-out forwards;
}

@keyframes levelup-anim {
  0%   { transform: scale(0.5); opacity: 0; }
  20%  { transform: scale(1.2); opacity: 1; }
  60%  { transform: scale(1.0); opacity: 1; }
  100% { transform: scale(1.1) translateY(-40px); opacity: 0; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .game-main {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    overflow-y: auto;
  }

  .panel-left  { border-right: none; border-bottom: 1px solid var(--border); }
  .panel-right { border-left: none;  border-top:    1px solid var(--border); }

  .combat-arena { min-height: 70vh; }
  .monster-emoji { font-size: 5rem; }
  .btn-attack { width: 130px; height: 130px; font-size: 0.85rem; }

  .class-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
}

@media (max-width: 500px) {
  .class-grid { grid-template-columns: 1fr; }
  .create-box { padding: 20px; }
}
