* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
}

:root {
  --bg: #f8f9fa;
  --card: #ffffff;
  --text: #0f172a;
  --subtle: #94a3b8;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-soft: #edf0f3;
  --grid-bg: #ffffff;
  --cell-a: #ffffff;
  --cell-b: #fafbfc;
  --cell-line: #edf0f3;
  --goal: #f0fdf4;
  --start: #f0f8ff;
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.08), 0 1px 4px rgba(0, 0, 0, 0.04);
  --shadow-soft: 0 2px 8px rgba(0, 0, 0, 0.06);
  --menu-grid-line: rgba(15, 23, 42, 0.045);
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --green: #16a34a;
  --red: #ef4444;
  --red-dark: #7f1d1d;
  --blue: #3b82f6;
  --blue-dark: #1e3a5f;
  --gold: #f59e0b;
}

body.dark {
  --bg: #070c16;
  --card: #161e33;
  --text: #f1f5f9;
  --subtle: #64748b;
  --muted: #94a3b8;
  --border: #252d44;
  --border-soft: #1f2840;
  --grid-bg: #161e33;
  --cell-a: #161e33;
  --cell-b: #1a2238;
  --cell-line: #1f2840;
  --goal: #0d2a1c;
  --start: #0f1a2c;
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4), 0 1px 4px rgba(0, 0, 0, 0.3);
  --shadow-soft: 0 2px 8px rgba(0, 0, 0, 0.3);
  --menu-grid-line: rgba(148, 163, 184, 0.065);
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg);
  background-image: linear-gradient(var(--menu-grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--menu-grid-line) 1px, transparent 1px);
  background-size: 40px 40px;
  color: var(--text);
  overscroll-behavior: contain;
  overflow-x: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.screen {
  width: 100%;
  max-width: 520px;
  padding: 0 16px;
  animation: screenIn 0.38s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.tutorial-screen {
  padding-bottom: 24px;
}

@keyframes screenIn {
  from {
    opacity: 0;
    transform: translateX(28px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

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

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