/* Global Reset & Fantasy Dark Theme */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: #0b0f19;
  color: #e2e8f0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

/* Main Status Card (The RPG Window) */
.status-card {
  background: linear-gradient(145deg, #131825, #0f1420);
  border: 2px solid #3b82f6;
  border-radius: 12px;
  box-shadow: 0 0 25px rgba(59, 130, 246, 0.3), inset 0 0 15px rgba(59, 130, 246, 0.1);
  width: 100%;
  max-width: 420px;
  padding: 24px;
}

/* Header & Typography */
.status-header h1 {
  font-size: 1.75rem;
  color: #f8fafc;
  letter-spacing: 1px;
  text-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

.character-subtitle {
  font-size: 0.9rem;
  color: #94a3b8;
  margin-top: 4px;
}

.divider {
  border: none;
  height: 1px;
  background: #334155;
  margin: 16px 0;
}

/* Vitals (HP / MP) Section */
.vitals-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.vital-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: bold;
  color: #cbd5e1;
  margin-bottom: 4px;
}

.bar-track {
  background-color: #1e293b;
  border: 1px solid #334155;
  border-radius: 4px;
  height: 12px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  transition: width 0.4s ease-in-out;
}

.hp-fill {
  background: linear-gradient(90deg, #ef4444, #f87171);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
}

.mp-fill {
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.6);
}

/* Attributes Section */
.attributes-section h2, .skills-section h2 {
  font-size: 1.1rem;
  color: #38bdf8;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
/* EXP Bar Styling */
.exp-fill {
  background: linear-gradient(90deg, #a855f7, #c084fc);
  box-shadow: 0 0 8px rgba(168, 85, 247, 0.6);
}

/* Attributes Section (Dot-Leader Line Layout) */
.stats-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.stats-list li {
  display: flex;
  align-items: baseline;
  font-weight: bold;
  font-size: 0.95rem;
}

.dot-leader {
  flex-grow: 1;
  border-bottom: 2px dotted #334155;
  margin: 0 8px;
}

.stat-name {
  color: #94a3b8;
  text-transform: uppercase;
}

.stat-value {
  color: #f8fafc;
}

/* Skills List Section */
.skills-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.skills-list li {
  background: #1e293b;
  border-left: 3px solid #38bdf8;
  padding: 8px 12px;
  border-radius: 0 6px 6px 0;
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
}

.skill-level {
  color: #94a3b8;
  font-size: 0.85rem;
}
/* Control Panel Styling */
.controls-section {
  margin-top: 24px;
  border-top: 1px dashed #334155;
  padding-top: 16px;
}

/* Update button grid to a balanced 2-column layout */
.button-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.rpg-btn {
  background: #1e293b;
  border: 1px solid #38bdf8;
  color: #38bdf8;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
}

.rpg-btn:hover {
  background: #38bdf8;
  color: #0b0f19;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}

.rpg-btn.danger {
  border-color: #ef4444;
  color: #ef4444;
}

.rpg-btn.danger:hover {
  background: #ef4444;
  color: #f8fafc;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

.rpg-btn.success {
  border-color: #22c55e;
  color: #22c55e;
}

.rpg-btn.success:hover {
  background: #22c55e;
  color: #f8fafc;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.5);
}

/* Purple EXP command button accent */
.rpg-btn.exp-btn {
  border-color: #c084fc;
  color: #c084fc;
}

.rpg-btn.exp-btn:hover {
  background: #a855f7;
  color: #f8fafc;
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.6);
}

/* Cosplay Display Responsiveness */
@media (max-width: 480px) {
  body {
    padding: 12px;
    align-items: flex-start;
  }
  
  .status-card {
    max-width: 100%;
    padding: 16px;
  }
  
  .button-grid {
    grid-template-columns: 1fr; /* Stack buttons vertically on small screens for easy tapping */
  }
}

.modal-card {
  background: #0b0f19;
  border: 1px solid #38bdf8;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.25);
  padding: 2rem;
  border-radius: 8px;
  width: 90%;
  max-width: 400px;
}

.modal-header h2 {
  color: #38bdf8;
  margin-top: 0;
  letter-spacing: 1px;
}

.modal-header p {
  color: #94a3b8;
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

.form-group {
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  color: #e2e8f0;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input {
  background: #1e293b;
  border: 1px solid #475569;
  color: #fff;
  padding: 0.75rem;
  border-radius: 4px;
  font-size: 1rem;
}

.form-group input:focus {
  outline: none;
  border-color: #38bdf8;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.4);
}

.full-width {
  width: 100%;
  margin-top: 1rem;
}

/* Helper Class to hide/show views */
.hidden {
  display: none !important;
}
/* Stat Allocation Section Styling */
.attributes-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.attributes-header h2 {
  margin: 0;
}

.points-badge {
  font-size: 0.8rem;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 0.25rem 0.6rem;
  border-radius: 12px;
  font-weight: 600;
}

.stat-controls {
  display: inline-flex;
  gap: 0.25rem;
  margin-left: 0.5rem;
}

.stat-btn {
  background: #1e293b;
  border: 1px solid #38bdf8;
  color: #38bdf8;
  border-radius: 4px;
  width: 22px;
  height: 22px;
  font-size: 0.85rem;
  font-weight: bold;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.stat-btn:hover {
  background: #38bdf8;
  color: #0b0f19;
  box-shadow: 0 0 6px rgba(56, 189, 248, 0.6);
}

.stat-btn:active {
  transform: scale(0.92);
}

/* Fullscreen dimmed backdrop */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

/* The popup window */
.modal-box {
  background: #0a1128;
  border: 2px solid #00d4ff;
  box-shadow: 0 0 15px rgba(0, 212, 255, 0.4);
  padding: 24px;
  border-radius: 8px;
  max-width: 380px;
  text-align: center;
  color: #e0f7fa;
}

.modal-actions {
  margin-top: 20px;
  display: flex;
  justify-content: space-around;
  gap: 12px;
}

/* --- Shared Base Button Styling --- */
.modal-actions .btn {
  background: transparent;
  font-family: inherit; /* Inherits your system font */
  font-size: 0.9rem;
  font-weight: bold;
  padding: 8px 18px;
  border-radius: 6px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: all 0.2s ease-in-out;
}

/* --- Secondary (Review / Cancel) Button --- */
.modal-actions .btn-secondary {
  color: #ff5252;
  border: 1.5px solid #ff5252;
  box-shadow: inset 0 0 6px rgba(255, 82, 82, 0.2);
}

.modal-actions .btn-secondary:hover {
  background: rgba(255, 82, 82, 0.15);
  box-shadow: 0 0 12px rgba(255, 82, 82, 0.6), inset 0 0 8px rgba(255, 82, 82, 0.4);
  transform: translateY(-1px);
}

/* --- Primary (Accept / Confirm) Button --- */
.modal-actions .btn-primary {
  color: #00d4ff;
  border: 1.5px solid #00d4ff;
  box-shadow: inset 0 0 6px rgba(0, 212, 255, 0.2);
}

.modal-actions .btn-primary:hover {
  background: rgba(0, 212, 255, 0.15);
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.6), inset 0 0 8px rgba(0, 212, 255, 0.4);
  transform: translateY(-1px);
}

/* Click Active State (tactile push feel) */
.modal-actions .btn:active {
  transform: translateY(1px);
}

/* --- Level Up Animation Overlay --- */
.status-card {
  position: relative; /* Anchor point for absolute overlay positioning */
}

.levelup-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  opacity: 0;
  pointer-events: none; /* Prevents blocking clicks when invisible */
  z-index: 100;
  text-align: center;
  width: 100%;
}

.levelup-banner span {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 4px;
  color: #fbbf24;
  text-shadow: 
    0 0 10px rgba(251, 191, 36, 0.8),
    0 0 25px rgba(245, 158, 11, 0.6),
    0 0 50px rgba(217, 119, 6, 0.4);
  text-transform: uppercase;
}

/* The Triggered Animation Class */
.levelup-banner.animate-levelup {
  animation: levelUpSequence 1.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes levelUpSequence {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.4);
  }
  25% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.15);
  }
  40% {
    transform: translate(-50%, -50%) scale(1);
  }
  75% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -65%) scale(1.1);
  }
}

/* --- Header Layout for Icon Alignment --- */
.status-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

/* --- 2x2 Cyber Waffle Icon Button --- */
.menu-toggle-btn {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid #38bdf8;
  border-radius: 6px;
  width: 34px;
  height: 34px;
  display: grid;
  grid-template-columns: repeat(2, 6px);
  grid-gap: 4px;
  justify-content: center;
  align-content: center;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.2);
  transition: all 0.2s ease-in-out;
}

.menu-toggle-btn:hover {
  background: rgba(56, 189, 248, 0.2);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.6);
  transform: scale(1.05);
}

.waffle-dot {
  width: 6px;
  height: 6px;
  background-color: #38bdf8;
  border-radius: 1px;
  box-shadow: 0 0 4px #38bdf8;
}

/* --- Smooth Collapsible Drawer Animation --- */
.controls-section {
  max-height: 250px;
  opacity: 1;
  overflow: hidden;
  transition: max-height 0.3s ease-out, opacity 0.25s ease-out, margin 0.3s ease;
}

.controls-section.collapsed {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

/* --- Critical HP Window Warning (10% or below) --- */
.status-card.critical-status {
  border-color: #ef4444 !important;
  animation: windowCriticalPulse 1.2s infinite ease-in-out;
}

@keyframes windowCriticalPulse {
  0% {
    box-shadow: 0 0 25px rgba(239, 68, 68, 0.4), inset 0 0 15px rgba(239, 68, 68, 0.2);
  }
  50% {
    box-shadow: 0 0 50px rgba(239, 68, 68, 0.85), inset 0 0 30px rgba(239, 68, 68, 0.45);
  }
  100% {
    box-shadow: 0 0 25px rgba(239, 68, 68, 0.4), inset 0 0 15px rgba(239, 68, 68, 0.2);
  }
}

/* --- Death Modal Styling --- */
.death-backdrop {
  background: rgba(15, 0, 0, 0.85);
  backdrop-filter: blur(10px);
}

.death-card {
  border-color: #ef4444;
  box-shadow: 0 0 35px rgba(239, 68, 68, 0.6), inset 0 0 20px rgba(239, 68, 68, 0.2);
}

.death-title {
  color: #ef4444;
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: 3px;
  text-shadow: 0 0 15px rgba(239, 68, 68, 0.8);
  margin-bottom: 8px;
}

.death-subtitle {
  color: #fca5a5;
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.btn-respawn {
  width: 100%;
  color: #f87171;
  border: 1.5px solid #ef4444;
  background: rgba(239, 68, 68, 0.15);
  padding: 10px 16px;
}

.btn-respawn:hover {
  background: #ef4444;
  color: #0b0f19;
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.8);
}

/* Ensure the card is the coordinate anchor */
.status-card {
  position: relative;
}

/* --- Attached Quest Tab --- */
.card-quest-tab {
  position: absolute;
  left: -28px;
  top: 60px;
  background: #131825;
  border: 1.5px solid #38bdf8;
  border-right: none;
  border-radius: 6px 0 0 6px;
  padding: 10px 4px;
  cursor: pointer;
  z-index: 20;
  box-shadow: -4px 0 10px rgba(56, 189, 248, 0.3);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Hide the tab when drawer is open so it doesn't overlap the border */
.card-quest-tab.hidden-tab {
  opacity: 0;
  pointer-events: none;
  transform: translateX(10px);
}

.quest-tab-text {
  writing-mode: vertical-rl;
  text-orientation: upright;
  color: #38bdf8;
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 2px;
}

/* --- Attached Left-Flank Wing Panel --- */
.quest-wing {
  position: absolute;
  top: -2px;
  right: 100%;
  width: 290px;
  max-width: 80vw;
  height: calc(100% + 4px); /* Scales 1:1 with card height */
  background: linear-gradient(145deg, #131825, #0b0f19);
  border: 2px solid #38bdf8;
  border-right: none;
  border-radius: 12px 0 0 12px;
  box-shadow: -10px 0 25px rgba(0, 0, 0, 0.7), inset 0 0 15px rgba(56, 189, 248, 0.1);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  z-index: 15;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
  transform-origin: right center;
}

.quest-wing.collapsed {
  transform: translateX(20px) scaleX(0);
  opacity: 0;
  pointer-events: none;
}

.wing-close-btn {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
}

.wing-close-btn:hover {
  color: #ef4444;
}

.quest-wing-desc {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-bottom: 12px;
}

/* Sub-headings for Active vs Completed */
.quest-section-title {
  font-size: 0.75rem;
  color: #38bdf8;
  letter-spacing: 1px;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.quest-section-title.completed-title {
  color: #22c55e;
}

.completed-log .quest-item {
  border-left-color: #22c55e;
  opacity: 0.6;
  background: rgba(30, 41, 59, 0.4);
}

/* Quest List & Item Formatting */
.quest-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.quest-item {
  background: #1e293b;
  border: 1px solid #334155;
  border-left: 3px solid #fbbf24;
  border-radius: 4px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.quest-item.completed {
  border-left-color: #22c55e;
  opacity: 0.55;
}

.quest-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.quest-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: #f8fafc;
}

.quest-item.completed .quest-title {
  text-decoration: line-through;
  color: #94a3b8;
}

.quest-reward {
  font-size: 0.7rem;
  font-weight: bold;
  color: #fbbf24;
}

.btn-complete-quest {
  align-self: flex-end;
  background: rgba(251, 191, 36, 0.15);
  border: 1px solid #fbbf24;
  color: #fbbf24;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: bold;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-complete-quest:hover {
  background: #fbbf24;
  color: #0b0f19;
}