.game-shell {
  margin: 22px 0 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.game-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.game-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
}

.game-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.93rem;
}

.game-area {
  padding: 14px;
}

.game-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.game-button,
.game-input,
.game-select {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 16px;
}

.game-button {
  padding: 9px 13px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.game-button.secondary {
  background: var(--accent-soft);
  color: var(--accent);
}

.game-input,
.game-select {
  width: 100%;
  max-width: 220px;
  padding: 8px 10px;
  background: var(--bg);
  color: var(--text);
}

.game-message {
  margin: 10px 0 0;
  color: var(--muted);
}

.reaction-pad {
  display: grid;
  place-items: center;
  min-height: 230px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--accent-soft);
  text-align: center;
  touch-action: manipulation;
  user-select: none;
}

.reaction-pad.ready {
  background: #7a1f18;
  color: #fff;
}

.reaction-pad.go {
  background: #1f7a45;
  color: #fff;
}

.history-list {
  margin: 12px 0 0;
  padding-left: 20px;
}

.baseball-log {
  max-height: 240px;
  margin-top: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.baseball-log p {
  margin: 0;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
}

.baseball-log p:last-child {
  border-bottom: 0;
}

.grid-2048 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: min(100%, 360px);
  aspect-ratio: 1;
  margin: 0 auto;
  padding: 8px;
  border-radius: 8px;
  background: #9f8f7d;
  touch-action: none;
}

.tile-2048 {
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #cdc1b4;
  color: #2f2a25;
  font-size: clamp(1.2rem, 8vw, 2rem);
  font-weight: 900;
}

.tile-2048[data-value="2"] { background: #eee4da; }
.tile-2048[data-value="4"] { background: #ede0c8; }
.tile-2048[data-value="8"] { background: #f2b179; color: #fff; }
.tile-2048[data-value="16"] { background: #f59563; color: #fff; }
.tile-2048[data-value="32"] { background: #f67c5f; color: #fff; }
.tile-2048[data-value="64"] { background: #f65e3b; color: #fff; }
.tile-2048[data-value="128"], .tile-2048[data-value="256"], .tile-2048[data-value="512"] { background: #edcf72; color: #fff; }
.tile-2048[data-value="1024"], .tile-2048[data-value="2048"] { background: #3d3a33; color: #fff; }

.memory-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.memory-grid {
  display: grid;
  gap: 8px;
  width: min(100%, 520px);
  margin: 0 auto;
}

.memory-grid.easy { grid-template-columns: repeat(4, 1fr); }
.memory-grid.normal { grid-template-columns: repeat(4, 1fr); }
.memory-grid.hard { grid-template-columns: repeat(6, 1fr); }

.memory-card {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: clamp(1.4rem, 9vw, 2.2rem);
  cursor: pointer;
  touch-action: manipulation;
}

.memory-card.matched {
  background: #1f7a45;
  color: #fff;
}

.typing-target {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--accent-soft);
  font-size: 1.08rem;
  font-weight: 700;
}

.typing-input {
  width: 100%;
  min-height: 130px;
  margin-top: 12px;
  padding: 12px;
  resize: vertical;
}

.home-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 24px 0;
}

.home-card {
  display: block;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow);
}

.home-card strong {
  display: block;
  margin-bottom: 6px;
  font-size: 1.1rem;
}

.home-card span {
  color: var(--muted);
}

@media (min-width: 640px) {
  .game-area {
    padding: 18px;
  }

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

@media (max-width: 380px) {
  .memory-grid.hard {
    gap: 5px;
  }

  .memory-card {
    border-radius: 6px;
    font-size: 1.25rem;
  }
}
