#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

/* ── Persistent stat header ──────────────────── */

#stat-header {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-bright);
  padding: 8px 14px;
  z-index: 90;
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
}

#stat-header.knocked-out {
  animation: knockedOutPulse 1.5s ease infinite;
  border-bottom-color: var(--accent-red);
}

#stat-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
}

#hdr-name-level {
  font-family: var(--font-display);
  font-size: 0.44rem;
  color: var(--accent-gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 45%;
}

#hdr-stats {
  font-family: var(--font-display);
  font-size: 0.44rem;
  color: var(--text-primary);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

#stat-header-hp {
  display: flex;
  align-items: center;
  gap: 6px;
}

#hdr-hp-label {
  font-size: 0.8rem;
  flex-shrink: 0;
  line-height: 1;
}

#hdr-hp-track {
  flex: 1;
  height: 7px;
}

#hdr-hp-text {
  font-family: var(--font-display);
  font-size: 0.4rem;
  color: var(--text-muted);
  flex-shrink: 0;
  white-space: nowrap;
}

#stat-header-energy {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

#hdr-energy-label {
  font-size: 0.8rem;
  flex-shrink: 0;
  line-height: 1;
}

#hdr-energy-track {
  flex: 1;
  height: 7px;
}

#hdr-energy-text {
  font-family: var(--font-display);
  font-size: 0.4rem;
  color: var(--accent-blue);
  flex-shrink: 0;
  white-space: nowrap;
}

#screen-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 16px 80px;
  -webkit-overflow-scrolling: touch;
}

#stat-header:not(.hidden) ~ #screen-container {
  padding-top: 92px;
}

/* Bottom navigation */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-bright);
  z-index: 100;
  safe-area-inset-bottom: env(safe-area-inset-bottom);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 56px;
  padding: 8px 4px;
  color: var(--text-muted);
  transition: color var(--transition), background var(--transition);
  border-top: 2px solid transparent;
  transition: all var(--transition);
}

.nav-btn:active {
  background: var(--bg-card);
}

.nav-btn.active {
  color: var(--accent-gold);
  border-top-color: var(--accent-gold);
}

.nav-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.nav-label {
  font-size: 0.6rem;
  font-family: var(--font-display);
  letter-spacing: 0.02em;
}

/* Modal overlay */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(2px);
  animation: fadeIn 0.15s ease;
}

#modal-overlay.slide-up {
  align-items: flex-end;
}

#modal-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 90dvh;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: slideUp 0.2s ease;
}

#modal-content {
  padding: 24px 20px 32px;
}

/* Toast notifications */
#toast-container {
  position: fixed;
  top: 92px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 448px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideDown 0.25s ease, fadeOut 0.3s ease 2.5s forwards;
  pointer-events: auto;
  box-shadow: var(--shadow);
}

.toast-achievement {
  border-color: var(--accent-gold);
  box-shadow: var(--shadow-glow-gold);
}

.toast-success {
  border-color: var(--accent-green);
}

.toast-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.toast-text {
  flex: 1;
  font-size: 0.85rem;
}

.toast-title {
  font-family: var(--font-display);
  font-size: 0.55rem;
  color: var(--accent-gold);
  margin-bottom: 2px;
}

/* Section headers */
.screen-title {
  font-family: var(--font-display);
  font-size: 0.7rem;
  color: var(--accent-gold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* Generic section */
.section {
  margin-bottom: 20px;
}

.section-label {
  font-family: var(--font-display);
  font-size: 0.5rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
}

/* Divider */
.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

@keyframes slideDown {
  from { transform: translateY(-20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

@keyframes fadeOut {
  to { opacity: 0; transform: translateY(-8px); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%       { transform: translateX(-4px); }
  75%       { transform: translateX(4px); }
}

@keyframes levelUp {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.05); }
  100% { transform: scale(1); }
}
