@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Space+Grotesk:wght@500;600;700&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  /* ===== BACKGROUNDS (deep navy-black) ===== */
  --color-bg-primary: #0A0E14;
  --color-bg-secondary: #121821;
  --color-bg-tertiary: #1B2430;
  --color-bg-overlay: rgba(10, 14, 20, 0.94);

  /* ===== TEXT ===== */
  --color-text-primary: #F1F5F9;
  --color-text-secondary: #9AA7B8;
  --color-text-tertiary: #5C6B7E;

  /* ===== ACCENT — single electric blue ===== */
  --color-accent-primary: #3B82F6;
  --color-accent-secondary: #2563EB;
  --color-accent-tertiary: #60A5FA;

  /* ===== SEMANTIC ===== */
  --color-success: #14532D;
  --color-success-text: #34D399;
  --color-warning: #F59E0B;
  --color-error: #7F1D1D;
  --color-error-text: #F87171;
  --color-info: #38BDF8;

  /* ===== BORDERS ===== */
  --color-border: #232B38;
  --color-border-hover: #3B4658;
  --color-border-active: #3B82F6;
  --border-width: 1px;

  /* ===== FONTS ===== */
  --font-display: 'Space Grotesk', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Courier New', monospace;
  --font-ui: 'Inter', sans-serif;

  /* ===== FLUID TYPOGRAPHY — larger, readable (base 1rem→1.125rem) ===== */
  --text-xs:   clamp(0.75rem,  0.72rem + 0.12vw, 0.8125rem);
  --text-sm:   clamp(0.875rem, 0.84rem + 0.18vw, 1rem);
  --text-base: clamp(1rem,     0.95rem + 0.25vw, 1.125rem);
  --text-md:   clamp(1.125rem, 1.05rem + 0.35vw, 1.25rem);
  --text-lg:   clamp(1.25rem,  1.15rem + 0.5vw,  1.5rem);
  --text-xl:   clamp(1.5rem,   1.35rem + 0.7vw,  1.875rem);
  --text-2xl:  clamp(1.875rem, 1.6rem + 1.1vw,   2.75rem);
  --text-3xl:  clamp(2.5rem,   2rem + 1.8vw,     4rem);

  --leading-tight: 1.15;
  --leading-normal: 1.55;
  --leading-relaxed: 1.7;
  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* ===== FLUID SPACING ===== */
  --space-3xs: clamp(2px,  0.2vw, 4px);
  --space-2xs: clamp(4px,  0.4vw, 6px);
  --space-xs:  clamp(6px,  0.6vw, 8px);
  --space-sm:  clamp(8px,  0.9vw, 12px);
  --space-md:  clamp(12px, 1.3vw, 18px);
  --space-lg:  clamp(18px, 2.2vw, 28px);
  --space-xl:  clamp(28px, 3.2vw, 40px);
  --space-2xl: clamp(40px, 4.5vw, 56px);
  --space-3xl: clamp(56px, 6vw,   80px);

  /* ===== RADII ===== */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* ===== SHADOWS ===== */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md:  0 6px 16px rgba(0,0,0,0.45), 0 2px 6px rgba(0,0,0,0.3);
  --shadow-lg:  0 14px 36px rgba(0,0,0,0.55), 0 6px 12px rgba(0,0,0,0.35);

  /* ===== ANIMATION ===== */
  --duration-instant: 50ms;
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 400ms;
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.25, 1.2, 0.5, 1);
}

/* ===== BASE RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  background-color: var(--color-bg-primary);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100dvh;
}

::selection { background: var(--color-accent-primary); color: #fff; }
:focus-visible { outline: 2px solid var(--color-accent-primary); outline-offset: 2px; }

a { color: var(--color-accent-primary); text-decoration: none; }
a:hover { color: var(--color-accent-tertiary); }

h1, h2, h3 { font-family: var(--font-display); line-height: var(--leading-tight); color: var(--color-text-primary); letter-spacing: -0.01em; }
h1 { font-size: var(--text-3xl); font-weight: var(--weight-bold); }
h2 { font-size: var(--text-2xl); font-weight: var(--weight-semibold); }
h3 { font-size: var(--text-xl); font-weight: var(--weight-semibold); }

/* ---- Scrollbar ---- */
* { scrollbar-width: thin; scrollbar-color: var(--color-border-hover) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--color-border-hover); border-radius: var(--radius-full); }

/* Timer / stat / counter elements default to mono */
[class*="timer"], [class*="wpm"], [class*="stat"], [class*="counter"] { font-family: var(--font-mono); }

/* ===== COMPONENT CLASSES ===== */
.card {
  background: var(--color-bg-secondary);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: border-color var(--duration-fast) var(--ease-out-expo),
              box-shadow var(--duration-fast) var(--ease-out-expo),
              transform var(--duration-fast) var(--ease-out-expo);
}
.card:hover {
  border-color: var(--color-border-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.card:active { transform: translateY(0) scale(0.98); }

.btn-primary {
  display: inline-block;
  background: var(--color-accent-primary);
  color: #fff;
  font-family: var(--font-ui);
  font-weight: var(--weight-semibold);
  font-size: var(--text-base);
  letter-spacing: 0.01em;
  text-decoration: none;
  text-align: center;
  border: none;
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-lg);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out-expo),
              transform var(--duration-instant) var(--ease-spring),
              box-shadow var(--duration-fast) var(--ease-out-expo);
}
.btn-primary:hover { background: var(--color-accent-tertiary); }
.btn-primary:active { transform: scale(0.97); background: var(--color-accent-secondary); }

.btn-secondary {
  display: inline-block;
  background: transparent;
  color: var(--color-text-primary);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-lg);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-out-expo), color var(--duration-fast) var(--ease-out-expo);
}
.btn-secondary:hover { border-color: var(--color-accent-primary); color: var(--color-accent-tertiary); }

.badge {
  display: inline-block;
  background: var(--color-bg-tertiary);
  color: var(--color-accent-tertiary);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  padding: var(--space-3xs) var(--space-xs);
  border-radius: var(--radius-sm);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ===== GAME LAYOUT UTILITIES ===== */
.game-container {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md) var(--space-2xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
}
@media (max-width: 480px) {
  .game-container { padding: var(--space-md) var(--space-sm) var(--space-xl); max-width: 100%; }
}

/* ===== HAND-CRAFTED DETAILS ===== */
hr {
  border: none;
  height: 1px;
  background: var(--color-border);
  margin: var(--space-lg) 0;
}

kbd, .key {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  background: var(--color-bg-tertiary);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-3xs) var(--space-xs);
  box-shadow: 0 1px 0 var(--color-border);
}

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

@keyframes win-glow {
  0%, 100% { box-shadow: 0 0 0 rgba(59,130,246,0); }
  50%      { box-shadow: 0 0 0 2px rgba(59,130,246,0.5), 0 6px 24px rgba(59,130,246,0.28); }
}
.game-won { animation: win-glow var(--duration-slow) var(--ease-in-out) 3; }

/* ===== GAME TILE COMPONENTS (hub mini-board cards) ===== */
.game-tile {
  position: relative;
  background: var(--color-bg-secondary);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
}
.game-tile:hover {
  transform: translateY(-4px);
  border-color: rgba(255,255,255,0.15);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.tile-surface {
  flex: 1;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  position: relative;
  overflow: hidden;
  background: var(--color-bg-primary);
}
.tile-info {
  padding: var(--space-sm) var(--space-md);
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-xs);
}
.tile-name {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  margin: 0;
}
.tile-meta {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ===== LEGACY ALIASES (keep until all game files are updated) ===== */
:root {
  --color-bg-card:        var(--color-bg-secondary);
  --color-bg-elevated:    var(--color-bg-tertiary);
  --color-accent-success: var(--color-success-text);
  --color-accent-danger:  var(--color-error-text);
  --color-accent-warning: var(--color-warning);
  --color-text-muted:     var(--color-text-tertiary);
  --border-color:         var(--color-border);
  --border-width-thin:    var(--border-width);
  --border-radius-sm:     var(--radius-sm);
  --border-radius-md:     var(--radius-md);
  --border-radius-lg:     var(--radius-lg);
}
