/* =========================================================
   ming_Lucas · 样式表
   改颜色 → 修改下面的 CSS 变量即可
   ========================================================= */

:root {
  --bg: #f5f2ea;
  --surface: #fffcf5;
  --ink: #17140f;
  --muted: #6f675c;
  --line: rgba(23, 20, 15, 0.14);
  --accent: #d1482a;
  --accent-soft: rgba(209, 72, 42, 0.12);
  --shadow: 0 24px 60px -30px rgba(23, 20, 15, 0.35);
  --max: 1180px;
  --pad: clamp(20px, 5vw, 48px);
  --serif: "Noto Serif SC", "Songti SC", "Source Han Serif SC", Georgia, "Times New Roman", serif;
  --sans: "Inter", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

html[data-theme="dark"] {
  --bg: #100e0c;
  --surface: #191613;
  --ink: #f4eee4;
  --muted: #a79d90;
  --line: rgba(244, 238, 228, 0.16);
  --accent: #ff7a4f;
  --accent-soft: rgba(255, 122, 79, 0.14);
  --shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.85);
  color-scheme: dark;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
  overflow-x: clip;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body.nav-open {
  overflow: hidden;
}

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

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
}

::selection {
  background: var(--accent);
  color: #fff;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 200;
  padding: 10px 16px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 999px;
  transform: translateY(-200%);
  transition: transform 0.2s ease;
}

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

.wrap {
  width: 100%;
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: var(--pad);
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

@supports not (background: color-mix(in srgb, red 50%, blue)) {
  .site-header {
    background: var(--bg);
  }
}

.site-header.is-scrolled {
  border-bottom-color: var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 28px;
  height: 76px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
  font-family: var(--serif);
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.brand-mark {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 5px var(--accent-soft);
}

.nav {
  display: flex;
  align-items: center;
  gap: 34px;
}

.nav-link {
  position: relative;
  font-size: 0.92rem;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding-block: 6px;
  transition: color 0.25s ease;
}

.nav-link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s var(--ease);
}

.nav-link:hover,
.nav-link.active {
  color: var(--ink);
}

.nav-link:hover::after,
.nav-link.active::after {
  transform: scaleX(1);
}

.nav-close {
  display: none;
}

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

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: border-color 0.25s ease, background 0.25s ease, transform 0.25s ease;
}

.icon-btn:hover {
  border-color: var(--ink);
  transform: translateY(-1px);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

html[data-theme="light"] .icon-sun,
html[data-theme="dark"] .icon-moon {
  display: none;
}

.menu-btn {
  display: none;
  gap: 5px;
  flex-direction: column;
}

.menu-btn span {
  display: block;
  width: 16px;
  height: 1.5px;
  background: currentColor;
  transition: transform 0.3s ease;
}

.nav-scrim {
  display: none;
}

/* ---------- Hero ---------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
  align-items: center;
  gap: clamp(32px, 6vw, 80px);
  min-height: clamp(560px, 88vh, 880px);
  padding-block: clamp(48px, 8vh, 96px) clamp(56px, 9vh, 110px);
}

.hero h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  line-height: 0.98;
  letter-spacing: -0.02em;
}

.hero-name {
  display: block;
  font-size: clamp(2.8rem, 7.2vw, 6.4rem);
  white-space: nowrap;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: clamp(28px, 4vw, 40px);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 24px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.88rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease, transform 0.3s var(--ease);
}

.btn:hover {
  transform: translateY(-2px);
}

.btn-solid {
  background: var(--ink);
  color: var(--bg);
}

.btn-solid:hover {
  background: var(--accent);
  color: #fff;
}

.btn-ghost {
  border-color: var(--line);
  color: var(--ink);
}

.btn-ghost:hover {
  border-color: var(--ink);
}

.portrait {
  position: relative;
  justify-self: end;
  width: min(100%, 360px);
  margin: 0;
}

.portrait::before {
  content: "";
  position: absolute;
  inset: 20px -14px -14px 20px;
  border: 1px solid var(--accent);
  border-radius: 260px 260px 22px 22px;
}

.portrait-frame {
  position: relative;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 260px 260px 22px 22px;
  overflow: hidden;
}

.portrait-frame img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 252px 252px 14px 14px;
  background: var(--accent-soft);
}

.portrait figcaption {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding-left: 4px;
  font-size: 0.76rem;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.dot-sep {
  opacity: 0.5;
}

/* ---------- Marquee ---------- */

.marquee {
  overflow: hidden;
  border-block: 1px solid var(--line);
  padding-block: 16px;
  background: var(--surface);
}

.marquee-track {
  display: flex;
  width: max-content;
  animation: marquee 38s linear infinite;
}

.marquee-group {
  display: flex;
  align-items: center;
  gap: 46px;
  padding-right: 46px;
  flex: none;
  font-family: var(--serif);
  font-size: 0.95rem;
  letter-spacing: 0.28em;
  color: var(--muted);
  white-space: nowrap;
}

.marquee .sep {
  color: var(--accent);
  font-size: 0.7rem;
}

@keyframes marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

.marquee:hover .marquee-track {
  animation-play-state: paused;
}

/* ---------- Sections ---------- */

.section {
  padding-block: clamp(72px, 10vw, 140px);
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: clamp(28px, 4vw, 44px);
}

.section-kicker {
  margin: 0 0 14px;
  font-size: 0.74rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}

.section h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2rem, 4.4vw, 3.4rem);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.section-note {
  margin: 0 0 6px;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* ---------- Game tabs ---------- */

.game-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.game-tab {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.86rem;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

.game-tab span {
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.55;
}

.game-tab:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.game-tab[aria-selected="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.game-tab[aria-selected="true"] span {
  opacity: 0.6;
}

.games-hint {
  margin: 0 0 clamp(22px, 3vw, 32px);
  font-size: 0.76rem;
  color: var(--muted);
  opacity: 0.8;
}

.game-panel:focus {
  outline: none;
}

.game-panel:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 6px;
  border-radius: 24px;
}

/* ---------- Game stage ---------- */

.game-stage {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: clamp(24px, 4vw, 56px);
  padding: clamp(14px, 2.4vw, 28px);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
}

.board-wrap {
  position: relative;
  width: 100%;
  max-width: 520px;
  margin-inline: auto;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: #12100e;
}

.board-snake canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.board-snake.playing {
  touch-action: none;
}

.board-2048,
.board-memory {
  padding: clamp(8px, 1.4vw, 12px);
  background: var(--bg);
  touch-action: none;
}

.game-info {
  padding: clamp(4px, 1vw, 12px) clamp(0px, 1vw, 8px);
}

.game-kicker {
  margin: 0 0 10px;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
}

.game-info h3 {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: clamp(1.6rem, 2.6vw, 2.1rem);
  font-weight: 500;
  line-height: 1.2;
}

.game-info > p {
  max-width: 42ch;
  margin: 0 0 22px;
  font-size: 0.92rem;
  line-height: 1.85;
  color: var(--muted);
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 22px;
}

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

.scoreboard > div {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.score-label {
  display: block;
  margin-bottom: 2px;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.scoreboard strong {
  font-family: var(--serif);
  font-size: 1.65rem;
  font-weight: 500;
  line-height: 1.2;
}

.game-keys {
  display: grid;
  gap: 9px;
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--muted);
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  margin: 0 2px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--bg);
  font: inherit;
  font-size: 0.7rem;
  color: var(--ink);
}

.game-restart {
  margin-top: 2px;
}

.dpad {
  display: none;
  grid-template-areas:
    ". up ."
    "left down right";
  grid-template-columns: repeat(3, 46px);
  gap: 6px;
  justify-content: center;
  margin: 0 0 18px;
}

.dpad button {
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.dpad button:hover {
  border-color: var(--ink);
}

.dpad button:active {
  transform: scale(0.94);
  background: var(--accent-soft);
}

.dpad button[data-dir="up"] { grid-area: up; }
.dpad button[data-dir="left"] { grid-area: left; }
.dpad button[data-dir="down"] { grid-area: down; }
.dpad button[data-dir="right"] { grid-area: right; }

/* ---------- Game overlay ---------- */

.game-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  background: rgba(10, 8, 6, 0.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #f4eee4;
}

.game-overlay[hidden] {
  display: none;
}

.overlay-kicker {
  margin: 0;
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #ff9a75;
}

.game-overlay h3 {
  margin: 2px 0 0;
  font-family: var(--serif);
  font-size: clamp(1.25rem, 2.2vw, 1.7rem);
  font-weight: 500;
  color: #f7f2e8;
}

.game-overlay p {
  max-width: 30ch;
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.7;
  color: rgba(247, 242, 232, 0.72);
}

.game-overlay .btn {
  margin-top: 12px;
  background: #f4eee4;
  color: #17140f;
}

.game-overlay .btn:hover {
  background: #ff7a4f;
  color: #1b1712;
}

/* ---------- 2048 ---------- */

.grid-2048 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: clamp(6px, 1vw, 9px);
  width: 100%;
  height: 100%;
}

.cell-2048 {
  position: relative;
  border-radius: 10px;
  background: color-mix(in srgb, var(--ink) 7%, transparent);
}

@supports not (background: color-mix(in srgb, red 50%, blue)) {
  .cell-2048 { background: rgba(127, 127, 127, 0.1); }
}

.tile-2048 {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-family: var(--serif);
  font-size: clamp(1rem, 2.2vw, 1.7rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  animation: tile-in 0.18s var(--ease);
}

.tile-2048.tile-small {
  font-size: clamp(0.8rem, 1.7vw, 1.35rem);
}

@keyframes tile-in {
  from { transform: scale(0.86); opacity: 0.6; }
  to { transform: scale(1); opacity: 1; }
}

/* ---------- Memory ---------- */

.memory-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: clamp(6px, 1vw, 9px);
  width: 100%;
  height: 100%;
}

.memory-card {
  position: relative;
  padding: 0;
  border: 0;
  background: transparent;
  perspective: 800px;
  cursor: pointer;
}

.memory-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 10px;
}

.memory-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.4s var(--ease);
}

.memory-card.flipped .memory-inner,
.memory-card.matched .memory-inner {
  transform: rotateY(180deg);
}

.memory-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.memory-front {
  background: #1c1916;
  border-color: rgba(244, 238, 228, 0.16);
  font-family: var(--serif);
  font-size: clamp(1rem, 2vw, 1.4rem);
  color: rgba(244, 238, 228, 0.26);
}

.memory-back {
  background: var(--accent-soft);
  border-color: var(--accent);
  font-size: clamp(1.4rem, 3vw, 2.2rem);
  transform: rotateY(180deg);
}

.memory-card.matched .memory-back {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.memory-card.matched {
  cursor: default;
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  padding-block: 26px;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  font-size: 0.76rem;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.footer-inner p {
  margin: 0;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.footer-links a:hover {
  color: var(--ink);
}

/* ---------- Reveal ---------- */

.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
  transition-delay: var(--d, 0ms);
}

.reveal.in {
  opacity: 1;
  transform: none;
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    min-height: 0;
    padding-top: clamp(40px, 8vw, 64px);
  }

  .portrait {
    justify-self: start;
    width: min(100%, 300px);
    margin-top: 12px;
  }

  .game-stage {
    grid-template-columns: 1fr;
  }

  .game-info > p {
    max-width: none;
  }
}

@media (hover: none), (max-width: 900px) {
  .dpad {
    display: grid;
  }
}

@media (max-width: 820px) {
  .nav {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    width: min(84vw, 340px);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 92px 28px 32px;
    background: var(--bg);
    border-left: 1px solid var(--line);
    box-shadow: var(--shadow);
    transform: translateX(102%);
    transition: transform 0.4s var(--ease);
  }

  body.nav-open .nav {
    transform: translateX(0);
  }

  .nav-link {
    padding: 16px 0;
    border-bottom: 1px solid var(--line);
    font-family: var(--serif);
    font-size: 1.45rem;
    color: var(--ink);
  }

  .nav-link::after {
    display: none;
  }

  .nav-close {
    position: absolute;
    top: 22px;
    right: 22px;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: transparent;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
  }

  .menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .nav-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(0, 0, 0, 0.48);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

  body.nav-open .nav-scrim {
    opacity: 1;
    pointer-events: auto;
  }

  body.nav-open .menu-btn span:first-child {
    transform: translateY(3.25px) rotate(45deg);
  }

  body.nav-open .menu-btn span:last-child {
    transform: translateY(-3.25px) rotate(-45deg);
  }
}

@media (max-width: 560px) {
  .header-inner {
    height: 68px;
  }

  .hero-actions {
    width: 100%;
  }

  .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  .section-head {
    align-items: flex-start;
  }

  .section-note {
    margin-top: -4px;
  }

  .footer-inner {
    flex-direction: column;
  }

  .game-stage {
    padding: 10px;
    border-radius: 18px;
  }

  .board-wrap {
    border-radius: 14px;
  }

  .game-info {
    padding: 6px 4px 4px;
  }

  .game-tab {
    flex: 1 1 auto;
    justify-content: center;
    padding: 9px 12px;
    font-size: 0.8rem;
  }

  .game-tab span {
    display: none;
  }

  .scoreboard strong {
    font-size: 1.4rem;
  }

  .game-keys {
    font-size: 0.74rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }
}
