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

body {
  background-color: #0d0d1a;
  color: #f5e6d3;
  font-family: 'IBM Plex Sans', sans-serif;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

#root {
  height: 100vh;
  height: 100dvh;
}

::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: #141428;
}
::-webkit-scrollbar-thumb {
  background: #2a1f4e;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #8b5cf6;
}

@keyframes float-petal {
  0% { transform: translateY(-10vh) translateX(0) rotate(0deg); opacity: 0; }
  10% { opacity: 0.6; }
  90% { opacity: 0.6; }
  100% { transform: translateY(110vh) translateX(100px) rotate(720deg); opacity: 0; }
}

@keyframes glow-pulse {
  0%, 100% { text-shadow: 0 0 10px rgba(139, 92, 246, 0.5), 0 0 20px rgba(139, 92, 246, 0.3); }
  50% { text-shadow: 0 0 20px rgba(139, 92, 246, 0.8), 0 0 40px rgba(139, 92, 246, 0.5), 0 0 60px rgba(236, 72, 153, 0.3); }
}

@keyframes warning-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; box-shadow: 0 0 8px rgba(239, 68, 68, 0.6); }
}

@keyframes toast-slide {
  0% { transform: translateX(120%); opacity: 0; }
  10% { transform: translateX(0); opacity: 1; }
  90% { transform: translateX(0); opacity: 1; }
  100% { transform: translateX(120%); opacity: 0; }
}

@keyframes typewriter-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

@keyframes danger-border {
  0%, 100% { border-color: #2a1f4e; }
  50% { border-color: #ef4444; box-shadow: 0 0 15px rgba(239, 68, 68, 0.3); }
}

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

.petal {
  position: fixed;
  width: 8px;
  height: 8px;
  background: radial-gradient(ellipse, #ffb7c5 0%, #ff69b4 100%);
  border-radius: 50% 0 50% 0;
  pointer-events: none;
  z-index: 0;
  animation: float-petal linear infinite;
  opacity: 0;
}

.title-glow {
  animation: glow-pulse 3s ease-in-out infinite;
}

.stat-warning {
  animation: warning-pulse 1s ease-in-out infinite;
}

.toast-anim {
  animation: toast-slide 3.5s ease-in-out forwards;
}

.danger-border {
  animation: danger-border 1.5s ease-in-out infinite;
}

.fade-in {
  animation: fadeIn 0.3s ease-out forwards;
}

.action-btn {
  background: linear-gradient(135deg, #1e1b3a 0%, #2a1f4e 100%);
  border: 1px solid #3d2d6b;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.action-btn:hover {
  border-color: #8b5cf6;
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.3);
  transform: translateY(-1px);
}

.action-btn:active {
  transform: translateY(0);
}

.action-btn.danger:hover {
  border-color: #ef4444;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.3);
}

.action-btn.social:hover {
  border-color: #ec4899;
  box-shadow: 0 0 12px rgba(236, 72, 153, 0.3);
}

.panel-border {
  border: 1px solid transparent;
  background-clip: padding-box;
  position: relative;
}

.panel-border::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: linear-gradient(135deg, #2a1f4e, #1a1040, #2a1f4e);
  z-index: -1;
  border-radius: 8px;
}

.narrative-text {
  font-family: 'Crimson Pro', serif;
  font-size: 1.1rem;
  line-height: 1.8;
  letter-spacing: 0.02em;
}

.narrative-old {
  opacity: 0.5;
}

.stat-bar-container {
  height: 8px;
  background: rgba(20, 20, 40, 0.8);
  border-radius: 4px;
  overflow: hidden;
}

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

.tab-active {
  border-bottom: 2px solid #8b5cf6;
  color: #f5e6d3;
}

.tab-inactive {
  border-bottom: 2px solid transparent;
  color: #666;
}

.mobile-tab-active {
  background: linear-gradient(to top, rgba(139, 92, 246, 0.2), transparent);
  color: #8b5cf6;
}

@media (max-width: 768px) {
  .narrative-text {
    font-size: 0.95rem;
    line-height: 1.65;
  }

  .action-btn {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
  }

  .action-btn:active {
    transform: scale(0.96);
    opacity: 0.85;
  }

  .stat-bar-container {
    height: 6px;
  }

  .item-slot {
    min-height: 44px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .modal-overlay > div {
    max-height: calc(100dvh - 2rem) !important;
    margin: 1rem !important;
    border-radius: 16px !important;
  }

  .toggle-switch {
    min-width: 44px;
    min-height: 28px;
    height: 28px;
  }

  .toggle-switch::after {
    width: 24px;
    height: 24px;
  }

  .toggle-switch.active::after {
    transform: translateX(16px);
  }
}

/* Safe area support */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .mobile-safe-bottom {
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-safe-top {
    padding-top: env(safe-area-inset-top);
  }
}

/* Compact stat strip for mobile */
.mobile-stat-strip {
  display: flex;
  gap: 6px;
  padding: 6px 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.mobile-stat-strip::-webkit-scrollbar {
  display: none;
}
.mobile-stat-chip {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  border-radius: 20px;
  background: rgba(20, 20, 40, 0.7);
  border: 1px solid #2a1f4e;
  font-size: 11px;
  white-space: nowrap;
  flex-shrink: 0;
  font-family: 'IBM Plex Sans', sans-serif;
}
.mobile-stat-chip.warning {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.15);
  animation: warning-pulse 1.5s ease-in-out infinite;
}
.mobile-stat-chip-bar {
  width: 24px;
  height: 4px;
  background: rgba(20, 20, 40, 0.8);
  border-radius: 2px;
  overflow: hidden;
}
.mobile-stat-chip-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* Character creation */
.char-creation-screen {
  flex: 1;
  overflow-y: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1.5rem 1rem;
}

.char-creation-inner {
  max-width: 520px;
  width: 100%;
  background: linear-gradient(135deg, rgba(26, 16, 64, 0.6), rgba(13, 13, 26, 0.8));
  border: 1px solid #2a1f4e;
  border-radius: 12px;
  padding: 2rem;
  animation: fadeIn 0.5s ease-out;
}

.char-creation-name-input {
  width: 100%;
  background: rgba(13, 13, 26, 0.8);
  border: 1px solid #2a1f4e;
  border-radius: 8px;
  padding: 10px 14px;
  color: #f5e6d3;
  font-family: 'Crimson Pro', serif;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.char-creation-name-input:focus {
  border-color: #8b5cf6;
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.2);
}

.char-creation-name-input::placeholder {
  color: rgba(245, 230, 211, 0.25);
  font-style: italic;
}

.char-creation-stat-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.char-stat-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e1b3a, #2a1f4e);
  border: 1px solid #3d2d6b;
  border-radius: 6px;
  color: #f5e6d3;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.char-stat-btn:hover:not(:disabled) {
  border-color: #8b5cf6;
  box-shadow: 0 0 8px rgba(139, 92, 246, 0.3);
}

.char-stat-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.char-stat-bar-bg {
  height: 8px;
  background: rgba(20, 20, 40, 0.8);
  border-radius: 4px;
  overflow: hidden;
}

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

/* Character stats grid display */
.char-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.char-stat-chip {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px 6px;
  border-radius: 6px;
  background: rgba(20, 20, 40, 0.6);
  border: 1px solid rgba(42, 31, 78, 0.5);
  font-size: 11px;
  font-family: 'IBM Plex Sans', sans-serif;
  cursor: default;
}

.char-stat-icon {
  font-size: 10px;
}

.char-stat-label {
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.05em;
}

.char-stat-value {
  margin-left: auto;
  font-weight: 700;
  font-size: 11px;
  opacity: 0.9;
}

/* Micro map styles */
.micro-map-cell {
  transition: all 0.2s ease;
}

.micro-map-cell:hover {
  transform: scale(1.1);
  z-index: 1;
}

@media (max-width: 768px) {
  .char-creation-inner {
    padding: 1.25rem;
  }
  
  .char-creation-stat-row {
    gap: 2px;
  }
  
  .char-creation-stat-row .w-32 {
    width: 5.5rem;
    flex-shrink: 0;
  }
  
  .char-stat-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
  }
  
  .char-stats-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
  }
  
  .char-stat-chip {
    padding: 4px 5px;
  }
}

.item-slot {
  background: linear-gradient(135deg, #1a1040, #0d0d1a);
  border: 1px solid #2a1f4e;
  border-radius: 6px;
  transition: all 0.2s;
}

.item-slot:hover {
  border-color: #8b5cf6;
  box-shadow: 0 0 8px rgba(139, 92, 246, 0.2);
}

.modal-overlay {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.toggle-switch {
  width: 44px;
  height: 24px;
  background: #2a1f4e;
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transition: background 0.3s;
}

.toggle-switch.active {
  background: #8b5cf6;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #f5e6d3;
  border-radius: 50%;
  transition: transform 0.3s;
}

.toggle-switch.active::after {
  transform: translateX(20px);
}