@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&family=ZCOOL+KuaiLe&display=swap");

:root {
  --bg: #f3f7ff;
  --ink: #1f2a44;
  --muted: #5b6b84;
  --panel: rgba(255, 255, 255, 0.86);
  --line: rgba(70, 109, 177, 0.24);
  --brand: #2578f2;
  --brand-strong: #1350b8;
  --accent: #ff8f3f;
  --ok: #28a479;
  --leaf: #4f9e6e;
  --petal: #ff7ca2;
  --sun: #ffd56c;
  --radius: 18px;
  --shadow: 0 14px 38px rgba(31, 42, 68, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Space Grotesk", "PingFang SC", "Noto Sans SC", sans-serif;
  background: radial-gradient(circle at 5% 12%, #e4fff0 0%, transparent 32%),
    radial-gradient(circle at 89% 18%, #ffe8f1 0%, transparent 30%),
    radial-gradient(circle at 82% 76%, #fff3d4 0%, transparent 24%),
    linear-gradient(145deg, #f7fffc 0%, #fefaf1 100%);
  position: relative;
  overflow-x: hidden;
}

.bg-orb {
  position: fixed;
  width: 260px;
  height: 260px;
  border-radius: 999px;
  filter: blur(30px);
  opacity: 0.45;
  z-index: -1;
  animation: float 8s ease-in-out infinite;
}

.orb-1 {
  background: #6bb4ff;
  left: -80px;
  top: 30px;
}

.orb-2 {
  background: #ffc28f;
  right: -80px;
  top: 55vh;
  animation-delay: 1.2s;
}

.hero {
  padding: 42px 20px 22px;
  text-align: center;
  animation: rise-in 0.5s ease both;
}

.hero-kicker {
  margin: 0;
  color: var(--brand-strong);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 6px 0 8px;
  font-family: "ZCOOL KuaiLe", "Kaiti SC", cursive;
  font-size: clamp(2rem, 2.2vw + 1.5rem, 3.2rem);
  color: #13376f;
}

.hero-subtitle {
  margin: 0 auto;
  max-width: 620px;
  color: var(--muted);
}

.hero-universe-nav {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.hero-universe-link {
  text-decoration: none;
  color: #1e4878;
  border: 1px solid rgba(30, 72, 120, 0.25);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  padding: 6px 11px;
  font-size: 0.82rem;
  font-weight: 600;
}

.hero-universe-link:hover {
  border-color: rgba(19, 80, 184, 0.5);
  color: #123f76;
}

.hero-motifs {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.hero-motif {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(79, 158, 110, 0.28);
  background: rgba(255, 255, 255, 0.76);
  font-size: 0.86rem;
  font-weight: 600;
  color: #23536d;
  animation: rise-in 0.5s ease both;
}

.layout {
  width: min(1140px, calc(100% - 28px));
  margin: 12px auto 40px;
  display: grid;
  gap: 18px;
  grid-template-columns: 330px 1fr;
}

.sidebar,
.stage {
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.sidebar {
  padding: 16px;
}

.sidebar-top h2 {
  margin: 0;
}

.sidebar-top p {
  color: var(--muted);
  margin: 6px 0 12px;
}

.sidebar-mood {
  border: 1px solid rgba(79, 158, 110, 0.25);
  background: linear-gradient(150deg, rgba(79, 158, 110, 0.12), rgba(255, 124, 162, 0.11));
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 12px;
}

.sidebar-mood h3 {
  margin: 0;
  font-size: 1rem;
}

.sidebar-mood p {
  margin: 6px 0 10px;
  color: #315a73;
  font-size: 0.87rem;
  line-height: 1.45;
}

.mood-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.mood-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(19, 80, 184, 0.17);
  color: #1d4c7e;
  font-size: 0.8rem;
  font-weight: 600;
}

.game-list {
  display: grid;
  gap: 12px;
}

.game-list-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.88);
  animation: rise-in 0.45s ease both;
  animation-delay: var(--delay, 0ms);
}

.game-list-card.active {
  border-color: rgba(37, 120, 242, 0.72);
  box-shadow: 0 8px 24px rgba(37, 120, 242, 0.14);
}

.game-list-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.game-list-card h3 {
  margin: 0;
  font-size: 1.05rem;
}

.game-list-card span {
  font-size: 0.76rem;
  color: var(--brand-strong);
  font-weight: 700;
  background: rgba(37, 120, 242, 0.12);
  border-radius: 999px;
  padding: 4px 10px;
}

.game-list-card p {
  margin: 8px 0 12px;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.42;
}

.stage {
  padding: 20px;
  min-height: 620px;
}

.stage-head {
  margin-bottom: 14px;
}

.stage-head h2 {
  margin: 10px 0 6px;
  font-size: clamp(1.5rem, 1.5vw + 1rem, 2rem);
}

.stage-head p {
  color: var(--muted);
  margin: 0;
}

.game-host {
  border-radius: 16px;
  border: 1px dashed rgba(70, 109, 177, 0.4);
  background: rgba(248, 252, 255, 0.7);
  min-height: 490px;
  padding: 18px;
}

.welcome-panel {
  height: 100%;
  border-radius: 12px;
  border: 1px solid rgba(37, 120, 242, 0.2);
  padding: 24px;
  background: linear-gradient(155deg, rgba(37, 120, 242, 0.07), rgba(255, 143, 63, 0.07));
}

.welcome-panel h3 {
  margin-top: 0;
  font-size: 1.3rem;
}

.welcome-panel p {
  color: var(--muted);
  max-width: 620px;
  line-height: 1.6;
}

.icey-welcome {
  border: 1px solid rgba(79, 158, 110, 0.28);
  background: radial-gradient(circle at 82% 20%, rgba(255, 124, 162, 0.2), transparent 42%),
    radial-gradient(circle at 15% 82%, rgba(79, 158, 110, 0.22), transparent 46%),
    linear-gradient(150deg, rgba(255, 255, 255, 0.78), rgba(247, 255, 249, 0.74));
}

.welcome-grid {
  display: grid;
  gap: 14px;
}

.welcome-intro h3 {
  margin: 8px 0;
  font-family: "ZCOOL KuaiLe", "Kaiti SC", cursive;
  font-size: clamp(1.5rem, 1.4vw + 1rem, 2rem);
  color: #1f4f72;
}

.panel-kicker {
  margin: 0;
  display: inline-flex;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #165778;
  border: 1px solid rgba(22, 87, 120, 0.24);
  background: rgba(255, 255, 255, 0.78);
}

.birth-pill {
  margin: 12px 0 0;
  display: inline-flex;
  align-items: center;
  padding: 7px 11px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 600;
  color: #1a5e7f;
  border: 1px solid rgba(37, 120, 242, 0.24);
  background: rgba(255, 255, 255, 0.82);
}

.welcome-section h4 {
  margin: 0 0 8px;
  font-size: 1rem;
  color: #24516c;
}

.welcome-section-note {
  margin: 0 0 10px;
  color: #46667f;
  font-size: 0.88rem;
  line-height: 1.45;
}

.interest-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.interest-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 600;
  border: 1px solid rgba(79, 158, 110, 0.3);
  background: rgba(255, 255, 255, 0.85);
  color: #245a42;
  animation: chip-in 0.45s ease both;
  animation-delay: var(--chip-delay, 0ms);
}

.interest-chip.alt {
  border-color: rgba(255, 124, 162, 0.35);
  color: #8a3154;
  background: rgba(255, 248, 252, 0.88);
}

.welcome-reco-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.welcome-reco-item {
  border: 1px solid rgba(37, 120, 242, 0.2);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.82);
}

.welcome-reco-item h4 {
  margin: 0;
  color: #214f73;
  font-size: 0.98rem;
}

.welcome-reco-item p {
  margin: 7px 0 9px;
  font-size: 0.86rem;
  line-height: 1.45;
  color: #43637f;
}

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

.memory-photo {
  margin: 0;
  min-height: 180px;
  border: 1px solid rgba(37, 120, 242, 0.2);
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  background: #d9e7f8;
  animation: rise-in 0.45s ease both;
  animation-delay: var(--photo-delay, 0ms);
}

.memory-photo.wide {
  grid-column: span 2;
  min-height: 220px;
}

.memory-photo.portrait {
  min-height: 260px;
}

.memory-photo img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.memory-photo figcaption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  gap: 3px;
  padding: 10px;
  background: linear-gradient(180deg, rgba(10, 23, 52, 0) 0%, rgba(10, 23, 52, 0.72) 100%);
  color: #fff;
}

.memory-photo figcaption strong {
  font-size: 0.9rem;
  line-height: 1.25;
}

.memory-photo figcaption span {
  font-size: 0.78rem;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.9);
}

.welcome-play-btn {
  padding: 7px 10px;
  font-size: 0.84rem;
  border-color: rgba(37, 120, 242, 0.34);
  background: rgba(255, 255, 255, 0.7);
}

.game-card-shell {
  max-width: 780px;
  margin: 0 auto;
}

.game-intro {
  margin: 0 0 16px;
  color: var(--muted);
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

input[type="number"],
input[type="text"] {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  min-width: 180px;
  font: inherit;
  background: #fff;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  font: inherit;
  border-radius: 11px;
  border: 0;
  padding: 10px 14px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.primary-btn {
  color: #fff;
  background: linear-gradient(130deg, var(--brand), var(--brand-strong));
  box-shadow: 0 8px 18px rgba(37, 120, 242, 0.28);
}

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

.secondary-btn {
  color: #213047;
  background: #e8efff;
}

.ghost-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
}

.feedback {
  margin: 14px 0 0;
  font-weight: 500;
}

.ttt-grid {
  margin: 14px 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(75px, 1fr));
  gap: 10px;
  max-width: 340px;
}

.ttt-cell {
  border: 1px solid rgba(66, 98, 160, 0.35);
  border-radius: 12px;
  background: #fff;
  font-family: "ZCOOL KuaiLe", cursive;
  font-size: clamp(1.8rem, 2vw, 2.4rem);
  aspect-ratio: 1;
  cursor: pointer;
}

.ttt-cell.winner {
  background: linear-gradient(145deg, rgba(255, 143, 63, 0.2), rgba(37, 120, 242, 0.2));
  border-color: rgba(37, 120, 242, 0.9);
}

.score-row {
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
}

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

.memory-card {
  border: 1px solid rgba(66, 98, 160, 0.35);
  border-radius: 12px;
  background: #fff;
  font-size: 1.5rem;
  aspect-ratio: 1;
  cursor: pointer;
}

.memory-card.matched {
  background: rgba(40, 164, 121, 0.16);
  border-color: rgba(40, 164, 121, 0.65);
}

.reaction-zone {
  border-radius: 14px;
  border: 1px solid var(--line);
  min-height: 190px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 18px;
  margin-bottom: 14px;
  user-select: none;
  font-weight: 700;
  font-size: 1.1rem;
}

.reaction-zone.idle {
  background: #eef4ff;
}

.reaction-zone.waiting {
  background: #ffeac8;
}

.reaction-zone.ready {
  background: #cef7e7;
  border-color: rgba(40, 164, 121, 0.6);
}

.snake-canvas {
  display: block;
  width: min(100%, 420px);
  height: auto;
  margin: 0 0 14px;
  border-radius: 14px;
  border: 1px solid rgba(66, 98, 160, 0.35);
  background: #f8fbff;
}

.g2048-shell {
  max-width: 520px;
}

.g2048-board {
  width: min(100%, 420px);
  display: grid;
  grid-template-columns: repeat(4, minmax(50px, 1fr));
  gap: 9px;
  background: #d4ddf3;
  border-radius: 14px;
  padding: 9px;
  margin-bottom: 14px;
}

.g2048-cell {
  aspect-ratio: 1;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.35);
}

.g2048-tile {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: clamp(1.1rem, 2.5vw, 1.7rem);
  font-weight: 700;
  transition: background 0.2s ease, transform 0.2s ease;
}

.g2048-tile.v-0 {
  color: transparent;
  background: rgba(255, 255, 255, 0.35);
}

.g2048-tile.v-2 {
  background: #f1f5ff;
}

.g2048-tile.v-4 {
  background: #e3edff;
}

.g2048-tile.v-8 {
  color: #fff;
  background: #7ea8ff;
}

.g2048-tile.v-16 {
  color: #fff;
  background: #6d93f6;
}

.g2048-tile.v-32 {
  color: #fff;
  background: #5583f0;
}

.g2048-tile.v-64 {
  color: #fff;
  background: #3b6fe1;
}

.g2048-tile.v-128 {
  color: #fff;
  background: #ffaf66;
}

.g2048-tile.v-256 {
  color: #fff;
  background: #ff9a3b;
}

.g2048-tile.v-512 {
  color: #fff;
  background: #f27f20;
}

.g2048-tile.v-1024 {
  color: #fff;
  background: #d96b11;
}

.g2048-tile.v-2048 {
  color: #fff;
  background: linear-gradient(140deg, #ffce62, #ff8f3f);
}

.g2048-tile.v-super {
  color: #fff;
  background: linear-gradient(140deg, #ffce62, #2578f2);
}

.mine-toolbar {
  margin-bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.mine-select {
  min-width: 130px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font: inherit;
  background: #fff;
}

.mine-board {
  width: min(100%, 560px);
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
}

.mine-cell {
  aspect-ratio: 1;
  border: 1px solid rgba(66, 98, 160, 0.35);
  border-radius: 8px;
  background: #eaf1ff;
  display: grid;
  place-items: center;
  padding: 0;
  font-weight: 700;
  font-size: clamp(0.68rem, 1.8vw, 0.95rem);
  cursor: pointer;
}

.mine-cell.revealed {
  background: #fff;
}

.mine-cell.mine {
  background: #ffd6d6;
  border-color: rgba(198, 47, 47, 0.45);
}

.mine-cell.flagged {
  background: #fff0d6;
}

.mine-cell.n1 {
  color: #2e61cc;
}

.mine-cell.n2 {
  color: #2f9a3f;
}

.mine-cell.n3 {
  color: #c83a3a;
}

.mine-cell.n4 {
  color: #5f43c8;
}

.mine-cell.n5 {
  color: #983c1f;
}

.mine-cell.n6 {
  color: #0e95a1;
}

.mine-cell.n7 {
  color: #2b2f38;
}

.mine-cell.n8 {
  color: #596273;
}

.footer {
  text-align: center;
  padding: 0 10px 22px;
  color: var(--muted);
  font-size: 0.9rem;
}

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

@keyframes chip-in {
  from {
    transform: translateY(6px) scale(0.96);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(16px);
  }
}

@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .stage {
    min-height: 540px;
  }

  .welcome-reco-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .memory-wall {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .memory-photo.wide {
    grid-column: span 2;
  }
}

@media (max-width: 680px) {
  .hero {
    padding-top: 30px;
  }

  .sidebar,
  .stage {
    padding: 14px;
    border-radius: 14px;
  }

  .game-host {
    min-height: 420px;
    padding: 12px;
  }

  .memory-grid {
    grid-template-columns: repeat(3, minmax(64px, 1fr));
  }

  .ttt-grid {
    max-width: 100%;
  }

  .hero-motifs {
    margin-top: 12px;
    gap: 6px;
  }

  .hero-universe-nav {
    margin-top: 11px;
    gap: 6px;
  }

  .hero-universe-link {
    font-size: 0.76rem;
    padding: 5px 9px;
  }

  .hero-motif {
    font-size: 0.78rem;
    padding: 5px 9px;
  }

  .welcome-panel {
    padding: 16px;
  }

  .birth-pill {
    width: 100%;
    justify-content: center;
  }

  .welcome-reco-grid {
    grid-template-columns: 1fr;
  }

  .memory-wall {
    grid-template-columns: 1fr;
  }

  .memory-photo,
  .memory-photo.wide,
  .memory-photo.portrait {
    min-height: 220px;
    grid-column: span 1;
  }

  .mine-board {
    gap: 3px;
  }
}
