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

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* ── Global thin scrollbar ── */
html {
  scrollbar-width: thin;
  scrollbar-color: var(--border-2) transparent;
}
::-webkit-scrollbar         { width: 6px; height: 6px; }
::-webkit-scrollbar-track   { background: transparent; }
::-webkit-scrollbar-thumb   { background: var(--border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-2); }

:root {
  --nav-height: 56px;

  /* Brand palette */
  --orange:       #FF9D3D;
  --orange-h:     #FFBD73;
  --orange-dark:  #E07A1A;
  --orange-light: rgba(255, 157, 61, 0.12);
  --peach:        #FFBD73;
  --peach-light:  #FFECD6;
  --yellow:       #FEEE91;
  --yellow-light: #FFFAE0;
  --sky-blue:     #C4E1F6;
  --sky-dark:     #7BBFE0;
  --sky-light:    #EBF5FF;

  /* Neutral surfaces */
  --page-bg:    #F5F9FC;
  --surface:    #FFFFFF;
  --surface-2:  #EBF5FF;

  /* Text */
  --text:     #1A1A2E;
  --text-2:   #4A5068;
  --muted:    #7A8499;
  --muted-2:  #A0AAB8;

  /* Borders */
  --border:       #C4E1F6;
  --border-2:     #7BBFE0;
  --border-dark:  #1A1A2E;

  /* Legacy aliases — keep for backward compat with existing components */
  --bg:    var(--page-bg);
  --bg2:   var(--sky-light);
  --bg3:   var(--sky-light);
  --card:  var(--surface);
  --card2: var(--surface-2);
  --card3: rgba(255, 255, 255, 0.92);
  --accent:   var(--orange);
  --accent-h: var(--orange-h);
  --accent-a: var(--orange-dark);
  --border2:  var(--border-2);

  /* Semantic */
  --success:    #34C759;
  --success-bg: #E8F9EE;
  --error:      #FF3B30;
  --error-bg:   #FFEDEC;
  --warn:       #FEEE91;

  /* Border radius */
  --r-sm: 8px;
  --r:    12px;
  --r-lg: 18px;

  /* Hard-offset shadows (no blur — Axis Industrial style) */
  --shadow-sm:     3px 3px 0 var(--sky-blue);
  --shadow:        4px 4px 0 var(--sky-blue);
  --shadow-accent: 4px 4px 0 var(--orange-dark);
  --shadow-soft:   0 8px 24px rgba(26, 26, 46, 0.10);

  /* Typography */
  --font:      'Space Grotesk', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Layout */
  --page-max:      1120px;
  --layout-max:    var(--page-max);
  --layout-gutter: 1rem;
  /* ⚠️ Do NOT increase --layout-top beyond 1.25rem — causes excessive title gap.
     Extra top space should come from .neo-hero padding-top (max 0.75rem). */
  --layout-top:    1rem;
  --layout-bottom: 4rem;

  /* Fluid type scale */
  --step--1: clamp(0.82rem, 0.79rem + 0.12vw, 0.9rem);
  --step-0:  clamp(0.95rem, 0.91rem + 0.15vw, 1rem);
  --step-1:  clamp(1.08rem, 1rem + 0.35vw, 1.2rem);
  --step-2:  clamp(1.28rem, 1.1rem + 0.6vw, 1.48rem);
  --step-3:  clamp(1.55rem, 1.2rem + 1vw, 1.95rem);
  --step-4:  clamp(1.9rem, 1.35rem + 1.4vw, 2.45rem);
}

html {
  scroll-behavior: smooth;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--page-bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--step-0);
  line-height: 1.7;
}

body {
  overflow-x: hidden;
  caret-color: transparent;
}

input,
textarea,
[contenteditable]:not([contenteditable="false"]),
[role="textbox"] {
  caret-color: auto;
}

img, video, svg {
  max-width: 100%;
  display: block;
}

a {
  color: var(--orange);
  text-decoration: none;
}

a:hover {
  color: var(--orange-dark);
  text-decoration: underline;
}

button, input, select, textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

h1, h2, h3, h4 {
  margin: 0;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-family: 'Space Grotesk', 'Noto Sans KR', sans-serif;
  color: var(--text);
}

h1 { font-size: var(--step-4); font-weight: 700; }
h2 { font-size: var(--step-2); font-weight: 600; }
h3 { font-size: var(--step-1); font-weight: 600; }

p, ul, ol {
  margin: 0;
}

hr {
  border: none;
  border-top: 2px solid var(--border);
  margin: 1.5rem 0;
}

:focus-visible {
  outline: 3px solid rgba(255, 157, 61, 0.4);
  outline-offset: 2px;
}

/* ── Utilities ── */
.neo-muted { color: var(--muted); }

.neo-lead {
  color: var(--muted);
  font-size: var(--step-0);
  line-height: 1.6;
  margin-top: 0.75rem;
  max-width: 52rem;
}

.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  flex-shrink: 0;
  color: inherit;
}
.icon-sm { width: 16px; height: 16px; }
.icon-md { width: 24px; height: 24px; }
.icon-lg { width: 32px; height: 32px; }

/* ── Layout ── */
.neo-wrap,
.neo-page {
  width: min(100%, var(--layout-max));
  margin: 0 auto;
  padding-inline: var(--layout-gutter);
}

.neo-page {
  padding-block: var(--layout-top) var(--layout-bottom);
}

.neo-section + .neo-section {
  margin-top: 1.5rem;
}

.neo-stack    { display: flex; flex-direction: column; gap: 1rem; }
.neo-stack-sm { gap: 0.65rem; }

.neo-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.neo-split {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.neo-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.neo-grid   { display: grid; gap: 1rem; }
.neo-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.neo-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.neo-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.neo-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

/* ── Navigation ── */
.neo-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 2px solid var(--border);
  background: rgba(255, 255, 255, 0.90);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.neo-nav-inner {
  width: min(100%, var(--layout-max));
  min-height: 56px;
  margin: 0 auto;
  padding-inline: var(--layout-gutter);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.neo-logo {
  color: var(--text) !important;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  flex-shrink: 0;
  font-family: 'Space Grotesk', sans-serif;
  text-decoration: none !important;
}
.neo-logo-acc { color: var(--orange); }

.neo-logo:hover,
.neo-logo:hover .neo-logo-acc {
  color: var(--orange-dark) !important;
  text-decoration: none !important;
}

.neo-links {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex: 1 1 auto;
  overflow-x: auto;
  scrollbar-width: none;
}

.neo-links::-webkit-scrollbar { display: none; }

.neo-links a {
  flex-shrink: 0;
  color: var(--text-2) !important;
  padding: 0.42rem 0.68rem;
  border-radius: var(--r-sm);
  font-size: var(--step--1);
  font-weight: 500;
  transition: background 0.12s ease, color 0.12s ease;
}

.neo-links a:hover,
.neo-links a.neo-active {
  color: var(--text) !important;
  text-decoration: none !important;
}

.neo-links a:hover {
  background: var(--orange-light);
}

.neo-links a.neo-active {
  color: var(--orange) !important;
  font-weight: 600;
  background: var(--orange-light);
  border: 1.5px solid rgba(255, 157, 61, 0.4);
}

/* ── Hero ──
   padding-top: max 0.75rem — together with --layout-top (1rem) = ~1.75rem total.
   Do NOT increase this further. */
.neo-hero {
  padding: 0.75rem 0 1.25rem;
}

.neo-eyebrow {
  color: var(--orange);
  font-size: var(--step--1);
  font-weight: 700;
  margin-bottom: 0.4rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ── Card & Panel ── */
.neo-panel,
.neo-card {
  border: 2px solid var(--border);
  background: var(--surface);
}

.neo-panel {
  border-radius: var(--r-lg);
  padding: 1.35rem;
  background: var(--surface-2);
  box-shadow: none;
}

.neo-card {
  border-radius: var(--r);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.12s, box-shadow 0.12s, transform 0.12s;
}

.neo-card:hover {
  border-color: var(--orange);
  box-shadow: 4px 4px 0 var(--orange);
  transform: translate(-2px, -2px);
}

.neo-card-title {
  font-size: var(--step-1);
  font-weight: 600;
  color: var(--text);
}

.neo-card-desc {
  color: var(--muted);
  font-size: var(--step--1);
}

/* ── KPI ── */
.neo-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
}

.neo-kpi {
  border: 2px solid var(--border);
  border-left: 4px solid var(--orange);
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  padding: 0.95rem 1rem;
}

.neo-kpi-label {
  color: var(--muted);
  font-size: var(--step--1);
}

.neo-kpi-value {
  display: block;
  margin-top: 0.22rem;
  font-size: var(--step-2);
  font-weight: 700;
  color: var(--text);
}

/* ── Buttons ── */
.neo-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 42px;
  padding: 0 1.1rem;
  border: 2px solid var(--border-dark);
  border-radius: var(--r-sm);
  background: var(--orange);
  color: var(--text) !important;
  font-weight: 600;
  box-shadow: 3px 3px 0 var(--orange-dark);
  transition: background 0.12s, box-shadow 0.12s, transform 0.12s;
  text-decoration: none !important;
}

.neo-btn:hover {
  background: var(--peach);
  box-shadow: 2px 2px 0 var(--orange-dark);
  transform: translate(-1px, -1px);
  text-decoration: none !important;
  color: var(--text) !important;
}

.neo-btn:active {
  background: var(--orange);
  transform: translate(2px, 2px);
  box-shadow: none;
}

.neo-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.neo-btn-ghost {
  border: 2px solid var(--border-2);
  background: transparent;
  color: var(--text-2) !important;
  box-shadow: none;
}

.neo-btn-ghost:hover {
  background: var(--surface-2);
  border-color: var(--sky-dark);
  color: var(--text) !important;
  transform: none;
  box-shadow: none;
}

/* ── Form inputs ── */
.neo-input,
.neo-select,
.neo-textarea {
  width: 100%;
  min-height: 42px;
  padding: 0.65rem 0.9rem;
  border: 2px solid var(--border-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
}

.neo-textarea {
  min-height: 120px;
  resize: vertical;
}

.neo-input::placeholder,
.neo-textarea::placeholder {
  color: var(--muted-2);
}

.neo-input:focus,
.neo-select:focus,
.neo-textarea:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(255, 157, 61, 0.18);
}

/* ── Badges ── */
.neo-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.18rem 0.52rem;
  border-radius: 4px;
  font-size: 0.74rem;
  font-weight: 600;
  background: var(--orange-light);
  color: var(--orange-dark);
  border: 1px solid rgba(255, 157, 61, 0.25);
}

.neo-badge-green  { background: rgba(52, 199, 89, 0.12); color: #1a7a3c; border-color: rgba(52,199,89,0.25); }
.neo-badge-yellow { background: var(--yellow-light);     color: #8B6800; border-color: rgba(254,238,145,0.6); }
.neo-badge-red    { background: rgba(255, 59, 48, 0.1);  color: #cc1200; border-color: rgba(255,59,48,0.2); }

/* ── Lists & Docs ── */
.neo-list {
  display: grid;
  gap: 0.65rem;
  padding-left: 1.1rem;
}

.neo-doc {
  max-width: 74ch;
}

.neo-doc p + p,
.neo-doc ul + p,
.neo-doc p + ul {
  margin-top: 0.8rem;
}

/* ── App-mode page (full-height, e.g. bus, parking) ── */
.neo-app-page {
  height: calc(100svh - var(--nav-height) - 1px);
  min-height: calc(100svh - var(--nav-height) - 1px);
  padding-block: 0.9rem calc(0.9rem + env(safe-area-inset-bottom, 0px));
  overflow: hidden;
}

.neo-app-shell {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  height: 100%;
  min-height: 0;
}

.neo-app-panel {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.neo-app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.9rem;
  flex-wrap: wrap;
}

.neo-app-header-copy {
  display: grid;
  gap: 0.35rem;
}

.neo-app-header-copy p {
  color: var(--muted);
}

/* ── Accessibility ── */
.neo-visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Responsive ── */
@media (max-width: 960px) {
  .neo-grid-3,
  .neo-grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .neo-hero {
    padding-top: 0.5rem;
  }
}

@media (max-width: 640px) {
  :root {
    --nav-height: 52px;
    --layout-gutter: 0.85rem;
    --layout-top: 0.75rem;
    --layout-bottom: 3rem;
  }

  .neo-page,
  .neo-wrap {
    padding-inline: var(--layout-gutter);
  }

  .neo-page {
    padding-block: var(--layout-top) var(--layout-bottom);
  }

  .neo-nav-inner {
    min-height: 52px;
    padding-inline: var(--layout-gutter);
  }

  .neo-grid-2,
  .neo-grid-3,
  .neo-grid-4,
  .neo-card-grid {
    grid-template-columns: 1fr;
  }

  .neo-panel,
  .neo-card {
    padding: 1rem;
  }

  .neo-actions {
    width: 100%;
  }

  .neo-actions > * {
    width: 100%;
  }

  .neo-btn,
  .neo-btn-ghost {
    width: 100%;
  }

  .neo-app-page {
    padding-block: 0.7rem calc(0.85rem + env(safe-area-inset-bottom, 0px));
  }
}

/* ── PC: no page-level scroll — content scrolls inside .neo-page ── */
/* 스크롤바가 나타날 때 body/header 폭이 틀어지는 현상 방지.
   PC(≥761px)에서 html/body 자체는 스크롤 없이 고정.
   .neo-page 가 내부 스크롤 컨테이너 역할을 한다. */
@media (min-width: 761px) {
  html {
    overflow: hidden;
    height: 100svh;
  }

  body {
    overflow: hidden;
    height: 100svh;
    display: flex;
    flex-direction: column;
    min-height: unset;
  }

  /* Vue 앱 루트 컨테이너 */
  #app {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }

  /* 일반 페이지의 스크롤 컨테이너
     .neo-app-page(15퍼즐·버스 등)는 자체 height/overflow를 유지 */
  .neo-page:not(.neo-app-page) {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scrollbar-gutter: stable;
    scroll-behavior: smooth;
  }

  /* 네비게이션은 화면 위에서 크기를 유지한다. */
  .neo-nav { flex-shrink: 0; }
}

/* ══════════════════════════════════════════════════════════════════
   게임 페이지 공통 레이아웃 (DESIGN.md §11)
   ══════════════════════════════════════════════════════════════════ */

/* ── game-topbar ── */
.game-topbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
  min-height: 38px;
}

.game-back {
  flex-shrink: 0;
  font-size: var(--step--1);
  font-weight: 600;
  color: var(--text-2);
  text-decoration: none;
  padding: 0.25rem 0.5rem;
  border: 2px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  white-space: nowrap;
  transition: border-color 0.12s, color 0.12s;
  line-height: 1.4;
}
.game-back:hover { border-color: var(--sky-dark); color: var(--text); }

.game-title {
  font-size: var(--step-0);
  font-weight: 700;
  color: var(--text);
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

/* ── game-modebar (모드 탭 행) ── */
.game-modebar {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.game-modebar::-webkit-scrollbar { display: none; }

.game-mode-tab {
  flex-shrink: 0;
  padding: 0.25rem 0.65rem;
  border: 2px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-2);
  font-size: var(--step--1);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.1s;
  line-height: 1.4;
}
.game-mode-tab:hover:not(.active) { border-color: var(--sky-dark); }
.game-mode-tab.active {
  border-color: var(--orange-dark);
  background: var(--orange);
  color: #fff;
  box-shadow: 2px 2px 0 var(--orange-dark);
}

/* ── game-topbar-actions ── */
.game-topbar-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
  align-items: center;
  margin-left: auto;
}

/* ? 도움말 버튼 */
.game-help-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 2px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-2);
  font-size: var(--step-0);
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.1s;
  line-height: 1;
}
.game-help-btn:hover { border-color: var(--sky-dark); background: var(--sky-light); color: var(--text); }

/* 아이콘 액션 버튼 (🏆, ↺ 등) */
.game-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.6rem;
  border: 2px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-2);
  font-size: var(--step--1);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.1s;
  line-height: 1.4;
}
.game-icon-btn:hover { border-color: var(--sky-dark); background: var(--sky-light); }
.game-icon-btn.primary {
  border-color: var(--orange-dark);
  background: var(--orange);
  color: #fff;
  box-shadow: 2px 2px 0 var(--orange-dark);
}
.game-icon-btn.primary:hover { transform: translate(-1px,-1px); box-shadow: 3px 3px 0 var(--orange-dark); }

/* ── game-body (= neo-app-panel alias) ── */
.game-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

/* ── 도움말 모달 공통 ── */
.game-help-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.38);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 1rem;
}
.game-help-modal {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--r);
  box-shadow: 4px 4px 0 var(--border-2);
  padding: 1.5rem 1.75rem;
  max-width: 420px;
  width: 100%;
  max-height: 80svh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.game-help-modal h2 {
  font-size: var(--step-1);
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.game-help-section { display: flex; flex-direction: column; gap: 0.35rem; }
.game-help-section h3 {
  font-size: var(--step--1);
  font-weight: 700;
  color: var(--orange);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.game-help-section p,
.game-help-section li {
  font-size: var(--step-0);
  color: var(--text);
  margin: 0;
  line-height: 1.5;
}
.game-help-section ul { padding-left: 1.2em; margin: 0; }
.game-help-close {
  align-self: flex-end;
  padding: 0.3rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-2);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.1s;
}
.game-help-close:hover { border-color: var(--text-2); }

/* kbd 스타일 (조작법 표기) */
.game-help-modal kbd {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  background: var(--page-bg);
  font-size: var(--step--1);
  font-family: inherit;
  font-weight: 700;
  color: var(--text);
  box-shadow: 1px 1px 0 var(--border);
  white-space: nowrap;
}

/* ── 모바일 게임 topbar 축소 ── */
@media (max-width: 640px) {
  .game-topbar { gap: 0.4rem; }
  .game-back { padding: 0.2rem 0.4rem; font-size: var(--step--2); }
  .game-title { font-size: var(--step--1); }
  .game-mode-tab { padding: 0.2rem 0.5rem; font-size: var(--step--2); }
  .game-help-btn { width: 30px; height: 30px; font-size: var(--step--1); }
  .game-icon-btn { padding: 0.2rem 0.45rem; font-size: var(--step--2); }
  .game-help-modal { padding: 1.25rem 1.25rem; }
}
