:root {
  --bg: #090a10;
  --bg-soft: #11131c;
  --surface: #151824;
  --surface-2: #1c2030;
  --text: #f5f6fb;
  --muted: #9298ab;
  --line: rgba(255,255,255,.09);
  --accent: #b7ff3c;
  --accent-2: #7c5cff;
  --pink: #ff4fd8;
  --cyan: #36d8ff;
  --danger: #ff5c73;
  --shadow: 0 25px 80px rgba(0,0,0,.32);
  --radius: 24px;
  --max: 1180px;
}

[data-theme="light"] {
  --bg: #f3f4f8;
  --bg-soft: #ffffff;
  --surface: #ffffff;
  --surface-2: #eceef5;
  --text: #11131a;
  --muted: #646a7b;
  --line: rgba(17,19,26,.1);
  --shadow: 0 25px 70px rgba(35,39,60,.12);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 80% 0%, rgba(124,92,255,.12), transparent 28rem),
    radial-gradient(circle at 10% 20%, rgba(54,216,255,.06), transparent 24rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
  transition: background .25s ease, color .25s ease;
}

body::selection {
  background: var(--accent);
  color: #0b0d12;
}

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

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

button {
  font: inherit;
}

.site-header {
  width: min(calc(100% - 40px), var(--max));
  margin: 0 auto;
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  border-bottom: 1px solid var(--line);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: -.04em;
}

.logo span {
  color: var(--accent);
}

.logo.small {
  font-size: 14px;
}

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

.nav-link {
  padding: 10px 15px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  transition: .2s ease;
}

.nav-link:hover,
.nav-link.active {
  color: var(--text);
  background: var(--surface);
}

.nav-link.active {
  box-shadow: inset 0 0 0 1px var(--line);
}

.theme-toggle {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 50%;
  cursor: pointer;
  transition: transform .2s ease, background .2s ease;
}

.theme-toggle:hover {
  transform: rotate(18deg);
  background: var(--surface-2);
}

.hero {
  width: min(calc(100% - 40px), var(--max));
  margin: 0 auto;
  min-height: 650px;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  align-items: center;
  gap: 60px;
  padding: 70px 0;
}

.eyebrow {
  margin: 0 0 18px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .2em;
}

.hero h1,
.about-hero h1 {
  max-width: 700px;
  margin: 0;
  font-size: clamp(55px, 7vw, 96px);
  line-height: .93;
  letter-spacing: -.075em;
}

.hero h1 span,
.about-hero h1 span {
  color: var(--accent);
}

.hero-text {
  max-width: 570px;
  margin: 30px 0;
  color: var(--muted);
  font-size: 17px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.btn {
  min-height: 50px;
  padding: 0 21px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-radius: 13px;
  font-weight: 850;
  font-size: 13px;
  letter-spacing: .02em;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}

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

.btn-primary {
  color: #0a0d0b;
  background: var(--accent);
  box-shadow: 0 10px 30px rgba(183,255,60,.15);
}

.btn-primary:hover {
  box-shadow: 0 14px 36px rgba(183,255,60,.24);
}

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

.hero-art {
  min-height: 490px;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 42px;
  background:
    linear-gradient(135deg, rgba(124,92,255,.17), transparent 55%),
    var(--surface);
  box-shadow: var(--shadow);
}

.floating-console {
  width: 290px;
  padding: 18px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 25px;
  transform: rotate(-8deg);
  background: #121520;
  box-shadow: 20px 30px 70px rgba(0,0,0,.45);
  animation: float 4s ease-in-out infinite;
  position: relative;
  z-index: 2;
}

.console-screen {
  height: 210px;
  border-radius: 16px;
  background:
    radial-gradient(circle at 60% 45%, rgba(183,255,60,.25), transparent 12%),
    linear-gradient(145deg, #19201b, #0b0e12);
  padding: 26px;
  position: relative;
  overflow: hidden;
}

.screen-line {
  width: 65%;
  height: 5px;
  border-radius: 5px;
  background: rgba(183,255,60,.45);
  margin-bottom: 10px;
}

.screen-line.long { width: 80%; }
.screen-line.short { width: 43%; }

.screen-orb {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 50px rgba(183,255,60,.65);
  position: absolute;
  right: 35px;
  bottom: 35px;
}

.console-buttons {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding: 17px 5px 3px;
}

.console-buttons span {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #34394b;
}

.console-buttons span:nth-child(1) { background: var(--pink); }
.console-buttons span:nth-child(2) { background: var(--accent); }

.arc {
  position: absolute;
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 50%;
}

.arc-one {
  width: 600px;
  height: 600px;
  transform: translate(25%, 5%);
}

.arc-two {
  width: 380px;
  height: 380px;
  transform: translate(-45%, 35%);
}

.pixel-star {
  position: absolute;
  color: var(--accent);
  font-size: 30px;
  animation: twinkle 2s ease-in-out infinite;
}

.star-a { top: 18%; right: 16%; }
.star-b { bottom: 19%; left: 17%; animation-delay: .7s; }

@keyframes float {
  0%, 100% { transform: rotate(-8deg) translateY(0); }
  50% { transform: rotate(-5deg) translateY(-13px); }
}

@keyframes twinkle {
  0%, 100% { opacity: .35; transform: scale(.8); }
  50% { opacity: 1; transform: scale(1.1); }
}

.section {
  width: min(calc(100% - 40px), var(--max));
  margin: 0 auto;
  padding: 95px 0;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 30px;
  align-items: end;
  margin-bottom: 35px;
}

.section h2 {
  margin: 0;
  font-size: clamp(34px, 4vw, 54px);
  line-height: 1;
  letter-spacing: -.055em;
}

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

.game-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.game-card {
  min-height: 390px;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  position: relative;
  overflow: hidden;
  transition: transform .25s ease, border-color .25s ease;
}

.game-card::after {
  content: "";
  position: absolute;
  width: 170px;
  height: 170px;
  border-radius: 50%;
  right: -75px;
  top: -75px;
  filter: blur(1px);
  opacity: .16;
}

.card-snake::after { background: var(--accent); }
.card-memory::after { background: var(--pink); }
.card-tictactoe::after { background: var(--cyan); }

.game-card:hover {
  transform: translateY(-6px);
  border-color: rgba(183,255,60,.25);
}

.game-icon {
  font-size: 34px;
  margin-bottom: 50px;
}

.card-number {
  position: absolute;
  right: 28px;
  top: 29px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.game-card h3 {
  margin: 0 0 12px;
  font-size: 27px;
  letter-spacing: -.04em;
}

.game-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  min-height: 76px;
}

.card-meta {
  display: flex;
  gap: 7px;
  margin: 22px 0;
}

.card-meta span {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .08em;
}

.card-play {
  color: var(--accent);
  font-weight: 900;
  font-size: 13px;
}

.stats-strip {
  width: 100%;
  padding: 32px max(20px, calc((100% - var(--max)) / 2));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--accent);
  color: #0b0d0d;
}

.stats-strip div {
  padding: 5px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  border-right: 1px solid rgba(0,0,0,.12);
}

.stats-strip div:last-child { border: 0; }

.stats-strip strong {
  font-size: 32px;
  line-height: 1;
  letter-spacing: -.05em;
}

.stats-strip span {
  margin-top: 5px;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .13em;
}

.split-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 90px;
  align-items: center;
}

.large-copy {
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.8;
}

.site-footer {
  width: min(calc(100% - 40px), var(--max));
  margin: 0 auto;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.site-footer > div {
  display: flex;
  align-items: center;
  gap: 20px;
}

.site-footer a:hover {
  color: var(--text);
}

/* Games page */
.games-main {
  width: min(calc(100% - 40px), 980px);
  margin: 0 auto;
  padding-bottom: 100px;
}

.page-heading {
  padding: 95px 0 60px;
  text-align: center;
}

.page-heading h1 {
  margin: 0 0 20px;
  font-size: clamp(48px, 7vw, 78px);
  letter-spacing: -.07em;
  line-height: .95;
}

.page-heading > p:last-child {
  margin: 0 auto;
  max-width: 620px;
  color: var(--muted);
}

.game-panel {
  padding: 30px;
  margin-bottom: 25px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
  scroll-margin-top: 30px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 25px;
}

.panel-index {
  color: var(--accent);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .14em;
}

.panel-header h2 {
  margin: 4px 0 0;
  font-size: 32px;
  letter-spacing: -.05em;
}

.small-btn {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  transition: .2s ease;
}

.small-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.snake-layout,
.memory-layout,
.ttt-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px;
  gap: 25px;
  align-items: start;
}

.canvas-wrap {
  width: 100%;
  max-width: 520px;
  aspect-ratio: 1;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  background: #07090c;
}

#snakeCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.canvas-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: rgba(7,9,12,.78);
  backdrop-filter: blur(4px);
  transition: opacity .2s ease;
}

.canvas-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.canvas-overlay strong {
  font-size: 26px;
}

.canvas-overlay span {
  color: #8c92a1;
  font-size: 12px;
  margin-bottom: 12px;
}

.game-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.score-box,
.control-help,
.duel-status {
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface-2);
}

.score-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
}

.score-box span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .1em;
}

.score-box strong {
  color: var(--accent);
  font-size: 23px;
  line-height: 1;
}

.control-help h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.control-help p {
  margin: 7px 0;
  color: var(--muted);
  font-size: 12px;
}

.memory-board {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.memory-card {
  aspect-ratio: 1;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  background: var(--surface-2);
  color: transparent;
  position: relative;
  transform-style: preserve-3d;
  transition: transform .35s ease;
  box-shadow: inset 0 0 0 1px var(--line);
}

.memory-card::before,
.memory-card::after {
  content: "";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: inherit;
  backface-visibility: hidden;
}

.memory-card::before {
  content: "?";
  color: var(--accent);
  font-weight: 900;
  font-size: 23px;
  background:
    linear-gradient(135deg, transparent 45%, rgba(183,255,60,.06) 45% 55%, transparent 55%),
    var(--surface-2);
}

.memory-card::after {
  content: attr(data-symbol);
  color: var(--text);
  background: var(--bg-soft);
  transform: rotateY(180deg);
  font-size: 29px;
}

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

.memory-card.matched::after {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.ttt-board {
  width: min(100%, 510px);
  aspect-ratio: 1;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}

.ttt-board button {
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface-2);
  color: var(--accent);
  cursor: pointer;
  font-size: clamp(42px, 8vw, 72px);
  font-weight: 900;
  line-height: 1;
  transition: transform .15s ease, background .15s ease;
}

.ttt-board button:hover:not(:disabled) {
  transform: scale(.97);
  background: var(--bg-soft);
}

.ttt-board button[data-value="O"] {
  color: var(--pink);
}

.ttt-board button.win {
  background: rgba(183,255,60,.12);
  border-color: var(--accent);
}

.duel-status {
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
}

/* About */
.about-hero {
  width: min(calc(100% - 40px), var(--max));
  margin: 0 auto;
  padding: 110px 0 80px;
}

.about-hero p:last-child {
  max-width: 650px;
  color: var(--muted);
  font-size: 18px;
  margin-top: 30px;
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.info-card {
  min-height: 380px;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  position: relative;
}

.info-number {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.info-card h2 {
  margin-top: 55px;
  font-size: 29px;
}

.info-card p {
  color: var(--muted);
  font-size: 13px;
}

.info-card ul {
  padding: 0;
  margin: 22px 0 0;
  list-style: none;
}

.info-card li {
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.info-card li::before {
  content: "↳";
  color: var(--accent);
  margin-right: 8px;
}

.quote-section {
  max-width: 850px;
  text-align: center;
  padding-top: 110px;
  padding-bottom: 110px;
}

.quote-mark {
  color: var(--accent);
  font-size: 80px;
  line-height: .6;
}

blockquote {
  margin: 25px 0;
  font-size: clamp(30px, 5vw, 50px);
  line-height: 1.08;
  letter-spacing: -.05em;
}

.quote-section p:last-child {
  color: var(--muted);
  font-size: 12px;
}

.tech-section {
  display: grid;
  grid-template-columns: .8fr 1.2fr;
  gap: 80px;
}

.file-list {
  border-top: 1px solid var(--line);
}

.file-list div {
  min-height: 60px;
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 20px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.file-list code {
  color: var(--accent);
  font-size: 12px;
}

.file-list span {
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 850px) {
  .hero {
    grid-template-columns: 1fr;
    padding-top: 55px;
  }

  .hero-art {
    min-height: 400px;
  }

  .game-cards,
  .about-grid {
    grid-template-columns: 1fr;
  }

  .game-card {
    min-height: 330px;
  }

  .split-section,
  .tech-section {
    grid-template-columns: 1fr;
    gap: 35px;
  }

  .snake-layout,
  .memory-layout,
  .ttt-layout {
    grid-template-columns: 1fr;
  }

  .game-sidebar {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  .control-help {
    grid-column: 1 / -1;
  }

  .duel-status {
    grid-column: 1 / -1;
  }
}

@media (max-width: 620px) {
  .site-header {
    width: min(calc(100% - 24px), var(--max));
    min-height: 72px;
    gap: 10px;
  }

  .main-nav {
    gap: 0;
  }

  .nav-link {
    padding: 8px 8px;
    font-size: 11px;
  }

  .theme-toggle {
    width: 35px;
    height: 35px;
  }

  .logo {
    font-size: 13px;
  }

  .hero,
  .section,
  .about-hero {
    width: min(calc(100% - 24px), var(--max));
  }

  .hero {
    min-height: auto;
    padding: 65px 0;
  }

  .hero h1,
  .about-hero h1 {
    font-size: clamp(48px, 16vw, 74px);
  }

  .hero-art {
    min-height: 320px;
    border-radius: 28px;
  }

  .floating-console {
    width: 235px;
  }

  .console-screen {
    height: 155px;
  }

  .section {
    padding: 70px 0;
  }

  .section-heading {
    align-items: start;
    flex-direction: column;
  }

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

  .stats-strip div:nth-child(2) {
    border-right: 0;
  }

  .game-panel {
    padding: 16px;
    border-radius: 20px;
  }

  .panel-header h2 {
    font-size: 25px;
  }

  .snake-layout,
  .memory-layout,
  .ttt-layout {
    gap: 16px;
  }

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

  .control-help {
    grid-column: 1 / -1;
  }

  .memory-board {
    gap: 7px;
  }

  .memory-card {
    border-radius: 10px;
  }

  .memory-card::after {
    font-size: 22px;
  }

  .file-list div {
    grid-template-columns: 1fr;
    gap: 3px;
    padding: 12px 0;
  }

  .site-footer {
    width: min(calc(100% - 24px), var(--max));
    min-height: 90px;
  }

  .site-footer > div {
    gap: 10px;
    flex-wrap: wrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .001ms !important;
  }
}
