:root {
  color-scheme: dark;
  --bg-top: #130f29;
  --bg-bottom: #04050c;
  --panel: rgba(14, 18, 40, 0.72);
  --panel-border: rgba(255, 255, 255, 0.14);
  --text-main: #f7f5ff;
  --text-soft: rgba(247, 245, 255, 0.76);
  --accent: #ffd76d;
  --accent-strong: #ff8f70;
  --mint: #7cf0d6;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, rgba(104, 84, 202, 0.25), transparent 28%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  color: var(--text-main);
}

body {
  overflow-x: hidden;
}

button,
a {
  font: inherit;
}

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

button {
  border: none;
}

.page-shell {
  position: relative;
  min-height: 100vh;
  padding: 28px;
}

.aurora {
  position: fixed;
  width: 34rem;
  height: 34rem;
  border-radius: 999px;
  filter: blur(30px);
  opacity: 0.28;
  pointer-events: none;
}

.aurora-left {
  top: -10rem;
  left: -12rem;
  background: radial-gradient(circle, rgba(117, 241, 215, 0.95), rgba(117, 241, 215, 0));
  animation: drift 11s ease-in-out infinite alternate;
}

.aurora-right {
  right: -8rem;
  bottom: -10rem;
  background: radial-gradient(circle, rgba(255, 143, 112, 0.92), rgba(255, 143, 112, 0));
  animation: drift 14s ease-in-out infinite alternate-reverse;
}

.panel,
.hero-panel,
.game-panel,
.catalog-hero,
.catalog-board {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.catalog-layout,
.game-layout {
  position: relative;
  z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.catalog-hero,
.hero-panel {
  padding: 30px;
}

.catalog-board,
.game-panel {
  padding: 20px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 10px;
  color: var(--mint);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.74rem;
}

h1 {
  margin: 0;
  font-size: clamp(2.6rem, 6vw, 4.4rem);
  line-height: 0.95;
}

h2,
.section-head h2 {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
}

.intro {
  margin: 18px 0 0;
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--text-soft);
}

.tips-card {
  margin-top: 28px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 22px;
}

.tips-card h2 {
  margin: 0 0 14px;
  font-size: 1.1rem;
}

.tips-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--text-soft);
  line-height: 1.8;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}

.section-note,
.subtle-text,
.mini-note {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.6;
}

.card-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.game-card {
  display: block;
  min-height: 220px;
  padding: 22px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background:
    radial-gradient(circle at top right, rgba(255, 215, 109, 0.14), transparent 28%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.game-card:hover,
.game-card:focus-visible {
  transform: translateY(-3px);
  border-color: rgba(124, 240, 214, 0.42);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

.card-badge {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(124, 240, 214, 0.14);
  color: var(--mint);
  font-size: 0.82rem;
}

.game-card h3 {
  margin: 16px 0 10px;
  font-size: 1.6rem;
}

.game-card p {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.7;
}

.card-cta {
  display: inline-flex;
  margin-top: 20px;
  color: var(--accent);
  font-weight: 700;
}

.home-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  color: var(--mint);
  font-size: 0.96rem;
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  padding: 16px 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
}

.stat-label {
  display: block;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.3rem, 4vw, 2rem);
}

.canvas-card,
.memory-card-wrap {
  position: relative;
  margin-top: 16px;
  overflow: hidden;
  border-radius: 26px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background:
    radial-gradient(circle at 50% 10%, rgba(255, 215, 109, 0.08), transparent 30%),
    linear-gradient(180deg, #10162f 0%, #05070e 100%);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 900 / 620;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 4, 10, 0.4);
  transition: opacity 180ms ease;
}

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

.overlay-card {
  width: min(90%, 400px);
  padding: 28px;
  text-align: center;
  border-radius: 26px;
  background: rgba(10, 12, 24, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.36);
}

.overlay-kicker {
  margin: 0;
  color: var(--mint);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.74rem;
}

.overlay-card h2 {
  margin: 10px 0 12px;
  font-size: 1.9rem;
}

.overlay-card p {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.7;
}

.primary-button,
.ghost-button,
.control-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.primary-button,
.ghost-button {
  padding: 14px 24px;
  border-radius: 999px;
}

.primary-button {
  margin-top: 20px;
  color: #0b1021;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  box-shadow: 0 12px 32px rgba(255, 143, 112, 0.4);
}

.ghost-button,
.control-chip {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.control-chip {
  min-width: 58px;
  min-height: 48px;
  border-radius: 16px;
}

.primary-button:hover,
.ghost-button:hover,
.control-chip:hover,
.primary-button:focus-visible,
.ghost-button:focus-visible,
.control-chip:focus-visible {
  transform: translateY(-1px);
}

.control-row {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.touch-row {
  margin-top: 16px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.touch-controls {
  display: flex;
  gap: 10px;
}

.memory-board {
  padding: 22px;
}

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

.memory-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border: none;
  padding: 0;
  background: transparent;
  perspective: 900px;
}

.memory-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  transition: transform 220ms ease, opacity 220ms ease, border-color 220ms ease;
  backface-visibility: hidden;
}

.memory-front {
  background: linear-gradient(135deg, rgba(124, 240, 214, 0.18), rgba(124, 240, 214, 0.04));
  border: 1px solid rgba(124, 240, 214, 0.16);
}

.memory-back {
  transform: rotateY(180deg);
  background: linear-gradient(135deg, rgba(255, 215, 109, 0.18), rgba(255, 143, 112, 0.14));
  border: 1px solid rgba(255, 215, 109, 0.14);
}

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

.memory-tile.flipped .memory-back,
.memory-tile.matched .memory-back {
  transform: rotateY(0deg);
}

.memory-tile.matched .memory-back {
  box-shadow: 0 0 0 2px rgba(124, 240, 214, 0.35);
}

@keyframes drift {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(30px, -24px, 0) scale(1.1);
  }
}

@media (max-width: 980px) {
  .page-shell {
    padding: 18px;
  }

  .catalog-layout,
  .game-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .card-grid,
  .memory-grid,
  .hud {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .section-head,
  .control-row {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 640px) {
  .catalog-hero,
  .catalog-board,
  .hero-panel,
  .game-panel {
    border-radius: 22px;
    padding: 18px;
  }

  .touch-row,
  .touch-controls {
    justify-content: center;
  }

  .ghost-button,
  .primary-button {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .card-grid,
  .memory-grid,
  .hud {
    grid-template-columns: 1fr;
  }
}

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