/* Reset and base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Soft Pastel Runner palette */
  --bg-primary: #f5f0e8;
  --bg-secondary: #e8e0d5;
  --bg-tertiary: #d4cdc4;

  /* Text colors */
  --text-primary: #3d3d3d;
  --text-secondary: #6b6b6b;
  --text-on-accent: #ffffff;

  /* Accent colors (sporty pastels) */
  --accent: #ff8a75;
  --energy: #7dd3c0;
  --money: #f4d06f;
  --followers: #87ceeb;
  --success: #98d89e;
  --warning: #f4d06f;

  /* Fonts */
  --font-pixel: 'Press Start 2P', monospace;
  --font-body: 'VT323', monospace;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  background:
    radial-gradient(circle at 20% 30%, rgba(125, 211, 192, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(244, 208, 111, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(135, 206, 235, 0.06) 0%, transparent 50%),
    linear-gradient(180deg, #e8e0d5 0%, #f5f0e8 50%, #e8e0d5 100%);
  color: var(--text-primary);
}

/* Game container - mobile first */
#game-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  overflow: hidden;
  background: var(--bg-primary);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.1);
}

/* Game header */
#game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px 8px;
  background: var(--bg-secondary);
}

.game-title {
  font-family: var(--font-pixel);
  font-size: 16px;
  color: var(--accent);
  letter-spacing: 2px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.game-version {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-secondary);
}

/* Sound toggle button */
.sound-btn {
  width: 32px;
  height: 32px;
  background: var(--bg-tertiary);
  border: 2px solid var(--bg-tertiary);
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  position: relative;
}

.sound-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.sound-btn .sound-on,
.sound-btn .sound-off {
  position: absolute;
  line-height: 1;
}

.sound-btn .sound-off {
  display: none;
  opacity: 0.4;
}

.sound-btn .sound-off::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 2px;
  background: var(--text-primary);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-45deg);
}

.sound-btn.muted .sound-on {
  display: none;
}

.sound-btn.muted .sound-off {
  display: block;
}

/* Stats bar */
#stats-bar {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--bg-tertiary);
  gap: 8px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 90px;
}

.stat-label {
  font-family: var(--font-pixel);
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Stat pills - unified sizing */
#energy-stat,
#money-stat,
#followers-stat {
  padding: 8px 12px;
  border-radius: 12px;
  min-height: 60px;
  justify-content: center;
}

#energy-stat {
  background: var(--energy);
}

#energy-stat .stat-label,
#energy-stat .stat-value {
  color: #2d5a50;
}

#money-stat {
  background: var(--money);
}

#money-stat .stat-label,
#money-stat .stat-value {
  color: #5a4a1a;
}

#followers-stat {
  background: var(--followers);
}

#followers-stat .stat-label,
#followers-stat .stat-value {
  color: #2a5a6a;
}

.stat-value {
  font-family: var(--font-body);
  font-size: 20px;
  font-weight: bold;
}

.stat-bar {
  width: 60px;
  height: 12px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 6px;
  overflow: hidden;
}

.stat-fill {
  height: 100%;
  background: #2d5a50;
  transition: width 0.3s ease;
  width: 100%;
}

/* Viewport */
#viewport {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  background: var(--bg-secondary);
  padding: 12px;
}

#game-canvas {
  width: 100%;
  max-width: 320px;
  height: 180px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #2d3748;
  border: 4px solid var(--accent);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#run-stats {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 12px;
  font-size: 16px;
  color: var(--text-secondary);
}

#run-stats span {
  padding: 4px 10px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  font-family: var(--font-body);
  border: 2px solid var(--bg-tertiary);
  border-bottom-color: #c4bdb4;
  border-right-color: #c4bdb4;
}

/* Screen container */
#screen-container {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  background: var(--bg-primary);
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

/* Bottom nav */
#bottom-nav {
  display: flex;
  justify-content: space-around;
  padding: 8px 4px;
  background: var(--bg-secondary);
  border-top: 2px solid var(--bg-tertiary);
}

.nav-btn {
  flex: 1;
  padding: 10px 4px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 16px;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
}

.nav-btn.active {
  background: var(--accent);
  color: var(--text-on-accent);
  border: 2px solid var(--accent);
  border-bottom-color: #e07060;
  border-right-color: #e07060;
}

.nav-btn:active {
  transform: scale(0.95);
}

/* Toast notifications */
#toast-container {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
  width: 90%;
  max-width: 360px;
}

.toast {
  padding: 12px 16px;
  background: #faf8f4;
  border: 2px solid var(--bg-tertiary);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  animation: slideIn 0.3s ease;
  font-family: var(--font-body);
  font-size: 18px;
  white-space: normal;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast::after {
  content: 'x';
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--text-secondary);
  margin-left: 12px;
  opacity: 0.6;
}

.toast:hover::after {
  opacity: 1;
}

/* Toast event type colors */
.toast.positive {
  border-left-color: var(--energy);
}

.toast.negative {
  border-left-color: var(--accent);
}

.toast.funny {
  border-left-color: var(--followers);
}

.toast.achievement {
  border-left-color: var(--money);
}

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

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

.toast.dismissing {
  animation: fadeOut 0.3s ease forwards;
}

/* Modal */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
}

#modal-overlay.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-secondary);
  padding: 20px;
  border-radius: 8px;
  max-width: 90%;
  max-height: 80%;
  overflow-y: auto;
  border: 2px solid var(--bg-tertiary);
}

/* Buttons */
.btn {
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
}

.btn-primary {
  background: var(--accent);
  color: var(--text-on-accent);
  border: 2px solid var(--accent);
  border-bottom-color: #e07060;
  border-right-color: #e07060;
}

.btn-primary:active {
  transform: scale(0.95);
  border-bottom-color: var(--accent);
  border-right-color: var(--accent);
}

.btn-primary:disabled {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: not-allowed;
  border-color: var(--bg-tertiary);
}

.btn-secondary {
  background: var(--energy);
  color: var(--text-on-accent);
  border: 2px solid var(--energy);
  border-bottom-color: #6dc3b0;
  border-right-color: #6dc3b0;
}

/* Progress bars */
.progress-bar {
  width: 100%;
  height: 20px;
  background: var(--bg-tertiary);
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid var(--bg-tertiary);
}

.progress-fill {
  height: 100%;
  transition: width 0.3s ease;
}

/* Cards */
.card {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
  border: 2px solid var(--bg-tertiary);
  border-left: 4px solid var(--accent);
}

.card-title {
  font-family: var(--font-pixel);
  font-size: 10px;
  font-weight: normal;
  margin-bottom: 12px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.card-subtitle {
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--text-secondary);
}

/* Utility */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }

/* Custom scrollbar */
#screen-container::-webkit-scrollbar,
.modal-content::-webkit-scrollbar {
  width: 8px;
}

#screen-container::-webkit-scrollbar-track,
.modal-content::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

#screen-container::-webkit-scrollbar-thumb,
.modal-content::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 4px;
}

#screen-container::-webkit-scrollbar-thumb:hover,
.modal-content::-webkit-scrollbar-thumb:hover {
  background: #e07060;
}

/* Firefox scrollbar */
#screen-container,
.modal-content {
  scrollbar-width: thin;
  scrollbar-color: var(--accent) var(--bg-tertiary);
}

/* Recovery Run Mini-Game */
.minigame-wrapper {
  margin-top: 12px;
}

.minigame-canvas {
  display: block;
  width: 100%;
  height: 200px;
  background: #87CEEB;
  border-radius: 8px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: pointer;
}
