/* === APP SHELL === */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  position: relative;
}

/* Header */
.hdr {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-4);
  background: var(--bg-glass);
  backdrop-filter: blur(20px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
  transition: transform var(--duration-normal) var(--ease);
}

.hdr--hidden { transform: translateY(-100%); }

.hdr-brand {
  font-weight: 800;
  font-size: 20px;
  color: var(--gold);
  letter-spacing: -0.5px;
}

.hdr-center {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.hdr-level {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 4px 10px;
  background: var(--bg-2);
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
}

.hdr-currency {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.hdr-currency-icon {
  width: 16px;
  height: 16px;
}

.hdr-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

.hdr-btn {
  position: relative;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  color: var(--text-3);
  transition: background var(--duration-fast), color var(--duration-fast);
}

.hdr-btn:active { background: var(--bg-2); color: var(--text-1); }

.hdr-btn-dot {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 8px;
  height: 8px;
  background: var(--loss);
  border-radius: 50%;
  border: 2px solid var(--bg-0);
  animation: pulse-dot 2s infinite;
}

/* Main content area */
.main {
  flex: 1;
  padding-top: var(--header-h);
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + var(--sp-4));
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
}

.main-inner {
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

/* Bottom Navigation */
.nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg-glass);
  backdrop-filter: blur(20px) saturate(1.4);
  border-top: 1px solid var(--border);
  transition: transform var(--duration-normal) var(--ease);
}

.nav--hidden { transform: translateY(100%); }

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: var(--nav-h);
  color: var(--text-3);
  font-size: 10px;
  font-weight: 500;
  transition: color var(--duration-fast);
  position: relative;
}

.nav-item.active { color: var(--cyan); }

.nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  background: var(--cyan);
  border-radius: 0 0 var(--r-full) var(--r-full);
}

.nav-item .icon {
  width: 22px;
  height: 22px;
  transition: transform var(--duration-fast) var(--ease-bounce);
}

.nav-item:active .icon { transform: scale(0.85); }

.nav-badge {
  position: absolute;
  top: 6px;
  left: 50%;
  margin-left: 6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--loss);
  border-radius: var(--r-full);
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

/* Desktop sidebar */
@media (min-width: 768px) {
  .nav { display: none; }

  .sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--bg-surface);
    border-left: 1px solid var(--border);
    padding: var(--sp-5) var(--sp-3);
    overflow-y: auto;
    z-index: 90;
  }

  .main {
    margin-right: var(--sidebar-w);
    max-width: 600px;
  }

  .hdr {
    right: var(--sidebar-w);
  }
}

/* Sidebar (hidden on mobile) */
.sidebar {
  display: none;
}

.sidebar-brand {
  font-weight: 800;
  font-size: 22px;
  color: var(--gold);
  padding: 0 var(--sp-3);
  margin-bottom: var(--sp-6);
}

.sidebar-section {
  margin-bottom: var(--sp-4);
}

.sidebar-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-3);
  padding: 0 var(--sp-3);
  margin-bottom: var(--sp-2);
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  transition: background var(--duration-fast), color var(--duration-fast);
}

.sidebar-item:active { background: rgba(255,255,255,0.04); color: var(--text-1); }
.sidebar-item.active { background: var(--cyan-dim); color: var(--cyan); }

/* Screen transitions */
.screen {
  animation: screen-enter var(--duration-normal) var(--ease) both;
}

.screen-exit {
  animation: screen-exit var(--duration-fast) var(--ease) both;
}

@keyframes screen-enter {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes screen-exit {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-8px); }
}

/* Toast container */
.toast-layer {
  position: fixed;
  top: calc(var(--header-h) + var(--sp-3));
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
  width: calc(100% - var(--sp-8));
  max-width: 360px;
}

/* Overlay / modals */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity var(--duration-normal);
  pointer-events: none;
}

.overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* Particle canvas */
#particles {
  position: fixed;
  inset: 0;
  z-index: 300;
  pointer-events: none;
}

/* Icon base */
.icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }
.icon-xl { width: 32px; height: 32px; }
.icon-fill { fill: currentColor; stroke: none; }

/* Game immersive mode */
.immersive .hdr,
.immersive .nav { transform: translateY(-100%); }
.immersive .nav { transform: translateY(100%); }
.immersive .main { padding-top: 0; padding-bottom: 0; max-width: 100%; }
