:root {
  --bg: #f7f9fc;
  --panel: #ffffff;
  --text: #142033;
  --muted: #61708a;
  --line: #dfe6f0;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --tube: #eaf0f8;
  --tube-border: #b8c5d8;
  --shadow: 0 16px 48px rgba(35, 48, 70, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
}

a {
  color: inherit;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(18px, 5vw, 56px);
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  color: var(--primary);
  font-size: 18px;
  font-weight: 800;
  text-decoration: none;
}

.site-nav {
  display: flex;
  gap: 18px;
  color: var(--muted);
  font-size: 14px;
}

.site-nav a {
  text-decoration: none;
}

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

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 18px 64px;
}

.hero {
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: center;
}

.home-hero {
  align-items: center;
  background: linear-gradient(180deg, #ffffff, #eef5ff);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 0 auto;
  max-width: 900px;
  padding: clamp(32px, 7vw, 72px) 20px;
  text-align: center;
}

.hero-copy {
  max-width: 760px;
  text-align: center;
}

.eyebrow {
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin: 0 0 10px;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(32px, 4.5vw, 52px);
  line-height: 1;
  margin: 0 0 14px;
}

h2 {
  font-size: 24px;
  line-height: 1.25;
  margin: 0 0 12px;
}

.hero-text {
  color: var(--muted);
  font-size: 17px;
  max-width: 680px;
  margin: 0;
}

.game-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(18px, 3vw, 28px);
  width: min(100%, 760px);
}

.game-topbar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.game-topbar > div {
  background: #f3f6fb;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}

.stat-label {
  color: var(--muted);
  display: block;
  font-size: 12px;
}

.game-board {
  align-items: end;
  display: flex;
  gap: clamp(14px, 3vw, 28px);
  justify-content: center;
  min-height: 360px;
  overflow-x: auto;
  padding: 34px 4px 24px;
}

.tube-wrap {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tube {
  align-items: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.78), var(--tube));
  border: 3px solid var(--tube-border);
  border-top: 0;
  border-radius: 0 0 24px 24px;
  cursor: pointer;
  display: flex;
  flex-direction: column-reverse;
  height: 250px;
  justify-content: flex-start;
  min-width: 74px;
  padding: 10px 8px;
  position: relative;
  transition: transform 0.16s ease, border-color 0.16s ease;
}

.tube::before {
  background: rgba(255, 255, 255, 0.86);
  border: 3px solid var(--tube-border);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  content: "";
  height: 16px;
  left: -3px;
  position: absolute;
  right: -3px;
  top: -16px;
}

.tube.selected {
  border-color: var(--primary);
  transform: translateY(-8px);
}

.tube.selected::before {
  border-color: var(--primary);
}

.ball {
  border-radius: 999px;
  box-shadow: inset -8px -10px 18px rgba(0, 0, 0, 0.18), inset 8px 8px 14px rgba(255, 255, 255, 0.35);
  height: 56px;
  margin-top: 4px;
  width: 56px;
}

.tube-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

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

button,
.button-link {
  background: var(--primary);
  border: 0;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 800;
  justify-content: center;
  padding: 11px 16px;
  text-decoration: none;
}

button:hover,
.button-link:hover {
  background: var(--primary-dark);
}

button:disabled {
  background: #9aa8bc;
  cursor: not-allowed;
}

.game-message {
  color: var(--muted);
  margin: 14px 0 0;
  min-height: 26px;
  text-align: center;
}

.tutorial-box {
  align-items: center;
  background: #eef5ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  color: var(--text);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-top: 12px;
  padding: 12px 14px;
}

.tutorial-box button {
  flex: 0 0 auto;
  padding: 9px 12px;
}

.quick-rules {
  background: #f8fbff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  margin-top: 14px;
  padding: 12px 14px;
}

.quick-rules strong {
  color: var(--text);
}

.quick-rules ol {
  margin: 8px 0 0;
  padding-left: 20px;
}

.quick-rules li {
  margin: 4px 0;
}

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

.game-list {
  margin-top: 32px;
}

.game-card {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 24px;
  grid-template-columns: 220px minmax(0, 1fr);
  padding: 24px;
}

.game-card p {
  color: var(--muted);
}

.game-card-preview {
  align-items: center;
  background: #f3f6fb;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, 52px);
  justify-content: center;
  min-height: 180px;
}

.game-card-preview span {
  border-radius: 999px;
  box-shadow: inset -8px -10px 18px rgba(0, 0, 0, 0.18), inset 8px 8px 14px rgba(255, 255, 255, 0.35);
  height: 52px;
  width: 52px;
}

.content-grid article,
.faq,
.link-band,
.page-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
}

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

.link-band {
  align-items: center;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-top: 24px;
}

.faq {
  margin-top: 24px;
}

details {
  border-top: 1px solid var(--line);
  padding: 14px 0;
}

details:first-of-type {
  border-top: 0;
}

summary {
  cursor: pointer;
  font-weight: 800;
}

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

.dialog {
  align-items: center;
  background: rgba(10, 18, 32, 0.52);
  bottom: 0;
  display: flex;
  justify-content: center;
  left: 0;
  padding: 20px;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 20;
}

.dialog[hidden] {
  display: none;
}

.dialog-card {
  background: #fff;
  border-radius: 8px;
  max-width: 360px;
  padding: 28px;
  text-align: center;
  width: 100%;
}

.simple-page {
  max-width: 860px;
}

.simple-page h1 {
  font-size: clamp(34px, 5vw, 56px);
}

.tool-box {
  background: #f3f6fb;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  margin: 18px 0;
  padding: 18px;
}

textarea,
input {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  padding: 12px;
  width: 100%;
}

.output-box {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  min-height: 80px;
  padding: 14px;
}

@media (max-width: 820px) {
  .site-header,
  .link-band {
    align-items: flex-start;
    flex-direction: column;
  }

  main {
    padding: 18px 12px 48px;
  }

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

  .game-card-preview {
    min-height: 150px;
  }

  .hero {
    gap: 14px;
  }

  .hero-copy {
    max-width: 620px;
  }

  .eyebrow {
    font-size: 11px;
    margin-bottom: 6px;
  }

  h1 {
    font-size: clamp(30px, 8vw, 42px);
    margin-bottom: 10px;
  }

  .hero-text {
    font-size: 15px;
  }

  .game-panel {
    padding: 14px;
  }

  .game-topbar {
    margin-bottom: 10px;
  }

  .game-board {
    justify-content: flex-start;
    min-height: 230px;
    padding: 28px 2px 16px;
  }

  .tube {
    height: 188px;
    min-width: 56px;
  }

  .ball {
    height: 42px;
    width: 42px;
  }

  .tutorial-box {
    align-items: stretch;
    flex-direction: column;
  }

  .tutorial-box button {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .site-header {
    gap: 10px;
    padding: 12px;
  }

  .brand {
    font-size: 16px;
  }

  .site-nav {
    flex-wrap: wrap;
    gap: 10px;
  }

  .game-topbar {
    gap: 6px;
    grid-template-columns: repeat(3, 1fr);
  }

  .game-topbar > div {
    padding: 8px 6px;
  }

  .tube {
    height: 156px;
    min-width: 48px;
    padding: 7px 5px;
  }

  .ball {
    height: 34px;
    width: 34px;
  }

  .tube-label,
  .quick-rules,
  .game-message {
    font-size: 13px;
  }

  .controls button {
    flex: 1 1 96px;
    padding: 10px 12px;
  }
}
