:root {
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif;
  --background: 220 43% 97%;
  --foreground: 224 38% 12%;
  --card: 0 0% 100%;
  --card-foreground: 224 38% 12%;
  --popover: 0 0% 100%;
  --popover-foreground: 224 38% 12%;
  --primary: 221 83% 53%;
  --primary-foreground: 210 40% 98%;
  --secondary: 214 32% 91%;
  --secondary-foreground: 224 38% 12%;
  --muted: 214 32% 91%;
  --muted-foreground: 220 9% 38%;
  --accent: 38 92% 50%;
  --accent-foreground: 224 38% 12%;
  --destructive: 0 72% 51%;
  --destructive-foreground: 210 40% 98%;
  --success: 142 71% 36%;
  --success-foreground: 210 40% 98%;
  --warning: 38 92% 50%;
  --warning-foreground: 224 38% 12%;
  --info: 199 89% 48%;
  --info-foreground: 210 40% 98%;
  --border: 214 24% 84%;
  --input: 214 24% 84%;
  --ring: 221 83% 53%;
  --radius: 0.625rem;
  --shadow-sm: 0 1px 2px hsl(var(--foreground) / 0.05);
  --shadow-md: 0 4px 12px hsl(var(--foreground) / 0.08);
  --shadow-lg: 0 12px 32px hsl(var(--foreground) / 0.12);
  --shadow-elegant: 0 18px 48px hsl(var(--primary) / 0.24);
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.dark {
  --background: 224 38% 8%;
  --foreground: 210 40% 96%;
  --card: 224 34% 12%;
  --card-foreground: 210 40% 96%;
  --popover: 224 34% 12%;
  --popover-foreground: 210 40% 96%;
  --primary: 217 91% 60%;
  --primary-foreground: 224 38% 8%;
  --secondary: 223 24% 18%;
  --secondary-foreground: 210 40% 96%;
  --muted: 223 24% 18%;
  --muted-foreground: 215 20% 72%;
  --accent: 38 92% 55%;
  --accent-foreground: 224 38% 8%;
  --destructive: 0 72% 58%;
  --destructive-foreground: 210 40% 98%;
  --success: 142 69% 45%;
  --success-foreground: 224 38% 8%;
  --warning: 38 92% 55%;
  --warning-foreground: 224 38% 8%;
  --info: 199 89% 58%;
  --info-foreground: 224 38% 8%;
  --border: 223 20% 26%;
  --input: 223 20% 26%;
  --ring: 217 91% 60%;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: hsl(var(--background));
}

body {
  min-height: 100%;
  margin: 0;
  font-family: var(--font-sans);
  background: radial-gradient(circle at top left, hsl(var(--primary) / 0.12), transparent 32rem), hsl(var(--background));
  color: hsl(var(--foreground));
}

button, a {
  -webkit-tap-highlight-color: transparent;
}

.btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: calc(var(--radius) - 2px);
  padding: 0.75rem 1rem;
  font-size: 1rem;
  line-height: 1.5rem;
  font-weight: 500;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
  outline: none;
}

.btn:focus-visible, .nav-link:focus-visible, .touch-control:focus-visible {
  box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--ring));
}

.btn-primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  box-shadow: var(--shadow-elegant);
}

.btn-secondary {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  border: 1px solid hsl(var(--border));
}

.btn-danger {
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}

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

.nav-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  border-radius: calc(var(--radius) - 2px);
  padding: 0.5rem 0.75rem;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
}

.nav-link[aria-current='page'] {
  background: hsl(var(--primary) / 0.12);
  color: hsl(var(--primary));
}

.card {
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.game-shell {
  position: relative;
  overflow: hidden;
  min-height: 420px;
  border-radius: calc(var(--radius) + 4px);
  background: linear-gradient(180deg, hsl(var(--info) / 0.18), hsl(var(--muted)) 42%, hsl(var(--foreground) / 0.08));
}

.game-canvas {
  display: block;
  width: 100%;
  height: 420px;
  background: hsl(var(--muted));
}

.touch-control {
  min-width: 72px;
  min-height: 56px;
  border-radius: 999px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--popover) / 0.86);
  color: hsl(var(--popover-foreground));
  font-size: 1.5rem;
  line-height: 2rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
}

.toast-item {
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--popover));
  color: hsl(var(--popover-foreground));
  box-shadow: var(--shadow-lg);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
}

.toast-item.success {
  border-color: hsl(var(--success) / 0.48);
}

.toast-item.error {
  border-color: hsl(var(--destructive) / 0.48);
}

.stat-pill {
  border-radius: 999px;
  background: hsl(var(--primary) / 0.12);
  color: hsl(var(--primary));
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 500;
}

@media (min-width: 640px) {
  .game-canvas {
    height: 520px;
  }
  .game-shell {
    min-height: 520px;
  }
}
