:root {
  --bg: #f7faf9;
  --surface: #ffffff;
  --ink: #13201f;
  --muted: #60706d;
  --line: #dce8e4;
  --teal: #0f9f95;
  --teal-dark: #08786f;
  --coral: #ff6a57;
  --yellow: #f6c84f;
  --blue: #4d8cff;
  --shadow: 0 18px 44px rgba(22, 44, 41, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top left, rgba(15, 159, 149, 0.13), transparent 34%), var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

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

button {
  border: 0;
  font: inherit;
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid rgba(220, 232, 228, 0.8);
  background: rgba(247, 250, 249, 0.88);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-weight: 900;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.nav a {
  min-width: 0;
  padding: 9px 14px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.nav a.is-active {
  background: var(--ink);
  color: white;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 56px;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 32px;
  padding: 44px 0 34px;
}

.hero h1,
.game-header h1 {
  margin: 0;
  max-width: 760px;
  font-size: clamp(36px, 6vw, 78px);
  line-height: 0.98;
  letter-spacing: 0;
}

.hero p,
.game-header p {
  max-width: 650px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.7;
}

.primary-action,
.ghost-action,
.button-stack button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 0 18px;
  font-size: 15px;
  font-weight: 800;
}

.primary-action,
.button-stack .accent {
  background: var(--teal);
  color: white;
  box-shadow: 0 12px 28px rgba(15, 159, 149, 0.22);
}

.ghost-action,
.button-stack button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.button-stack button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

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

.game-card {
  position: relative;
  display: grid;
  min-height: 330px;
  grid-template-columns: 1fr 220px;
  gap: 24px;
  overflow: hidden;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.game-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 24px 56px rgba(22, 44, 41, 0.15);
}

.card-copy {
  display: flex;
  flex-direction: column;
  justify-content: end;
}

.game-type {
  color: var(--teal-dark);
  font-size: 14px;
  font-weight: 800;
}

.game-card h2 {
  margin: 10px 0 10px;
  font-size: 34px;
}

.game-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.mini-sudoku,
.mini-gems,
.mini-link,
.mini-tile-stack,
.mini-gomoku {
  align-self: center;
  justify-self: end;
}

.mini-sudoku {
  display: grid;
  width: 198px;
  height: 198px;
  grid-template-columns: repeat(9, 1fr);
  border: 2px solid var(--ink);
  background: white;
}

.mini-sudoku span {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.mini-gems {
  display: grid;
  width: 210px;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.mini-link {
  display: grid;
  width: 210px;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  padding: 10px;
  border-radius: 8px;
  background: #e9f4f1;
}

.mini-link span,
.link-tile {
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.88);
  border-radius: 8px;
  background: linear-gradient(145deg, #16312d, #0f9f95);
  color: white;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.2), 0 4px 0 rgba(22, 44, 41, 0.14);
  font-weight: 900;
}

.mini-link span {
  aspect-ratio: 1;
  font-size: 18px;
}

.mini-tile-stack {
  position: relative;
  width: 210px;
  height: 210px;
  border-radius: 8px;
  background: #e9f4f1;
}

.mini-tile-stack span {
  position: absolute;
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  background: linear-gradient(145deg, #0b7e76, #13b5a9);
  color: white;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.18), 0 8px 16px rgba(22, 44, 41, 0.18);
  font-size: 26px;
}

.mini-gomoku {
  position: relative;
  display: grid;
  width: 210px;
  height: 210px;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  padding: 14px;
  border: 2px solid #805726;
  border-radius: 8px;
  background: #d7a452;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.32);
}

.mini-gomoku span {
  position: relative;
  display: grid;
  place-items: center;
}

.mini-gomoku span::before {
  position: absolute;
  inset: 50% -1px auto;
  height: 1px;
  background: rgba(74, 47, 20, 0.62);
  content: "";
}

.mini-gomoku span::after {
  position: absolute;
  inset: -1px auto -1px 50%;
  width: 1px;
  background: rgba(74, 47, 20, 0.62);
  content: "";
}

.mini-stone {
  z-index: 1;
  width: 18px;
  height: 18px;
  border-radius: 50%;
}

.mini-stone.black {
  background: radial-gradient(circle at 32% 26%, #6f7a78 0 9%, #141a19 42%, #050606 100%);
}

.mini-stone.white {
  border: 1px solid rgba(0, 0, 0, 0.16);
  background: radial-gradient(circle at 32% 26%, white 0 18%, #f0f0e6 55%, #cfcfc4 100%);
}

.gem-preview,
.gem {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.96);
  border-radius: 50%;
  clip-path: none;
  box-shadow:
    inset 0 -8px 0 rgba(0, 0, 0, 0.26),
    inset 0 3px 0 rgba(255, 255, 255, 0.24),
    0 4px 0 rgba(22, 44, 41, 0.18);
}

.gem-preview::before,
.gem::before {
  position: absolute;
  top: 15%;
  left: 18%;
  width: 42%;
  height: 22%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  content: "";
}

.gem-preview::after,
.gem::after {
  position: absolute;
  inset: 24%;
  border: 2px solid rgba(255, 255, 255, 0.34);
  border-radius: 50%;
  content: "";
}

.gem-ruby {
  background: radial-gradient(circle at 32% 24%, #ffb0b8 0 12%, #ff2d4c 30%, #b60024 72%, #7d001a 100%);
}

.gem-emerald {
  background: radial-gradient(circle at 32% 24%, #91ffe6 0 12%, #00b889 30%, #00745f 72%, #00483d 100%);
}

.gem-sun {
  background: radial-gradient(circle at 32% 24%, #fff19a 0 12%, #ffc400 32%, #c87900 72%, #824100 100%);
}

.gem-sapphire {
  background: radial-gradient(circle at 32% 24%, #a9ddff 0 12%, #1d7dff 30%, #0047c7 72%, #002c86 100%);
}

.gem-violet {
  background: radial-gradient(circle at 32% 24%, #e0b8ff 0 12%, #894dff 30%, #4b20b8 72%, #2d0f76 100%);
}

.gem-amber {
  background: radial-gradient(circle at 32% 24%, #ffd1a0 0 12%, #ff761f 32%, #b93f00 72%, #752500 100%);
}

.coming-soon {
  margin-top: 28px;
  padding: 26px 0;
}

.coming-soon h2 {
  margin: 0 0 16px;
  font-size: 24px;
}

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

.soon-grid div {
  min-height: 88px;
  display: grid;
  place-items: center;
  border: 1px dashed #adc5bf;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
  background: rgba(255, 255, 255, 0.62);
}

.game-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 0;
}

.game-header h1 {
  font-size: clamp(42px, 7vw, 88px);
}

.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 22px;
  align-items: start;
}

.board-panel,
.side-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.board-panel {
  display: grid;
  min-height: 620px;
  place-items: center;
  padding: 22px;
}

.side-panel {
  padding: 18px;
}

.sudoku-board {
  display: grid;
  width: min(74vw, 560px);
  max-width: 100%;
  grid-template-columns: repeat(9, 1fr);
  border: 3px solid var(--ink);
  background: var(--ink);
  gap: 1px;
}

.sudoku-cell {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 0;
  background: white;
  color: var(--ink);
  font-size: clamp(20px, 4vw, 34px);
  font-weight: 800;
}

.sudoku-cell:nth-child(3n) {
  border-right: 2px solid var(--ink);
}

.sudoku-cell:nth-child(n + 19):nth-child(-n + 27),
.sudoku-cell:nth-child(n + 46):nth-child(-n + 54) {
  border-bottom: 2px solid var(--ink);
}

.sudoku-cell.given {
  background: #eef7f5;
}

.sudoku-cell.selected {
  outline: 4px solid var(--yellow);
  outline-offset: -4px;
}

.sudoku-cell.error {
  background: #ffe9e5;
  color: #c83220;
}

.sudoku-cell.same {
  background: #f7f1d7;
}

.number-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 18px 0;
}

.number-pad button {
  min-height: 58px;
  border-radius: 8px;
  background: #edf8f6;
  color: var(--teal-dark);
  font-size: 24px;
  font-weight: 900;
}

.number-pad .wide {
  grid-column: 1 / -1;
  min-height: 46px;
  background: #fff4e9;
  color: #a84b10;
  font-size: 18px;
}

.button-stack {
  display: grid;
  gap: 10px;
}

.status-line,
.score-card,
.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.status-line strong,
.score-card strong {
  color: var(--ink);
  font-size: 24px;
}

.field-row {
  gap: 14px;
}

.field-row span {
  flex: 1;
}

.field-row select {
  width: 128px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  padding: 0 10px;
}

.match-board {
  display: grid;
  width: min(74vw, 560px);
  max-width: 100%;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  padding: 10px;
  border-radius: 8px;
  background: #e9f4f1;
}

.link-board {
  display: grid;
  width: min(74vw, 640px);
  max-width: 100%;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  padding: 10px;
  border-radius: 8px;
  background: #e9f4f1;
}

.link-tile {
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  font-size: clamp(24px, 5vw, 38px);
  transition: opacity 140ms ease, transform 140ms ease, outline-color 140ms ease;
}

.link-tile:hover {
  transform: translateY(-2px);
}

.link-tile.selected {
  outline: 4px solid var(--yellow);
  outline-offset: 2px;
}

.link-tile.hint {
  outline: 4px solid var(--coral);
  outline-offset: 2px;
}

.link-tile.empty {
  pointer-events: none;
  opacity: 0;
}

.tile-play-area {
  gap: 18px;
}

.tile-board {
  position: relative;
  width: min(76vw, 650px);
  height: min(62vw, 470px);
  min-height: 360px;
  border-radius: 8px;
  background: #e9f4f1;
  overflow: hidden;
}

.stack-tile {
  position: absolute;
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 8px;
  background: linear-gradient(145deg, #0d8f86, #12b6aa);
  color: white;
  box-shadow: inset 0 -7px 0 rgba(0, 0, 0, 0.2), 0 10px 16px rgba(22, 44, 41, 0.18);
  font-size: 32px;
  transition: transform 140ms ease, opacity 140ms ease, filter 140ms ease;
}

.stack-tile:not(.blocked):hover {
  transform: translateY(-4px);
}

.stack-tile.blocked {
  cursor: not-allowed;
  filter: grayscale(0.35) brightness(0.72);
}

.tile-tray {
  display: grid;
  width: min(76vw, 650px);
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.tray-slot {
  display: grid;
  min-height: 62px;
  place-items: center;
  border: 1px dashed #adc5bf;
  border-radius: 8px;
  color: white;
  font-size: 30px;
  font-weight: 900;
}

.tray-slot.filled {
  border-style: solid;
  background: linear-gradient(145deg, #13201f, #0f9f95);
}

.gomoku-board {
  position: relative;
  display: grid;
  width: min(74vw, 610px);
  max-width: 100%;
  grid-template-columns: repeat(15, 1fr);
  padding: 16px;
  border: 3px solid #7e5525;
  border-radius: 8px;
  background: #d9aa5b;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35), 0 18px 36px rgba(82, 51, 19, 0.16);
}

.gomoku-point {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  background: transparent;
}

.gomoku-point::before {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(74, 47, 20, 0.72);
  content: "";
}

.gomoku-point::after {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: rgba(74, 47, 20, 0.72);
  content: "";
}

.gomoku-point.edge-top::after {
  top: 50%;
}

.gomoku-point.edge-bottom::after {
  bottom: 50%;
}

.gomoku-point.edge-left::before {
  left: 50%;
}

.gomoku-point.edge-right::before {
  right: 50%;
}

.stone {
  position: absolute;
  z-index: 2;
  inset: 12%;
  border-radius: 50%;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.22), 0 4px 7px rgba(50, 31, 14, 0.25);
}

.stone.black {
  background: radial-gradient(circle at 34% 26%, #68716e 0 8%, #151a19 42%, #050606 100%);
}

.stone.white {
  border: 1px solid rgba(0, 0, 0, 0.18);
  background: radial-gradient(circle at 32% 26%, #ffffff 0 18%, #f0eee6 54%, #c7c4b8 100%);
}

.stone.win {
  outline: 4px solid var(--coral);
  outline-offset: 2px;
}

.gem {
  transition: transform 140ms ease, opacity 140ms ease;
}

.gem.selected {
  transform: scale(0.88);
  outline: 4px solid var(--ink);
  outline-offset: 2px;
}

.gem.removing {
  opacity: 0;
  transform: scale(0.2);
}

.game-message {
  min-height: 52px;
  margin: 16px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

@media (max-width: 860px) {
  .topbar,
  .hero,
  .game-header {
    align-items: stretch;
    flex-direction: column;
  }

  .nav {
    width: 100%;
  }

  .nav a {
    flex: 1;
    min-width: 72px;
    text-align: center;
  }

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

  .game-card {
    grid-template-columns: 1fr;
  }

  .mini-sudoku,
  .mini-gems,
  .mini-link,
  .mini-tile-stack,
  .mini-gomoku {
    justify-self: start;
  }

  .board-panel {
    min-height: auto;
  }
}
