:root {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #647089;
  --line: #d9e1ec;
  --accent: #1f7a5c;
  --accent-dark: #15543f;
  --gold: #d99a1b;
  --red: #c8433f;
  --felt: #116149;
  --felt-dark: #0b3f32;
  --shadow: 0 16px 40px rgba(23, 32, 51, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  line-height: 1.6;
  letter-spacing: 0;
  overscroll-behavior-y: contain;
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

.site-header {
  height: 60px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 0 28px;
  background: #172033;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 80;
}

.brand {
  font-size: 20px;
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
}

.desktop-nav {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
}

.desktop-nav a {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.84);
  text-decoration: none;
}

.desktop-nav a:hover,
.desktop-nav a:focus-visible {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}

.header-download,
.mobile-menu {
  display: none;
}

main {
  padding: 28px 18px 0;
}

.game-shell {
  width: min(1240px, 100%);
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.game-top {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 18px;
  background: #f9fbfe;
  border-bottom: 1px solid var(--line);
}

.mode-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mode-btn,
.control-bar button,
.stock-card,
.result-card button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  transition:
    border-color 0.18s,
    background 0.18s,
    color 0.18s;
}

.mode-btn {
  padding: 0 16px;
}

.mode-btn.active,
.control-bar button:first-child,
.result-card button {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.mode-btn:hover,
.mode-btn:focus-visible,
.control-bar button:hover,
.control-bar button:focus-visible,
.stock-card:hover,
.stock-card:focus-visible,
.result-card button:hover,
.result-card button:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.control-bar button:disabled,
.stock-card:disabled {
  cursor: not-allowed;
  color: #97a3b6;
  background: #eef2f7;
  border-color: var(--line);
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(74px, 1fr));
  gap: 8px;
}

.score-grid div {
  min-height: 48px;
  display: grid;
  place-items: center;
  padding: 4px 8px;
  border-radius: 6px;
  background: #101828;
  color: #fff;
}

.score-grid span {
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
}

.score-grid strong {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 20px;
  line-height: 1;
  color: #f4c95d;
  white-space: nowrap;
}

.client-notice {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: #fff7e6;
  border-bottom: 1px solid #f1d39b;
  color: #68430d;
}

.client-notice.hidden {
  display: none;
}

.client-notice-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #f4d792;
  color: #6b4405;
  font-size: 18px;
  font-weight: 900;
}

.client-notice p {
  margin: 0;
  display: grid;
  gap: 2px;
  min-width: 0;
}

.client-notice span {
  color: #7a5a25;
  font-size: 14px;
}

.client-notice a {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border-radius: 6px;
  background: var(--gold);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.client-notice-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 6px;
  background: rgba(104, 67, 13, 0.1);
  color: #68430d;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.play-area {
  position: relative;
  padding: 18px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.055) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.055) 1px, transparent 1px), var(--felt);
  background-size: 20px 20px;
}

.table-top {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr) 240px;
  gap: 12px;
  align-items: stretch;
  margin-bottom: 14px;
}

.stock-card {
  min-height: 74px;
  display: grid;
  place-content: center;
  gap: 2px;
  padding: 8px;
  background: #fff;
}

.stock-card span {
  color: var(--muted);
  font-size: 13px;
}

.stock-card strong {
  font-size: 18px;
}

.foundation-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(54px, 1fr));
  gap: 8px;
}

.foundation-pile {
  min-height: 74px;
  display: grid;
  place-items: center;
  padding: 4px;
  border: 1px dashed rgba(255, 255, 255, 0.48);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(11, 63, 50, 0.36);
  font-weight: 900;
  text-align: center;
}

.foundation-pile.black,
.foundation-pile.red {
  border-style: solid;
  background: #fff;
  color: #111827;
}

.foundation-pile.red {
  color: var(--red);
}

.status-card {
  min-height: 74px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 12px;
  border-radius: 6px;
  background: #fff;
  border: 1px solid var(--line);
}

.status-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.status-card strong {
  overflow-wrap: anywhere;
  font-size: 16px;
  line-height: 1.35;
}

.tableau-scroll {
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-color: rgba(255, 255, 255, 0.45) rgba(11, 63, 50, 0.4);
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

.tableau {
  --card-top: 5px;
  --card-step: 28px;
  --card-height: 104px;
  --table-min-height: 560px;
  min-width: 980px;
  min-height: var(--table-min-height);
  display: grid;
  grid-template-columns: repeat(10, minmax(84px, 1fr));
  gap: 8px;
  align-items: start;
}

.column {
  position: relative;
  min-height: calc(var(--table-min-height) - 12px);
  padding: 5px;
  border-radius: 8px;
  background: rgba(11, 63, 50, 0.32);
  outline: 1px solid rgba(255, 255, 255, 0.08);
}

.column.hint-target {
  outline: 2px solid #f4c95d;
  background: rgba(244, 201, 93, 0.14);
}

.empty-slot {
  height: 118px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(255, 255, 255, 0.42);
  border-radius: 7px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 14px;
  font-weight: 800;
}

.card {
  --offset: 0;
  position: absolute;
  top: calc(var(--card-top) + var(--offset) * var(--card-step));
  left: 5px;
  right: 5px;
  height: var(--card-height);
  display: grid;
  grid-template-rows: auto 1fr;
  justify-items: start;
  gap: 2px;
  padding: 8px;
  border: 1px solid rgba(15, 23, 42, 0.18);
  border-radius: 7px;
  background: #fff;
  color: #111827;
  box-shadow: 0 3px 8px rgba(2, 6, 23, 0.22);
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}

.card.face-down {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%) 0 0 / 14px 14px,
    linear-gradient(135deg, transparent 75%, rgba(255, 255, 255, 0.2) 75%) 0 0 / 14px 14px,
    #174b8e;
  border-color: rgba(255, 255, 255, 0.2);
}

.card.face-up.red {
  color: var(--red);
}

.card span {
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.card strong {
  align-self: end;
  justify-self: end;
  font-size: 28px;
  line-height: 1;
}

.card.selected {
  transform: translateY(-5px);
  outline: 3px solid #f4c95d;
  z-index: 20;
}

.card.hint-source {
  outline: 3px solid rgba(244, 201, 93, 0.72);
  z-index: 18;
}

.result-overlay {
  position: absolute;
  inset: 18px;
  display: grid;
  place-items: center;
  padding: 20px;
  border-radius: 8px;
  background: rgba(16, 24, 40, 0.62);
  z-index: 50;
}

.result-overlay[hidden] {
  display: none;
}

.result-card {
  width: min(300px, 100%);
  display: grid;
  gap: 10px;
  padding: 22px;
  border-radius: 8px;
  background: #fff;
  text-align: center;
  box-shadow: var(--shadow);
}

.result-card strong {
  font-size: 24px;
  line-height: 1.2;
}

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

.result-card button {
  width: 100%;
}

.control-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 0 18px 18px;
  background: var(--felt);
}

.content-page {
  width: min(980px, 100%);
  margin: 28px auto 0;
  padding: 0 18px;
}

.content-page article {
  margin-bottom: 18px;
  padding: 28px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.content-page h1,
.content-page h2 {
  margin: 0 0 10px;
  line-height: 1.25;
}

.content-page h1 {
  font-size: 32px;
}

.content-page h2 {
  margin-top: 24px;
  font-size: 23px;
}

.content-page p,
.content-page li {
  color: var(--muted);
}

.content-page a {
  color: var(--accent-dark);
  font-weight: 800;
}

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

.game-card {
  min-height: 78px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--ink);
  text-decoration: none;
}

.game-card:hover,
.game-card:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.game-card-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  font-size: 18px;
  font-weight: 900;
}

.game-card-icon.snake {
  background: #1f7a5c;
}

.game-card-icon.gomoku {
  background: #172033;
}

.game-card-icon.mine {
  background: #0f8b8d;
}

.game-card-icon.tile {
  background: #2563eb;
  font-size: 13px;
}

.game-card-icon.block {
  background: #172033;
}

.game-card strong {
  color: var(--ink);
  font-size: 18px;
  line-height: 1.2;
}

.game-card-icon.jump {
  background: #d93a2f;
}

.game-card-icon.sudoku {
  background: #2f6f9f;
}

.site-footer {
  margin-top: 34px;
  padding: 22px 18px;
  color: var(--muted);
  text-align: center;
  border-top: 1px solid var(--line);
}

.site-footer p {
  margin: 6px 0;
}

.site-footer a {
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: none;
}

@media (max-width: 900px) {
  .game-top,
  .table-top {
    grid-template-columns: 1fr;
  }

  .score-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .foundation-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .tableau {
    min-width: 820px;
    grid-template-columns: repeat(10, 76px);
  }
}

@media (max-width: 700px) {
  .game-shell {
    overflow: visible;
  }

  .site-header {
    height: 48px;
    grid-template-columns: minmax(0, 1fr) auto 40px;
    gap: 6px;
    padding: 0 8px;
  }

  .brand {
    font-size: 17px;
  }

  .desktop-nav {
    display: none;
  }

  .header-download {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    border-radius: 6px;
    background: #fff7e6;
    color: #68430d;
    border: 1px solid #e5c16b;
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
  }

  .mobile-menu {
    display: block;
    position: relative;
  }

  .mobile-menu summary {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    gap: 4px;
    padding: 10px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    cursor: pointer;
    list-style: none;
  }

  .mobile-menu summary::-webkit-details-marker {
    display: none;
  }

  .mobile-menu span {
    width: 18px;
    height: 2px;
    display: block;
    border-radius: 2px;
    background: #fff;
  }

  .mobile-menu nav {
    position: fixed;
    top: 48px;
    right: 8px;
    z-index: 90;
    width: min(220px, calc(100vw - 16px));
    display: grid;
    gap: 4px;
    padding: 10px;
    border-radius: 8px;
    background: #172033;
    box-shadow: var(--shadow);
  }

  .mobile-menu:not([open]) nav {
    display: none;
  }

  .mobile-menu nav a {
    min-height: 42px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    border-radius: 6px;
    color: #fff;
    text-decoration: none;
  }

  main {
    padding: 8px 8px 0;
  }

  .game-top {
    grid-template-columns: minmax(132px, 0.92fr) minmax(0, 1.08fr);
    align-items: stretch;
    gap: 8px;
    padding: 8px;
  }

  .mode-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
  }

  .mode-btn {
    min-height: 36px;
    padding: 0 4px;
    font-size: 13px;
  }

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

  .score-grid div {
    min-height: 35px;
    padding: 2px 4px;
  }

  .score-grid span {
    font-size: 10px;
  }

  .score-grid strong {
    font-size: 15px;
  }

  .client-notice {
    display: none;
  }

  .play-area {
    padding: 6px;
  }

  .table-top {
    grid-template-columns: 74px minmax(0, 1fr);
    gap: 6px;
    margin-bottom: 6px;
  }

  .stock-card {
    min-height: 66px;
    padding: 5px;
  }

  .stock-card span {
    font-size: 12px;
  }

  .stock-card strong {
    font-size: 16px;
  }

  .foundation-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
  }

  .foundation-pile {
    min-height: 31px;
    padding: 1px;
    border-radius: 5px;
    font-size: 10px;
  }

  .status-card {
    grid-column: 1 / -1;
    min-height: 34px;
    display: flex;
    align-items: center;
    padding: 6px 8px;
  }

  .status-card span {
    display: none;
  }

  .status-card strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
  }

  .tableau-scroll {
    margin: 0 -6px;
    padding: 0 6px 8px;
    scroll-snap-type: x proximity;
  }

  .tableau {
    --card-top: 4px;
    --card-step: 20px;
    --card-height: 80px;
    --table-min-height: 438px;
    min-width: 650px;
    grid-template-columns: repeat(10, 60px);
    gap: 5px;
  }

  .column {
    min-height: calc(var(--table-min-height) - 10px);
    padding: 4px;
    border-radius: 6px;
    scroll-snap-align: start;
  }

  .empty-slot {
    height: var(--card-height);
    border-radius: 6px;
    font-size: 11px;
  }

  .card {
    top: calc(var(--card-top) + var(--offset) * var(--card-step));
    left: 4px;
    right: 4px;
    padding: 5px;
    border-radius: 6px;
  }

  .card span {
    font-size: 14px;
  }

  .card strong {
    font-size: 21px;
  }

  .card.selected {
    transform: translateY(-3px);
    outline-width: 2px;
  }

  .card.hint-source {
    outline-width: 2px;
  }

  .result-overlay {
    position: fixed;
    inset: 0;
    padding: 16px;
    border-radius: 0;
    z-index: 100;
  }

  .result-card {
    padding: 18px;
  }

  .control-bar {
    position: sticky;
    bottom: 0;
    z-index: 45;
    gap: 6px;
    padding: 6px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: 0 -8px 20px rgba(2, 6, 23, 0.18);
  }

  .control-bar button {
    min-height: 40px;
    font-size: 13px;
  }

  .content-page {
    margin-top: 14px;
    padding: 0 10px;
  }

  .content-page article {
    padding: 20px;
  }

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

  .game-card {
    min-height: 64px;
    padding: 10px;
  }

  .game-card-icon {
    width: 38px;
    height: 38px;
    font-size: 17px;
  }

  .game-card-icon.tile {
    font-size: 12px;
  }

  .game-card strong {
    font-size: 17px;
  }

  .site-footer {
    margin-top: 20px;
    padding: 18px 12px;
    font-size: 13px;
  }
}

@media (max-width: 380px) {
  .game-top {
    grid-template-columns: minmax(120px, 0.9fr) minmax(0, 1.1fr);
  }

  .mode-btn {
    min-height: 34px;
    font-size: 12px;
  }

  .score-grid strong {
    font-size: 14px;
  }

  .tableau {
    --card-step: 19px;
    --card-height: 76px;
    --table-min-height: 420px;
    min-width: 610px;
    grid-template-columns: repeat(10, 56px);
    gap: 4px;
  }

  .card span {
    font-size: 13px;
  }

  .card strong {
    font-size: 20px;
  }
}
