@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&family=Inter:wght@400;500;600&display=swap');

/* ===== DESIGN TOKENS — 4-colour system ===== */
:root {
  /* Brand palette */
  --green:  #69B238;
  --yellow: #F9AF19;
  --teal:   #1BB1B4;
  --white:  #FFFFFF;

  /* Semantic aliases */
  --color-primary:       #1BB1B4;
  --color-primary-dark:  #69B238;
  --color-primary-light: rgba(27,177,180,0.12);
  --color-accent:        #F9AF19;
  --color-accent-light:  rgba(249,175,25,0.13);
  --color-bg:            #FFFFFF;
  --color-card:          rgba(27,177,180,0.07);
  --color-text:          #1A1A1A;
  --color-text-light:    #555555;
  --color-white:         #FFFFFF;
  --color-success:       #69B238;
  --color-error:         #C62828;
  --color-wall:          #1BB1B4;
  --color-floor:         #C4956A;
  --color-wood:          #C4956A;

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 40px;
  --space-2xl: 64px;

  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 8px  rgba(27,177,180,0.15);
  --shadow-md: 0 4px 12px rgba(27,177,180,0.20);
  --shadow-lg: 0 8px 24px rgba(27,177,180,0.25);

  --transition: 0.2s ease;
  --transition-slow: 0.4s ease;

  --font-heading: 'Nunito', sans-serif;
  --font-body: 'Inter', sans-serif;
}

[data-theme="dark"] {
  --color-bg:           #052222;
  --color-card:         rgba(27,177,180,0.15);
  --color-text:         #FFFFFF;
  --color-text-light:   rgba(255,255,255,0.65);
  --color-white:        #083030;
  --color-primary:      #1BB1B4;
  --color-primary-dark: #69B238;
  --color-accent-light: rgba(249,175,25,0.18);
  --shadow-sm: 0 2px 8px  rgba(0,0,0,0.35);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.45);
}

/* ===== RESET ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--transition-slow), color var(--transition-slow);
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  line-height: 1.2;
}

h1 { font-size: 2.5rem; font-weight: 900; }
h2 { font-size: 1.8rem; font-weight: 800; }
h3 { font-size: 1.2rem; font-weight: 700; }

img { max-width: 100%; height: auto; display: block; }

a { color: inherit; }

/* ===== LAYOUT ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.section {
  padding: var(--space-2xl) 0;
}

.section-header {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.section-header h2 {
  color: var(--color-primary-dark);
  margin-bottom: var(--space-sm);
}

.section-header p {
  color: var(--color-text-light);
  font-size: 1.1rem;
  max-width: 600px;
  margin: 0 auto;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 12px 28px;
  border: none;
  border-radius: var(--radius-lg);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}

.btn:hover { transform: scale(1.05); }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--color-primary);
  color: white;
  box-shadow: 0 4px 14px rgba(0,105,92,0.35);
}

.btn-primary:hover { box-shadow: 0 6px 20px rgba(0,105,92,0.45); }

.btn-accent {
  background: var(--color-accent);
  color: var(--color-text);
  box-shadow: 0 4px 14px rgba(249,168,37,0.35);
}

.btn-accent:hover { box-shadow: 0 6px 20px rgba(249,168,37,0.45); }

.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
}

.btn-outline:hover { background: var(--color-primary-light); }

.btn-ghost {
  background: rgba(255,255,255,0.15);
  color: white;
  border: 2px solid rgba(255,255,255,0.3);
}

.btn-ghost:hover { background: rgba(255,255,255,0.25); }

.btn-lg {
  padding: 16px 40px;
  font-size: 1.15rem;
}

.btn-sm {
  padding: 8px 18px;
  font-size: 0.88rem;
}

.btn-full { width: 100%; }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ===== CARDS ===== */
.card {
  background: var(--color-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--space-lg);
  transition: transform var(--transition), box-shadow var(--transition);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

/* ===== GRID ===== */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-lg); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-lg); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-lg); }

/* ===== TOAST NOTIFICATIONS ===== */
#toast-container {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  background: white;
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.95rem;
  animation: toastIn 0.35s ease, toastOut 0.35s ease 2.65s forwards;
  min-width: 260px;
  max-width: 360px;
  border-left: 4px solid var(--color-primary);
  pointer-events: all;
  color: var(--color-text);
}

.toast.success { border-color: var(--color-success); }
.toast.error   { border-color: var(--color-error); }
.toast.warning { border-color: var(--color-accent); }
.toast.coins   { border-color: var(--color-accent); background: var(--color-accent-light); }

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

@keyframes toastIn {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

@keyframes toastOut {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(110%); opacity: 0; }
}

/* ===== COIN POPUP ANIMATION ===== */
.coin-popup {
  position: fixed;
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: 1.4rem;
  color: var(--color-accent);
  pointer-events: none;
  z-index: 9998;
  text-shadow: 0 2px 8px rgba(0,0,0,0.25);
  animation: coinPop 1.2s ease forwards;
}

@keyframes coinPop {
  0%   { transform: translateY(0)    scale(0.5); opacity: 1; }
  30%  { transform: translateY(-20px) scale(1.3); opacity: 1; }
  100% { transform: translateY(-70px) scale(1);   opacity: 0; }
}

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
  backdrop-filter: blur(4px);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--color-white);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  transform: scale(0.88) translateY(20px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  color: var(--color-text);
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

.modal-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  background: var(--color-bg);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--color-text-light);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}

.modal-close:hover { background: rgba(0,0,0,0.1); }

.modal h2 {
  margin-bottom: var(--space-lg);
  color: var(--color-primary-dark);
}

/* ===== PROGRESS BAR ===== */
.progress-bar {
  background: rgba(0,0,0,0.1);
  border-radius: var(--radius-full);
  height: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== SPINNER ===== */
.spinner {
  width: 36px;
  height: 36px;
  border: 4px solid rgba(0,105,92,0.15);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  margin: 0 auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== BADGE ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--color-primary);
  color: white;
  border-radius: var(--radius-full);
  padding: 4px 12px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.8rem;
}

.badge-accent { background: var(--color-accent); color: var(--color-text); }
.badge-light  { background: var(--color-primary-light); color: var(--color-primary); }

/* ===== ANIMATE ON SCROLL ===== */
.fade-in {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.65s ease, transform 0.65s ease;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

.fade-in.delay-1 { transition-delay: 0.1s; }
.fade-in.delay-2 { transition-delay: 0.2s; }
.fade-in.delay-3 { transition-delay: 0.3s; }
.fade-in.delay-4 { transition-delay: 0.4s; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--color-bg); }
::-webkit-scrollbar-thumb { background: var(--color-primary); border-radius: var(--radius-full); }

/* ===== UTILITIES ===== */
.hidden         { display: none !important; }
.text-center    { text-align: center; }
.text-accent    { color: var(--color-accent); }
.text-primary   { color: var(--color-primary); }
.text-muted     { color: var(--color-text-light); }
.mt-sm  { margin-top: var(--space-sm); }
.mt-md  { margin-top: var(--space-md); }
.mt-lg  { margin-top: var(--space-lg); }
.mt-xl  { margin-top: var(--space-xl); }
.mb-md  { margin-bottom: var(--space-md); }
.mb-lg  { margin-bottom: var(--space-lg); }
.flex   { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }

:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ===== TEAL BACKGROUNDS: WHITE TEXT ===== */
[style*="#1BB1B4"],
[style*="var(--teal)"],
.teal-bg {
  color: #FFFFFF !important;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.4rem; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .section { padding: var(--space-xl) 0; }
  .container { padding: 0 var(--space-md); }
  #toast-container { left: var(--space-md); right: var(--space-md); bottom: var(--space-md); }
  .btn-lg { padding: 13px 28px; font-size: 1rem; }
  .modal { padding: var(--space-lg); }
}
