:root {
  --bg: #0f1218;
  --panel: #161a23;
  --panel-2: #1c2130;
  --line: #2a3040;
  --text: #e6e9f0;
  --muted: #8f97ab;
  --accent: #3ec9dc;
  --danger: #ef5367;
  --I: #3ec9dc; --O: #e9cf3a; --T: #b65ee3; --S: #75d63b;
  --Z: #ef5367; --J: #4f71e8; --L: #f28a2c; --G: #50555f;
  --mono: Consolas, "Courier New", monospace;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 110px; }
body {
  margin: 0;
  background: radial-gradient(1200px 700px at 70% -10%, #1f2840 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Leelawadee UI", "Noto Sans Thai", Tahoma, system-ui, sans-serif;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); }
b { font-weight: 600; }
small { color: var(--muted); }
code, kbd { font-family: var(--mono); }
code { background: var(--panel-2); padding: 1px 6px; border-radius: 4px; }
.red { color: var(--danger); }
.purple { color: var(--T); }

/* ── top bar ───────────────────────────────────── */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px max(16px, calc((100% - 1080px) / 2));
  background: rgba(15, 18, 24, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.logo { font-family: var(--mono); letter-spacing: 0.12em; font-weight: 700; color: var(--accent); text-decoration: none; }
.btn {
  display: inline-block;
  padding: 8px 18px;
  border-radius: 999px;
  background: var(--accent);
  color: #06232a;
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(62, 201, 220, 0.35); }
.btn.big { padding: 14px 36px; font-size: 18px; }

/* ── hero ──────────────────────────────────────── */
.hero {
  max-width: 1080px;
  margin: 0 auto;
  padding: 48px 16px 24px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 48px;
  align-items: center;
}
.eyebrow { margin: 0; color: var(--accent); font-family: var(--mono); letter-spacing: 0.15em; font-size: 13px; text-transform: uppercase; }
.hero h1 { margin: 4px 0 12px; font-size: clamp(40px, 7vw, 64px); line-height: 1.1; }
.lead { font-size: 18px; color: #c9cfdc; margin: 0 0 8px; max-width: 34em; }
.lead.strong { color: var(--text); font-weight: 600; }
.quick { list-style: none; padding: 0; margin: 28px 0 0; display: flex; gap: 12px; flex-wrap: wrap; }
.quick li {
  display: flex; gap: 10px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 16px 10px 10px; flex: 1 1 150px;
}
.quick .num {
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: #06232a; font-weight: 700; font-family: var(--mono);
}
.quick b { display: block; line-height: 1.3; }
.quick small { display: block; line-height: 1.3; }

.demo { margin: 0; text-align: center; }
.demo figcaption {
  margin-top: 12px; min-height: 1.6em;
  font-family: var(--mono); letter-spacing: 0.04em; color: var(--muted);
  transition: color 0.2s;
}
.demo figcaption.pop { color: var(--O); font-weight: 700; }

/* ── section nav chips ─────────────────────────── */
.chips {
  position: sticky; top: 53px; z-index: 9;
  display: flex; gap: 8px; overflow-x: auto;
  padding: 10px max(16px, calc((100% - 1080px) / 2));
  background: rgba(15, 18, 24, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chips a {
  flex: none;
  padding: 5px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel);
  color: var(--text); text-decoration: none; font-size: 14px;
  transition: border-color 0.15s, color 0.15s;
}
.chips a:hover, .chips a.on { border-color: var(--accent); color: var(--accent); }

/* ── sections ──────────────────────────────────── */
main { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
section { padding: 56px 0 16px; }
section h2 {
  display: flex; align-items: baseline; gap: 14px;
  font-size: clamp(26px, 4vw, 34px); margin: 0 0 16px;
}
.sec { font-family: var(--mono); font-size: 15px; color: var(--accent); letter-spacing: 0.1em; }
h3 { margin: 0 0 12px; font-size: 19px; }
h3.sub { margin-top: 36px; }
.intro { font-size: 17px; color: #c9cfdc; max-width: 46em; margin: 0 0 24px; }
.note {
  margin-top: 20px; padding: 12px 16px;
  border-left: 3px solid var(--accent);
  background: var(--panel); border-radius: 0 10px 10px 0;
  color: #c9cfdc;
}
.hint { font-size: 14px; color: var(--muted); margin: 12px 0 0; }
.tag { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: rgba(182, 94, 227, 0.18); color: var(--T); margin-left: 6px; vertical-align: middle; }

.panel, .card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cards { display: grid; gap: 16px; }
.cards.four { grid-template-columns: repeat(4, 1fr); }
.cards.three { grid-template-columns: repeat(3, 1fr); }
.card h3 { margin-bottom: 6px; }
.card p { margin: 0; color: #c9cfdc; font-size: 15px; }
.card .icon {
  width: 44px; height: 44px; border-radius: 12px; margin-bottom: 14px;
  display: grid; place-items: center; font-size: 22px;
  color: var(--c); background: color-mix(in srgb, var(--c) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 40%, transparent);
}

/* ── controls ──────────────────────────────────── */
.keys, .gestures { list-style: none; margin: 0; padding: 0; }
.keys li {
  display: grid; grid-template-columns: 130px 1fr; align-items: center; gap: 12px;
  padding: 9px 0; border-bottom: 1px dashed var(--line);
}
.keys li:last-child { border-bottom: 0; }
.keys li small { display: block; font-size: 13px; }
.keys span { display: flex; gap: 6px; flex-wrap: wrap; }
kbd {
  display: inline-grid; place-items: center;
  min-width: 34px; height: 34px; padding: 0 8px;
  border-radius: 8px;
  background: linear-gradient(#2b3245, #20263a);
  border: 1px solid #3a4258;
  box-shadow: 0 3px 0 #0b0e14;
  color: var(--text); font-size: 14px; font-weight: 700;
}
kbd.wide { min-width: 80px; }
.gestures li { display: flex; gap: 14px; align-items: center; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.gestures small { display: block; font-size: 13px; }
.g {
  flex: none; width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--panel-2); border: 1px solid var(--line);
  color: var(--accent); font-size: 20px;
}
.small-label { margin: 16px 0 8px; font-size: 13px; color: var(--muted); }
.touchbar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.touchbar span {
  display: grid; place-items: center; height: 42px;
  border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line);
  font-size: 18px;
}
.touchbar .txt { font-size: 11px; font-family: var(--mono); font-weight: 700; }

/* ── board diagrams (drawn by how.js) ──────────── */
.bd {
  --cell: 18px;
  display: inline-grid;
  grid-template-columns: repeat(10, var(--cell));
  grid-auto-rows: var(--cell);
  gap: 1px;
  padding: 4px;
  background: #0b0e14;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.bd.big { --cell: 26px; }
.bd i { display: block; border-radius: 3px; background: rgba(255, 255, 255, 0.025); }
.bd i[data-c] {
  background: var(--k);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25), inset 0 2px 0 rgba(255, 255, 255, 0.25);
}
.bd i.act { outline: 2px solid #fff; outline-offset: -2px; }
.bd i.ghost { background: transparent; box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--k) 55%, transparent); }
.bd .flash i { animation: flash 0.5s ease-in-out infinite alternate; }
.bd.row-flash-static .flash i { animation: none; filter: brightness(1.5); }
@keyframes flash { to { filter: brightness(1.9); } }
.bd .row { display: contents; }

/* ── pieces ────────────────────────────────────── */
.pieces { display: grid; grid-template-columns: repeat(7, 1fr); gap: 12px; margin-bottom: 20px; }
.piece {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 8px 10px; text-align: center;
}
.piece .shape {
  --cell: 16px;
  display: inline-grid; grid-template-columns: repeat(4, var(--cell)); grid-auto-rows: var(--cell); gap: 2px;
  height: calc(var(--cell) * 2 + 2px);
}
.piece .shape i { border-radius: 3px; }
.piece .shape i[data-c] { background: var(--k); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25), inset 0 2px 0 rgba(255, 255, 255, 0.25); }
.piece b { display: block; margin-top: 8px; font-family: var(--mono); font-size: 18px; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.facts.two { grid-template-columns: 1fr 1fr; margin-top: 20px; }
.fact { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.fact p { margin: 4px 0 0; color: #c9cfdc; font-size: 15px; }

/* ── attack bars ───────────────────────────────── */
.bars { display: grid; gap: 10px; }
.bar { display: grid; grid-template-columns: 120px 1fr 28px; gap: 12px; align-items: center; }
.bar .lbl { font-family: var(--mono); font-size: 13px; font-weight: 700; letter-spacing: 0.04em; line-height: 1.2; }
.bar .lbl small { display: block; font-family: inherit; font-weight: 400; font-size: 12px; }
.bar .track { height: 14px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.bar .track i {
  display: block; height: 100%;
  width: calc(var(--v) / 6 * 100%);
  min-width: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff8796, var(--danger));
  transform-origin: left; transform: scaleX(0);
  transition: transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.bars.shown .track i { transform: scaleX(1); }
.bar.t .track i { background: linear-gradient(90deg, #d79af2, var(--T)); }
.bar > b { font-family: var(--mono); font-size: 18px; text-align: right; }
.bar.hot > b { color: var(--O); }
.bar.t .lbl { font-size: 12px; }

.tspin { display: flex; align-items: center; justify-content: center; gap: 24px; flex-wrap: wrap; margin-top: 24px; }
.tspin figure { margin: 0; text-align: center; max-width: 240px; }
.tspin figcaption { margin-top: 8px; font-size: 14px; color: #c9cfdc; }
.arrow { font-size: 34px; color: var(--T); }

.bonus .big-num { font-family: var(--mono); font-size: 30px; font-weight: 700; color: var(--O); margin-bottom: 4px; }
.mini-table { width: 100%; margin-top: 12px; border-collapse: collapse; font-size: 14px; }
.mini-table td { padding: 4px 0; border-bottom: 1px solid var(--line); }
.mini-table td:first-child { font-family: var(--mono); color: var(--muted); }
.mini-table td:last-child { text-align: right; font-family: var(--mono); font-weight: 700; }

.boost {
  margin-top: 16px; padding: 22px; border-radius: var(--radius);
  background: linear-gradient(120deg, rgba(239, 83, 103, 0.14), rgba(242, 138, 44, 0.08));
  border: 1px solid rgba(239, 83, 103, 0.35);
}
.boost h3 { color: #ff8796; margin-bottom: 4px; }
.boost-head p { margin: 0 0 16px; color: #d8dce6; }
.timeline { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.timeline div {
  text-align: center; padding: 10px 4px; border-radius: 10px;
  background: rgba(15, 18, 24, 0.6); border: 1px solid rgba(239, 83, 103, 0.25);
}
.timeline b { display: block; font-family: var(--mono); font-size: 20px; }
.timeline div:nth-child(1) b { color: #ffd0d6; }
.timeline div:nth-child(2) b { color: #ffadb7; }
.timeline div:nth-child(3) b { color: #ff8796; }
.timeline div:nth-child(4) b { color: #ff6b7d; }
.timeline div:nth-child(5) b { color: var(--danger); }
.timeline small { font-size: 12px; }

.example {
  margin-top: 16px; padding: 18px 22px; border-radius: var(--radius);
  background: var(--panel); border: 1px dashed #3a4258;
  display: grid; grid-template-columns: auto 1fr; column-gap: 16px; align-items: center;
}
.ex-label {
  grid-row: span 2;
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.1em;
  padding: 4px 10px; border-radius: 6px; background: var(--panel-2); color: var(--muted);
}
.example p { margin: 0; }
.calc { font-family: var(--mono); font-size: 20px; margin-top: 4px !important; }
.calc small { font-size: 11px; vertical-align: super; }

/* ── garbage ───────────────────────────────────── */
.garbage-flow { display: grid; grid-template-columns: 1fr auto 1fr; gap: 20px; align-items: center; }
.step { text-align: center; }
.step > b { display: block; margin-top: 10px; font-size: 17px; }
.step p { margin: 4px auto 0; color: #c9cfdc; font-size: 15px; max-width: 22em; }
.gwrap { display: inline-flex; gap: 6px; align-items: stretch; }
.meter { width: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; position: relative; overflow: hidden; }
.meter i { position: absolute; left: 0; right: 0; bottom: 0; background: var(--danger); box-shadow: 0 0 12px var(--danger); }
.step.good {
  max-width: 230px; padding: 20px; border-radius: var(--radius);
  background: rgba(117, 214, 59, 0.08); border: 1px solid rgba(117, 214, 59, 0.35);
}
.step.good > b { color: var(--S); margin-top: 6px; }
.vs { font-family: var(--mono); font-size: 13px; color: var(--S); letter-spacing: 0.06em; }

/* ── lose / win ────────────────────────────────── */
.ticks { list-style: none; padding: 0; margin: 0; }
.ticks li { position: relative; padding: 8px 0 8px 34px; border-bottom: 1px dashed var(--line); }
.ticks li:last-child { border-bottom: 0; }
.ticks.x li::before {
  content: "✕"; position: absolute; left: 0; top: 8px;
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px;
  background: rgba(239, 83, 103, 0.18); color: var(--danger);
}
.panel.lose { border-color: rgba(239, 83, 103, 0.35); }
.panel.win { border-color: rgba(233, 207, 58, 0.4); background: linear-gradient(160deg, rgba(233, 207, 58, 0.1), var(--panel) 60%); }
.panel.win p { margin: 0; color: #d8dce6; }
.crown { font-size: 44px; line-height: 1; margin-bottom: 10px !important; }

/* ── tips ──────────────────────────────────────── */
.tips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.tip { display: flex; gap: 14px; align-items: flex-start; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.tip span { font-family: var(--mono); font-weight: 700; color: var(--accent); font-size: 20px; line-height: 1.3; }
.tip p { margin: 0; color: #c9cfdc; }
.tip b { color: var(--text); }

/* ── host ──────────────────────────────────────── */
.host-steps { list-style: none; counter-reset: s; padding: 0; margin: 0; display: grid; gap: 10px; }
.host-steps li {
  counter-increment: s;
  position: relative; padding: 14px 18px 14px 60px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  color: #c9cfdc;
}
.host-steps li b { color: var(--text); }
.host-steps li::before {
  content: counter(s);
  position: absolute; left: 16px; top: 13px;
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--mono); font-weight: 700;
  background: var(--panel-2); border: 1px solid var(--accent); color: var(--accent);
}

.cta { text-align: center; padding: 64px 0 32px; }
.cta h2 { margin: 0 0 18px; font-size: 30px; }
footer { text-align: center; color: var(--muted); font-family: var(--mono); font-size: 12px; letter-spacing: 0.1em; padding: 24px 16px 40px; }

/* ── small screens ─────────────────────────────── */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 28px; padding-top: 32px; }
  .demo { order: -1; }
  .cards.four { grid-template-columns: 1fr 1fr; }
  .cards.three, .facts, .tips { grid-template-columns: 1fr 1fr; }
  .pieces { grid-template-columns: repeat(4, 1fr); }
  .garbage-flow { grid-template-columns: 1fr; }
  .step.good { max-width: none; }
}
@media (max-width: 640px) {
  .split, .cards.four, .cards.three, .facts, .facts.two, .tips { grid-template-columns: 1fr; }
  .bd.big { --cell: 17px; }
  .lead { font-size: 16px; }
  .intro { font-size: 16px; }
  .timeline { grid-template-columns: repeat(3, 1fr); }
  .keys li { grid-template-columns: 110px 1fr; }
  .bar { grid-template-columns: 104px 1fr 24px; }
  .example { grid-template-columns: 1fr; }
  .ex-label { grid-row: auto; justify-self: start; margin-bottom: 8px; }
  .calc { font-size: 17px; }
  .chips { top: 51px; }
}
@media (max-width: 380px) {
  .pieces { gap: 8px; }
  .piece { padding: 12px 4px 8px; }
  .piece .shape { --cell: 12px; }
  .bd { --cell: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .bd .flash i { animation: none; filter: brightness(1.5); }
  .bar .track i { transition: none; }
}
