:root {
  color-scheme: only light;
  --ink: #1c1c1e;
  --ink-deep: #050038;
  --slate: #5c6070;
  --muted: #9295a2;
  --canvas: #ffffff;
  --surface: #f7f8fa;
  --line: #e2e4e9;
  --line-soft: #eef0f3;
  --yellow: #ffd02f;
  --yellow-soft: #fff4c4;
  --coral: #ffc6c6;
  --rose: #fde0f0;
  --teal: #c3faf5;
  --blue-soft: #e8ebff;
  --orange-soft: #ffe6cd;
  --purple-soft: #eee7ff;
  --blue: #4262ff;
  --font: "Noto Sans SC", "Microsoft YaHei UI", "PingFang SC", Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html {
  color-scheme: only light;
  background: #fbf8f1;
  scroll-behavior: smooth;
  scroll-padding-top: 84px;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background-color: #fbf8f1;
  background-image: url("./assets/oddpedia-background-v1.png");
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;
  background-attachment: fixed;
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; }

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.shell {
  width: min(1120px, calc(100% - 64px));
  margin-inline: auto;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 10px;
  left: 10px;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  transform: translateY(-150%);
}

.skip-link:focus { transform: translateY(0); }

.site-header {
  position: sticky;
  z-index: 40;
  top: 0;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
}

.header-inner {
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand,
.brand-copy,
.header-meta,
.saved-filter,
.language-toggle {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 11px;
  background: var(--yellow);
  font-size: 21px;
  font-weight: 800;
  transform: rotate(-3deg);
}

.brand-copy {
  gap: 7px;
}

.brand-copy strong { font-size: 17px; }
.brand-copy span { color: var(--slate); font-size: 14px; font-weight: 600; }

.header-meta { gap: 10px; }

.library-count {
  margin-right: 5px;
  color: var(--muted);
  font-size: 14px;
}

.library-count b { color: var(--ink); }

.saved-filter {
  min-height: 38px;
  gap: 7px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}

.saved-filter svg { width: 17px; height: 17px; }
.saved-filter b { min-width: 14px; font-size: 13px; }

.saved-filter.active {
  border-color: var(--ink);
  background: var(--ink);
  color: white;
}

.saved-filter.active svg { fill: var(--yellow); color: var(--yellow); }

.language-toggle {
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: var(--surface);
}

.language-toggle button {
  min-width: 38px;
  height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--slate);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.language-toggle button.active {
  background: var(--ink);
  color: white;
}

.main-shell { padding-block: 64px 90px; }

.intro { text-align: center; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 14px;
  color: #6f5a0c;
  font-size: 14px;
  font-weight: 700;
}

.eyebrow span:first-child { color: #c89600; }

.intro h1 {
  margin: 0;
  color: var(--ink-deep);
  font-size: clamp(40px, 5vw, 58px);
  font-weight: 600;
  letter-spacing: -0.055em;
  line-height: 1.08;
}

.intro-copy {
  margin: 16px 0 0;
  color: var(--slate);
  font-size: 17px;
}

.deck-tools {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 44px;
}

.search-box {
  display: flex;
  width: 260px;
  height: 44px;
  flex: 0 0 auto;
  align-items: center;
  gap: 9px;
  padding: 0 10px 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--slate);
  transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

.search-box:focus-within {
  border-color: var(--blue);
  background: white;
  box-shadow: 0 0 0 3px rgba(66, 98, 255, 0.1);
}

.search-box svg { width: 18px; height: 18px; }

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 15px;
}

.search-box input::placeholder { color: var(--muted); }

kbd {
  display: grid;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: white;
  color: var(--muted);
  font-family: inherit;
  font-size: 11px;
}

.category-strip {
  display: flex;
  min-width: 0;
  flex: 1;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: none;
}

.category-strip::-webkit-scrollbar { display: none; }

.category-pill {
  min-height: 38px;
  flex: 0 0 auto;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: var(--slate);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}

.category-pill.active {
  border-color: var(--ink);
  background: var(--ink);
  color: white;
}

.deck-area { margin-top: 16px; }

.deck-status {
  display: flex;
  min-height: 40px;
  align-items: center;
  justify-content: space-between;
  padding-inline: 6px;
  color: var(--muted);
  font-size: 14px;
}

.deck-status p { margin: 0; }

.deck-status button {
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--blue);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}

.card-stage {
  position: relative;
  width: min(940px, calc(100% - 42px));
  min-height: 500px;
  margin: 0 auto;
  isolation: isolate;
}

.ghost-card,
.knowledge-card,
.empty-card {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: white;
}

.ghost-card {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.ghost-card-mid {
  transform: translate(12px, 10px) rotate(1.1deg);
  background: #fafafa;
}

.ghost-card-back {
  transform: translate(22px, 18px) rotate(2deg);
  background: #f4f4f5;
}

.knowledge-card {
  position: relative;
  display: flex;
  min-height: 500px;
  flex-direction: column;
  overflow: hidden;
  padding: 26px 28px 22px;
  box-shadow: 0 18px 48px -34px rgba(5, 0, 56, 0.34);
  cursor: grab;
  touch-action: pan-y;
  user-select: none;
  will-change: transform, opacity;
}

.knowledge-card[hidden] {
  display: none;
}

.card-stage.is-empty .ghost-card {
  display: none;
}

.knowledge-card.dragging {
  cursor: grabbing;
  transition: none;
}

.card-head,
.card-foot,
.card-actions,
.deck-nav,
.progress-wrap {
  display: flex;
  align-items: center;
}

.card-head,
.card-foot { justify-content: space-between; gap: 20px; }

.category-badge {
  display: inline-flex;
  min-height: 27px;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--slate);
  font-size: 13px;
  font-weight: 750;
}

.card-number {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.card-main {
  display: grid;
  flex: 1;
  grid-template-columns: 290px minmax(0, 1fr);
  align-items: center;
  gap: 44px;
  padding-block: 26px 30px;
}

.emoji-panel {
  position: relative;
  display: grid;
  height: 310px;
  place-items: center;
  overflow: hidden;
  border-radius: 22px;
  background: var(--card-tint, var(--yellow-soft));
}

.emoji-panel::before,
.emoji-panel::after {
  position: absolute;
  width: 120px;
  height: 120px;
  border: 2px solid rgba(28, 28, 30, 0.09);
  border-radius: 50%;
  content: "";
}

.emoji-panel::before { top: -52px; left: -42px; }
.emoji-panel::after { right: -52px; bottom: -48px; }

#cardEmoji {
  position: relative;
  z-index: 1;
  font-size: 108px;
  filter: drop-shadow(0 8px 0 rgba(255, 255, 255, 0.52));
}

.tone-yellow { --card-tint: var(--yellow-soft); }
.tone-teal { --card-tint: var(--teal); }
.tone-coral { --card-tint: var(--coral); }
.tone-rose { --card-tint: var(--rose); }
.tone-blue { --card-tint: var(--blue-soft); }
.tone-orange { --card-tint: var(--orange-soft); }
.tone-purple { --card-tint: var(--purple-soft); }

.fact-copy h2 {
  margin: 0;
  color: var(--ink-deep);
  font-size: clamp(28px, 3.2vw, 42px);
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 1.18;
}

.fact-summary {
  margin: 16px 0 0;
  color: var(--slate);
  font-size: 17px;
  line-height: 1.7;
}

.why-block {
  margin-top: 25px;
  padding-top: 21px;
  border-top: 1px solid var(--line-soft);
}

.why-block > span {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.why-block p {
  margin: 8px 0 0;
  color: var(--slate);
  font-size: 15px;
  line-height: 1.72;
}

.card-foot {
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
}

.card-foot > a {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
}

.card-foot > a:hover { color: var(--blue); }

.card-actions { gap: 8px; }

.round-action {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: white;
  cursor: pointer;
}

.round-action svg { width: 18px; height: 18px; }

.round-action.saved {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--yellow);
}

.round-action.saved svg { fill: currentColor; }

.empty-card {
  display: grid;
  min-height: 500px;
  place-items: center;
  padding: 48px 24px;
  text-align: center;
}

.empty-card[hidden] { display: none; }
.empty-card > span { font-size: 62px; }
.empty-card h2 { margin: 14px 0 0; font-size: 27px; }
.empty-card p { margin: 9px 0 22px; color: var(--slate); }

.empty-card button,
.random-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: white;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}

.deck-nav {
  width: min(700px, 100%);
  justify-content: center;
  gap: 15px;
  margin: 38px auto 0;
}

.nav-arrow {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: white;
  cursor: pointer;
  transition: border-color 150ms ease, transform 150ms ease;
}

.nav-arrow:hover { border-color: var(--ink); transform: translateY(-2px); }

.progress-wrap {
  width: 150px;
  flex-direction: column;
  gap: 7px;
}

.progress-wrap > span {
  color: var(--slate);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  width: 100%;
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--ink);
  transition: width 180ms ease;
}

.random-button {
  min-height: 46px;
  padding-inline: 20px;
}

.random-button svg { width: 17px; height: 17px; }

.gesture-hint {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

footer {
  padding-block: 32px;
  border-top: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(12px);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: var(--muted);
  font-size: 13px;
}

.footer-inner span { color: var(--ink); font-weight: 700; }
.footer-inner p { margin: 0; }

.toast {
  position: fixed;
  z-index: 100;
  bottom: 24px;
  left: 50%;
  visibility: hidden;
  padding: 10px 17px;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  box-shadow: 0 10px 30px rgba(5, 0, 56, 0.16);
  font-size: 14px;
  font-weight: 700;
  opacity: 0;
  transform: translate(-50%, 10px);
  transition: opacity 160ms ease, transform 160ms ease, visibility 160ms ease;
}

.toast.show { visibility: visible; opacity: 1; transform: translate(-50%, 0); }

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

@media (max-width: 850px) {
  .shell { width: min(100% - 36px, 720px); }
  .library-count { display: none; }
  .deck-tools { align-items: stretch; flex-direction: column; }
  .search-box { width: 100%; }
  .category-strip { margin-inline: -18px; padding-inline: 18px; }
  .card-stage { width: calc(100% - 24px); }
  .card-main { grid-template-columns: 220px minmax(0, 1fr); gap: 30px; }
  .emoji-panel { height: 280px; }
  #cardEmoji { font-size: 88px; }
}

@media (max-width: 640px) {
  body {
    background-color: #fbf8f1;
    background-image: url("./assets/oddpedia-background-mobile-v1.png");
    background-repeat: repeat-y;
    background-position: center top;
    background-size: 100% auto;
    background-attachment: scroll;
  }

  .shell { width: calc(100% - 28px); }
  .header-inner { min-height: 64px; }
  .brand-copy span,
  .saved-filter > span { display: none; }
  .saved-filter { padding-inline: 10px; }
  .main-shell { padding-block: 48px 70px; }
  .intro {
    padding: 24px 16px;
    border: 1px solid rgba(5, 0, 56, 0.07);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.84);
    box-shadow: 0 14px 36px -32px rgba(5, 0, 56, 0.38);
    backdrop-filter: blur(8px);
  }
  .eyebrow { color: #715800; }
  .intro h1 { color: #050038; font-size: 40px; }
  .intro-copy { color: #464b5a; font-size: 16px; }
  .deck-tools { margin-top: 34px; }
  .search-box,
  .category-pill,
  .knowledge-card,
  .empty-card,
  .round-action,
  .nav-arrow {
    background-color: #ffffff;
  }
  .search-box { color: #5c6070; }
  .search-box input { color: #1c1c1e; }
  .search-box input::placeholder { color: #747887; opacity: 1; }
  .category-strip { margin-inline: -14px; padding-inline: 14px; }
  .category-pill { color: #505564; }
  .category-pill.active,
  .random-button { background-color: #1c1c1e; color: #ffffff; }
  .deck-status { color: #555a68; font-weight: 650; }
  .card-stage { width: calc(100% - 14px); min-height: 590px; }
  .knowledge-card { min-height: 590px; padding: 20px 19px 17px; border-radius: 24px; }
  .ghost-card, .empty-card { border-radius: 24px; }
  .ghost-card-mid { transform: translate(7px, 8px) rotate(0.8deg); }
  .ghost-card-back { transform: translate(12px, 15px) rotate(1.5deg); }
  .card-main { grid-template-columns: 1fr; align-items: start; gap: 23px; padding-block: 20px 24px; }
  .emoji-panel { height: 185px; border-radius: 18px; }
  #cardEmoji { font-size: 76px; }
  .fact-copy h2 { font-size: 27px; }
  .fact-summary { margin-top: 12px; font-size: 16px; }
  .why-block { margin-top: 17px; padding-top: 16px; }
  .why-block p { font-size: 15px; }
  .card-foot { padding-top: 14px; }
  .deck-nav { gap: 9px; margin-top: 32px; }
  .nav-arrow { width: 46px; height: 46px; }
  .progress-wrap { width: 72px; }
  .progress-wrap > span { color: #4b5060; font-weight: 700; }
  .random-button { width: 46px; min-height: 46px; padding: 0; }
  .random-button span { display: none; }
  .gesture-hint { margin-top: 15px; color: #555a68; font-weight: 600; }
  footer { background: rgba(255, 255, 255, 0.86); }
  .footer-inner { color: #5b6070; }
  .footer-inner { align-items: flex-start; flex-direction: column; gap: 8px; }
  kbd { display: none; }
}

@media (max-width: 380px) {
  .brand-copy { display: none; }
  .intro h1 { font-size: 36px; }
  .card-stage { width: calc(100% - 10px); }
  .fact-copy h2 { font-size: 25px; }
  .card-main { gap: 18px; }
  .emoji-panel { height: 160px; }
}

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