:root {
  --bg-dark: #0b0f14;
  --bg-card: #121820;
  --bg-card-hover: #17202c;
  --bg-secondary: #1a222f;
  --border-dim: #232f42;
  --border-gold: #c59b27;
  --border-glow: rgba(197, 155, 39, 0.4);
  
  --text-main: #e6edf3;
  --text-muted: #8b9bb4;
  --text-gold: #e5b93b;
  --text-cyan: #38bdf8;
  --text-emerald: #34d399;
  
  --accent-gold: #d4a72c;
  --accent-gold-hover: #e5b93b;
  --accent-cyan: #0ea5e9;
  --danger: #ef4444;

  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.5);
  --shadow-hover: 0 8px 30px rgba(197, 155, 39, 0.2);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

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

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: 'Inter', -apple-system, sans-serif;
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 15% 10%, rgba(30, 58, 102, 0.25) 0%, transparent 40%),
    radial-gradient(circle at 85% 90%, rgba(197, 155, 39, 0.1) 0%, transparent 50%);
}

h1, h2, h3, h4, .brand-title {
  font-family: 'Cinzel', serif;
  letter-spacing: 0.5px;
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Navigation Bar */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(18, 24, 32, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-dim);
  padding: 0.85rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-icon {
  font-size: 1.8rem;
  filter: drop-shadow(0 0 8px rgba(197, 155, 39, 0.5));
}

.brand-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-gold);
  line-height: 1.1;
  display: block;
}

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

/* Character Selector */
.char-picker-container {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-secondary);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-dim);
}

.char-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.select-wrapper select {
  background: transparent;
  border: none;
  color: var(--text-cyan);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  outline: none;
}

.select-wrapper select option {
  background: var(--bg-card);
  color: var(--text-main);
}

/* Coins Badge */
.coins-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: linear-gradient(135deg, rgba(197, 155, 39, 0.2), rgba(30, 41, 59, 0.6));
  border: 1px solid var(--border-gold);
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  box-shadow: 0 0 12px rgba(197, 155, 39, 0.2);
}

.coin-icon {
  font-size: 1.1rem;
}

.coin-amount {
  font-weight: 700;
  color: var(--text-gold);
  font-size: 1rem;
}

.coin-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* User Identity */
.user-profile {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-secondary);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-dim);
  font-size: 0.85rem;
}

.user-name {
  font-weight: 600;
  color: var(--text-main);
}

.btn-logout {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  padding-left: 0.4rem;
  transition: color 0.2s;
}

.btn-logout:hover {
  color: var(--danger);
}

/* Buttons */
.btn {
  font-family: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  border: none;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-gold), #a37f1e);
  color: #0b0f14;
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(197, 155, 39, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-gold-hover), #b89025);
  box-shadow: 0 4px 15px rgba(197, 155, 39, 0.5);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-main);
  border: 1px solid var(--border-dim);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-muted);
}

.btn-icon {
  padding: 0.5rem 0.8rem;
  border-radius: var(--radius-md);
}

.badge-pill {
  background: var(--accent-cyan);
  color: #0b0f14;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  margin-left: 0.2rem;
}

/* Hero Section */
.hero-banner {
  padding: 2.5rem 2rem 1.5rem;
  text-align: center;
  max-width: 900px;
  margin: 0 auto;
}

.hero-content h1 {
  font-size: 2.2rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 0.6rem;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.7);
}

.hero-content p {
  color: var(--text-muted);
  font-size: 1rem;
}

/* Catalog Controls */
.catalog-controls {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.category-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tab-btn {
  background: var(--bg-secondary);
  color: var(--text-muted);
  border: 1px solid var(--border-dim);
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tab-btn:hover {
  color: var(--text-main);
  background: var(--bg-card-hover);
  border-color: var(--border-gold);
}

.tab-btn.active {
  background: linear-gradient(135deg, rgba(197, 155, 39, 0.25), rgba(30, 41, 59, 0.8));
  color: var(--text-gold);
  border-color: var(--border-gold);
  box-shadow: 0 0 12px rgba(197, 155, 39, 0.25);
}

.search-box {
  position: relative;
  min-width: 280px;
}

.search-box input {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-md);
  padding: 0.6rem 2.2rem 0.6rem 2.2rem;
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-box input:focus {
  border-color: var(--border-gold);
  box-shadow: 0 0 8px rgba(197, 155, 39, 0.3);
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
  opacity: 0.6;
}

.clear-btn {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}

/* Items Section */
.items-section {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 2rem;
  width: 100%;
}

.catalog-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.2rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.delivery-notice {
  color: var(--text-cyan);
  font-size: 0.8rem;
}

.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

/* Item Card */
.item-card {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-card);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.item-card:hover {
  transform: translateY(-4px);
  background: var(--bg-card-hover);
  border-color: var(--border-gold);
  box-shadow: var(--shadow-hover);
}

.item-card-header {
  display: flex;
  gap: 0.9rem;
  margin-bottom: 0.8rem;
}

.item-icon-frame {
  width: 48px;
  height: 48px;
  min-width: 48px;
  background: #000;
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: inset 0 0 8px rgba(197, 155, 39, 0.3);
}

.item-info h3 {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  margin-bottom: 0.25rem;
}

.item-category-tag {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 700;
  color: var(--text-cyan);
}

.item-details {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex-grow: 1;
}

.item-effect {
  color: var(--text-gold);
  font-style: italic;
}

.item-lore {
  font-size: 0.75rem;
  opacity: 0.7;
}

.item-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 0.85rem;
}

.item-cost {
  font-weight: 700;
  color: var(--text-gold);
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.95rem;
}

/* Modals & Drawers */
.modal-backdrop, .drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-backdrop.active, .drawer-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 90%;
  padding: 1.5rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
  transform: scale(0.95);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.active .modal {
  transform: scale(1);
}

.modal-header, .drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.2rem;
  border-bottom: 1px solid var(--border-dim);
  padding-bottom: 0.8rem;
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  transition: color 0.2s;
}

.btn-close:hover {
  color: #fff;
}

.modal-item-preview {
  display: flex;
  gap: 1rem;
  align-items: center;
  background: var(--bg-secondary);
  padding: 0.9rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.2rem;
}

.modal-summary {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
  padding-bottom: 0.4rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.8rem;
}

/* Slide-over Drawer */
.drawer {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 440px;
  max-width: 90vw;
  background: var(--bg-card);
  border-left: 1px solid var(--border-dim);
  padding: 1.5rem;
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.drawer-backdrop.active .drawer {
  transform: translateX(0);
}

.drawer-body {
  flex-grow: 1;
  overflow-y: auto;
}

.drawer-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1.2rem;
  line-height: 1.4;
}

.parcel-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-md);
  padding: 0.9rem;
  margin-bottom: 0.8rem;
}

.parcel-card h4 {
  font-size: 0.95rem;
  color: var(--text-gold);
  margin-bottom: 0.2rem;
}

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

/* Toast Hub */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 300;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  padding: 0.9rem 1.2rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 0.8rem;
  color: #fff;
  font-size: 0.9rem;
  min-width: 320px;
  animation: slideIn 0.3s ease;
}

.toast.success {
  border-color: var(--text-emerald);
}

.toast.error {
  border-color: var(--danger);
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Loading State */
.loading-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-muted);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(197, 155, 39, 0.2);
  border-top-color: var(--border-gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Utilities */
.text-gold { color: var(--text-gold); }
.text-cyan { color: var(--text-cyan); }
.text-emerald { color: var(--text-emerald); }

/* Responsive */
@media (max-width: 768px) {
  .navbar { padding: 0.85rem 1rem; flex-direction: column; gap: 0.8rem; }
  .nav-controls { width: 100%; justify-content: space-between; flex-wrap: wrap; }
  .catalog-controls { padding: 0 1rem; flex-direction: column; }
  .search-box { width: 100%; }
}
