:root {
  --cream: #fff4e0;
  --card: #fffbf2;
  --ink: #3d2b22;
  --ink-soft: #6b5446;
  --sky: #a7d8ec;
  --sky-light: #ddf1f8;
  --mint: #9fd8b0;
  --mint-light: #d4eedb;
  --mint-deep: #3f8f63;
  --coral: #ee8e73;
  --coral-light: #f8d3c6;
  --coral-deep: #c45a43;
  --butter: #f7d774;
  --butter-light: #fbeab4;
  --peach: #f9c7a8;
  --lavender: #c9b8e8;
  --lavender-light: #e7def6;
  --line: 3px solid var(--ink);
  --shadow: 4px 4px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --round: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Hiragino Maru Gothic ProN", "Nunito", system-ui, sans-serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --wide: 1120px;
  --read: 680px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background-color: var(--cream);
  background-image: radial-gradient(rgba(61, 43, 34, 0.07) 1.2px, transparent 1.2px);
  background-size: 22px 22px;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
}

a { color: var(--coral-deep); text-underline-offset: 3px; text-decoration-thickness: 2px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px dashed var(--coral-deep); outline-offset: 3px; }

.skip { position: absolute; left: -9999px; top: 0; background: var(--ink); color: var(--cream); padding: 8px 12px; }
.skip:focus { left: 8px; top: 8px; z-index: 10; }

.wrap { max-width: var(--wide); margin: 0 auto; padding: 0 24px; }
.read { max-width: var(--read); }

h1, h2, h3 { font-family: var(--round); font-weight: 800; line-height: 1.15; margin: 0; letter-spacing: 0.005em; }
h1 { font-size: 46px; }
h2 { font-size: 32px; }
h3 { font-size: 21px; }
p { margin: 0 0 1em; }
.lede { font-size: 19px; line-height: 1.6; }
.muted { color: var(--ink-soft); }
.small { font-size: 14px; }

/* Header */
.site-header { background: var(--card); border-bottom: var(--line); position: relative; z-index: 2; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-top: 14px; padding-bottom: 14px; flex-wrap: wrap; }
.wordmark { display: inline-flex; align-items: center; gap: 10px; font-family: var(--round); font-size: 26px; font-weight: 800; color: var(--ink); text-decoration: none; }
.wordmark:hover { color: var(--ink); }
.wordmark .mark { width: 34px; height: 34px; flex: none; }
.site-nav { display: flex; gap: 10px; flex-wrap: wrap; }
.site-nav a {
  font-family: var(--round); font-weight: 700; font-size: 15px; color: var(--ink); text-decoration: none;
  padding: 6px 14px; border: 2.5px solid transparent; border-radius: 999px;
}
.site-nav a:hover { border-color: var(--ink); background: var(--butter-light); }
.site-nav a[aria-current="page"] { border-color: var(--ink); background: var(--butter); }

/* Buttons */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--round); font-size: 17px; font-weight: 800; letter-spacing: 0.01em;
  padding: 11px 22px; border: var(--line); border-radius: 14px;
  background: var(--butter); color: var(--ink); text-decoration: none; cursor: pointer;
  box-shadow: var(--shadow); transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.button:hover { color: var(--ink); background: #f9df8d; }
.button:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.button.secondary { background: var(--card); }
.button.secondary:hover { background: var(--butter-light); }
.button.up { background: var(--mint); }
.button.up:hover { background: #b2e1c0; }
.button.down { background: var(--coral); }
.button.down:hover { background: #f2a38c; }
.button .tri { font-size: 13px; }
.textlink { font-family: var(--round); font-weight: 700; color: var(--ink); }

/* Panels (retro dialog boxes) */
.panel-box { background: var(--card); border: var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 24px 26px; }
.tag {
  display: inline-block; font-family: var(--round); font-weight: 800; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase;
  background: var(--card); border: 2.5px solid var(--ink); border-radius: 999px; padding: 3px 12px; margin: 0 0 14px;
}
.tag.sky { background: var(--sky-light); }
.tag.mint { background: var(--mint-light); }
.tag.coral { background: var(--coral-light); }
.tag.butter { background: var(--butter-light); }
.tag.lav { background: var(--lavender-light); }

/* Hero */
.hero { position: relative; background: var(--sky-light); border-bottom: var(--line); overflow: hidden; }
.hero .wrap { position: relative; z-index: 1; padding-top: 56px; padding-bottom: 230px; }
.hero-card { max-width: 600px; }
.hero h1 { margin-bottom: 16px; }
.actions { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; margin-top: 22px; }
.sun { position: absolute; top: 34px; right: 9%; width: 96px; height: 96px; }
.cloud { position: absolute; width: 150px; height: 70px; }
.cloud.c1 { top: 40px; right: 30%; }
.cloud.c2 { top: 150px; right: 4%; width: 120px; }
.cloud.c3 { top: 22px; left: 46%; width: 110px; display: none; }
.ground { position: absolute; left: 0; right: 0; bottom: -2px; width: 100%; height: auto; display: block; }
@media (prefers-reduced-motion: no-preference) {
  .cloud.c1 { animation: drift 26s ease-in-out infinite alternate; }
  .cloud.c2 { animation: drift 32s ease-in-out infinite alternate-reverse; }
  @keyframes drift { from { transform: translateX(0); } to { transform: translateX(-40px); } }
}

/* Sections */
.section { padding: 64px 0; }
.section-title { margin-bottom: 26px; }
.section-title p { margin: 10px 0 0; max-width: var(--read); }

.levels { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.levels li { position: relative; padding-top: 30px; }
.coin {
  position: absolute; top: 0; left: 22px; width: 44px; height: 44px; border-radius: 50%;
  background: var(--butter); border: var(--line); display: grid; place-items: center;
  font-family: var(--round); font-weight: 800; font-size: 19px; z-index: 1;
}
.levels .panel-box { padding-top: 30px; height: 100%; }
.levels h3 { margin-bottom: 8px; }
.levels p { margin: 0; }

.areas { display: grid; grid-template-columns: repeat(2, 1fr); gap: 22px; }
.area { display: grid; grid-template-columns: 64px 1fr; gap: 16px; align-items: start; }
.area .icon { width: 64px; height: 64px; border: var(--line); border-radius: 16px; display: grid; place-items: center; }
.area .icon svg { width: 40px; height: 40px; }
.area h3 { font-size: 20px; margin-bottom: 4px; }
.area p { margin: 0 0 8px; font-size: 16px; }
.area.mint .icon { background: var(--mint-light); }
.area.butter .icon { background: var(--butter-light); }
.area.sky .icon { background: var(--sky-light); }
.area.coral .icon { background: var(--coral-light); }
.status { font-family: var(--round); font-weight: 800; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.status.live { color: var(--mint-deep); }

/* Game cartridges */
.carts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.cart { position: relative; background: var(--card); border: var(--line); border-radius: 18px 18px 10px 10px; box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.cart .label { padding: 18px 22px 8px; border-bottom: var(--line); position: relative; min-height: 112px; }
.cart.mint .label { background: var(--mint-light); }
.cart.lav .label { background: var(--lavender-light); }
.cart.coral .label { background: var(--coral-light); }
.cart.butter .label { background: var(--butter-light); }
.cart .label h3 { font-size: 22px; margin-bottom: 4px; }
.cart .label h3 a { color: var(--ink); text-decoration: none; }
.cart .label .meta { font-size: 14px; color: var(--ink-soft); margin: 0; }
.cart .body { padding: 16px 22px 20px; display: flex; flex-direction: column; gap: 14px; flex: 1; }
.cart .body p { margin: 0; }
.cart .body .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: auto; flex-wrap: wrap; }
.cart .ridges { position: absolute; top: 10px; right: 14px; display: flex; gap: 4px; }
.cart .ridges i { width: 6px; height: 18px; border: 2px solid var(--ink); border-radius: 3px; background: var(--card); }
.stamp {
  font-family: var(--round); font-weight: 800; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase;
  border: 2.5px dashed var(--ink-soft); color: var(--ink-soft); border-radius: 10px; padding: 4px 10px; transform: rotate(-3deg);
}

/* Principles */
.rules { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 36px; }
.rules li { display: grid; grid-template-columns: 30px 1fr; gap: 12px; padding: 12px 0; border-bottom: 2px dashed rgba(61, 43, 34, 0.25); }
.rules li:nth-last-child(-n+2) { border-bottom: 0; }
.check { width: 28px; height: 28px; border: 2.5px solid var(--ink); border-radius: 8px; background: var(--mint); display: grid; place-items: center; margin-top: 2px; }
.check svg { width: 16px; height: 16px; }
.rules b { font-family: var(--round); font-weight: 800; font-size: 18px; display: block; }

/* Audience */
.cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.cols h3 { font-size: 20px; margin-bottom: 8px; }
.cols p { margin: 0; font-size: 16px; }

/* Inner pages */
.page-head { padding: 52px 0 28px; }
.page-head h1 { font-size: 42px; margin-bottom: 12px; }
.prose { padding: 8px 0 72px; }
.prose .panel-box { padding: 30px 34px; }
.prose h2 { font-size: 26px; margin: 34px 0 10px; }
.prose h2:first-child { margin-top: 0; }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin-bottom: 8px; }

/* Footer */
.site-footer { position: relative; background: var(--ink); color: var(--cream); margin-top: 40px; padding: 70px 0 42px; font-size: 15px; }
.site-footer .hills { position: absolute; top: -38px; left: 0; width: 100%; height: 40px; display: block; }
.site-footer .wrap { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: start; }
.site-footer .wordmark { color: var(--cream); font-size: 22px; }
.site-footer p { margin: 8px 0 0; color: #e9dcc8; }
.footer-nav { display: flex; gap: 18px; flex-wrap: wrap; }
.footer-nav a { color: var(--cream); font-family: var(--round); font-weight: 700; text-decoration: none; }
.footer-nav a:hover { text-decoration: underline; color: var(--butter); }

/* ---------- Game page ---------- */
.game-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; }
.game-meta { font-size: 15px; color: var(--ink-soft); margin: 0; }
.cabinet { background: var(--card); border: var(--line); border-radius: 22px; box-shadow: var(--shadow); overflow: hidden; margin-bottom: 32px; }
.cabinet-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 18px; background: var(--lavender-light); border-bottom: var(--line); }
.cabinet-top .title { font-family: var(--round); font-weight: 800; font-size: 16px; letter-spacing: 0.06em; text-transform: uppercase; }
.dots { display: flex; gap: 6px; }
.dots i { width: 14px; height: 14px; border-radius: 50%; border: 2.5px solid var(--ink); }
.dots i:nth-child(1) { background: var(--coral); }
.dots i:nth-child(2) { background: var(--butter); }
.dots i:nth-child(3) { background: var(--mint); }

.hud { display: flex; gap: 12px; flex-wrap: wrap; padding: 16px 18px 0; }
.hud .chip { display: flex; align-items: baseline; gap: 8px; background: var(--cream); border: 2.5px solid var(--ink); border-radius: 12px; padding: 6px 14px; }
.hud .chip span { font-family: var(--round); font-weight: 800; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.hud .chip strong { font-family: var(--round); font-weight: 800; font-size: 22px; }

.game-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 330px; grid-template-rows: auto 1fr;
  grid-template-areas: "board ctrl" "board talk"; column-gap: 26px; padding: 18px; align-items: start;
}
.board { grid-area: board; width: 100%; }
.ctrl { grid-area: ctrl; }
.talk { grid-area: talk; }
.chart { width: 100%; height: 92px; display: block; background: var(--sky-light); border: 2.5px solid var(--ink); border-radius: 12px; margin-bottom: 14px; }
.grid1024 { display: grid; grid-template-columns: repeat(32, 1fr); gap: 3px; width: 100%; background: var(--cream); border: 2.5px solid var(--ink); border-radius: 12px; padding: 10px; }
.cell { aspect-ratio: 1 / 1; border-radius: 3px; background: var(--peach); transition: transform 0.35s ease, opacity 0.35s ease, background-color 0.2s ease; }
.cell.up { background: var(--mint-deep); }
.cell.down { background: var(--coral-deep); }
.cell.out { background: #eadfcd; transform: scale(0.55); opacity: 0.55; }
.cell.win { background: var(--butter); box-shadow: 0 0 0 2px var(--ink); transform: scale(1.35); position: relative; z-index: 1; }
@media (prefers-reduced-motion: reduce) { .cell { transition: none; } }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 14px; color: var(--ink-soft); margin: 12px 0 0; }
.legend span::before { content: ""; display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend .l-up::before { background: var(--mint-deep); }
.legend .l-down::before { background: var(--coral-deep); }
.legend .l-out::before { background: #eadfcd; }
.legend .l-win::before { background: var(--butter); box-shadow: 0 0 0 2px var(--ink); }

.side .controls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0 0 10px; }
.side .controls .button { padding: 14px 10px; font-size: 18px; }
.keys { margin: 0 0 14px; }
.history-label { font-family: var(--round); font-weight: 800; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); margin: 0; }
.history { font-size: 18px; letter-spacing: 0.06em; min-height: 28px; margin: 2px 0 0; }
.history .h-up { color: var(--mint-deep); }
.history .h-down { color: var(--coral-deep); }
.dialog { position: relative; margin-top: 16px; background: var(--card); border: var(--line); border-radius: 16px; padding: 14px 16px; font-size: 16px; box-shadow: var(--shadow-sm); }
.dialog .who { font-family: var(--round); font-weight: 800; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 4px; }
.dialog p:last-child { margin-bottom: 0; }
.post { margin: 12px 0 4px; padding: 12px 14px; border: 2.5px solid var(--ink); border-radius: 14px; background: var(--butter-light); font-size: 15px; }
.post .avatar { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--butter); border: 2.5px solid var(--ink); font-family: var(--round); font-weight: 800; font-size: 13px; margin-right: 8px; vertical-align: middle; }
.dialog .post .who { font-family: var(--round); font-weight: 800; font-size: 15px; text-transform: none; letter-spacing: 0; color: var(--ink); margin: 0; }
.mode-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.notice { font-size: 14px; color: var(--ink-soft); border-top: 2px dashed rgba(61, 43, 34, 0.25); padding-top: 12px; margin-top: 18px; }
.bump { animation: bump 0.35s ease; }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .bump { animation: none; } }

@media (max-width: 920px) {
  h1 { font-size: 38px; }
  .levels, .cols { grid-template-columns: 1fr; gap: 26px; }
  .areas, .carts, .rules { grid-template-columns: 1fr; }
  .rules li:nth-last-child(2) { border-bottom: 2px dashed rgba(61, 43, 34, 0.25); }
  .game-layout { grid-template-columns: 1fr; grid-template-rows: auto; grid-template-areas: "ctrl" "board" "talk"; row-gap: 14px; }
  .site-footer .wrap { grid-template-columns: 1fr; }
  .sun { right: 5%; width: 72px; height: 72px; }
  .cloud { display: none; }
}

@media (max-width: 560px) {
  body { font-size: 16px; }
  .wrap { padding: 0 16px; }
  h1 { font-size: 31px; }
  h2 { font-size: 26px; }
  .lede { font-size: 17px; }
  .wordmark { font-size: 22px; }
  .site-nav a { padding: 5px 10px; font-size: 14px; }
  .hero .wrap { padding-top: 32px; padding-bottom: 170px; }
  .panel-box { padding: 20px; }
  .ground { height: 190px; width: 100%; }
  .sun { top: auto; bottom: 150px; right: 6%; width: 56px; height: 56px; }
  .section { padding: 46px 0; }
  .grid1024 { gap: 2px; padding: 6px; }
  .game-layout { padding: 12px; }
  .hud { padding: 12px 12px 0; gap: 8px; }
  .hud .chip { padding: 4px 10px; }
  .hud .chip strong { font-size: 18px; }
  .keys { display: none; }
  .prose .panel-box { padding: 22px 20px; }
}
