:root {
  --bg: #f3f7ff;
  --surface: #ffffff;
  --surface-alt: #eef4ff;
  --text: #0f1b2d;
  --muted: #4b5f7f;
  --primary: #1b5fd2;
  --primary-strong: #0d49ac;
  --accent: #e53f50;
  --accent-strong: #c82233;
  --line: #d7e2f5;
  --success: #1e9b68;
  --shadow: 0 16px 40px rgba(16, 56, 128, 0.14);
  --radius: 18px;
  --radius-sm: 12px;
  --container: min(1180px, 94vw);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 0% -10%, rgba(27, 95, 210, 0.12), transparent 38%),
    radial-gradient(circle at 100% 0%, rgba(229, 63, 80, 0.1), transparent 36%),
    var(--bg);
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
  line-height: 1.5;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  display: block;
}

.container {
  width: var(--container);
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.site-header-inner {
  width: var(--container);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 76px;
}

.logo-wrap {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.logo-wrap:hover {
  text-decoration: none;
}

.logo-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  box-shadow: 0 10px 20px rgba(15, 64, 147, 0.2);
}

.logo-text strong {
  display: block;
  font-size: 1.05rem;
  line-height: 1.15;
}

.logo-text span {
  color: var(--muted);
  font-size: 0.84rem;
}

.nav-toggle {
  display: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  width: 44px;
  height: 44px;
  border-radius: 10px;
}

.nav-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.nav-toggle span,
.nav-toggle span::before,
.nav-toggle span::after {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  margin: 0 auto;
  position: relative;
  border-radius: 4px;
}

.nav-toggle span::before,
.nav-toggle span::after {
  content: "";
  position: absolute;
  left: 0;
}

.nav-toggle span::before {
  top: -6px;
}

.nav-toggle span::after {
  top: 6px;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 18px;
}

.top-nav a {
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
}

.top-nav a:hover {
  color: var(--primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 12px 20px;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.14s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  box-shadow: 0 10px 22px rgba(13, 73, 172, 0.25);
}

.btn-primary:hover {
  box-shadow: 0 16px 26px rgba(13, 73, 172, 0.3);
}

.btn-accent {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 10px 22px rgba(200, 34, 51, 0.22);
}

.btn-accent:hover {
  box-shadow: 0 16px 26px rgba(200, 34, 51, 0.28);
}

.btn-ghost {
  color: var(--primary);
  background: #eef4ff;
  border: 1px solid #c5d7f8;
}

.btn-sm {
  padding: 10px 14px;
  font-size: 0.86rem;
}

.page-main {
  flex: 1 0 auto;
  padding: 28px 0 64px;
}

.hero {
  margin-top: 10px;
}

.hero-grid {
  display: grid;
  gap: 22px;
}

.hero-copy {
  text-align: center;
}

h1,
h2,
h3 {
  line-height: 1.2;
  margin: 0 0 10px;
}

h1 {
  font-size: clamp(1.7rem, 2.5vw, 2.7rem);
}

h2 {
  font-size: clamp(1.4rem, 2vw, 1.95rem);
}

p {
  margin: 0 0 14px;
}

.lead {
  font-size: clamp(1rem, 1.2vw, 1.18rem);
  color: var(--muted);
  max-width: 760px;
  margin: 0 auto 16px;
}

.hero-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.game-shell {
  width: min(1100px, 100%);
  margin: 14px auto 0;
  background: var(--surface);
  border: 1px solid #d9e5fb;
  border-radius: 24px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.game-topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #f8fbff, #edf4ff);
}

.score-card {
  flex: 1;
  min-width: 130px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.score-title {
  margin: 0;
  font-size: 0.78rem;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.score-value {
  margin: 4px 0 0;
  font-size: 1.3rem;
  font-weight: 800;
}

.game-stage {
  display: grid;
  grid-template-columns: 1fr 296px;
  gap: 14px;
  padding: 14px;
}

.board-wrap {
  background: #eef3fb;
  border: 1px solid #cfdcf3;
  border-radius: 20px;
  padding: 16px;
  position: relative;
}

.board {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  aspect-ratio: 1 / 1;
  display: grid;
  gap: 8px;
  background: #eef3fb;
  padding: 16px;
  border-radius: 20px;
  box-shadow: inset 0 0 0 1px rgba(47, 111, 228, 0.18);
}

.board-cell {
  border: 2px solid #d7e3f8;
  border-radius: 11px;
  background: #f8fafc;
  box-shadow: none;
  cursor: pointer;
  transition:
    background-color 0.12s ease,
    border-color 0.12s ease,
    box-shadow 0.12s ease,
    transform 0.12s ease;
}

.board-cell:hover {
  border-color: #b9cff2;
}

.board-cell:active {
  transform: scale(0.99);
}

.board-cell.fill-1 {
  background: #d5e4ff;
  border-color: #2f6fe4;
  box-shadow: inset 0 1px 5px rgba(22, 69, 164, 0.2);
}

.board-cell.fill-2 {
  background: #cfe0ff;
  border-color: #2f6fe4;
  box-shadow: inset 0 1px 6px rgba(22, 69, 164, 0.24);
}

.board-cell.fill-3 {
  background: #ffd6dc;
  border-color: #e5485d;
  box-shadow: inset 0 1px 6px rgba(169, 34, 53, 0.22);
}

.board-cell.preview-valid {
  transform: scale(1.02);
}

.board-cell.preview-valid.preview-blue {
  background: #9fc0ff;
  border-color: #1456d9;
  box-shadow:
    0 0 0 2px rgba(20, 86, 217, 0.24),
    0 0 14px rgba(20, 86, 217, 0.25);
}

.board-cell.preview-valid.preview-red {
  background: #ffb7c2;
  border-color: #d92d45;
  box-shadow:
    0 0 0 2px rgba(217, 45, 69, 0.2),
    0 0 14px rgba(217, 45, 69, 0.23);
}

.board-cell.preview-invalid {
  background: #ffe3e6;
  border-color: #d92d45;
  box-shadow: 0 0 0 2px rgba(217, 45, 69, 0.16);
}

.board-cell.place-pop {
  transform: scale(1.04);
}

.board-cell.clearing {
  background: #ffe58a;
  border-color: #d4a500;
  box-shadow:
    0 0 0 2px rgba(212, 165, 0, 0.22),
    0 0 16px rgba(212, 165, 0, 0.32);
}

.game-overlay {
  position: absolute;
  inset: 14px;
  background: rgba(10, 24, 52, 0.72);
  border-radius: 16px;
  color: #fff;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 14px;
}

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

.game-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel {
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
}

.panel h3 {
  font-size: 1rem;
  margin-bottom: 10px;
}

.pieces {
  display: grid;
  gap: 10px;
}

.piece {
  border: 1px solid #c8daf8;
  border-radius: 12px;
  background: #fff;
  padding: 8px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.2s ease, transform 0.08s ease;
}

.piece:hover {
  border-color: #1b5fd2;
}

.piece:active {
  transform: scale(0.98);
}

.piece.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(229, 63, 80, 0.18);
}

.piece.used {
  opacity: 0.4;
  cursor: not-allowed;
}

.piece-grid {
  display: inline-grid;
  gap: 5px;
}

.piece-cell {
  width: 16px;
  height: 16px;
  border-radius: 5px;
  background: #ffffff;
  border: 2px solid #c8d8f2;
}

.piece-cell.on-1 {
  background: #d5e4ff;
  border-color: #2f6fe4;
}

.piece-cell.on-2 {
  background: #d5e4ff;
  border-color: #2f6fe4;
}

.piece-cell.on-3 {
  background: #ffd9df;
  border-color: #e5485d;
}

.controls {
  display: grid;
  gap: 8px;
}

.control-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.game-status {
  margin: 8px 0 0;
  min-height: 22px;
  color: var(--muted);
  font-size: 0.92rem;
}

.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 6px 12px;
  border: 1px solid #c9dcf7;
  background: #f4f8ff;
  font-size: 0.83rem;
  font-weight: 700;
  color: var(--primary-strong);
}

.card-grid {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.card-grid.modes {
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
}

.card-grid.info {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 6px 16px rgba(22, 61, 126, 0.08);
  transition: transform 0.14s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 24px rgba(22, 61, 126, 0.13);
  border-color: #b4cdf6;
}

.card h3 {
  margin-bottom: 6px;
  font-size: 1.08rem;
}

.section {
  margin-top: 36px;
}

.steps,
.bullet-list,
.faq-list,
.links-list {
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.steps li,
.bullet-list li,
.links-list li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}

.links-list li {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    background-color 0.15s ease,
    border-color 0.15s ease;
}

.links-list li:hover,
.links-list li:focus-within {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
  background: #f8fbff;
  border-color: #c9dcf7;
}

.links-list li > a {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 56px;
  padding: 12px 14px;
  padding-right: 180px;
  text-decoration: none;
  cursor: pointer;
}

.links-list li > a:hover {
  text-decoration: none;
}

.links-list li > a:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: -2px;
  border-radius: 12px;
}

.links-list li .badge {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  pointer-events: none;
}

.mode-list {
  display: grid;
  gap: 10px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.mode-list li {
  margin: 0;
}

.mode-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 16px 20px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid #e3eaf6;
  text-decoration: none;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    background-color 0.15s ease,
    border-color 0.15s ease;
}

.mode-card:hover,
.mode-card:focus-visible {
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
  background: #f8fbff;
  border-color: #c9dcf7;
  text-decoration: none;
}

.mode-card:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.mode-title {
  font-weight: 700;
  color: var(--text);
}

.mode-button {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 84px;
  border-radius: 999px;
  padding: 8px 14px;
  border: 1px solid #c2d7fb;
  background: #eef4ff;
  color: #1f56bf;
  font-size: 0.85rem;
  font-weight: 700;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.mode-card:hover .mode-button,
.mode-card:focus-visible .mode-button {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

.faq-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}

.faq-item summary {
  cursor: pointer;
  font-weight: 700;
}

.faq-item p {
  margin: 10px 0 0;
  color: var(--muted);
}

.seo-text {
  background: linear-gradient(180deg, #ffffff 0%, #f5f9ff 100%);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
}

.seo-text p,
.seo-text li {
  color: #2a3d5f;
}

.breadcrumbs {
  margin: 4px 0 16px;
  font-size: 0.9rem;
  color: var(--muted);
}

.breadcrumbs a {
  color: var(--muted);
}

.breadcrumbs span {
  margin: 0 6px;
}

.notice {
  border-radius: 12px;
  border: 1px solid #c0daf8;
  background: #edf6ff;
  padding: 12px 14px;
  color: #204579;
}

.site-footer {
  margin-top: 42px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.site-footer-inner {
  width: var(--container);
  margin: 0 auto;
  padding: 22px 0 30px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.site-footer__credit {
  margin-left: auto;
  font-size: 0.875rem;
  color: var(--muted);
  opacity: 0.8;
  white-space: nowrap;
}

.site-footer__credit a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease, opacity 0.2s ease;
}

.site-footer__credit a:hover,
.site-footer__credit a:focus-visible {
  opacity: 1;
  border-bottom-color: currentColor;
  outline: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

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

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

@media (max-width: 860px) {
  .top-nav {
    position: absolute;
    top: 76px;
    right: 3vw;
    left: 3vw;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 18px 32px rgba(14, 42, 90, 0.15);
    padding: 12px;
    display: none;
    flex-direction: column;
    align-items: stretch;
  }

  .top-nav.open {
    display: flex;
  }

  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .site-header-inner {
    min-height: 70px;
  }

  .top-nav .btn {
    width: 100%;
  }

  .site-footer__credit {
    margin-left: 0;
    white-space: normal;
  }
}

@media (max-width: 640px) {
  .page-main {
    padding-top: 20px;
  }

  .game-shell {
    border-radius: 18px;
  }

  .game-topbar,
  .game-stage {
    padding: 10px;
  }

  .board-wrap {
    padding: 10px;
  }

  .board {
    gap: 6px;
    padding: 10px;
  }

  .piece-cell {
    width: 14px;
    height: 14px;
  }

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

  .control-row {
    grid-template-columns: 1fr;
  }

  .links-list li > a {
    padding-right: 132px;
  }

  .score-value {
    font-size: 1.12rem;
  }
}
