:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #e0e7ff;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1);
  --radius: 12px;
  --radius-sm: 8px;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --text: #e2e8f0;
  --text-light: #94a3b8;
  --border: #334155;
  --primary-light: rgba(99,102,241,.18);
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.4);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.4);
}

/* Theme toggle button */
.theme-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 28px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: .9rem;
  cursor: pointer;
  transition: all .15s;
  line-height: 1;
  flex-shrink: 0;
}
.theme-btn:hover { border-color: var(--primary); background: var(--primary-light); }

/* Cannon scene dark mode overrides */
[data-theme="dark"] .hist-panel {
  background: rgba(15,23,42,.9);
  border-color: rgba(255,255,255,.08);
}
[data-theme="dark"] .hist-panel-title,
[data-theme="dark"] .hist-val { color: #e2e8f0; }
[data-theme="dark"] .reset-scene-btn {
  background: rgba(15,23,42,.88);
  color: #e2e8f0;
  border-color: rgba(255,255,255,.14);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans KR', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.logo {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav { display: flex; gap: 4px; }
.nav a {
  color: var(--text-light);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all .15s;
}
.nav a:hover { background: var(--primary-light); color: var(--primary); }

/* Language switch */
.lang-switch { display: flex; gap: 3px; }
.lang-btn {
  padding: 4px 9px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--text-light);
  transition: all .15s;
  font-family: inherit;
  line-height: 1.4;
}
.lang-btn:hover { border-color: var(--primary); color: var(--primary); }
.lang-btn.active { background: var(--primary); border-color: var(--primary); color: white; }

/* Hero */
.hero {
  text-align: center;
  padding: 56px 16px 36px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: white;
}
.hero h1 {
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  font-weight: 800;
  margin-bottom: 10px;
}
.hero p { opacity: .85; font-size: 1.05rem; }

/* Section */
.section { padding: 36px 0 0; }
.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

/* Game Grid */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 40px;
}

/* Game Card */
.game-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px 18px;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: all .2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}
.game-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}
.game-card .icon { font-size: 2.4rem; line-height: 1; }
.game-card h3 { font-size: .95rem; font-weight: 700; }
.game-card p { font-size: .82rem; color: var(--text-light); line-height: 1.5; }

/* Page header (individual game pages) */
.page-header {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: white;
  padding: 28px 16px 24px;
  text-align: center;
}
.page-header .breadcrumb {
  font-size: .82rem;
  opacity: .75;
  margin-bottom: 6px;
}
.page-header .breadcrumb a { color: white; text-decoration: none; }
.page-header h1 {
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 800;
  margin-bottom: 4px;
}
.page-header p { opacity: .88; font-size: .95rem; }

/* Game area */
.game-area {
  max-width: 860px;
  margin: 28px auto 0;
  padding: 0 16px;
}

/* Card */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 22px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: .95rem;
  font-weight: 600;
  transition: all .15s;
  font-family: inherit;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: #ef4444; color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 6px 14px; font-size: .85rem; }
.btn-lg { padding: 14px 32px; font-size: 1.05rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* Inputs */
.input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .95rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s;
  outline: none;
  font-family: inherit;
}
.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.1);
}
.input-sm { padding: 7px 10px; font-size: .88rem; }

/* Related games */
.related-games {
  max-width: 860px;
  margin: 32px auto 48px;
  padding: 0 16px;
}
.related-games h2 { font-size: 1rem; font-weight: 700; margin-bottom: 12px; }
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.related-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  font-size: .88rem;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: all .15s;
}
.related-card:hover { border-color: var(--primary); color: var(--primary); }
.related-card span { font-size: 1.4rem; }

/* Number badge */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 1rem;
  color: white;
}

/* Footer */
footer {
  text-align: center;
  padding: 28px 16px;
  color: var(--text-light);
  font-size: .82rem;
  border-top: 1px solid var(--border);
  margin-top: 16px;
}

/* Utility */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-sm { font-size: .875rem; }
.text-light { color: var(--text-light); }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }

@media (max-width: 600px) {
  .game-grid { grid-template-columns: repeat(2, 1fr); }
  .card { padding: 16px; }
  .btn-lg { padding: 12px 24px; }
}
