:root {
  --teal: #e8601c;
  --teal-deep: #1c5fa8;
  --sky: #3aa0e8;
  --gold: #ffc21a;
  --text: #1b2733;
  --muted: #5a6878;
  --card: #ffffff;
  --page: #fdf6ea;
  --line: #eadfca;
  --link: #c24a0c;
  --soft: #fff0dc;
  --nav-w: 230px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --text: #eaf1f4;
    --muted: #a7b4c0;
    --card: #17242f;
    --page: #0e171f;
    --line: #26394a;
    --link: #ffab6b;
    --soft: #33261a;
  }
}
* { box-sizing: border-box; }
html { scroll-padding-top: 76px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 17px/1.6 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Hiragino Sans", "Apple SD Gothic Neo", "PingFang TC", "Thonburi", Arial, sans-serif;
}
a { color: var(--link); }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; z-index: 30; background: var(--card); padding: 8px 12px; border-radius: 8px; }

/* Top bar */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  background: linear-gradient(100deg, var(--teal-deep), var(--sky));
  border-bottom: 4px solid var(--gold);
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 900; font-size: 1.45rem; font-style: italic; letter-spacing: 0.01em; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25); }
.brand img { display: block; height: 46px; width: auto; }
.lang { position: relative; }
.lang summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.16);
  font-weight: 600; font-size: 0.95rem; white-space: nowrap;
}
.lang summary::-webkit-details-marker { display: none; }
.lang summary svg { width: 20px; height: 20px; }
.lang ul {
  position: absolute; right: 0; top: calc(100% + 8px); margin: 0; padding: 6px; list-style: none;
  background: var(--card); border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  max-height: min(70vh, 640px); overflow: auto; min-width: 230px;
}
.lang li a { display: block; padding: 8px 12px; border-radius: 9px; color: var(--text); text-decoration: none; }
.lang li a:hover { background: var(--soft); }
.lang li a[aria-current] { font-weight: 700; background: var(--soft); }

/* Page navigation: a scrolling row on phones, a sidebar on wide screens */
.layout { max-width: 1160px; margin: 0 auto; }
.pages ul {
  display: flex; gap: 8px; margin: 0; padding: 12px 16px; list-style: none;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  border-bottom: 1px solid var(--line); background: var(--page);
}
.pages ul::-webkit-scrollbar { display: none; }
.pages a {
  display: flex; align-items: center; gap: 7px; white-space: nowrap;
  padding: 7px 13px 7px 9px; border-radius: 999px; background: var(--card);
  color: var(--text); text-decoration: none; font-weight: 600; font-size: 0.95rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
.pages a[aria-current] { background: var(--teal); color: #fff; }
.icon { width: 24px; height: 24px; flex: none; }
main { padding: 8px 16px 40px; max-width: 800px; margin: 0 auto; }
@media (min-width: 900px) {
  .layout { display: grid; grid-template-columns: var(--nav-w) 1fr; gap: 32px; padding: 0 24px; }
  .pages ul {
    position: sticky; top: 74px; flex-direction: column; gap: 4px; overflow: visible;
    padding: 24px 0; border: 0; background: none;
  }
  .pages a { box-shadow: none; background: none; padding: 8px 12px; border-radius: 12px; white-space: normal; }
  .pages a:hover { background: var(--card); }
  .pages a[aria-current] { background: var(--teal); }
  main { padding: 24px 0 56px; margin: 0; }
}

/* Content */
h1 { font-size: clamp(1.8rem, 5vw, 2.4rem); line-height: 1.15; margin: 18px 0 10px; }
h2 { font-size: 1.4rem; line-height: 1.25; margin: 0 0 10px; }
h3 { font-size: 1.08rem; margin: 20px 0 4px; }
p, ul, ol { margin: 8px 0; }
li { margin: 4px 0; }
.lead { font-size: 1.12rem; color: var(--muted); margin: 0 0 18px; }
section {
  background: var(--card); border-radius: 20px; padding: 20px 22px; margin: 0 0 18px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}
.muted { color: var(--muted); font-size: 0.93rem; }
.note {
  background: var(--soft); border-radius: 14px; padding: 10px 14px; margin: 12px 0;
}
.toc { margin: 0 0 18px; }
.toc p { margin: 0 0 6px; font-weight: 700; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.toc ol { display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0; list-style: none; }
.toc a {
  display: block; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line);
  text-decoration: none; font-size: 0.92rem; background: var(--card);
}
table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 0.97rem; }
th, td { text-align: left; vertical-align: top; padding: 8px 6px; border-bottom: 1px solid var(--line); }
th { font-size: 0.85rem; color: var(--muted); }
td .inline { margin-right: 2px; }
img.inline { width: 28px; height: 28px; vertical-align: -8px; }
.icon.inline { vertical-align: -6px; }
svg.icon { display: inline-block; vertical-align: -5px; }

/* Picture rows and figures */
.row { display: flex; flex-wrap: wrap; gap: 14px 12px; align-items: flex-start; margin: 12px 0; }
.tile { margin: 0; width: 92px; text-align: center; font-size: 0.85rem; line-height: 1.3; color: var(--muted); }
.tile img { width: 64px; height: 64px; display: block; margin: 0 auto 4px; }
.item { margin: 0; width: calc(50% - 6px); max-width: 220px; text-align: center; font-size: 0.88rem; line-height: 1.35; color: var(--muted); }
.item img { width: 100%; height: auto; aspect-ratio: 4 / 3; display: block; }
.item strong { color: var(--text); }
.swatch { margin: 0; width: 76px; text-align: center; font-size: 0.82rem; line-height: 1.25; color: var(--muted); }
.swatch span { display: block; width: 44px; height: 44px; margin: 0 auto 4px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.15), 0 1px 3px rgba(0, 0, 0, 0.2); }
img.inline { width: 28px; height: 28px; vertical-align: -8px; }
td img.inline { width: 40px; height: 40px; }

/* Index cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; padding: 0; list-style: none; margin: 14px 0; }
.cards a {
  display: flex; gap: 12px; align-items: center; height: 100%; padding: 14px; border-radius: 16px;
  background: var(--card); color: var(--text); text-decoration: none; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}
.cards img, .cards svg { width: 52px; height: 52px; flex: none; object-fit: contain; }
.cards a[href="worlds.html"] img { object-fit: cover; border-radius: 10px; }
.cards strong { display: block; }
.cards span span { color: var(--muted); font-size: 0.9rem; line-height: 1.35; display: block; }
.hero { border-radius: 22px; overflow: hidden; margin: 6px 0 16px; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12); }
.hero img { display: block; width: 100%; height: auto; }

/* Worlds and tracks */
.worlds { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; padding: 0; list-style: none; margin: 0 0 18px; }
.world { margin: 0; }
.world a { display: block; height: 100%; background: var(--card); border-radius: 16px; overflow: hidden; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.07); color: var(--text); text-decoration: none; }
.world .poster { width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; display: block; }
.world .name { display: block; font-weight: 800; padding: 8px 12px 0; }
.world .tag { display: block; padding: 0 12px 10px; font-size: 0.85rem; color: #b45f00; font-weight: 600; }
.world .tag.free { color: #2f8a1f; }
@media (prefers-color-scheme: dark) { .world .tag { color: var(--gold); } .world .tag.free { color: #8ee07a; } }
.tracks { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 0; margin: 12px 0; list-style: none; }
@media (min-width: 640px) { .tracks { grid-template-columns: repeat(4, 1fr); } }
.tracks li { margin: 0; position: relative; border-radius: 12px; overflow: hidden; }
.tracks img { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; }
.tracks span {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 8px 6px; color: #fff; font-weight: 800;
  font-size: 0.88rem; line-height: 1.2; background: linear-gradient(transparent, rgba(0, 0, 0, 0.65));
}

/* Previous and next, suggestion, footer */
.steps { display: flex; justify-content: space-between; gap: 12px; margin-top: 24px; }
.steps a {
  flex: 1; max-width: 48%; padding: 12px 16px; border-radius: 14px; background: var(--card);
  text-decoration: none; font-weight: 700; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}
.steps a span { display: block; font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.steps .next { margin-left: auto; text-align: right; }
.suggest { margin: 12px 0 0; padding: 10px 14px; border-radius: 14px; background: var(--soft); font-weight: 600; }
footer { text-align: center; color: var(--muted); font-size: 0.9rem; padding: 8px 16px 40px; border-top: 1px solid var(--line); }
footer p { margin: 8px 0; }
.store {
  display: inline-block; padding: 10px 18px; border-radius: 999px; background: var(--teal-deep); color: #fff !important;
  text-decoration: none; font-weight: 700; margin-top: 16px;
}
@media (max-width: 520px) {
  main table { display: block; overflow-x: auto; font-size: 0.92rem; }
}
:lang(ja) { word-break: auto-phrase; }
