:root {
  --bg: #faf9f6; --surface: #ffffff; --surface-2: #f3f1ec; --ink: #16282a; --body: #3a4a49; --body-strong: #2a3a39; --body-2: #52605f; --muted: #68756f; --line: #e7e3dc;
  --accent: #0f766e; --accent-soft: #e2f1ee; --peach: #f2a08f; --peach-soft: #fde8e3;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --segvh: 66vh;
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
.nojs { padding: 20px; }

#scroller { position: relative; height: calc(var(--segs, 20) * var(--segvh) + 100vh); }
.stage { position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; background: var(--bg); overflow: hidden; }

.bar { flex: none; display: flex; align-items: center; gap: 18px; padding: 8px clamp(14px, 2.4vw, 32px); min-height: 54px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: -.01em; text-decoration: none; white-space: nowrap; }
.logo { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--accent); color: #fff; }
.where { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; color: var(--muted); }
.count { flex: none; font-size: 12px; font-weight: 700; padding: 5px 12px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-variant-numeric: tabular-nums; transition: opacity .3s; }

.arena { position: relative; flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr; padding: clamp(12px, 2vw, 22px) clamp(14px, 2.4vw, 32px); }
.arena[data-mode="intro"] .board { opacity: 0; visibility: hidden; pointer-events: none; }
.board { transition: opacity .5s ease, visibility .5s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn { font: inherit; font-weight: 700; font-size: 13.5px; padding: 11px 18px; border-radius: 999px; border: 1.5px solid var(--ink); background: var(--ink); color: #fff; cursor: pointer; transition: transform .2s, box-shadow .2s; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(28, 25, 23, .18); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--ink); box-shadow: none; }

.board { position: relative; min-height: 0; border-radius: 24px; background: #fff; border: 1px solid var(--line); box-shadow: 0 14px 40px rgba(28, 25, 23, .07); overflow: hidden; background-image: radial-gradient(#e9e5dc 1px, transparent 1px); background-size: 22px 22px; }
#dia { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.cap { position: absolute; left: 14px; right: 14px; top: 12px; padding: 8px 14px; border-radius: 12px; background: rgba(22, 40, 42, .9); color: #fff; font-size: 13.5px; font-weight: 600; opacity: 0; transform: translateY(-6px); transition: opacity .25s, transform .25s; pointer-events: none; }
.cap.on { opacity: 1; transform: none; }
.dots { position: absolute; left: 0; right: 0; bottom: 10px; display: flex; justify-content: center; gap: 6px; }
.dots button { width: 9px; height: 9px; padding: 0; border-radius: 50%; border: 0; background: #d8d3c9; cursor: pointer; transition: transform .2s, background .2s; }
.dots button.done { background: var(--accent); opacity: .5; } .dots button.cur { background: var(--accent); transform: scale(1.5); opacity: 1; }

/* diagram parts */
#dia .g, #dia .e, #dia .n, #dia .t { opacity: 0; }
#dia text { font-family: var(--font); }
.n .in { transition: none; }
.n .ring { fill: none; stroke: var(--accent); stroke-width: 3; opacity: 0; }
.n.cur .ring { opacity: 1; animation: ring 1.4s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes ring { 0% { transform: scale(.85); opacity: .9; } 100% { transform: scale(1.35); opacity: 0; } }
.n { cursor: default; } .final .n { cursor: pointer; }
.final .n:hover .tile, .final .n:hover image { filter: drop-shadow(0 4px 8px rgba(28, 25, 23, .25)); }
.fxdot { fill: var(--accent); stroke: #fff; stroke-width: 2; }

/* intro */
.intro { position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; gap: clamp(18px, 4vw, 56px); padding: 20px clamp(18px, 6vw, 90px); pointer-events: none; }
.i-art { flex: none; width: clamp(150px, 22vw, 260px); aspect-ratio: 400 / 450; }
.i-art img { width: 100%; height: 100%; display: block; filter: drop-shadow(0 16px 20px rgba(28, 25, 23, .16)); animation: float 3.6s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.i-copy { max-width: 560px; }
.i-copy h2 { margin: 0; font-size: clamp(24px, 3.2vw, 42px); letter-spacing: -.03em; line-height: 1.12; }
.i-copy h2.pop { animation: rise .45s cubic-bezier(.2, .9, .3, 1) both; }

.outro { max-width: 760px; margin: 0 auto; padding: 40px 22px 60px; color: var(--muted); font-size: 13px; line-height: 1.6; text-align: center; }
.outro a { color: var(--accent); font-weight: 600; }

/* full-page diagram */
.modal { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; background: var(--bg); }
.modal[hidden] { display: none; }
.m-head { flex: none; display: flex; align-items: center; gap: 14px; padding: 12px clamp(14px, 3vw, 32px); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.m-head h2 { margin: 0; font-size: 18px; letter-spacing: -.01em; }
.m-tools { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.m-tools button { font: inherit; font-weight: 600; font-size: 13px; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.m-tools button:hover { border-color: var(--ink); }
.m-x { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: #fff; font-size: 22px; line-height: 1; cursor: pointer; }
.m-body { flex: 1; min-height: 0; background-image: radial-gradient(#e9e5dc 1px, transparent 1px); background-size: 22px 22px; cursor: grab; touch-action: none; }
.m-body.drag { cursor: grabbing; }
.m-body svg { width: 100%; height: 100%; display: block; }
.m-body svg .g, .m-body svg .e, .m-body svg .n, .m-body svg .t { opacity: 1 !important; }

@media (max-width: 860px) {
  :root { --segvh: 74vh; }
  .arena { padding: 10px 12px 12px; }
  .board { border-radius: 18px; }
  .say { left: 10px; right: 10px; bottom: 26px; gap: 4px; }
  .nami { width: 74px; }
  .bubble { padding: 11px 14px; font-size: 13.5px; line-height: 1.45; }
  .where { display: none; }
  .intro { flex-direction: column; gap: 12px; padding: 24px 22px; text-align: center; } .i-art { width: clamp(130px, 40vw, 190px); }
  .cap { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
[hidden] { display: none !important; }

/* Nami speaks on top of the diagram */
.say { position: absolute; left: 22px; right: 22px; bottom: 30px; z-index: 4; display: flex; align-items: flex-end; gap: 6px; pointer-events: none; }
.say > * { pointer-events: auto; }
.nami { flex: none; width: clamp(96px, 10.5vw, 150px); height: auto; margin-bottom: -4px; filter: drop-shadow(0 10px 14px rgba(28, 25, 23, .18)); }
.col { display: flex; flex-direction: column; gap: 10px; min-width: 0; max-width: 780px; }
.bubble { position: relative; padding: 16px 22px; border-radius: 20px; background: rgba(255, 255, 255, .94); backdrop-filter: blur(8px); border: 1px solid var(--line); box-shadow: 0 14px 34px rgba(28, 25, 23, .14); font-size: clamp(15px, 1.3vw, 18px); line-height: 1.55; color: var(--body-strong); font-weight: 500; }
.bubble::before { content: ""; position: absolute; left: -8px; bottom: 22px; width: 16px; height: 16px; background: inherit; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); transform: rotate(45deg); border-bottom-left-radius: 4px; }
.bubble.pop { animation: rise .45s cubic-bezier(.2, .9, .3, 1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.actions { padding-left: 4px; }
.cap { top: 12px; }
@media (max-width: 860px) { .bubble::before { bottom: 16px; } .say { align-items: flex-end; } }
.col { flex: 1 1 auto; }
@media (max-width: 860px) { .nami { width: 64px; } .bubble { font-size: 13px; padding: 10px 13px; } }

.i-list { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 10px; }
.i-list:empty { display: none; }
.i-list li { display: flex; align-items: center; gap: 14px; padding: 12px 18px; border-radius: 16px; background: #fff; border: 1px solid var(--line); box-shadow: 0 8px 22px rgba(28, 25, 23, .06); font-size: clamp(17px, 1.7vw, 22px); font-weight: 600; letter-spacing: -.015em; animation: rise .5s var(--d, 0s) cubic-bezier(.2, .9, .3, 1) both; }
.i-list b { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 14px; }
@media (max-width: 860px) { .i-list li { text-align: left; font-size: 16px; padding: 10px 14px; } }

/* text colour: deep teal-ink for headings, softer slate for body, accent for the words that matter */
.i-copy h2 em { font-style: normal; color: var(--accent); }
.bubble b.t { font-weight: 650; color: var(--accent); }
.i-list li { color: var(--ink); }
.where { color: var(--muted); }
