/* PTD Reborn Guide. Colours come from the game's own HUD: the charcoal bottom bar, the crimson speed buttons,
   the gold of the Rare Candy you defend and the orange slot squares on every map. */
[hidden] { display: none !important; }
:root {
  --bg: #f4f4f2;
  --panel: #ffffff;
  --ink: #1b1e21;
  --muted: #5a6168;
  --line: #dcdfe2;
  --hud: #1f2326;
  --hud-2: #2c3135;
  --red: #c41237;
  --red-dark: #9c0d2b;
  --gold: #efce63;
  --slot: #f0a030;
  --good: #2f7d32;
  --warn: #b86e00;
  --bad: #c41237;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 "Rubik", system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: #a10f2e; text-underline-offset: 2px; }
a:hover { color: var(--red); }
img { max-width: 100%; height: auto; }
.px { image-rendering: pixelated; }
.wrap { max-width: 1140px; margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 760px; }
h1 { font-size: clamp(1.75rem, 3.6vw, 2.5rem); line-height: 1.15; margin: 28px 0 10px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.4rem; line-height: 1.25; margin: 40px 0 10px; font-weight: 700; }
h3 { font-size: 1.1rem; margin: 24px 0 6px; font-weight: 600; }
p, li { max-width: 75ch; }
.lede { font-size: 1.1rem; color: #33393e; }
.muted { color: var(--muted); }
small { font-size: .86em; }
code { font: .95em "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace; font-variant-numeric: slashed-zero; background: #eceeef; padding: 1px 5px; border-radius: 4px; }
button { font: inherit; }

/* ---------- header: the game's HUD bar ---------- */
.top { background: var(--hud); color: #fff; position: sticky; top: 0; z-index: 20; }
.top .wrap { display: flex; align-items: center; gap: 18px; min-height: 58px; }
.brand { display: flex; align-items: center; gap: 9px; color: #fff; text-decoration: none; font-weight: 700; white-space: nowrap; }
.brand:hover { color: var(--gold); }
.brand img { width: 26px; height: 27px; }
.top nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; margin-left: auto; }
.top nav::-webkit-scrollbar { display: none; }
.top nav a { color: #d7dadc; text-decoration: none; padding: 7px 11px; border-radius: 6px; font-size: .94rem; white-space: nowrap; transition: background .15s, color .15s; }
.top nav a:hover { background: var(--hud-2); color: #fff; }
.top nav a[aria-current] { color: #fff; box-shadow: inset 0 -3px 0 var(--red); border-radius: 6px 6px 0 0; }
@media (max-width: 860px) {
  .top .wrap { flex-wrap: wrap; gap: 0; padding-top: 8px; }
  .top nav { margin: 4px -20px 0; padding: 0 14px 6px; width: calc(100% + 40px); }
}

.foot { background: var(--hud); color: #b9bec2; margin-top: 72px; padding: 28px 0 36px; font-size: .92rem; }
.foot a { color: #fff; }
.foot p { max-width: 90ch; margin: 6px 0; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; background: var(--red); color: #fff; border: 0; border-radius: 8px; padding: 12px 20px; font-weight: 600; cursor: pointer; text-decoration: none; transition: background .15s, transform .1s; }
.btn:hover { background: var(--red-dark); color: #fff; }
.btn:active { transform: translateY(1px) scale(.98); }
.btn[disabled] { opacity: .65; cursor: progress; }
.btn-ghost { background: #fff; color: var(--ink); border: 1px solid #c8ccd0; }
.btn-ghost:hover { background: #f1f2f3; color: var(--ink); }
.copy { border: 1px solid #c8ccd0; background: #fff; color: var(--ink); border-radius: 6px; padding: 5px 12px; min-height: 40px; cursor: pointer; font-size: .9rem; transition: background .15s, border-color .15s, color .15s; }
.copy:hover { border-color: var(--ink); }
.copy.done { background: var(--good); border-color: var(--good); color: #fff; }

/* ---------- type tags (main-series colours; Poison, Ghost, Dragon moved off violet) ---------- */
.type { background: var(--tc, #666); display: inline-block; font-size: .74rem; font-weight: 600; color: #fff; border-radius: 4px; padding: 1px 7px; margin-right: 3px; line-height: 1.6; vertical-align: 1px; }
.t-normal { --tc: #666650 } .t-fire { --tc: #b9451a } .t-water { --tc: #3a6fd0 } .t-electric { --tc: #876900 }
.t-grass { --tc: #347523 } .t-ice { --tc: #227575 } .t-fighting { --tc: #b0302a } .t-poison { --tc: #a03d86 }
.t-ground { --tc: #83621f } .t-flying { --tc: #4766a2 } .t-psychic { --tc: #bf2d5c } .t-bug { --tc: #56700c }
.t-rock { --tc: #736625 } .t-ghost { --tc: #4d5a73 } .t-dragon { --tc: #2a5d9c } .t-dark { --tc: #574639 }
.t-steel { --tc: #6d7686 } .t-fairy { --tc: #a84a7f } .t-shadow { --tc: #3b2f3f }

/* ---------- home: hero + planner ---------- */
.hero { padding: 6px 0 4px; }
.hero h1 { margin-bottom: 6px; }
.hero .lede { margin: 0 0 18px; }
.tool { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.tool-form { padding: 20px 22px 22px; border-right: 1px solid var(--line); }
.tool-map { background: #15181a; display: flex; flex-direction: column; justify-content: center; min-height: 320px; }
.tool-map figcaption { color: #c9cdd0; font-size: .86rem; padding: 8px 14px; }
@media (max-width: 900px) { .tool { grid-template-columns: 1fr; } .tool-form { border-right: 0; border-bottom: 1px solid var(--line); } .tool-map { min-height: 0; } }
.field { display: block; font-weight: 600; margin-bottom: 14px; }
.field select, .field input, .pl-row input { display: block; width: 100%; margin-top: 6px; font: inherit; font-weight: 400; padding: 10px 12px; border: 1px solid #868c92; border-radius: 8px; background: #fff; color: var(--ink); }
.field select:focus, .pl-row input:focus { outline: 2px solid var(--red); outline-offset: 1px; border-color: transparent; }
.team-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-weight: 600; }
.team-head small { font-weight: 400; color: var(--muted); }
.pl-rows { margin: 6px 0 4px; }
.pl-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) 78px 34px; gap: 6px; align-items: center; margin: 6px 0; }
.pl-row input { margin: 0; padding: 8px 10px; }
.pl-row .pv { width: 40px; height: 40px; image-rendering: pixelated; background: #f1f2f3; border-radius: 6px; }
.pl-del { width: 44px; height: 44px; border: 1px solid #d3d7db; background: #fff; border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 1.1rem; line-height: 1; }
.pl-del:hover { color: var(--red); border-color: var(--red); }
.pl-add { background: none; border: 1px dashed #868c92; border-radius: 8px; padding: 10px 12px; min-height: 44px; cursor: pointer; color: var(--ink); width: 100%; transition: border-color .15s, background .15s; }
.pl-add:hover { border-color: var(--ink); background: #f7f8f8; }
.tool-go { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 16px; }
.pl-quota { color: var(--muted); font-size: .9rem; margin: 0; }
.pl-err { color: var(--red-dark); font-weight: 500; }

/* ---------- stage map with slots ---------- */
.stagemap { position: relative; line-height: 0; }
.stagemap img.map { width: 100%; height: auto; image-rendering: pixelated; display: block; }
.stagemap svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.stagemap .path { fill: none; stroke: #fff; stroke-opacity: .75; stroke-width: 2.2; stroke-dasharray: 5 4; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.stagemap .slot rect { fill: rgba(240, 160, 48, .18); stroke: var(--slot); stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.stagemap .slot.typed rect { stroke: var(--tc); stroke-width: 3.5; fill: rgba(255, 255, 255, .12); }
.stagemap .slot text { font-family: Rubik, sans-serif; font-weight: 700; fill: #fff; paint-order: stroke; stroke: #000; }
.stagemap .slot.on rect { fill: rgba(196, 18, 55, .25); stroke: #fff; }
.stagemap .candy { fill: var(--gold); stroke: #6b4f00; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.stagemap .range { fill: rgba(255, 255, 255, .08); stroke: #fff; stroke-opacity: .5; stroke-width: 1; vector-effect: non-scaling-stroke; }
.stagemap image.tw { image-rendering: pixelated; }
.stagemap .tw-g { animation: drop .35s ease-out both; }
@keyframes drop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .stagemap .tw-g { animation: none; } .btn, .copy, .pl-add { transition: none; } }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .84rem; color: var(--muted); margin: 8px 0 0; }
.legend i { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--slot); vertical-align: -1px; margin-right: 5px; border-radius: 2px; }
.legend i.c { background: var(--gold); border-color: #6b4f00; border-radius: 50%; }

/* ---------- plan output ---------- */
.result { margin-top: 26px; }
.result:empty { display: none; }
.res-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; border-radius: 10px; padding: 14px 18px; background: var(--panel); border: 1px solid var(--line); border-left: 6px solid var(--good); }
.res-head.tight { border-left-color: var(--warn); }
.res-head.leaks { border-left-color: var(--bad); }
.res-head img { width: 30px; height: 32px; }
.res-head b { font-size: 1.15rem; }
.res-head p { margin: 2px 0 0; color: var(--muted); }
.res-grid { display: grid; grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); gap: 20px; margin-top: 18px; align-items: start; }
@media (max-width: 900px) { .res-grid { grid-template-columns: 1fr; } }
.res-map { border-radius: 10px; overflow: hidden; background: #15181a; }
.towers { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.tower { display: grid; grid-template-columns: 30px 56px minmax(0, 1fr); gap: 10px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.tower .sn { width: 28px; height: 28px; border: 2px solid var(--slot); border-radius: 4px; display: grid; place-items: center; font-weight: 700; font-size: .9rem; }
.tower img { width: 56px; height: 56px; image-rendering: pixelated; }
.tower b { font-size: 1.02rem; }
.tower p { margin: 1px 0; font-size: .92rem; }
.share { height: 6px; background: #e8eaec; border-radius: 3px; margin-top: 6px; overflow: hidden; }
.share i { display: block; height: 100%; background: var(--red); border-radius: 3px; transform-origin: left; animation: grow .5s ease-out both; }
@keyframes grow { from { transform: scaleX(0); } }
.flag { display: inline-block; font-size: .78rem; font-weight: 600; padding: 0 6px; border-radius: 4px; background: #fdf1d6; color: #7a4d00; margin-right: 4px; }
.notes { background: #fff8e6; border: 1px solid #f1dca5; border-radius: 10px; padding: 10px 16px 10px 34px; margin: 16px 0 0; }
.notes li { margin: 3px 0; }
.wv td, .wv th { white-space: nowrap; }
.margin-bar { display: inline-block; width: 90px; height: 8px; background: #e8eaec; border-radius: 4px; vertical-align: middle; margin-right: 6px; overflow: hidden; }
.margin-bar i { display: block; height: 100%; }
.m-good i { background: var(--good); } .m-tight i { background: var(--warn); } .m-bad i { background: var(--bad); }

/* ---------- paywall ---------- */
.wall { position: relative; margin-top: 18px; border: 2px solid var(--ink); border-radius: 12px; background: var(--panel); padding: 20px 22px; display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 22px; }
@media (max-width: 760px) { .wall { grid-template-columns: 1fr; } }
.wall h3 { margin-top: 0; font-size: 1.25rem; }
.wall ul { padding-left: 20px; margin: 8px 0; }
.wall .buy { background: #f6f6f4; border-radius: 10px; padding: 16px; text-align: center; align-self: start; }
.wall .price { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.wall .buy .btn { width: 100%; justify-content: center; margin: 10px 0 6px; }
.wall .buy small { color: var(--muted); display: block; }
.wall details { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 10px; }
.wall details summary { cursor: pointer; color: var(--muted); }
.wall details input { padding: 8px 10px; border: 1px solid #868c92; border-radius: 8px; font: inherit; width: min(280px, 100%); margin: 6px 6px 0 0; }
.wall details button { padding: 8px 14px; border: 1px solid #868c92; border-radius: 8px; background: #fff; cursor: pointer; }
.teaser { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 10px; align-items: center; background: #f6f6f4; border-radius: 10px; padding: 10px 12px; margin: 10px 0; }
.teaser img { width: 56px; height: 56px; image-rendering: pixelated; }
.locked { margin-top: 8px; display: grid; gap: 6px; }
.locked span { display: block; height: 52px; border-radius: 10px; background: #eceeef; border: 1px dashed #cfd3d6; }

/* ---------- codes strip & codes page ---------- */
.strip { margin: 34px 0 0; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; }
.strip h2 { margin: 0 0 4px; font-size: 1.2rem; }
.strip p { margin: 0 0 12px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px 4px 10px; background: #fafafa; }
.chip code { background: none; padding: 0; font-weight: 600; font-size: 1rem; }
.chip .copy { padding: 3px 9px; font-size: .84rem; }
.codes { list-style: none; padding: 0; margin: 18px 0; display: grid; gap: 10px; max-width: none; }
.code-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 14px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; max-width: none; }
.code-row img { width: 64px; height: 64px; image-rendering: pixelated; object-fit: contain; }
.code-row code { font-size: 1.2rem; font-weight: 700; background: none; padding: 0; letter-spacing: .02em; }
.code-row p { margin: 2px 0 0; color: #3b4146; }
.checked { display: inline-block; background: #e7f2e7; color: #1f5e22; border-radius: 6px; padding: 3px 10px; font-size: .9rem; font-weight: 500; }

/* ---------- generic content ---------- */
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid #eceef0; vertical-align: middle; }
th { background: #f0f1f2; font-weight: 600; font-size: .88rem; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafafa; }
td .mi { display: inline-flex; align-items: center; gap: 4px; margin: 2px 10px 2px 0; white-space: nowrap; }
td .mi img { width: 36px; height: 36px; image-rendering: pixelated; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 1px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin: 18px 0; }
.facts div { background: var(--panel); padding: 10px 14px; box-shadow: 0 0 0 1px var(--line); }
.facts dt { font-size: .82rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }
.crumbs { font-size: .9rem; color: var(--muted); margin-top: 18px; }
.crumbs a { color: var(--muted); }
.stage-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 900px) { .stage-top { grid-template-columns: 1fr; } }
.stage-top .stagemap { border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.callout { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--red); border-radius: 8px; padding: 12px 16px; margin: 16px 0; }
.callout p { margin: 4px 0; }
.mons { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; max-width: none; }
.mons li { display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px 4px 4px; }
.mons img { width: 40px; height: 40px; image-rendering: pixelated; }
.pager { display: flex; justify-content: space-between; gap: 10px; margin: 36px 0 0; flex-wrap: wrap; }
.pager a { display: inline-block; padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); text-decoration: none; color: var(--ink); }
.pager a:hover { border-color: var(--ink); }
.links { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; margin: 18px 0; }
.links a { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 12px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; text-decoration: none; color: var(--ink); transition: border-color .15s, transform .15s; }
.links a:hover { border-color: var(--ink); transform: translateY(-2px); }
.links img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; image-rendering: pixelated; }
.links b { display: block; }
.links span { color: var(--muted); font-size: .9rem; line-height: 1.4; display: block; }
figure { margin: 18px 0; }
figure img { border-radius: 8px; border: 1px solid var(--line); display: block; }
figcaption { font-size: .88rem; color: var(--muted); margin-top: 6px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 700px) { .two { grid-template-columns: 1fr; } }
.steps { padding-left: 22px; }
.steps li { margin: 8px 0; }
.search { width: min(420px, 100%); font: inherit; padding: 10px 12px; border: 1px solid #868c92; border-radius: 8px; margin: 6px 0 12px; }
.calc { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 16px; }
.calc label { font-weight: 600; font-size: .94rem; }
.calc select, .calc input { display: block; width: 100%; margin-top: 4px; font: inherit; font-weight: 400; padding: 8px 10px; border: 1px solid #868c92; border-radius: 8px; background: #fff; }
.calc output { grid-column: 1 / -1; display: block; font-size: 1.05rem; border-top: 1px solid var(--line); padding-top: 12px; }
.calc output b { font-size: 1.6rem; }
.gym { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 26px; }
.gym-head { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.gym-head img { width: 56px; height: 56px; image-rendering: pixelated; }
.gym-head h3 { margin: 0; }
.gym-grid { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 18px; align-items: start; margin-top: 10px; }
@media (max-width: 760px) { .gym-grid { grid-template-columns: 1fr; } }
.gym-grid .stagemap { border-radius: 8px; overflow: hidden; }
[data-result] { scroll-margin-top: 96px; }
input, select, progress { accent-color: var(--red); }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.top a:focus-visible { outline-color: var(--gold); }
h1, h2, h3 { text-wrap: balance; }
@media (max-width: 760px) { .locked span:nth-child(n+2) { display: none; } }
