/* ═══════════════════════════════════════════════════════════
   JVDS Game System — Universal Game Design Framework
   ═══════════════════════════════════════════════════════════ */

:root {
  /* ── Brand Colors ── */
  --beige: #F0EAD6;
  --tan: #D2B48C;
  --tan-dk: #b8956a;
  --rose: #BC4749;
  --rose-dk: #9b3a3c;
  --teal: #70A3A7;
  --teal-dk: #4e7d80;
  --charcoal: #403B33;
  --charcoal-lt: #5a5449;

  /* ── Character Colors ── */
  --echo: #3EC9A7;
  --pip: #F5A623;
  --lumo: #818CF8;
  --squirt: #FFB6C1;
  --stardust: #A78BFA;
  --english: #F472B6;
  --strange: #34D399;
  --geo: #60A5FA;

  /* ── Background & Surface ── */
  --bg-dark: #0d0d12;
  --bg-darker: #08080c;
  --surface-1: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.08);
  --surface-hover: rgba(255, 255, 255, 0.12);
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);

  /* ── Text ── */
  --text-primary: #FFFFFF;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-tertiary: rgba(255, 255, 255, 0.4);

  /* ── Feedback ── */
  --success: #34D399;
  --success-light: rgba(52, 211, 153, 0.1);
  --error: #F87171;
  --error-light: rgba(248, 113, 113, 0.1);
  --warning: #FBBF24;
  --info: #60A5FA;

  /* ── Transitions ── */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ═══ TYPOGRAPHY ═══ */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Fredoka', cursive;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

a {
  text-decoration: none;
  color: inherit;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

/* ═══ GAME WRAPPER ═══ */
.game-container {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, var(--bg-dark) 0%, var(--bg-darker) 100%);
}

.game-canvas {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  min-height: 0;
  overflow: hidden;
}

.game-canvas canvas {
  max-width: 100%;
  max-height: 100%;
  display: block;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

/* ═══ GAME HUD ═══ */
.game-hud {
  position: fixed;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.hud-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.hud-pill {
  background: rgba(20, 14, 38, 0.8);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 700;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.hud-pill:hover {
  background: rgba(30, 24, 48, 0.9);
  border-color: var(--border-hover);
}

.hud-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.6;
}

.hud-value {
  font-size: 1.1rem;
  font-weight: 800;
}

/* ═══ BUTTONS ═══ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  transition: all var(--transition-fast);
  border: none;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  user-select: none;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--teal), var(--teal-dk));
  color: white;
  box-shadow: 0 4px 12px rgba(112, 163, 167, 0.3);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(112, 163, 167, 0.4);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--border-hover);
}

.btn-success {
  background: rgba(52, 211, 153, 0.2);
  color: var(--success);
  border: 1px solid rgba(52, 211, 153, 0.4);
}

.btn-success:hover:not(:disabled) {
  background: rgba(52, 211, 153, 0.3);
  border-color: rgba(52, 211, 153, 0.6);
}

.btn-danger {
  background: rgba(248, 113, 113, 0.2);
  color: var(--error);
  border: 1px solid rgba(248, 113, 113, 0.4);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.3);
  border-color: rgba(248, 113, 113, 0.6);
}

.btn-icon {
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 10px;
  font-size: 1.5rem;
}

/* ═══ CARDS ═══ */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  transition: all var(--transition-base);
}

.card:hover {
  background: var(--surface-2);
  border-color: var(--border-hover);
  transform: translateY(-2px);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.card-body {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* ═══ BADGES ═══ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.badge-primary {
  background: rgba(112, 163, 167, 0.2);
  color: var(--teal);
  border: 1px solid rgba(112, 163, 167, 0.3);
}

.badge-success {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid rgba(52, 211, 153, 0.3);
}

.badge-error {
  background: var(--error-light);
  color: var(--error);
  border: 1px solid rgba(248, 113, 113, 0.3);
}

.badge-warning {
  background: rgba(251, 191, 36, 0.15);
  color: var(--warning);
  border: 1px solid rgba(251, 191, 36, 0.3);
}

/* ═══ MODAL ═══ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 8, 12, 0.85);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px 28px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.6);
  animation: slideUp var(--transition-base);
}

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

.modal-header {
  margin-bottom: 20px;
}

.modal-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.modal-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.modal-body {
  margin-bottom: 24px;
}

.modal-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ═══ PROGRESS ═══ */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--teal-dk));
  border-radius: 999px;
  transition: width var(--transition-base);
  box-shadow: 0 0 10px rgba(112, 163, 167, 0.5);
}

.progress-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

/* ═══ ACHIEVEMENTS ═══ */
.achievement-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 12px;
}

.achievement {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface-1);
  border: 2px solid var(--border);
  transition: all var(--transition-fast);
  cursor: default;
}

.achievement.unlocked {
  background: rgba(52, 211, 153, 0.1);
  border-color: rgba(52, 211, 153, 0.4);
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.2);
}

.achievement-icon {
  font-size: 2.5rem;
  line-height: 1;
}

.achievement-name {
  font-size: 0.65rem;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
}

.achievement.unlocked .achievement-name {
  color: var(--success);
}

/* ═══ LEADERBOARD ═══ */
.leaderboard {
  width: 100%;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition-fast);
}

.leaderboard-row:hover {
  background: var(--surface-1);
}

.leaderboard-row.current {
  background: rgba(112, 163, 167, 0.1);
  border-color: rgba(112, 163, 167, 0.3);
}

.leaderboard-rank {
  font-weight: 800;
  font-size: 1.1rem;
  text-align: center;
  color: var(--text-secondary);
}

.leaderboard-name {
  font-weight: 700;
  color: var(--text-primary);
}

.leaderboard-score {
  font-weight: 800;
  color: var(--teal);
  font-size: 1.1rem;
  min-width: 80px;
  text-align: right;
}

/* ═══ RESPONSIVE ═══ */
@media (max-width: 768px) {
  .game-hud {
    top: 12px;
    left: 12px;
    right: 12px;
    font-size: 0.85rem;
  }

  .hud-pill {
    padding: 6px 12px;
    font-size: 0.75rem;
  }

  .btn {
    padding: 10px 16px;
    font-size: 0.85rem;
  }

  .modal-content {
    padding: 20px 16px;
  }

  .achievement-grid {
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  }
}

@media (max-width: 480px) {
  .game-container {
    height: 100dvh;
  }

  .game-canvas {
    padding: 8px;
  }

  .game-hud {
    flex-direction: column;
    align-items: flex-start;
  }

  .hud-group {
    width: 100%;
  }

  .hud-pill {
    flex: 1;
    justify-content: space-between;
  }

  .btn {
    padding: 10px 14px;
    font-size: 0.8rem;
  }

  .btn-icon {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }
}

/* ═══ ANIMATIONS ═══ */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(112, 163, 167, 0.4); }
  50% { box-shadow: 0 0 0 10px rgba(112, 163, 167, 0); }
}

@keyframes shimmer {
  0% { background-position: -1000px 0; }
  100% { background-position: 1000px 0; }
}

.pulse { animation: pulse var(--transition-base) infinite; }
.bounce { animation: bounce var(--transition-base) infinite; }
.glow { animation: glow 2s infinite; }

/* ═══ UTILITIES ═══ */
.hidden {
  display: none;
}

.invisible {
  visibility: hidden;
}

.blur {
  filter: blur(4px);
}

.grayscale {
  filter: grayscale(1);
}

.opacity-50 {
  opacity: 0.5;
}

.opacity-75 {
  opacity: 0.75;
}

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

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

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

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

.w-full {
  width: 100%;
}

.h-full {
  height: 100%;
}
