:root {
  --bg: #0b1020;
  --bg-soft: #11172b;
  --panel: rgba(23, 29, 52, 0.88);
  --panel-solid: #171d34;
  --panel-2: #202742;
  --text: #f7f8ff;
  --muted: #a8b0c8;
  --line: rgba(255, 255, 255, 0.1);
  --lime: #b8f34a;
  --coral: #ff8a66;
  --blue: #7c9dff;
  --yellow: #f6c85f;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
  --radius: 28px;
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

:root[data-theme="light"] {
  --bg: #f3f0e8;
  --bg-soft: #ebe7dc;
  --panel: rgba(255, 255, 255, 0.86);
  --panel-solid: #fffefa;
  --panel-2: #eeeae0;
  --text: #171b28;
  --muted: #677084;
  --line: rgba(21, 27, 43, 0.12);
  --shadow: 0 24px 70px rgba(44, 36, 22, 0.12);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 12% -8%, rgba(124, 157, 255, 0.19), transparent 32rem),
    radial-gradient(circle at 92% 18%, rgba(184, 243, 74, 0.1), transparent 26rem),
    var(--bg);
  color: var(--text);
  transition: background-color 180ms ease, color 180ms ease;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

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

.site-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.topbar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 88px;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  border: 0;
  padding: 6px 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 8px);
  gap: 3px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-solid);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.15);
}

.brand-mark i {
  width: 8px;
  height: 8px;
  border-radius: 3px;
  background: var(--lime);
}

.brand-mark i:nth-child(2) { background: var(--coral); }
.brand-mark i:nth-child(3) { background: var(--blue); }
.brand-mark i:nth-child(4) { background: var(--yellow); }

.brand-name {
  display: block;
  font-weight: 820;
  letter-spacing: -0.025em;
}

.brand-domain {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
}

.top-actions,
.nav-pills {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-pills {
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  backdrop-filter: blur(18px);
}

.nav-btn,
.icon-btn,
.ghost-btn,
.primary-btn {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}

.nav-btn {
  padding: 9px 14px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.nav-btn.active,
.nav-btn:hover {
  background: var(--panel-2);
  color: var(--text);
}

.icon-btn {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--panel);
}

.icon-btn:hover,
.ghost-btn:hover,
.primary-btn:hover {
  transform: translateY(-2px);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  align-items: stretch;
  gap: 24px;
  padding: 42px 0 54px;
}

.hero-copy {
  padding: 32px 0;
}

.eyebrow,
.section-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 0 6px rgba(184, 243, 74, 0.11);
}

.hero h1 {
  max-width: 760px;
  margin: 20px 0 18px;
  font-size: clamp(48px, 7.2vw, 92px);
  line-height: 0.96;
  letter-spacing: -0.065em;
}

.hero h1 .accent {
  color: var(--lime);
}

.hero-lead {
  max-width: 650px;
  margin: 0;
  color: var(--muted);
  font-size: clamp(16px, 2vw, 19px);
  line-height: 1.8;
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.tag {
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.025);
  font-size: 12px;
}

.daily-card {
  position: relative;
  min-height: 360px;
  overflow: hidden;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  isolation: isolate;
}

.daily-card::after {
  position: absolute;
  right: -80px;
  bottom: -100px;
  z-index: -1;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--card-accent, var(--blue)) 28%, transparent);
  filter: blur(20px);
  content: "";
}

.daily-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.daily-badge {
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--lime);
  color: #172008;
  font-weight: 850;
}

.daily-icon {
  display: grid;
  width: 112px;
  height: 112px;
  margin: 38px 0 26px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 30px;
  background: color-mix(in srgb, var(--card-accent, var(--blue)) 16%, var(--panel-solid));
  font-size: 52px;
  font-weight: 800;
  transform: rotate(-4deg);
}

.daily-card h2 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.035em;
}

.daily-card p {
  margin: 8px 0 22px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.primary-btn,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  font-weight: 780;
}

.primary-btn {
  background: var(--lime);
  color: #172008;
}

.ghost-btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
}

.games-section {
  padding: 18px 0 70px;
}

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

.section-heading h2,
.stats-hero h1 {
  margin: 8px 0 0;
  font-size: clamp(30px, 4vw, 44px);
  letter-spacing: -0.045em;
}

.section-heading p {
  max-width: 460px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
  text-align: right;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
}

.game-card {
  position: relative;
  grid-column: span 2;
  min-height: 250px;
  overflow: hidden;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.13);
  cursor: pointer;
  isolation: isolate;
  transition: transform 180ms ease, border-color 180ms ease;
}

.game-card:nth-child(1),
.game-card:nth-child(2) {
  grid-column: span 3;
  min-height: 290px;
}

.game-card:hover {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
  transform: translateY(-5px);
}

.game-card::before {
  position: absolute;
  inset: auto -40px -75px auto;
  z-index: -1;
  width: 190px;
  height: 190px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  content: "";
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.difficulty {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.card-number {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}

.game-glyph {
  display: grid;
  width: 72px;
  height: 72px;
  margin: 30px 0 24px;
  place-items: center;
  border-radius: 22px;
  background: color-mix(in srgb, var(--accent) 16%, var(--panel-2));
  color: var(--accent);
  font-size: 32px;
  font-weight: 900;
}

.game-card h3 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.025em;
}

.game-card p {
  max-width: 390px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.card-arrow {
  position: absolute;
  right: 22px;
  bottom: 20px;
  color: var(--accent);
  font-size: 22px;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 30px 0 42px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

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

.game-page {
  padding: 26px 0 76px;
}

.game-page-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  margin-bottom: 24px;
}

.back-btn {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.game-page-title h1 {
  margin: 2px 0 0;
  font-size: clamp(28px, 5vw, 44px);
  letter-spacing: -0.045em;
}

.game-page-title p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 20px;
  align-items: start;
}

.play-panel,
.side-panel,
.stat-card,
.stats-note {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.play-panel {
  min-height: 590px;
  padding: clamp(18px, 4vw, 34px);
  border-radius: var(--radius);
}

.side-panel {
  padding: 22px;
  border-radius: 22px;
}

.side-panel + .side-panel {
  margin-top: 14px;
}

.side-panel h3 {
  margin: 0 0 12px;
  font-size: 14px;
}

.side-panel p,
.side-panel li {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.side-panel ul {
  margin: 0;
  padding-left: 18px;
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.mini-stat {
  padding: 13px;
  border-radius: 14px;
  background: var(--panel-2);
}

.mini-stat span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.mini-stat strong {
  display: block;
  margin-top: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 18px;
}

.wide-btn {
  width: 100%;
}

.board-wrap {
  display: flex;
  min-height: 500px;
  align-items: center;
  justify-content: center;
}

.board-2048 {
  display: grid;
  width: min(100%, 500px);
  aspect-ratio: 1;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 10px;
  border-radius: 22px;
  background: #252c47;
  touch-action: none;
}

.tile-2048 {
  display: grid;
  min-width: 0;
  place-items: center;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.2);
  font-size: clamp(22px, 5vw, 43px);
  font-weight: 880;
  letter-spacing: -0.05em;
}

.tile-2048[data-value="2"] { background: #e9e4d3; color: #4b4b48; }
.tile-2048[data-value="4"] { background: #e8d7a9; color: #413f36; }
.tile-2048[data-value="8"] { background: #ffb66c; color: #27170d; }
.tile-2048[data-value="16"] { background: #ff8a66; color: #2b1008; }
.tile-2048[data-value="32"] { background: #f76b70; color: #fff; }
.tile-2048[data-value="64"] { background: #dc4b6e; color: #fff; }
.tile-2048[data-value="128"] { background: #f4d35e; color: #2c2405; font-size: clamp(19px, 4.5vw, 37px); }
.tile-2048[data-value="256"] { background: #b8f34a; color: #172008; font-size: clamp(19px, 4.5vw, 37px); }
.tile-2048[data-value="512"] { background: #71db74; color: #0b250d; font-size: clamp(19px, 4.5vw, 37px); }
.tile-2048[data-value="1024"] { background: #7c9dff; color: #0b1738; font-size: clamp(16px, 4vw, 31px); }
.tile-2048[data-value="2048"] { background: #ba8cff; color: #1b0732; font-size: clamp(16px, 4vw, 31px); }
.tile-2048[data-big="true"] { background: #6c4ea5; color: white; font-size: clamp(14px, 3.5vw, 27px); }

.puzzle-board {
  display: grid;
  width: min(100%, 500px);
  aspect-ratio: 1;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
  padding: 10px;
  border-radius: 22px;
  background: #252c47;
}

.puzzle-tile {
  border: 0;
  border-radius: 16px;
  background: linear-gradient(145deg, #91aaff, #6688f4);
  color: #0b1738;
  font-size: clamp(22px, 5vw, 40px);
  font-weight: 880;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12);
  cursor: pointer;
  transition: transform 120ms ease;
}

.puzzle-tile:hover { transform: scale(0.97); }
.puzzle-tile.blank { background: transparent; box-shadow: none; cursor: default; }

.lights-board {
  display: grid;
  width: min(100%, 510px);
  aspect-ratio: 1;
  grid-template-columns: repeat(5, 1fr);
  gap: 9px;
  padding: 12px;
  border-radius: 24px;
  background: #151b31;
}

.light-cell {
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 50%;
  background: #222943;
  cursor: pointer;
  transition: transform 140ms ease, background 180ms ease, box-shadow 180ms ease;
}

.light-cell::after {
  position: absolute;
  inset: 31%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  content: "";
}

.light-cell.on {
  border-color: #f6c85f;
  background: #f6c85f;
  box-shadow: 0 0 20px rgba(246, 200, 95, 0.5), inset 0 0 20px #fff2a6;
}

.light-cell.on::after { background: #fff9d7; }
.light-cell:hover { transform: scale(0.93); }

.memory-board {
  display: grid;
  width: min(100%, 590px);
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.memory-card {
  position: relative;
  aspect-ratio: 1;
  border: 0;
  border-radius: 18px;
  background: #252c47;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 260ms ease, background 180ms ease;
}

.memory-card::before {
  color: #68718e;
  font-size: clamp(20px, 4vw, 34px);
  font-weight: 850;
  content: "?";
}

.memory-card.revealed,
.memory-card.matched {
  background: color-mix(in srgb, var(--card-color) 28%, #252c47);
  transform: rotateY(180deg);
}

.memory-card span {
  display: none;
  color: var(--card-color);
  font-size: clamp(24px, 5vw, 44px);
  font-weight: 900;
  transform: rotateY(180deg);
}

.memory-card.revealed::before,
.memory-card.matched::before { display: none; }
.memory-card.revealed span,
.memory-card.matched span { display: block; }
.memory-card.matched { box-shadow: inset 0 0 0 2px var(--card-color); }

.mastermind-wrap {
  display: grid;
  width: min(100%, 610px);
  gap: 12px;
}

.master-row,
.master-input {
  display: grid;
  grid-template-columns: 34px 1fr 88px;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 9px 14px;
  border-radius: 17px;
  background: var(--panel-2);
}

.turn-number {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}

.code-dots,
.peg-grid {
  display: flex;
  align-items: center;
  gap: 10px;
}

.code-dot {
  width: 31px;
  height: 31px;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  background: var(--dot-color, transparent);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.15);
}

button.code-dot {
  cursor: pointer;
  transition: transform 130ms ease;
}

button.code-dot:hover { transform: translateY(-2px); }

.peg-grid {
  display: grid;
  grid-template-columns: repeat(2, 10px);
  justify-content: end;
  gap: 5px;
}

.peg {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
}

.peg.exact { background: #f8f8ff; }
.peg.near { background: #ff8a66; }

.master-input {
  grid-template-columns: 34px 1fr auto;
  margin-top: 6px;
  border: 1px solid color-mix(in srgb, var(--lime) 55%, transparent);
  background: color-mix(in srgb, var(--lime) 8%, var(--panel-2));
}

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

.game-message strong { color: var(--text); }

.stats-page {
  padding: 34px 0 78px;
}

.stats-hero {
  margin-bottom: 28px;
}

.stats-hero p {
  max-width: 620px;
  color: var(--muted);
  line-height: 1.7;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.stat-card {
  padding: 22px;
  border-radius: 21px;
}

.stat-card.featured {
  grid-column: span 2;
  background: linear-gradient(135deg, color-mix(in srgb, var(--blue) 22%, var(--panel-solid)), var(--panel));
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.stat-card strong {
  display: block;
  margin-top: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(28px, 5vw, 46px);
}

.stat-card small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
}

.stats-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 18px;
  padding: 20px 22px;
  border-radius: 20px;
  color: var(--muted);
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 100;
  max-width: min(360px, calc(100vw - 48px));
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f7f8ff;
  color: #161b2d;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
  font-size: 13px;
  font-weight: 720;
  animation: toast-in 220ms ease both;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
}

.noscript-card {
  width: min(520px, calc(100% - 40px));
  margin: 80px auto;
  padding: 30px;
  border-radius: 22px;
  background: var(--panel-solid);
  text-align: center;
}

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; padding-top: 20px; }
  .daily-card { min-height: 330px; }
  .game-card, .game-card:nth-child(1), .game-card:nth-child(2) { grid-column: span 3; }
  .game-layout { grid-template-columns: 1fr; }
  .game-sidebar { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .side-panel + .side-panel { margin-top: 0; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .site-shell { width: min(100% - 24px, 1180px); }
  .topbar { min-height: 76px; }
  .brand-domain, .nav-pills { display: none; }
  .hero { padding-bottom: 34px; }
  .hero-copy { padding: 18px 0 0; }
  .hero h1 { font-size: clamp(46px, 17vw, 70px); }
  .daily-card { min-height: 320px; padding: 22px; }
  .daily-icon { margin-top: 28px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .section-heading p { text-align: left; }
  .game-grid { grid-template-columns: 1fr; }
  .game-card, .game-card:nth-child(1), .game-card:nth-child(2) { grid-column: 1; min-height: 238px; }
  .site-footer { align-items: flex-start; flex-direction: column; }
  .game-page { padding-top: 10px; }
  .game-page-head { grid-template-columns: auto 1fr; }
  .game-page-head .ghost-btn { display: none; }
  .play-panel { min-height: 480px; padding: 14px; }
  .board-wrap { min-height: 420px; }
  .board-2048, .puzzle-board { gap: 6px; padding: 7px; }
  .lights-board { gap: 6px; padding: 8px; }
  .memory-board { gap: 7px; }
  .memory-card { border-radius: 13px; }
  .game-sidebar { grid-template-columns: 1fr; }
  .master-row, .master-input { grid-template-columns: 25px 1fr 58px; gap: 7px; padding: 8px; }
  .code-dots { gap: 5px; }
  .code-dot { width: 25px; height: 25px; }
  .master-input .primary-btn { min-height: 36px; padding: 0 12px; font-size: 12px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card.featured { grid-column: span 2; }
  .stats-note { align-items: flex-start; flex-direction: column; }
}

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