:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --text: #1f1f1f;
  --muted: #6b6b6b;
  --line: #e8e6e1;
  --accent: #3d7a5f;
  --accent-soft: #e8f3ec;
  --warm: #e8a87c;
  --radius: 16px;
  --shadow: 0 8px 30px rgba(31, 31, 31, 0.06);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "DM Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
}

.header {
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 20px 0;
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.logo {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.tagline {
  color: var(--muted);
  font-size: 0.9rem;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}

.intro h1 {
  font-size: clamp(2rem, 7vw, 2.8rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 12px;
}

.intro p {
  color: var(--muted);
  max-width: 420px;
  font-size: 1.02rem;
}

.stats {
  display: flex;
  gap: 20px;
  margin-top: 22px;
  font-size: 0.92rem;
  color: var(--muted);
}

.stats strong {
  color: var(--text);
  font-size: 1.1rem;
}

.play {
  margin-top: 36px;
}

.game-picker {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 14px;
  scrollbar-width: none;
}

.game-picker::-webkit-scrollbar {
  display: none;
}

.pick {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 10px 16px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s;
}

.pick:hover {
  border-color: #d0cec8;
  color: var(--text);
}

.pick.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.board {
  display: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.board.active {
  display: block;
}

.board-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.board-head h2 {
  font-size: 1.2rem;
  font-weight: 700;
}

.board-head p {
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 2px;
}

.score {
  font-size: 0.86rem;
  color: var(--muted);
  white-space: nowrap;
}

.score b {
  color: var(--accent);
}

canvas {
  display: block;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
  border-radius: 14px;
  background: #fafaf8;
  border: 1px solid var(--line);
}

.actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 14px;
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 12px 20px;
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: opacity 0.15s;
}

.btn:hover {
  opacity: 0.9;
}

.btn-soft {
  background: var(--accent-soft);
  color: var(--accent);
}

.dpad {
  display: none;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(3, 52px);
  gap: 6px;
  justify-content: center;
  margin-top: 14px;
}

.dpad button {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  font-size: 1.1rem;
  cursor: pointer;
}

.dpad button:nth-child(1) { grid-column: 2; }
.dpad button:nth-child(2) { grid-column: 1; grid-row: 2; }
.dpad button:nth-child(3) { grid-column: 3; grid-row: 2; }
.dpad button:nth-child(4) { grid-column: 2; grid-row: 3; }

.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  max-width: 360px;
  margin: 0 auto 16px;
}

.memory-card {
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: transparent;
  font-size: 1.5rem;
  cursor: pointer;
  transition: 0.15s;
}

.memory-card.open,
.memory-card.matched {
  color: var(--text);
  background: var(--accent-soft);
}

.memory-card.matched {
  border-color: var(--accent);
}

.ttt-grid {
  display: grid;
  grid-template-columns: repeat(3, 80px);
  gap: 8px;
  justify-content: center;
  margin-bottom: 16px;
}

.ttt-cell {
  width: 80px;
  height: 80px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
}

.ttt-cell:disabled {
  cursor: default;
}

.reaction {
  width: 100%;
  min-height: 180px;
  border: 1px solid var(--line);
  border-radius: 16px;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.12s;
}

.reaction.idle {
  background: var(--bg);
  color: var(--muted);
}

.reaction.waiting {
  background: #fde8e8;
  color: #b45353;
}

.reaction.go {
  background: #d8f0e3;
  color: var(--accent);
}

.hint {
  text-align: center;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

.grid2048 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  max-width: 320px;
  margin: 0 auto 16px;
  padding: 10px;
  background: #eceae4;
  border-radius: 14px;
}

.tile2048 {
  aspect-ratio: 1;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.1rem;
  background: #ddd9d0;
  color: transparent;
}

.tile2048.v2 { background: #eee4d4; color: #776e60; }
.tile2048.v4 { background: #ede0c8; color: #776e60; }
.tile2048.v8 { background: #f2b179; color: #fff; }
.tile2048.v16 { background: #f59563; color: #fff; }
.tile2048.v32 { background: #f67c5f; color: #fff; }
.tile2048.v64 { background: #f65e3b; color: #fff; }
.tile2048.v128 { background: #edcf72; color: #fff; font-size: 0.95rem; }
.tile2048.v256 { background: #edcc61; color: #fff; font-size: 0.95rem; }
.tile2048.v512 { background: #edc850; color: #fff; font-size: 0.95rem; }
.tile2048.v1024 { background: #edc53f; color: #fff; font-size: 0.8rem; }
.tile2048.v2048 { background: #3d7a5f; color: #fff; font-size: 0.8rem; }

.simon-grid {
  display: grid;
  grid-template-columns: repeat(2, 100px);
  gap: 12px;
  justify-content: center;
  margin-bottom: 14px;
}

.simon-btn {
  width: 100px;
  height: 100px;
  border: none;
  border-radius: 18px;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.1s, transform 0.1s;
}

.simon-btn[data-i="0"] { background: #f4a698; }
.simon-btn[data-i="1"] { background: #8ec5a0; }
.simon-btn[data-i="2"] { background: #8eb8e8; }
.simon-btn[data-i="3"] { background: #e8c47a; }

.simon-btn.lit {
  opacity: 1;
  transform: scale(1.04);
}

.about {
  margin-top: 40px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.about h2 {
  font-size: 1.1rem;
  margin-bottom: 8px;
}

.about p {
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 480px;
}

.footer {
  text-align: center;
  padding: 24px;
  color: var(--muted);
  font-size: 0.82rem;
}

@media (max-width: 600px) {
  .dpad { display: grid; }
  .ttt-grid { grid-template-columns: repeat(3, 72px); }
  .ttt-cell { width: 72px; height: 72px; }
  .simon-grid { grid-template-columns: repeat(2, 88px); }
  .simon-btn { width: 88px; height: 88px; }
}
