/*
  Design tokens: light = doc/singlebungglelab_main_page_ui_spec.md §5 안 B
  Dark = §6 베이스 + 안 B 톤(블루 #3B82F6 · 민트 #14B8A6 계열)
  Category accents §7 (배지 등)
*/
:root {
  color-scheme: light;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --secondary: #14b8a6;
  --soft-accent: #99f6e4;
  --ring: rgba(59, 130, 246, 0.35);
  --radius: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --header-bg: rgba(255, 255, 255, 0.92);
  --cat-tools: #3b82f6;
  --cat-games: #8b5cf6;
  --cat-random: #14b8a6;
  --cat-life: #f59e0b;
  --cat-util: #f59e0b;
  --cat-popular: #f97386;
  --cat-new: #22c55e;
}

/* Next 앱은 Tailwind용 `class="dark"` 만 쓰는 경우가 있어 선택자를 병행 */
html[data-theme="dark"],
html.dark {
  color-scheme: dark;
  --bg: #0f172a;
  --surface: #111827;
  --surface-raised: #1f2937;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --border: #374151;
  /* 라이트 B(#3B82F6)와 짝 — §6 Primary / Accent를 B 민트 쪽으로 살짝 기울임 */
  --primary: #60a5fa;
  --primary-hover: #93c5fd;
  --secondary: #2dd4bf;
  --soft-accent: #5eead4;
  --ring: rgba(59, 130, 246, 0.4);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --header-bg: rgba(17, 24, 39, 0.92);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial,
    "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.container {
  /* 메인 `layout-home` 외곽(min(1320px))과 맞춤 — 헤더·푸터·툴 허브 정렬 통일 */
  width: min(1320px, 100%);
  padding: 0 16px;
  margin: 0 auto;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  z-index: 9999;
}

.skip-link:focus {
  left: 16px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* —— Sticky top (header + category bar) —— */
.site-top {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(10px);
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
}

/* —— Header —— */
.site-header {
  border-bottom: 1px solid var(--border);
}

.header-inner {
  padding: 12px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  flex-shrink: 0;
  background-color: transparent;
  background-image: url("../icons/singlebungglelab_icon_nobackground.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.brand-text {
  min-width: 0;
}

.brand-title {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 56vw;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.header-search {
  display: none;
  width: min(200px, 28vw);
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.header-search:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

.theme-toggle:hover {
  border-color: var(--primary);
}

.theme-toggle-icon {
  font-size: 14px;
  line-height: 1;
}

.lang-select {
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  min-width: 7.25rem;
  font-family: inherit;
}

.lang-select:hover {
  border-color: var(--primary);
}

.lang-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

/* —— Category bar —— */
.category-bar {
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.category-bar-inner {
  display: flex;
  gap: 8px;
  padding: 10px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.category-pill {
  flex: 0 0 auto;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  white-space: nowrap;
}

.category-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.category-pill.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.category-pill--placeholder {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.65;
}

.category-pill--placeholder:hover {
  border-color: var(--border);
  color: var(--muted);
}

.category-pill--tools.is-active {
  background: var(--cat-tools);
  border-color: var(--cat-tools);
}

.category-pill--games.is-active {
  background: var(--cat-games);
  border-color: var(--cat-games);
}

.category-pill--random.is-active {
  background: var(--cat-random);
  border-color: var(--cat-random);
}

/* —— Hero —— */
.hero {
  padding: 20px 0 12px;
}

.hero-title {
  margin: 0;
  font-size: clamp(18px, 2.8vw, 24px);
  letter-spacing: -0.02em;
  line-height: 1.35;
}

.hero-desc {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.65;
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.hero--panel {
  padding: 20px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--primary) 7%, var(--surface));
  box-shadow: var(--shadow-sm);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-weight: 800;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 14px;
  border: 1px solid transparent;
  cursor: pointer;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* —— Ad slot (placeholder, no network) —— */
.ad-slot {
  margin: 12px 0 8px;
  min-height: 72px;
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  background: var(--surface);
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.ad-slot-label {
  opacity: 0.85;
  text-align: center;
  padding: 0 12px;
  line-height: 1.35;
}

.ad-slot--infeed,
.ad-slot--footer {
  border-style: solid;
  border-color: color-mix(in srgb, var(--muted) 45%, var(--border));
  background: color-mix(in srgb, var(--muted) 6%, var(--surface));
}

.ad-slot--infeed .ad-slot-label::before,
.ad-slot--footer .ad-slot-label::before,
.ad-slot--rail .ad-slot-label::before {
  content: "광고 · ";
  font-weight: 800;
  color: var(--muted);
}

.ad-slot--hero {
  min-height: 90px;
}

.ad-slot--infeed {
  margin-top: 16px;
  min-height: 100px;
}

.ad-slot--footer {
  margin: 8px 0 0;
  min-height: 100px;
}

/* —— Home: desktop 3-column (wireframe + spec §4) —— */
.layout-home {
  width: min(1320px, 100%);
  margin: 0 auto;
  padding: 24px 16px 0;
}

.layout-home__main {
  min-width: 0;
}

/* 툴/게임 상세: 본문 블록 세로 간격 (메인과 동일 중앙 열 폭) */
.tool-page-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.tool-page-stack > .page-header {
  padding-bottom: 4px;
}

/* 툴 페이지 상단 가로 슬롯: 메인 히어로 아래보다 살짝 낮게 */
.layout-home__main .ad-slot--tool-subheader {
  min-height: 72px;
  margin: 0;
}

/* 계산기와 설명 사이 인피드: 과한 높이 완화 */
.ad-slot--infeed-compact {
  min-height: 88px;
  margin-top: 4px;
  margin-bottom: 0;
}

.ad-rail {
  display: none;
}

.ad-slot--rail {
  width: 100%;
  margin: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 12px 8px;
}

.ad-slot--rail-short {
  min-height: 260px;
}

.ad-slot--rail-tall {
  min-height: 520px;
}

.layout-home__footer-ad {
  padding-top: 8px;
  padding-bottom: 4px;
}

@media (min-width: 1024px) {
  .layout-home {
    display: grid;
    grid-template-columns: minmax(120px, 150px) minmax(0, 1fr) minmax(130px, 180px);
    gap: 20px;
    align-items: start;
  }

  .ad-rail {
    display: block;
    position: sticky;
    top: 108px;
    align-self: start;
  }

  .ad-rail--left .ad-slot--rail-short {
    min-height: 280px;
  }

  .ad-rail--right .ad-slot--rail-tall {
    min-height: 600px;
  }
}

/* —— Hub cards (메인 / 허브 공통) —— */
.section-block {
  padding: 18px 0 8px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.section-link {
  font-size: 13px;
  font-weight: 800;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
}

.section-link:hover {
  text-decoration: underline;
}

.hub-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.hub-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.hub-card:hover {
  border-color: var(--primary);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

html[data-theme="dark"] .hub-card:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.hub-card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.hub-card__title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.hub-card__desc {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
  flex: 1;
}

.hub-card__cta {
  font-size: 13px;
  font-weight: 800;
  color: var(--primary);
}

/* —— 인기순위: 카테고리별 패널, 최대 2열 —— */
.section-head--solo {
  justify-content: flex-start;
}

.popular-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.popular-panel {
  --panel-accent: var(--primary);
  --panel-bg: color-mix(in srgb, var(--panel-accent) 24%, var(--surface));
  --panel-border: color-mix(in srgb, var(--panel-accent) 40%, var(--border));
  border-radius: 20px;
  padding: 18px 18px 12px;
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
  box-shadow: var(--shadow-sm);
}

.popular-panel--tools {
  --panel-accent: var(--cat-tools);
}

.popular-panel--games {
  --panel-accent: var(--cat-games);
}

.popular-panel--random {
  --panel-accent: var(--cat-random);
}

.popular-panel--growth {
  --panel-accent: var(--muted);
  --panel-bg: color-mix(in srgb, var(--muted) 10%, var(--surface));
  --panel-border: color-mix(in srgb, var(--muted) 30%, var(--border));
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  padding: 24px 20px;
}

html[data-theme="dark"] .popular-panel:not(.popular-panel--growth) {
  --panel-bg: color-mix(in srgb, var(--panel-accent) 18%, var(--surface));
  --panel-border: color-mix(in srgb, var(--panel-accent) 35%, var(--border));
}

html[data-theme="dark"] .popular-panel--growth {
  --panel-bg: color-mix(in srgb, var(--muted) 14%, var(--surface));
}

.popular-panel__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
  padding-bottom: 10px;
  border-bottom: 1px solid color-mix(in srgb, var(--panel-accent) 25%, var(--border));
}

.popular-panel__cat {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: color-mix(in srgb, var(--panel-accent) 58%, var(--text));
}

.popular-panel__all {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  color: var(--panel-accent);
}

.popular-panel__all:hover {
  text-decoration: underline;
}

.popular-panel__growth-text {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.55;
  text-align: center;
  color: var(--muted);
  max-width: 30em;
}

.popular-rank {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: pop-rank;
}

.popular-rank > li {
  counter-increment: pop-rank;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  padding: 4px 0;
  border-top: 1px solid color-mix(in srgb, var(--panel-accent) 14%, var(--border));
}

.popular-rank > li:first-child {
  border-top: none;
  padding-top: 2px;
}

.popular-rank > li::before {
  content: counter(pop-rank) ".";
  flex-shrink: 0;
  min-width: 1.75em;
  font-weight: 800;
  font-size: 14px;
  color: var(--panel-accent);
}

.popular-rank__link {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  text-decoration: none;
}

.popular-rank__link:hover {
  color: var(--panel-accent);
  text-decoration: underline;
}

.popular-rank__pending {
  flex: 1;
  min-width: 0;
}

.popular-rank__dots {
  display: inline-block;
}

.popular-rank__dots::before {
  content: "······";
  letter-spacing: 0.2em;
  font-weight: 700;
  color: var(--muted);
  opacity: 0.5;
}

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  flex-shrink: 0;
}

.badge--tools {
  color: var(--cat-tools);
  border-color: color-mix(in srgb, var(--cat-tools) 35%, var(--border));
  background: color-mix(in srgb, var(--cat-tools) 12%, var(--surface));
}

.badge--games {
  color: var(--cat-games);
  border-color: color-mix(in srgb, var(--cat-games) 35%, var(--border));
  background: color-mix(in srgb, var(--cat-games) 12%, var(--surface));
}

.badge--random {
  color: var(--cat-random);
  border-color: color-mix(in srgb, var(--cat-random) 35%, var(--border));
  background: color-mix(in srgb, var(--cat-random) 12%, var(--surface));
}

.badge--soon {
  border-style: dashed;
  opacity: 0.92;
}

.ladder-svg {
  display: block;
  width: 100%;
  max-width: 560px;
  height: auto;
  margin: 12px auto;
  color: var(--text, #1e293b);
}

.ladder-tool .ladder-lead {
  margin: 0 0 14px;
  font-size: 14px;
  line-height: 1.55;
  max-width: 40rem;
}

.ladder-tool .form-field--split {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px 16px;
  align-items: end;
}

.ladder-tool .ladder-dim-fields label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
}

.ladder-tool .ladder-dim-fields input[type="number"] {
  width: 100%;
  max-width: 120px;
}

.ladder-tool .ladder-dim-hint {
  margin: 4px 0 14px;
  font-size: 13px;
}

.ladder-board {
  margin-top: 4px;
}

.ladder-tool .ladder-row-label {
  margin: 10px 0 6px;
  font-size: 13px;
}

.ladder-row--names,
.ladder-row--prizes {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
}

.ladder-col-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.ladder-col-head--interactive {
  cursor: pointer;
  padding: 6px;
  margin: -6px;
  border-radius: 10px;
  transition: background 0.15s ease;
}

.ladder-col-head--interactive:hover {
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}

.ladder-col-head--interactive:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.ladder-name-input,
.ladder-prize-input {
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  font-size: 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.ladder-svg-wrap {
  min-height: 120px;
  margin: 4px 0 12px;
}

.ladder-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0 8px;
}

.ladder-tool .ladder-after-reveal-hint {
  margin: 0 0 14px;
  font-size: 13px;
  max-width: 40rem;
}

.ladder-tool .ladder-map-title {
  margin-top: 18px;
  font-size: 1rem;
}

.ladder-map-table {
  width: 100%;
  max-width: 520px;
  border-collapse: collapse;
  font-size: 14px;
}

.ladder-map-table td {
  padding: 6px 10px 6px 0;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.ladder-map-table tr:last-child td {
  border-bottom: none;
}

.dice-stage {
  display: flex;
  justify-content: center;
  margin: 12px 0 4px;
  min-height: 112px;
}

.dice-canvas {
  display: block;
  max-width: 100%;
  height: auto;
  vertical-align: middle;
}

.dice-count-hint {
  margin: -4px 0 12px;
  font-size: 13px;
  line-height: 1.5;
  max-width: 40rem;
}

.coin-tool .coin-stage {
  display: flex;
  justify-content: center;
  margin: 8px 0 20px;
}

.coin-perspective {
  perspective: 1100px;
  width: min(240px, 78vw);
  height: min(240px, 78vw);
  max-width: 100%;
}

.coin-3d {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 1.05s cubic-bezier(0.2, 0.85, 0.2, 1);
  will-change: transform;
}

.coin-3d.coin-3d--instant {
  transition: none !important;
}

.coin-face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(2.25rem, 12vw, 3.5rem);
  font-weight: 700;
  line-height: 1;
  box-shadow:
    inset 0 -8px 20px rgba(0, 0, 0, 0.12),
    0 10px 28px rgba(0, 0, 0, 0.15);
  border: 3px solid color-mix(in srgb, var(--border) 55%, transparent);
}

.coin-face--heads {
  background: linear-gradient(145deg, #fbbf24, #d97706);
  color: #1f2937;
  transform: rotateY(0deg) translateZ(3px);
}

.coin-face--tails {
  background: linear-gradient(145deg, #e2e8f0, #94a3b8);
  color: #0f172a;
  transform: rotateY(180deg) translateZ(3px);
}

.coin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.coin-last {
  margin-bottom: 8px;
}

.coin-stats {
  margin: 0 0 12px;
  font-size: 15px;
  line-height: 1.5;
}

@media (prefers-reduced-motion: reduce) {
  .coin-3d {
    transition-duration: 0.2s;
  }
}

.wheel-wrap {
  display: flex;
  justify-content: center;
  margin: 16px 0;
}

#wheelCanvas {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
}

/* —— 카테고리 SEO 안내 (메인) —— */
.category-seo-lead {
  margin: 0 0 18px;
  max-width: 52em;
  font-size: 14px;
  line-height: 1.55;
  color: var(--muted);
}

.category-showcase {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 4px 0 12px;
}

.category-showcase-block {
  --cat-seo-accent: var(--primary);
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  padding: 18px 18px 16px;
  border-left: 4px solid var(--cat-seo-accent);
}

.category-showcase-block--tools {
  --cat-seo-accent: var(--cat-tools);
}

.category-showcase-block--games {
  --cat-seo-accent: var(--cat-games);
}

.category-showcase-block--random {
  --cat-seo-accent: var(--cat-random);
}

.category-showcase-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

.category-showcase-head__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 14px;
}

.category-showcase-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.category-showcase-cta {
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.category-showcase-cta--tools {
  color: var(--cat-tools);
}

.category-showcase-cta--games {
  color: var(--cat-games);
}

.category-showcase-cta--random {
  color: var(--cat-random);
}

.category-showcase-cta:hover {
  text-decoration: underline;
}

.category-showcase-intro {
  margin: 0 0 14px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  max-width: 58em;
}

.category-seo-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.category-seo-box {
  padding: 14px 14px 13px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--cat-seo-accent) 22%, var(--border));
  background: color-mix(in srgb, var(--cat-seo-accent) 9%, var(--surface));
}

html[data-theme="dark"] .category-seo-box {
  background: color-mix(in srgb, var(--cat-seo-accent) 14%, var(--surface));
  border-color: color-mix(in srgb, var(--cat-seo-accent) 28%, var(--border));
}

.category-seo-box__title {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: color-mix(in srgb, var(--cat-seo-accent) 45%, var(--text));
}

.category-seo-box__text {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.category-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 900;
  color: #fff;
  flex-shrink: 0;
}

.category-icon--tools {
  background: var(--cat-tools);
}

.category-icon--games {
  background: var(--cat-games);
}

.category-icon--random {
  background: var(--cat-random);
}

/* —— Footer —— */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 0 max(20px, env(safe-area-inset-bottom, 0px));
  color: var(--muted);
  background: var(--surface);
  margin-top: 8px;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
}

.footer-link {
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
}

.footer-link:hover {
  color: var(--primary);
}

.footer-meta {
  font-size: 13px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  align-items: baseline;
}

.footer-contact::before {
  content: "·";
  margin-right: 0.35em;
  opacity: 0.65;
}

/* —— Legal (terms / privacy): wide column, 2-col sections on desktop —— */
/*
 * Hub/tool pages wrap .layout-home__main in a 3-col grid (side ads + main).
 * Legal pages only have <main> — without this, grid places main in column 1 (~150px).
 */
.layout-home.layout-home--legal {
  width: 100%;
  max-width: min(70rem, 100%);
  margin-left: auto;
  margin-right: auto;
  padding-left: clamp(14px, 3vw, 28px);
  padding-right: clamp(14px, 3vw, 28px);
}

@media (min-width: 1024px) {
  .layout-home.layout-home--legal {
    display: block;
  }

  .layout-home.layout-home--legal .layout-home__main {
    width: 100%;
    max-width: none;
  }
}

.tool-page-stack--legal {
  gap: 18px;
}

.page-header--legal .page-title {
  font-size: clamp(1.35rem, 3.2vw, 1.9rem);
  line-height: 1.3;
}

.content-card--legal {
  width: 100%;
  max-width: none;
  padding: clamp(22px, 4vw, 42px);
  box-sizing: border-box;
}

.legal-doc {
  max-width: none;
}

.legal-doc__lead {
  margin: 0 0 1.25rem;
  font-size: clamp(15px, 1.05rem, 17px);
  line-height: 1.75;
  color: var(--text);
}

.legal-doc__sections {
  display: grid;
  gap: 1rem 1.75rem;
}

@media (min-width: 900px) {
  .legal-doc__sections {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem 2rem;
  }

  .legal-doc__section--full {
    grid-column: 1 / -1;
  }
}

.legal-doc__section {
  margin: 0;
  padding: 1.1rem 1.15rem;
  border-radius: 14px;
  background: color-mix(in srgb, var(--muted) 7%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--border) 85%, transparent);
}

html[data-theme="dark"] .legal-doc__section {
  background: color-mix(in srgb, var(--muted) 12%, var(--surface));
}

.legal-doc__h2 {
  margin: 0 0 0.55rem;
  font-size: 1.0625rem;
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: -0.02em;
  color: var(--text);
}

.legal-doc__section p {
  margin: 0;
  font-size: 15px;
  line-height: 1.78;
  color: var(--text);
}

.legal-doc__nav {
  margin-top: 1.5rem;
  padding-top: 1.15rem;
  border-top: 1px solid var(--border);
}

.legal-doc__nav a {
  font-weight: 700;
  color: var(--primary);
}

/* —— Inner pages —— */
.muted {
  color: var(--muted);
}

.content-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.form {
  display: grid;
  gap: 12px;
}

label {
  font-weight: 800;
  font-size: 13px;
}

input,
textarea {
  width: 100%;
  margin-top: 6px;
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

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

button {
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
  font-weight: 900;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
}

button:hover {
  background: var(--primary-hover);
}

button.secondary {
  width: auto;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

button.secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.notice {
  border-radius: 14px;
  padding: 12px 12px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.notice-success {
  border-color: color-mix(in srgb, #22c55e 40%, var(--border));
  background: color-mix(in srgb, #22c55e 10%, var(--surface));
}

.notice-error {
  border-color: color-mix(in srgb, #ef4444 40%, var(--border));
  background: color-mix(in srgb, #ef4444 10%, var(--surface));
}

.notice-info {
  border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
}

/* —— BMI calculator —— */
.form-field {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.form-sub-label {
  display: block;
  font-weight: 700;
  font-size: 12px;
  margin-top: 8px;
  color: var(--muted);
}

.form-select {
  width: 100%;
  max-width: 280px;
  margin-top: 6px;
  margin-bottom: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  outline: none;
  cursor: pointer;
}

.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.form-field__split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 4px;
}

/* `[hidden]` 기본 display:none이 아래 display 규칙에 밀려 무시되므로 명시 */
.form-field__split[hidden],
.form-field__input[hidden] {
  display: none !important;
}

.bmi-bar-panel {
  margin-top: 14px;
}

.bmi-bar__marker--idle {
  display: none;
}

.bmi-bar-panel + .bmi-result-slot:not(:empty) {
  margin-top: 10px;
}

.bmi-result-slot {
  margin-top: 0;
}

.bmi-disclaimer {
  margin: 12px 0 0;
  font-size: 12px;
}

.bmi-notice__cat {
  margin-top: 6px;
}

.bmi-bar {
  margin-top: 14px;
}

.bmi-bar__hint {
  margin: 0 0 8px;
  font-size: 13px;
  line-height: 1.45;
}

.bmi-bar__axis {
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--muted);
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}

.bmi-bar__track-wrap {
  position: relative;
  height: 18px;
  margin: 4px 0 8px;
}

.bmi-bar__track {
  height: 14px;
  margin-top: 2px;
  border-radius: 7px;
  /* BMI 12–45: 구간 색 (저체중·정상·과체중·비만) */
  background: linear-gradient(
    to right,
    #fbbf24 0%,
    #fbbf24 19.7%,
    #22c55e 19.7%,
    #22c55e 39.4%,
    #fb923c 39.4%,
    #fb923c 54.5%,
    #ef4444 54.5%,
    #ef4444 100%
  );
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

html[data-theme="dark"] .bmi-bar__track {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.bmi-bar__marker {
  position: absolute;
  top: 0;
  width: 4px;
  height: 18px;
  margin-left: -2px;
  border-radius: 2px;
  background: var(--text);
  box-shadow: 0 0 0 2px var(--surface), 0 1px 4px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

.bmi-bar__position {
  margin: 0;
  font-size: 12px;
}

.bmi-article {
  margin-top: 0;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  width: 100%;
  box-sizing: border-box;
}

.bmi-article h2 {
  font-size: 1.05rem;
  font-weight: 800;
  margin: 1.35em 0 0.45em;
  letter-spacing: -0.02em;
  color: var(--text);
}

.bmi-article h2:first-of-type {
  margin-top: 0;
}

.bmi-article p {
  margin: 0 0 0.9em;
  font-size: 14px;
  line-height: 1.65;
  color: var(--muted);
  max-width: none;
  width: 100%;
}

.bmi-article p:last-child {
  margin-bottom: 0;
}

/* Knowledge MD 본문 전용 — `KnowledgeArticleBody` 의 article.knowledge-article (BMI `.bmi-article` 과 분리) */
.knowledge-article {
  margin-top: 0;
  padding: 18px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  width: 100%;
  box-sizing: border-box;
  font-size: 19px;
  line-height: 1.65;
  color: var(--muted);
}

.knowledge-article h1 {
  font-size: 1.35em;
  font-weight: 800;
  margin: 0 0 0.55em;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.35;
}

.knowledge-article h2 {
  font-size: 1.22em;
  font-weight: 800;
  margin: 1.15em 0 0.45em;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.35;
}

.knowledge-article h2:first-of-type {
  margin-top: 0;
}

.knowledge-article h3 {
  font-size: 1.1em;
  font-weight: 700;
  margin: 1.1em 0 0.4em;
  color: var(--text);
  line-height: 1.4;
}

.knowledge-article h4,
.knowledge-article h5,
.knowledge-article h6 {
  font-size: 1.02em;
  font-weight: 700;
  margin: 1em 0 0.35em;
  color: var(--text);
  line-height: 1.45;
}

.knowledge-article p {
  margin: 0 0 0.85em;
  font-size: 1em;
  line-height: 1.65;
  color: var(--muted);
  max-width: none;
  width: 100%;
}

.knowledge-article p:last-child {
  margin-bottom: 0;
}

.knowledge-article a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.knowledge-article strong {
  color: var(--text);
  font-weight: 700;
}

.knowledge-article ul,
.knowledge-article ol {
  margin: 0 0 0.85em;
  padding-left: 1.4em;
  color: var(--muted);
}

/* 문단 ↔ 목록 사이만 살짝 넓힘 (p·목록 각각 0.85em보다 큰 인접 마진이 병합되어 적용됨) */
.knowledge-article p + ul,
.knowledge-article p + ol {
  margin-top: 1.12em;
}

.knowledge-article ul + p,
.knowledge-article ol + p {
  margin-top: 1.12em;
}

.knowledge-article li {
  margin: 0.35em 0;
}

.knowledge-article li::marker {
  color: var(--muted);
}

.knowledge-article blockquote {
  margin: 0.75em 0;
  padding: 0.5em 0 0.5em 1em;
  border-left: 4px solid var(--border);
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 92%, var(--border));
}

html.dark .knowledge-article blockquote {
  background: color-mix(in srgb, var(--surface-raised) 80%, var(--border));
}

.knowledge-article code {
  font-size: 0.92em;
  padding: 0.15em 0.35em;
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface-raised) 70%, var(--border));
  color: var(--text);
}

.knowledge-article pre {
  overflow-x: auto;
  margin: 0.75em 0 1em;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 0.88em;
  line-height: 1.5;
  color: var(--muted);
}

.knowledge-article pre code {
  padding: 0;
  background: transparent;
  color: inherit;
}

.knowledge-article table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75em 0 1em;
  font-size: 0.95em;
  border: 1px solid var(--border);
  color: var(--muted);
}

.knowledge-article th,
.knowledge-article td {
  border: 1px solid var(--border);
  padding: 0.5em 0.65em;
  text-align: left;
  vertical-align: top;
}

.knowledge-article thead th {
  font-weight: 700;
  color: var(--text);
  background: color-mix(in srgb, var(--surface-raised) 75%, var(--border));
}

html.dark .knowledge-article thead th {
  background: color-mix(in srgb, var(--surface-raised) 65%, var(--border));
}

.knowledge-article tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--surface) 88%, var(--border));
}

html.dark .knowledge-article tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--surface-raised) 55%, var(--border));
}

.knowledge-article tbody td {
  color: var(--muted);
}

.knowledge-article hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.25em 0;
}

.knowledge-article img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

/* BMI 외 툴 페이지 정보 블록 — 동일 타이포 */
.tool-article {
  margin-top: 0;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  width: 100%;
  box-sizing: border-box;
}

.tool-article h2 {
  font-size: 1.05rem;
  font-weight: 800;
  margin: 1.35em 0 0.45em;
  letter-spacing: -0.02em;
  color: var(--text);
}

.tool-article h2:first-of-type {
  margin-top: 0;
}

.tool-article p {
  margin: 0 0 0.9em;
  font-size: 14px;
  line-height: 1.65;
  color: var(--muted);
  max-width: none;
  width: 100%;
}

.tool-article p:last-child {
  margin-bottom: 0;
}

.tool-disclaimer {
  margin: 12px 0 0;
  font-size: 12px;
}

.tool-result {
  margin-top: 12px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 14px;
}

/* 인터넷 속도(간이): 결과를 등급·색으로 구분 */
.net-speed-result {
  border-width: 2px;
}

.net-speed-result--pending {
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
  background: color-mix(in srgb, var(--primary) 6%, var(--surface));
}

.net-speed-result--error {
  border-color: color-mix(in srgb, #ef4444 45%, var(--border));
  background: color-mix(in srgb, #ef4444 8%, var(--surface));
  color: var(--text);
}

.net-speed-result__status {
  margin: 0;
  font-weight: 600;
}

.net-speed-result__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.net-speed-result__heading {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}

.net-speed-result__badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.net-speed-result__mbps-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  margin-bottom: 8px;
}

.net-speed-result__mbps {
  font-size: clamp(1.75rem, 5vw, 2.25rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.net-speed-result__mbps-unit {
  font-size: 1rem;
  font-weight: 700;
  opacity: 0.85;
}

.net-speed-result__label {
  font-size: 13px;
  color: var(--muted);
}

.net-speed-result__hint {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.45;
}

.net-speed-result__meta {
  margin: 0 0 6px;
  font-size: 12px;
}

.net-speed-result__legend {
  margin: 0;
  font-size: 11px;
  line-height: 1.4;
}

.net-speed-result--tier-excellent {
  border-color: color-mix(in srgb, #16a34a 55%, var(--border));
  background: linear-gradient(
    145deg,
    color-mix(in srgb, #16a34a 12%, var(--surface)) 0%,
    var(--surface) 55%
  );
}

.net-speed-result--tier-excellent .net-speed-result__badge {
  background: color-mix(in srgb, #16a34a 22%, var(--surface));
  color: #15803d;
  border: 1px solid color-mix(in srgb, #16a34a 40%, transparent);
}

.net-speed-result--tier-excellent .net-speed-result__mbps {
  color: #166534;
}

html[data-theme="dark"] .net-speed-result--tier-excellent .net-speed-result__badge {
  color: #86efac;
  border-color: color-mix(in srgb, #22c55e 45%, transparent);
}

html[data-theme="dark"] .net-speed-result--tier-excellent .net-speed-result__mbps {
  color: #bbf7d0;
}

.net-speed-result--tier-fast {
  border-color: color-mix(in srgb, #22c55e 45%, var(--border));
  background: color-mix(in srgb, #22c55e 10%, var(--surface));
}

.net-speed-result--tier-fast .net-speed-result__badge {
  background: color-mix(in srgb, #22c55e 18%, var(--surface));
  color: #166534;
  border: 1px solid color-mix(in srgb, #22c55e 35%, transparent);
}

.net-speed-result--tier-fast .net-speed-result__mbps {
  color: #15803d;
}

html[data-theme="dark"] .net-speed-result--tier-fast .net-speed-result__badge {
  color: #86efac;
}

html[data-theme="dark"] .net-speed-result--tier-fast .net-speed-result__mbps {
  color: #bbf7d0;
}

.net-speed-result--tier-good {
  border-color: color-mix(in srgb, #eab308 45%, var(--border));
  background: color-mix(in srgb, #eab308 10%, var(--surface));
}

.net-speed-result--tier-good .net-speed-result__badge {
  background: color-mix(in srgb, #eab308 20%, var(--surface));
  color: #a16207;
  border: 1px solid color-mix(in srgb, #ca8a04 35%, transparent);
}

.net-speed-result--tier-good .net-speed-result__mbps {
  color: #854d0e;
}

html[data-theme="dark"] .net-speed-result--tier-good .net-speed-result__badge {
  color: #fde047;
}

html[data-theme="dark"] .net-speed-result--tier-good .net-speed-result__mbps {
  color: #fef08a;
}

.net-speed-result--tier-fair {
  border-color: color-mix(in srgb, #f97316 50%, var(--border));
  background: color-mix(in srgb, #f97316 9%, var(--surface));
}

.net-speed-result--tier-fair .net-speed-result__badge {
  background: color-mix(in srgb, #f97316 18%, var(--surface));
  color: #c2410c;
  border: 1px solid color-mix(in srgb, #ea580c 38%, transparent);
}

.net-speed-result--tier-fair .net-speed-result__mbps {
  color: #9a3412;
}

html[data-theme="dark"] .net-speed-result--tier-fair .net-speed-result__badge {
  color: #fdba74;
}

html[data-theme="dark"] .net-speed-result--tier-fair .net-speed-result__mbps {
  color: #fed7aa;
}

.net-speed-result--tier-slow {
  border-color: color-mix(in srgb, #ef4444 50%, var(--border));
  background: color-mix(in srgb, #ef4444 8%, var(--surface));
}

.net-speed-result--tier-slow .net-speed-result__badge {
  background: color-mix(in srgb, #ef4444 16%, var(--surface));
  color: #b91c1c;
  border: 1px solid color-mix(in srgb, #ef4444 40%, transparent);
}

.net-speed-result--tier-slow .net-speed-result__mbps {
  color: #991b1b;
}

html[data-theme="dark"] .net-speed-result--tier-slow .net-speed-result__badge {
  color: #fca5a5;
}

html[data-theme="dark"] .net-speed-result--tier-slow .net-speed-result__mbps {
  color: #fecaca;
}

/* —— 카테고리 허브: SEO 안내 블록 —— */
.hub-seo {
  --hub-seo-accent: var(--primary);
  margin: 0 0 8px;
  padding: 16px 18px 14px;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--hub-seo-accent) 22%, var(--border));
  background: color-mix(in srgb, var(--hub-seo-accent) 8%, var(--surface));
  box-shadow: var(--shadow-sm);
}

.hub-seo--tools {
  --hub-seo-accent: var(--cat-tools);
}

.hub-seo--games {
  --hub-seo-accent: var(--cat-games);
}

.hub-seo--random {
  --hub-seo-accent: var(--cat-random);
}

html[data-theme="dark"] .hub-seo {
  background: color-mix(in srgb, var(--hub-seo-accent) 14%, var(--surface));
  border-color: color-mix(in srgb, var(--hub-seo-accent) 30%, var(--border));
}

.hub-seo__title {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: color-mix(in srgb, var(--hub-seo-accent) 50%, var(--text));
}

.hub-seo__lead {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  max-width: 52em;
}

.hub-seo__list {
  margin: 0;
  padding-left: 1.15em;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.hub-seo__list li {
  margin-bottom: 6px;
}

.hub-seo__list li:last-child {
  margin-bottom: 0;
}

.page-header {
  padding: 18px 0 10px;
}

.page-title {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.page-back {
  display: inline-block;
  margin-top: 10px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 800;
}

.page-back:hover {
  color: var(--primary);
}

.list {
  padding-left: 18px;
}

.notice .picked-value {
  word-break: break-word;
}

.top-nav {
  display: none;
}

.quick-links-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.quick-link {
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 12px 14px;
  border-radius: 14px;
  font-weight: 800;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.quick-link:hover {
  border-color: var(--primary);
  color: var(--primary);
}

@media (min-width: 640px) {
  .brand-subtitle {
    max-width: none;
  }

  .header-search {
    display: block;
  }

  .hero-title {
    font-size: 28px;
  }

  .hub-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .popular-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .category-seo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-links-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .page-title {
    font-size: 28px;
  }

  .footer-inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

@media (min-width: 960px) {
  .category-seo-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1200px) {
  .popular-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* —— Random tools: current / history / animations —— */
.section-title--tool-sub {
  margin: 18px 0 8px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.random-current {
  margin-top: 0;
}

.random-history-block {
  margin-top: 18px;
}

.random-history-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.random-history-list {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 14px;
  line-height: 1.55;
}

.random-history-list--cards {
  list-style: none;
  padding-left: 0;
}

.random-history-card {
  margin-bottom: 12px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.random-history-card__meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.random-history-empty {
  margin: 0 0 8px;
  font-size: 13px;
}

.random-history-empty[hidden] {
  display: none;
}

.random-num-anim {
  min-height: 2.5rem;
  margin: 10px 0 6px;
  font-size: clamp(1.25rem, 4vw, 1.75rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: var(--text);
}

.multi-anim {
  min-height: 2.75rem;
  margin: 10px 0 6px;
  font-size: clamp(1.1rem, 3.5vw, 1.5rem);
  font-weight: 600;
  color: var(--text);
  text-align: center;
}

.multi-anim--on {
  opacity: 0.92;
}

@keyframes sbl-pop-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.random-stagger-item {
  animation: sbl-pop-in 0.38s ease backwards;
}

.team-bucket {
  margin-bottom: 10px;
}

.team-bucket__ul {
  margin: 6px 0 0;
}

.shuffle-order-list {
  margin: 8px 0 0;
}

.multi-picked-list {
  margin: 8px 0 0;
}

.lotto-balls {
  min-height: 72px;
  margin: 12px 0 8px;
}

.lotto-ball-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 10px;
}

.lotto-ball-row--pb {
  margin-top: 4px;
}

.lotto-ball {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(145deg, #e2e8f0, #94a3b8);
  color: #0f172a;
  box-shadow: inset 0 -3px 8px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.1);
  border: 2px solid color-mix(in srgb, var(--border) 70%, transparent);
  transform: scale(0.92);
  opacity: 0.85;
  transition:
    transform 0.28s ease,
    opacity 0.28s ease;
}

.lotto-ball--white {
  background: linear-gradient(145deg, #f8fafc, #cbd5e1);
}

.lotto-ball--power {
  background: linear-gradient(145deg, #dc2626, #991b1b);
  color: #fff;
  border-color: color-mix(in srgb, #991b1b 50%, transparent);
}

.lotto-ball--reveal {
  transform: scale(1);
  opacity: 1;
}

.lotto-pb-lead {
  margin: 0 0 12px;
  max-width: 40rem;
  line-height: 1.55;
}

@media (prefers-reduced-motion: reduce) {
  .random-stagger-item {
    animation: none;
  }
  .lotto-ball {
    transition: none;
  }
}

/* Mini-games: guess number chips, RPS, reaction, Run for 63 */
.game-guess-history {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
}

.game-guess-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 2rem;
  align-items: center;
}

.game-guess-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: color-mix(in srgb, var(--surface-raised) 90%, var(--border));
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  animation: sbl-pop-in 0.32s ease backwards;
}

.game-guess-chip--correct {
  background: color-mix(in srgb, #22c55e 22%, var(--bg));
  border-color: color-mix(in srgb, #22c55e 45%, var(--border));
  color: var(--text);
}

@keyframes game-feedback-bounce {
  0% {
    transform: scale(0.98);
  }
  40% {
    transform: scale(1.01);
  }
  100% {
    transform: scale(1);
  }
}

.game-feedback-bounce {
  animation: game-feedback-bounce 0.45s ease;
}

.rps-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin: 12px 0;
}

.rps-btn {
  min-width: 6.5rem;
  padding: 12px 16px;
  font-size: 1.05rem;
  font-weight: 700;
  border-radius: 12px;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease;
}

.rps-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

.rps-btn:active:not(:disabled) {
  transform: translateY(0);
}

.rps-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.rps-result {
  min-height: 5rem;
  margin: 12px 0;
  padding: 14px;
  border-radius: 12px;
  text-align: center;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.45;
}

.rps-result--pending {
  opacity: 0.85;
  animation: sbl-pop-in 0.35s ease;
}

.rps-result--win {
  background: color-mix(in srgb, #22c55e 18%, var(--bg));
  animation: game-feedback-bounce 0.5s ease;
}

.rps-result--lose {
  background: color-mix(in srgb, #f97316 18%, var(--bg));
  animation: game-rps-shake 0.45s ease;
}

.rps-result--draw {
  background: color-mix(in srgb, var(--border) 35%, var(--bg));
}

@keyframes game-rps-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-6px);
  }
  75% {
    transform: translateX(6px);
  }
}

.reaction-panel {
  min-height: 140px;
  margin: 12px 0;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  font-size: clamp(1.1rem, 3vw, 1.65rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  transition:
    background 0.12s ease,
    color 0.12s ease,
    transform 0.2s ease;
}

.reaction-panel--idle {
  background: color-mix(in srgb, var(--border) 40%, var(--bg));
  color: var(--muted, #64748b);
}

.reaction-panel--wait {
  background: color-mix(in srgb, #dc2626 35%, #1e293b);
  color: #fff;
}

.reaction-panel--go {
  background: linear-gradient(145deg, #22c55e, #16a34a);
  color: #fff;
  animation: game-reaction-pulse 0.55s ease-in-out infinite alternate;
}

.reaction-panel--result {
  background: color-mix(in srgb, var(--border) 30%, var(--bg));
  color: var(--text);
  animation: sbl-pop-in 0.35s ease;
}

.reaction-panel--foul {
  background: color-mix(in srgb, #eab308 28%, var(--bg));
  color: var(--text);
  animation: game-rps-shake 0.4s ease;
}

@keyframes game-reaction-pulse {
  from {
    transform: scale(1);
    filter: brightness(1);
  }
  to {
    transform: scale(1.02);
    filter: brightness(1.06);
  }
}

.reaction-main-btn {
  width: 100%;
  max-width: 20rem;
  margin: 0 auto;
  display: block;
  padding: 14px 20px;
  font-size: 1.1rem;
  font-weight: 800;
  border-radius: 12px;
}

.ttt-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  max-width: 280px;
  margin: 12px auto;
}

.ttt-cell {
  aspect-ratio: 1;
  min-height: 72px;
  border-radius: 12px;
  font-size: clamp(1.75rem, 6vw, 2.25rem);
  font-weight: 800;
  line-height: 1;
  transition:
    transform 0.15s ease,
    background 0.15s ease;
}

.ttt-cell:hover:not(:disabled) {
  transform: scale(1.03);
}

.ttt-cell:disabled {
  cursor: default;
  opacity: 0.95;
}

.ttt-status {
  min-height: 2.5rem;
  margin: 10px 0;
  text-align: center;
  font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
  .game-guess-chip,
  .rps-result--pending,
  .rps-result--win,
  .rps-result--lose,
  .reaction-panel--go,
  .reaction-panel--result,
  .game-feedback-bounce {
    animation: none;
  }
  .rps-btn:hover:not(:disabled) {
    transform: none;
  }
  .ttt-cell:hover:not(:disabled) {
    transform: none;
  }
  .game1-win-modal__burst,
  .game1-newgame--pulse {
    animation: none !important;
  }
}

/* Guess number: invalid input, win modal, new game pulse */
.game1-guess-input.game1-input--invalid {
  border-color: #dc2626 !important;
  box-shadow: 0 0 0 2px color-mix(in srgb, #dc2626 35%, transparent);
  color: #dc2626;
}

.game1-range-hint {
  margin: 4px 0 0;
  font-size: 0.9rem;
  color: #dc2626;
}

.game1-newgame--pulse {
  animation: game1-newgame-pulse 1.1s ease-in-out infinite;
  box-shadow: 0 0 0 0 color-mix(in srgb, #22c55e 55%, transparent);
}

@keyframes game1-newgame-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.45);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(34, 197, 94, 0);
  }
}

.game1-win-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.game1-win-modal[hidden] {
  display: none;
}

.game1-win-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
}

.game1-win-modal__card {
  position: relative;
  max-width: 22rem;
  width: 100%;
  padding: 1.5rem 1.35rem 1.25rem;
  border-radius: 16px;
  background: var(--surface-raised);
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.22);
  text-align: center;
  animation: game1-modal-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes game1-modal-pop {
  from {
    opacity: 0;
    transform: scale(0.88) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.game1-win-modal__burst {
  position: absolute;
  inset: -30%;
  background: radial-gradient(circle, color-mix(in srgb, #fbbf24 35%, transparent) 0%, transparent 65%);
  opacity: 0.55;
  pointer-events: none;
  animation: game1-burst-spin 8s linear infinite;
}

@keyframes game1-burst-spin {
  to {
    transform: rotate(360deg);
  }
}

.game1-win-modal__emoji {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 6px;
  position: relative;
  z-index: 1;
  animation: game-feedback-bounce 0.65s ease;
}

.game1-win-modal__title {
  margin: 0 0 8px;
  font-size: 1.5rem;
  position: relative;
  z-index: 1;
}

.game1-win-modal__line {
  margin: 0 0 10px;
  font-weight: 700;
  position: relative;
  z-index: 1;
}

.game1-win-modal__hint {
  margin: 0 0 14px;
  font-size: 0.92rem;
  position: relative;
  z-index: 1;
}

.game1-win-modal__ok {
  position: relative;
  z-index: 1;
  padding: 10px 22px;
  font-weight: 700;
  border-radius: 10px;
}

/* RPS arena */
.rps-arena {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 3vw, 20px);
  margin: 14px 0 10px;
  flex-wrap: wrap;
}

.rps-arena__col {
  flex: 1 1 120px;
  max-width: 180px;
  text-align: center;
}

.rps-arena__label {
  display: block;
  font-size: 0.85rem;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--muted);
}

.rps-arena__display {
  min-height: 5.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: color-mix(in srgb, var(--border) 28%, var(--bg));
  border: 2px solid color-mix(in srgb, var(--border) 65%, transparent);
  font-size: 4.25rem;
  line-height: 1;
  transition:
    transform 0.25s ease,
    box-shadow 0.25s ease;
}

.rps-arena__display--pop {
  animation: game-feedback-bounce 0.45s ease;
}

.rps-arena__vs {
  font-weight: 900;
  font-size: 1.15rem;
  color: var(--muted);
  align-self: center;
}

.rps-emoji {
  font-style: normal;
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
}

.reaction-tier-line {
  margin-top: 10px;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.4;
}

.reaction-tier-table-wrap {
  margin-top: 14px;
  overflow-x: auto;
}

.reaction-tier-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.reaction-tier-table th,
.reaction-tier-table td {
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  padding: 8px 10px;
  text-align: left;
}

.reaction-tier-table th {
  background: color-mix(in srgb, var(--border) 22%, var(--bg));
  font-weight: 800;
}

/* Run for 63 — 7×9 */
.rf63-status {
  min-height: 2.25rem;
  margin: 6px 0 10px;
  text-align: center;
  font-weight: 700;
}

.rf63-wrap {
  margin: 0 auto;
  max-width: min(96vw, 420px);
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
  background: color-mix(in srgb, var(--muted) 8%, var(--bg));
  padding: 8px;
}

.rf63-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-template-rows: repeat(9, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
  aspect-ratio: 7 / 9;
}

/* Beat global `button.secondary` padding so tiles stay inside 7×9 cells (avoids stacked “ghost” outlines). */
.rf63-grid > button.rf63-tile.secondary {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rf63-tile {
  min-height: 0;
  min-width: 0;
  padding: 0;
  border-radius: 8px;
  font-size: clamp(0.72rem, 2.8vw, 0.95rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  cursor: pointer;
  transition:
    transform 0.12s ease,
    background 0.12s ease,
    opacity 0.12s ease;
}

.rf63-tile:hover:not(:disabled):not(.rf63-tile--done) {
  transform: scale(1.04);
  background: color-mix(in srgb, var(--primary) 14%, var(--surface));
}

/* Cleared tiles: keep grid cell but hide fully (beat button:disabled opacity) */
button.rf63-tile.rf63-tile--done:disabled {
  opacity: 0 !important;
  visibility: hidden;
  pointer-events: none;
  cursor: default;
  transform: none;
  border-color: transparent !important;
  background: transparent !important;
  color: transparent;
  box-shadow: none;
  transition: none !important;
}

.rf63-tile--wrong {
  animation: game-rps-shake 0.2s ease;
  background: color-mix(in srgb, #dc2626 22%, var(--surface)) !important;
}

@media (prefers-reduced-motion: reduce) {
  .rf63-tile:hover:not(:disabled):not(.rf63-tile--done) {
    transform: none;
  }
  .rf63-tile--wrong {
    animation: none;
  }
}
