:root {
  --primary: #00A859;
  --primary-dark: #008040;
  --secondary: #007BFF;
  --accent-blue: #2196F3;
  --accent-green: #00C853;
  --accent-orange: #FF9800;
  --accent-purple: #9C27B0;
  --accent-red: #D32F2F;
  --bg: #F5F8FA;
  --surface: #FFFFFF;
  --surface-dark: #E0E0E0;
  --divider: #E3E7ED;
  --text: #222B45;
  --text-secondary: #7B8190;
  --text-muted: #B0B7C3;
  --shadow: 0 2px 8px rgba(0,0,0,0.07);
  --radius: 18px;
  --radius-pill: 999px;
  --nav-height: 68px;
  --font-main: 'Roboto', 'Open Sans', Arial, sans-serif;
}

/* General Layout */
html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-main);
  font-size: 16px;
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

body {
  background: linear-gradient(120deg, #e3f0ff 0%, #f5f8fa 100%);
  min-height: 100vh;
  margin: 0;
  padding: 0;
}

/* Page Content Containers - unified for all pages */
.main-menu,
.game-page-content,
.deck-page-content,
.stats-page-content,
.profile-page-content,
.achievements-page-content {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 430px;
  margin: 48px auto 0 auto;
  padding: 32px 24px 120px 24px; /* 24px horizontal, 120px bottom for nav bar */
  box-sizing: border-box;
  min-height: calc(100vh - var(--nav-height) - 64px);
  overflow-y: auto;
  border: 1px solid var(--divider);
  display: flex;
  flex-direction: column;
  gap: 32px;
}

/* Card/Section Styling - unified for all cards */
.card,
.menu-section,
.stats-card,
.deck-card,
.achievement,
.chart-card {
  background: var(--surface-dark);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 0 24px 0; /* Only vertical padding, horizontal comes from parent */
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  width: 100%;
  max-width: 370px;
  box-sizing: border-box;
  min-height: 140px;
  position: relative;
  overflow: hidden;
  margin-left: auto;
  margin-right: auto;
}

/* Inner card/content for white background inside cards */
.inner-card,
.deck-card-content,
.achievement-content {
  background: var(--surface);
  border-radius: calc(var(--radius) - 4px);
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  padding: 18px 16px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

/* Example: Use these classes in your HTML/JS for deck and achievement content
   <div class="deck-card"><div class="deck-card-content">...</div></div>
   <div class="achievement locked"><div class="achievement-content">...</div></div>
*/

/* Ensure all children fit within the card */
.card > *,
.menu-section > *,
.stats-card > *,
.deck-card > *,
.achievement > *,
.chart-card > * {
  box-sizing: border-box;
  width: 100%;
  padding-left: 0;
  padding-right: 0;
  margin-left: 0;
  margin-right: 0;
}

/* Add spacing between elements inside cards */
.card > *:not(:last-child),
.menu-section > *:not(:last-child),
.stats-card > *:not(:last-child),
.deck-card > *:not(:last-child),
.achievement > *:not(:last-child),
.chart-card > *:not(:last-child) {
  margin-bottom: 14px;
}

/* Headings & Typography */
h1, h2, h3 {
  font-family: var(--font-main);
  font-weight: 700;
  letter-spacing: 0.5px;
}
h1 {
  font-size: 2rem;
  margin-top: 18px;
}
h2 {
  font-size: 1.2rem;
}
body, .main-menu, .menu-label, .quick-stats {
  font-size: 1.08em;
}
label {
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  display: block;
}

/* Uniform Button Row */
.button-row {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin: 24px 0;
}

/* Buttons */
.app-btn,
#view-stats-btn,
#save-name-btn,
#reset-stats-btn,
#edit-profile-btn {
  display: inline-block;
  min-width: 120px;
  padding: 14px 32px;
  background: var(--accent-blue);
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
  font-size: 1.1rem;
  font-weight: 700;
  box-shadow: var(--shadow);
  transition: background 0.18s, color 0.18s;
  cursor: pointer;
  text-align: center;
  letter-spacing: 0.02em;
  margin: 0 8px 0 0;
}
.app-btn:active,
#view-stats-btn:active,
#save-name-btn:active,
#edit-profile-btn:active {
  background: var(--primary-dark);
}
.app-btn.secondary {
  background: transparent;
  color: var(--accent-blue);
  border: 2px solid var(--accent-blue);
}
.app-btn.secondary:active {
  background: var(--accent-blue);
  color: #fff;
}
.app-btn.danger,
.app-btn.secondary.danger {
  background: var(--accent-red);
  color: #fff;
  border: none;
}

/* Special Buttons */
.stats-header .stat-pill,
.stats-summary .summary-item,
.app-btn,
#view-stats-btn {
  border-radius: var(--radius-pill);
}

/* Par selection buttons */
.par-btn {
  background: var(--surface-dark);
  color: var(--accent-blue);
  border: 2px solid var(--accent-blue);
  border-radius: var(--radius-pill);
  font-size: 1.1em;
  padding: 10px 22px;
  margin: 0 8px 0 0;
  font-weight: 600;
  box-shadow: var(--shadow);
  transition: background 0.18s, color 0.18s, border 0.18s;
  cursor: pointer;
}
.par-btn:active, .par-btn.selected {
  background: var(--accent-blue);
  color: #fff;
}

/* Score +/- buttons */
.score-btn {
  background: var(--surface-dark);
  color: var(--accent-blue);
  border: 2px solid var(--accent-blue);
  border-radius: 50%;
  font-size: 1.3em;
  width: 44px;
  height: 44px;
  /* Remove margin here */
  font-weight: 700;
  box-shadow: var(--shadow);
  transition: background 0.18s, color 0.18s, border 0.18s;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.score-btn:active, .score-btn.selected {
  background: var(--accent-blue);
  color: #fff;
}

.score-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin: 32px 0;
}

.score-value {
  font-size: 2.2em;
  font-weight: bold;
  min-width: 48px;
  text-align: center;
}
/* Challenge Yes/No buttons */
.challenge-btn {
  background: var(--surface-dark);
  color: var(--accent-green);
  border: 2px solid var(--accent-green);
  border-radius: var(--radius-pill);
  font-size: 1.1em;
  padding: 10px 24px;
  margin: 0 8px 0 0;
  font-weight: 600;
  box-shadow: var(--shadow);
  transition: background 0.18s, color 0.18s, border 0.18s;
  cursor: pointer;
}
.challenge-btn.active, .challenge-btn:active {
  background: var(--accent-green);
  color: #fff;
}

/* Chart Containers */
.stats-charts {
  display: flex;
  flex-direction: column;
  gap: 32px;
  margin: 32px 0;
}
.chart-card {
  background: var(--surface-dark);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1px solid var(--divider);
  gap: 16px;
}

/* Chart Legend */
.chart-legend {
  display: flex;
  gap: 18px;
  margin-top: 12px;
  flex-wrap: wrap;
  justify-content: center;
}
.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.98em;
  color: var(--text-secondary);
}
.chart-legend-color {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  display: inline-block;
}
.chart-legend-blue { background: var(--accent-blue); }
.chart-legend-green { background: var(--accent-green); }
.chart-legend-orange { background: var(--accent-orange); }
.chart-legend-purple { background: var(--accent-purple); }
.chart-legend-red { background: var(--accent-red); }

/* Inputs */
input[type="text"], input[type="email"], input[type="password"] {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--divider);
  border-radius: var(--radius-pill);
  font-size: 1em;
  margin-bottom: 16px;
  background: #fff;
  color: var(--text);
  transition: border 0.2s;
  box-sizing: border-box;
}
input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus {
  border: 2px solid var(--accent-blue);
  outline: none;
}

/* Navigation */
.bottom-navigation {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: var(--nav-height);
  background: var(--surface);
  display: flex;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -2px 16px rgba(0,0,0,0.08);
  z-index: 100;
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
  max-width: 100vw;
  box-sizing: border-box;
  padding-bottom: env(safe-area-inset-bottom, 0);
  border-top: 1.5px solid var(--divider);
  gap: 0;
}
.bottom-navigation button {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.3em;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0 4px 0;
  border-radius: var(--radius-pill);
  min-width: 56px;
  min-height: 56px;
  transition: color 0.2s, background 0.2s;
  margin: 0 4px;
}
.bottom-navigation button:active,
.bottom-navigation button.selected {
  background: var(--accent-blue);
  color: #fff;
}
.nav-icon {
  font-size: 1.8em;
  margin-bottom: 2px;
  line-height: 1;
}
.nav-label {
  font-size: 0.85em;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  z-index: 9999;
  left: 0; top: 0; right: 0; bottom: 0;
  background: rgba(30,32,36,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal {
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 90vw;
  width: 340px;
  padding: 32px 20px 20px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.modal-body {
  font-size: 1.1em;
  margin-bottom: 18px;
}
.modal-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
}

/* Deck Card Buttons */
.view-deck-btn,
.delete-deck-btn {
  border: none;
  outline: none;
  border-radius: var(--radius-pill);
  padding: 8px 18px;
  margin-left: 8px;
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: background 0.18s, color 0.18s;
}
.view-deck-btn {
  background: var(--accent-blue);
  color: #fff;
}
.view-deck-btn:active {
  background: var(--primary-dark);
}
.delete-deck-btn {
  background: var(--surface-dark);
  color: var(--accent-red);
  padding: 8px 12px;
}
.delete-deck-btn:active {
  background: var(--accent-red);
  color: #fff;
}

/* Remove Challenge Button in Challenge List */
.remove-challenge-btn {
  background: var(--surface-dark);
  color: var(--accent-red);
  border: none;
  border-radius: 50%;
  font-size: 1.1em;
  width: 32px;
  height: 32px;
  margin-left: 8px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: background 0.18s, color 0.18s;
  vertical-align: middle;
}
.remove-challenge-btn:active {
  background: var(--accent-red);
  color: #fff;
}

/* Add/Use/Close Deck Buttons */
#add-challenge-btn,
#use-deck-btn,
#use-default-deck-btn,
#close-deck-btn {
  display: inline-block;
  min-width: 120px;
  margin: 10px 8px 0 0;
  padding: 12px 0;
  background: var(--accent-blue);
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
  font-size: 1.05em;
  font-weight: 700;
  box-shadow: var(--shadow);
  transition: background 0.18s, color 0.18s;
  cursor: pointer;
}
#add-challenge-btn:active,
#use-deck-btn:active,
#use-default-deck-btn:active,
#close-deck-btn:active {
  background: var(--primary-dark);
}

/* Input fields in deck details */
#new-challenge-input,
#reward-input,
#penalty-input {
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--divider);
  padding: 10px 12px;
  font-size: 1em;
  margin-bottom: 8px;
  margin-right: 4px;
  background: #fff;
  color: var(--text);
  transition: border 0.2s;
  box-sizing: border-box;
}
#new-challenge-input:focus,
#reward-input:focus,
#penalty-input:focus {
  border: 2px solid var(--accent-blue);
  outline: none;
}

/* Consistent Iconography */
.menu-icon,
.nav-icon,
.achievement-icon {
  font-size: 2.2em;
  display: block;
  margin-bottom: 10px;
  color: var(--accent-blue);
}
.menu-label,
.nav-label {
  font-weight: 700;
  letter-spacing: 0.03em;
  font-size: 1.08em;
  color: var(--text);
  display: block;
  text-align: center;
}

/* Responsive Design for Mobile */
@media (max-width: 600px) {
  .main-menu,
  .stats-page-content,
  .profile-page-content,
  .achievements-page-content,
  .game-page-content,
  .deck-page-content {
    padding: 18px 4vw 120px 4vw; /* 120px bottom for nav bar */
    max-width: 100vw;
    margin-top: 24px;
    border-radius: 0;
    box-shadow: none;
    min-height: unset;
    gap: 24px;
  }

  .card,
  .menu-section,
  .stats-card,
  .deck-card,
  .achievement,
  .chart-card {
    border-radius: 14px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    max-width: 98vw;
    box-shadow: var(--shadow);
    background: var(--surface-dark);
    padding: 20px 0 16px 0;
  }

  .inner-card,
  .deck-card-content,
  .achievement-content {
    border-radius: 10px;
    padding: 14px 4vw;
    width: 100%;
  }

  .menu-card {
    width: 98vw;
    max-width: 98vw;
    padding: 22px 0;
    border-radius: 16px;
    font-size: 1em;
  }

  h1 {
    font-size: 1.4rem;
    margin-top: 10px;
  }
  h2 {
    font-size: 1.1rem;
  }

  .fab {
    width: 54px;
    height: 54px;
    font-size: 1.5em;
    right: 12px;
    bottom: 80px;
  }

  .stats-card,
  .chart-card,
  .deck-card,
  .achievement {
    padding: 14px 0;
    font-size: 0.98em;
  }

  .button-row {
    gap: 10px;
    margin: 16px 0;
  }

  .app-btn,
  #view-stats-btn,
  #save-name-btn,
  #reset-stats-btn,
  #edit-profile-btn {
    min-width: 90px;
    padding: 10px 12px;
    font-size: 1em;
    border-radius: 999px;
  }

  .par-btn,
  .challenge-btn {
    padding: 8px 12px;
    font-size: 1em;
    margin: 0 4px 0 0;
  }

  .score-btn {
    width: 36px;
    height: 36px;
    font-size: 1em;
    margin: 0;
  }

  .bottom-navigation {
    height: 60px;
    border-radius: 0;
    padding-bottom: 0;
  }

  .bottom-navigation button {
    min-width: 40px;
    min-height: 40px;
    font-size: 1em;
    padding: 4px 0 2px 0;
    margin: 0 2px;
  }

  .nav-icon {
    font-size: 1.3em;
    margin-bottom: 0;
  }
  .nav-label {
    font-size: 0.8em;
    margin-top: 0;
  }
}

/* Hide utility */
.hidden {
  display: none !important;
}