:root {
  /* 전체 사이트에서 공통으로 쓰는 색상과 그림자 값 */
  --bg: #f7f7f4;
  --surface: #ffffff;
  --surface-strong: #f0f4f2;
  --text: #202124;
  --muted: #626a73;
  --line: #d9ded9;
  --accent: #0f766e;
  --accent-strong: #0a5d57;
  --red: #c24135;
  --blue: #2563a9;
  --yellow: #d79a18;
  --shadow: 0 18px 44px rgba(25, 32, 36, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  overflow-x: hidden;
}

body {
  /* 모든 페이지의 기본 글꼴과 바깥 배경 */
  margin: 0;
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(247, 247, 244, 0.96)),
    var(--bg);
  font-family:
    Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

.app-shell {
  /* 메인 포털의 좌우 2분할 레이아웃 */
  display: grid;
  /* 첫 번째 값이 메뉴영역 폭, 두 번째 값이 오른쪽 상세영역 폭 */
  grid-template-columns: minmax(180px, 16vw) minmax(0, 1fr);
  width: 100%;
  min-height: 100vh;
  margin: 0 auto;
  padding: 0;
}

.app-list-pane {
  /* 왼쪽 메뉴영역: 앱 이름 목록이 들어가는 영역 */
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  justify-content: flex-start;
  border-right: 1px solid var(--line);
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.09), transparent 42%),
    var(--bg);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.language-control {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 10;
  display: grid;
  gap: 8px;
  width: 164px;
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-align: left;
}

.language-control select {
  min-height: 40px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  box-shadow: var(--shadow);
}

h1 {
  margin: 0;
  max-width: 8em;
  font-size: clamp(2.2rem, 5.4vw, 5.8rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.intro {
  max-width: 680px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.7;
}

.app-name-list {
  /* 메뉴영역 안에서 앱 이름 버튼들을 세로로 배치 */
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 0;
}

.app-name-button {
  /* 메뉴영역의 각 앱 이름 버튼 */
  width: fit-content;
  max-width: 100%;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.22;
  text-align: left;
}

.app-name-button:hover,
.app-name-button:focus-visible,
.app-name-button.is-active {
  color: var(--text);
  text-decoration: none;
  outline: none;
}

.app-detail-pane {
  /* 오른쪽 상세영역: 선택한 앱 제목과 go 링크가 들어가는 영역 */
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  justify-content: flex-start;
  gap: 28px;
  padding: clamp(28px, 6vw, 84px);
  background: rgba(255, 255, 255, 0.72);
}

.detail-copy {
  /* 오른쪽 상세영역 안의 제목/설명 텍스트 묶음 */
  width: 100%;
}

#detail-title {
  /* 오른쪽 상세영역의 앱 제목 */
  margin: 0;
  font-size: clamp(2.6rem, 7vw, 7.2rem);
  line-height: 0.98;
  letter-spacing: 0;
}

#detail-description {
  /* 오른쪽 상세영역의 앱 설명 */
  margin: 28px 0 0;
  color: var(--muted);
  font-size: clamp(1.1rem, 2vw, 1.7rem);
  line-height: 1.65;
}

.go-link {
  /* 오른쪽 상세영역의 큰 실행 링크 */
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  color: var(--text);
  font-size: clamp(5.5rem, 18vw, 16rem);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 0.78;
  text-decoration: none;
}

.go-link:hover,
.go-link:focus-visible {
  color: var(--accent-strong);
  outline: none;
  text-decoration: underline;
  text-decoration-thickness: 8px;
  text-underline-offset: 16px;
}

.go-link[aria-disabled="true"] {
  pointer-events: none;
  color: #a3aaad;
}

.empty-state {
  padding: 32px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  background: var(--surface);
}

.mini-app {
  /* 개별 샘플 앱 페이지의 중앙 정렬 배경 */
  display: grid;
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.mini-app-panel {
  /* 개별 샘플 앱의 콘텐츠 박스 */
  width: min(680px, 100%);
  max-width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.mini-app-panel h1 {
  max-width: none;
  font-size: clamp(1.8rem, 5vw, 3rem);
}

.mini-app-header {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.icon-button:hover,
.icon-button:focus-visible,
.icon-button.is-active {
  color: var(--accent-strong);
  outline: none;
}

.icon-button svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
}

.stopwatch-panel[hidden],
.puzzle-records[hidden] {
  display: none;
}

.stopwatch-panel {
  display: grid;
  gap: 6px;
  margin: 18px 0 0;
}

.stopwatch-time {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  font-weight: 900;
  line-height: 1;
}

.stopwatch-status,
.records-title,
.record-empty,
.record-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
}

.puzzle-records {
  display: grid;
  gap: 10px;
  margin: 18px 0 0;
}

.record-list {
  display: grid;
  gap: 8px;
}

.record-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-strong);
}

.record-time {
  margin: 0;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 900;
  line-height: 1.3;
}

.joseon-app {
  align-items: start;
  padding: 16px;
}

.joseon-panel {
  width: min(1040px, 100%);
}

.joseon-mnemonic {
  margin: 18px 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-strong);
  color: var(--text);
  font-size: clamp(0.95rem, 4vw, 1.15rem);
  font-weight: 900;
  line-height: 1.65;
  word-break: keep-all;
}

.joseon-guide {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.6;
}

.joseon-tree {
  margin: 22px 0 0;
  overflow-x: auto;
  padding: 8px 0 12px;
}

.family-tree,
.family-tree ol {
  display: flex;
  margin: 0;
  padding: 0;
  list-style: none;
}

.family-tree {
  width: max-content;
  min-width: 100%;
  justify-content: center;
}

.family-node {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

.family-children {
  position: relative;
  flex-wrap: wrap;
  justify-content: center;
  gap: 22px 12px;
  width: max-content;
  max-width: 100%;
  margin-top: 24px;
  padding-top: 24px;
}

.family-node.has-children > .family-children::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 24px;
  background: var(--line);
  transform: translateX(-50%);
}

.family-children > .family-node::before {
  content: "";
  position: absolute;
  top: -24px;
  left: 50%;
  width: 2px;
  height: 24px;
  background: var(--line);
  transform: translateX(-50%);
}

.family-children > .family-node::after {
  content: "";
  position: absolute;
  top: -24px;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--line);
}

.family-children > .family-node:first-child::after {
  left: 50%;
  width: 50%;
}

.family-children > .family-node:last-child::after {
  width: 50%;
}

.family-children > .family-node:only-child::after {
  display: none;
}

.king-card {
  position: relative;
  z-index: 1;
  display: flex;
  width: 92px;
  min-height: 54px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--surface);
  text-align: center;
}

.king-card h3 {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.15;
}

.king-order {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.74rem;
  font-weight: 900;
}

.lotto-panel {
  max-width: 720px;
}

.lotto-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 24px 0 0;
}

.lotto-controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.lotto-controls select {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.lotto-controls output {
  display: grid;
  min-height: 42px;
  place-items: center start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--surface-strong);
  color: var(--text);
  font: inherit;
}

.lotto-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0 0;
}

.lotto-stat-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.9rem;
}

.lotto-stat-table caption {
  padding: 10px;
  font-weight: 800;
  text-align: left;
}

.lotto-stat-table.hot caption {
  background: #fefce8;
  color: #713f12;
  border-bottom: 2px solid #eab308;
}

.lotto-stat-table.cold caption {
  background: #eef2ff;
  color: #3730a3;
  border-bottom: 2px solid #818cf8;
}

.lotto-stat-table th,
.lotto-stat-table td {
  padding: 8px 10px;
  border-top: 1px solid var(--line);
  text-align: left;
}

.lotto-stat-table th {
  color: var(--muted);
  font-size: 0.78rem;
}

.number-output {
  /* 로또번호 생성기 결과 숫자 영역 */
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 8px;
  margin: 24px 0;
}

.number-output button {
  display: grid;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--surface-strong);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.number-output button.is-hot {
  background: #eab308;
  color: #1c0a00;
}

.number-output button.is-cold {
  background: #818cf8;
  color: #1e1b4b;
}

.number-output button.is-picked {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
  font-weight: 900;
}

.selected-lotto {
  display: grid;
  gap: 10px;
  margin: 0 0 16px;
}

.selected-title,
.save-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
}

.selected-numbers {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface-strong);
  color: var(--text);
  font-weight: 800;
  line-height: 1.5;
}

.selected-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.primary-button {
  /* 샘플 앱에서 공통으로 쓰는 주요 버튼 */
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.lotto-random-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.saved-lotto {
  display: grid;
  gap: 10px;
  margin: 18px 0 0;
}

.saved-list {
  display: grid;
  gap: 8px;
}

.saved-empty {
  margin: 0;
  color: var(--muted);
}

.saved-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-strong);
}

.saved-numbers,
.saved-meta {
  margin: 0;
}

.saved-numbers {
  font-weight: 900;
  line-height: 1.45;
}

.saved-meta {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.trash-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.trash-button:hover,
.trash-button:focus-visible {
  color: var(--red);
  outline: none;
}

.trash-button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.secondary-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--surface);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.secondary-button:disabled {
  cursor: default;
  opacity: 0.45;
}

.tile-grid {
  /* 슬라이드 퍼즐 보드: 기본은 4x4 */
  display: grid;
  grid-template-columns: repeat(4, minmax(64px, 1fr));
  gap: 8px;
  margin: 24px 0;
  border-radius: 10px;
}

.tile-grid[data-grid-size="3"] {
  /* 3x3 퍼즐 보드에서만 열 개수를 3개로 변경 */
  grid-template-columns: repeat(3, minmax(64px, 1fr));
}

.tile-grid + .primary-button {
  /* 퍼즐의 NEW 버튼을 퍼즐 보드와 같은 폭으로 맞춤 */
  width: 100%;
}

.tile-grid button {
  /* 퍼즐의 각 타일 버튼 */
  display: grid;
  aspect-ratio: 1;
  overflow: hidden;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: #fbf6e8;
  color: #24315f;
  font-size: 1.4rem;
  font-weight: 900;
  cursor: pointer;
}

.tile-grid img {
  /* 퍼즐 타일 안에 들어가는 숫자 이미지 */
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.tile-grid button.empty {
  /* 퍼즐에서 타일이 없는 빈 칸 */
  background: #ece1cc;
  color: transparent;
}

.tile-grid.is-complete {
  animation: puzzle-complete-flash 680ms ease-out;
}

.tile-grid.is-complete button:not(.empty) {
  animation: puzzle-tile-pop 420ms ease-out;
}

@keyframes puzzle-complete-flash {
  0% {
    box-shadow: 0 0 0 0 rgba(15, 118, 110, 0);
  }

  35% {
    box-shadow: 0 0 0 6px rgba(15, 118, 110, 0.28), 0 0 28px rgba(15, 118, 110, 0.24);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(15, 118, 110, 0);
  }
}

@keyframes puzzle-tile-pop {
  0%,
  100% {
    transform: scale(1);
  }

  45% {
    transform: scale(1.035);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tile-grid.is-complete,
  .tile-grid.is-complete button:not(.empty) {
    animation: none;
  }
}

@media (max-width: 860px) {
  /* 태블릿/모바일에서는 메뉴영역과 상세영역을 위아래로 배치 */
  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-list-pane {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .app-name-list {
    margin-top: 0;
  }

  .app-detail-pane {
    min-height: 62vh;
  }
}

@media (max-width: 620px) {
  /* 작은 모바일 화면에서 좌우 여백과 go 크기를 조정 */
  .language-control {
    top: 16px;
    right: 16px;
    width: 148px;
  }

  .app-list-pane,
  .app-detail-pane {
    padding: 24px;
  }

  .lotto-controls {
    grid-template-columns: 1fr;
  }

  .lotto-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .lotto-stat-table {
    font-size: 0.82rem;
  }

  .lotto-stat-table caption,
  .lotto-stat-table th,
  .lotto-stat-table td {
    padding-right: 8px;
    padding-left: 8px;
  }

  .number-output {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .go-link {
    font-size: clamp(5rem, 34vw, 9rem);
  }
}
