/* ═══════════════════════════════════════════════════════════════
   T.U.N.I.N.G. (tuning.php) — tn-* scoped. Loaded after css/home.css (tokens, shared hm-* bits).
   Five tabs (js/tuning.js shows one at a time; without it they follow each other): the Special Tuning Skill of
   every Character Memory, the Tuning Skills, the slot rules per costume rarity, the items, the game's guide.
   t0 / t1 / t2 = the rarity group that reaches a level: C + R, SR, PUR (the colours the costume pages use).
   ═══════════════════════════════════════════════════════════════ */

.tn { --t0: #c9ced8; --t1: #ffc400; --t2: #ff5ea8; }
.tn .t0 { --tier: var(--t0); }
.tn .t1 { --tier: var(--t1); }
.tn .t2 { --tier: var(--t2); }

/* ── Top ───────────────────────────────────────────────────────── */
.tn-top { display: grid; align-items: center; gap: 18px 28px; margin-top: 6px; }
.tn-top-txt { display: grid; gap: 4px; min-width: 0; }
.tn-title { margin: 0; font: 400 clamp(2.6rem, 9vw, 5rem)/0.9 var(--font-display); letter-spacing: 0.02em; text-transform: uppercase; transform: skewX(-6deg); transform-origin: left bottom; text-shadow: 4px 4px 0 var(--red), 7px 7px 0 var(--ink); overflow-wrap: anywhere; }
.tn-lead { margin: 16px 0 0 !important; }
.tn-banner { display: block; width: 100%; height: auto; max-height: 300px; border: 4px solid var(--ink); background: var(--panel); object-fit: cover; box-shadow: 8px 8px 0 var(--yellow); }
@media (min-width: 900px) {
    .tn-top { grid-template-columns: minmax(0, 1fr) minmax(0, 460px); }
    .tn-banner { max-height: none; }
}

/* ── Tabs + search (same look as the missions page) ────────────── */
.tn-bar { position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: -14px 0; padding: 9px 12px; border: 3px solid var(--ink); background: rgba(23, 25, 31, 0.96); box-shadow: 4px 4px 0 var(--ink); }
.tn-tabs { display: flex; flex: 1 1 auto; gap: 7px; min-width: 0; padding: 2px 4px !important; overflow-x: auto; scrollbar-width: thin; }
.tn-tabs li { flex: none; }
.tn-tabs a { display: block; padding: 8px 14px 7px; border: 2px solid var(--ink); background: var(--panel-2); font: 400 1rem/1 var(--font-head); letter-spacing: 0.04em; text-transform: uppercase; transform: skewX(-9deg); transition: background 0.12s, color 0.12s; }
.tn-tabs a span { display: inline-block; transform: skewX(9deg); }
.tn-tabs a i { margin-left: 4px; color: var(--dim); font-size: 0.78em; font-style: normal; font-variant-numeric: tabular-nums; }
.tn-tabs a:hover { background: #fff; color: var(--ink); }
.tn-tabs a.is-on { background: var(--yellow); color: var(--ink); }
.tn-tabs a.is-on i, .tn-tabs a:hover i { color: inherit; }
.tn-tabs a.is-empty { opacity: 0.45; }
.tn .tn-tabs a:focus-visible { outline-offset: -3px; }   /* inside the tab: the scrolling strip clips what lies outside it */
.tn-search { flex: 1 1 220px; max-width: 340px; margin: 0; }
.tn-search input { width: 100%; padding: 7px 10px; border: 2px solid var(--ink); background: var(--bg); color: var(--text); font: inherit; font-size: 0.92rem; }
.tn-search input:focus { outline: 2px solid var(--yellow); outline-offset: 0; }
.tn-panel { scroll-margin-top: 124px; }   /* clears the sticky bar, which is two rows tall on narrow screens */
.tn-panel[hidden], .tn-li[hidden], .tn-search[hidden], .tn-filters[hidden], .tn-none[hidden], .tn-hide { display: none; }
.tn-none { color: var(--dim); text-align: center; }
.tn-more { flex: none; color: var(--yellow); font: 400 0.95rem/1 var(--font-head); letter-spacing: 0.04em; text-transform: uppercase; }
.tn-more:hover { text-decoration: underline; }

/* ── Filters of the special skills ─────────────────────────────── */
.tn-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; margin-bottom: 14px; }
.tn-chips { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.tn-chip { position: relative; margin: 0; cursor: pointer; }
.tn-chip input { position: absolute; opacity: 0; pointer-events: none; }
.tn-chip span { display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px; border: 2px solid var(--ink); background: var(--panel-2); font: 400 0.9rem/1.2 var(--font-head); white-space: nowrap; transition: background 0.12s, color 0.12s, transform 0.12s; }
.tn-chip img { flex: none; filter: drop-shadow(1px 1px 0 var(--ink)); }
.tn-chip:hover span { transform: translateY(-2px); }
.tn-chip input:checked + span { background: var(--acc, var(--yellow)); color: var(--ink); box-shadow: 3px 3px 0 var(--ink); }
.tn-chip input:focus-visible + span { outline: 3px solid var(--yellow); outline-offset: 2px; }
.tn-count { margin: 0 0 0 auto !important; color: var(--dim); font-size: 0.86rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tn-count b { color: var(--text); font: 400 1.15rem/1 var(--font-head); }

/* Which rarity reaches which level. */
.tn-reach { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin: 0 0 16px !important; color: var(--dim); font-size: 0.86rem; }
.tn-reach > b { color: var(--text); font: 400 0.8rem/1 var(--font-head); letter-spacing: 0.1em; text-transform: uppercase; }
.tn-reach > span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.tn-reach > span > i { width: 14px; height: 14px; border: 2px solid var(--ink); background: var(--tier); }
.tn-rar { display: inline-block; padding: 1px 9px; background: var(--t0); color: var(--ink); font: 400 0.8rem/1.35 var(--font-head); letter-spacing: 0.06em; transform: skewX(-9deg); }
.tn-rar + .tn-rar { margin-left: 5px; }
.tn-rar-c { background: #7d8492; }
.tn-rar-sr { background: var(--t1); }
.tn-rar-ssr, .tn-rar-essr { background: var(--t2); }

/* ── Skill cards ───────────────────────────────────────────────── */
.tn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 370px), 1fr)); gap: 14px 16px; }
.tn-grid-n { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.tn-li { min-width: 0; scroll-margin-top: 80px; }
.tn-card { display: grid; align-content: start; gap: 10px; height: 100%; padding: 12px 14px 13px; border: 3px solid var(--ink); border-left: 6px solid var(--acc, var(--yellow)); background: var(--panel); box-shadow: 4px 4px 0 var(--line); }
.tn-li.is-hit .tn-card { box-shadow: 4px 4px 0 var(--yellow); }
.tn-card-h { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.tn-who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tn-who img { flex: none; width: 48px; height: 48px; border: 2px solid var(--ink); background: var(--panel-2); object-fit: cover; }
.tn-who span { display: grid; min-width: 0; }
.tn-who b { font: 400 1.05rem/1.15 var(--font-head); overflow-wrap: anywhere; }
.tn-who small { color: var(--dim); font-size: 0.8rem; }
.tn-who:hover b { color: var(--yellow); }
.tn-tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 0 !important; }
.tn-tags span { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border: 2px solid var(--ink); background: var(--panel-2); font: 400 0.74rem/1.3 var(--font-head); letter-spacing: 0.05em; text-transform: uppercase; white-space: nowrap; }
.tn-role { color: var(--acc); }
.tn-side-h { color: #7fb4ff; }
.tn-side-v { color: #ff8f91; }
.tn-tags .tn-soon { background: var(--blue); color: #fff; }
.tn-sk { display: flex; align-items: flex-start; gap: 11px; padding-top: 10px; border-top: 1px solid var(--line); }
.tn-ic { flex: none; width: 52px; height: 52px; object-fit: contain; }
.tn-sk-txt { display: grid; gap: 3px; min-width: 0; }
.tn-sk-txt h3 { margin: 0; color: var(--yellow); font: 400 1.12rem/1.2 var(--font-head); overflow-wrap: anywhere; }
.tn-sk-txt p { margin: 0; color: #d0d4dc; font-size: 0.88rem; line-height: 1.38; overflow-wrap: anywhere; }
.tn-sk-txt .tn-up { color: var(--dim); font-size: 0.8rem; }
/* Eleven levels on two rows: 1-5 (every costume up to SR) over 6-11 (PUR only). */
.tn-lvs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0 !important; list-style: none; }
.tn-lvs li:nth-child(-n+5) { flex: 1 1 calc(20% - 4px); }
.tn-lvs li:nth-child(n+6) { flex: 1 1 calc(16.66% - 4px); }
.tn-lvs li { display: grid; justify-items: center; min-width: 0; padding: 2px 3px 3px; border: 1px solid var(--line); border-bottom: 3px solid var(--tier, var(--line)); background: rgba(7, 8, 10, 0.45); color: var(--text); font-size: 0.86rem; font-variant-numeric: tabular-nums; line-height: 1.25; }
.tn-lvs small { color: var(--dim); font-size: 0.64rem; }
.tn-fixed { margin: 0 !important; color: #e9d98a; font-size: 0.8rem; }
.tn-fixed b { color: var(--yellow); font-weight: 400; }
/* A Special Tuning Skill's fixed values, one line each: what the game does with the number. */
div.tn-fixed { display: grid; gap: 4px; }
div.tn-fixed b { color: var(--dim); font: 400 0.7rem/1 var(--font-head); letter-spacing: 0.1em; text-transform: uppercase; }
.tn-fixed ul { display: grid; gap: 3px; margin: 0; padding: 0 !important; list-style: none; }
.tn-fixed li { padding-left: 9px; border-left: 3px solid var(--yellow); line-height: 1.35; overflow-wrap: anywhere; }
.tn-fixed .tn-off { border-left-color: var(--line); color: var(--dim); }
.tn-also { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 7px; margin: 0 !important; padding-top: 9px; border-top: 1px dashed var(--line); font-size: 0.82rem; }
.tn-also b { color: var(--dim); font: 400 0.7rem/1 var(--font-head); letter-spacing: 0.1em; text-transform: uppercase; }
.tn-also a { padding: 2px 8px; border: 2px solid var(--ink); background: var(--panel-2); }
.tn-also a:hover { background: var(--yellow); color: var(--ink); }

/* Tuning Skills: no owner, a row of the memories that give it. */
.tn-card-n { border-left-width: 3px; }
.tn-card-n .tn-lvs li { flex: 1 1 calc(25% - 4px); }
.tn-by { display: grid; gap: 7px; padding-top: 9px; border-top: 1px dashed var(--line); }
.tn-by > b { color: var(--dim); font: 400 0.7rem/1 var(--font-head); letter-spacing: 0.1em; text-transform: uppercase; }
.tn-by > b i { color: var(--text); font-style: normal; }
.tn-faces { display: flex; flex-wrap: wrap; gap: 5px; }
.tn-faces a { display: block; border: 2px solid var(--ink); border-bottom: 3px solid var(--acc); background: var(--panel-2); transition: transform 0.12s; }
.tn-faces a:hover { transform: translateY(-2px); }
.tn-faces a.is-soon { opacity: 0.55; }
.tn-faces img { display: block; width: 44px; height: 44px; object-fit: cover; }

/* ── Slot rules ────────────────────────────────────────────────── */
.tn-rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr)); gap: 18px 16px; }
.tn-rule { display: grid; align-content: start; gap: 14px; padding: 14px 16px 16px; border: 3px solid var(--ink); background: var(--panel); box-shadow: 6px 6px 0 var(--tier); }
.tn-rule-h { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 12px; }
.tn-rule-h h3 { margin: 0; }
.tn-rule-h .tn-rar { padding: 3px 14px; font-size: 1.05rem; box-shadow: 2px 2px 0 var(--ink); }
.tn-rule-h small { color: var(--dim); font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.tn-board { display: grid; gap: 6px; }
.tn-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)) minmax(0, 1.5fr); gap: 5px; }
.tn-s { position: relative; display: grid; place-items: center; min-height: 40px; border: 2px solid var(--ink); background: var(--panel-2); font-style: normal; }
.tn-s b { font: 400 1.05rem/1 var(--font-head); font-variant-numeric: tabular-nums; }
.tn-s.is-locked { background: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0 6px, transparent 6px 12px), var(--bg); color: var(--dim); }
.tn-s.is-up::after { content: "▲"; position: absolute; top: 1px; right: 3px; color: var(--yellow); font-size: 0.6rem; line-height: 1; }
.tn-s-sp { border-color: var(--tier, var(--yellow)); background: var(--ink); }
.tn-s-sp em { margin-left: 2px; color: var(--tier, var(--yellow)); font-style: normal; }
.tn-facts { display: grid; gap: 0; margin: 0; }
.tn-facts > div { display: flex; align-items: center; justify-content: space-between; gap: 6px 14px; min-height: 40px; padding: 5px 0; border-top: 1px solid var(--line); }
.tn-facts dt { min-width: 0; color: #c9cdd6; font-size: 0.86rem; font-weight: 400; overflow-wrap: anywhere; }
.tn-facts dd { display: flex; flex: none; align-items: center; gap: 6px; margin: 0; font-size: 0.92rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tn-facts dd b { color: var(--yellow); font: 400 1.1rem/1 var(--font-head); }
.tn-facts dd small { color: var(--dim); font-size: 0.76rem; }
.tn-cost { display: inline-flex; align-items: center; gap: 3px; }
.tn-cost img { width: 28px; height: 28px; object-fit: contain; }
.tn-cost b { color: var(--yellow); font: 400 1.1rem/1 var(--font-head); font-variant-numeric: tabular-nums; }
.tn-total { display: grid; gap: 8px; margin: 0 !important; padding: 10px 12px; border: 2px solid var(--ink); background: var(--panel-2); }
.tn-total > b { color: var(--dim); font: 400 0.72rem/1 var(--font-head); letter-spacing: 0.1em; text-transform: uppercase; }
.tn-total > span { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.tn-legend { display: grid; gap: 8px; margin-top: 18px !important; color: #c9cdd6; font-size: 0.86rem; }
.tn-legend li { display: flex; align-items: center; gap: 10px; }
.tn-legend .tn-s { flex: none; width: 46px; min-height: 34px; }
.tn-legend .tn-s-sp { width: 58px; }

/* ── Items ─────────────────────────────────────────────────────── */
.tn-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 12px 14px; }
.tn-item { display: flex; align-items: center; gap: 12px; height: 100%; padding: 10px 12px; border: 3px solid var(--ink); background: var(--panel); box-shadow: 4px 4px 0 var(--line); }
.tn-item img { flex: none; width: 64px; height: 64px; object-fit: contain; }
.tn-item div { display: grid; gap: 4px; min-width: 0; }
.tn-item h3 { margin: 0; font: 400 1.08rem/1.2 var(--font-head); overflow-wrap: anywhere; }
.tn-item p { margin: 0; color: #c9cdd6; font-size: 0.86rem; line-height: 1.35; }

/* ── Guide ─────────────────────────────────────────────────────── */
.tn-quote { position: relative; margin: 0 0 18px; padding: 14px 18px 14px 46px; border: 3px solid var(--ink); background: var(--panel-2); box-shadow: 4px 4px 0 var(--yellow); }
.tn-quote::before { content: "“"; position: absolute; top: 2px; left: 12px; color: var(--yellow); font: 400 3rem/1 var(--font-display); }
.tn-quote p { margin: 0; font-size: 1rem; line-height: 1.5; }
.tn-guide { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 14px 16px; margin-bottom: 18px; }
.tn-step { display: grid; align-content: start; gap: 8px; padding: 14px 16px 16px; border: 3px solid var(--ink); background: var(--panel); box-shadow: 4px 4px 0 var(--line); }
.tn-step h3 { display: flex; align-items: center; gap: 9px; margin: 0 0 2px; color: var(--yellow); font: 400 1.15rem/1.2 var(--font-head); overflow-wrap: anywhere; }
.tn-step h3 img { flex: none; width: 34px; height: 34px; object-fit: contain; }
.tn-step p { margin: 0; color: #dfe2e8; font-size: 0.92rem; line-height: 1.5; }
.tn-notes { display: grid; gap: 6px; margin-top: 2px !important; }
.tn-notes li { position: relative; padding: 6px 10px 6px 28px; border-left: 3px solid var(--orange); background: rgba(255, 138, 31, 0.08); color: #e6d5c2; font-size: 0.84rem; line-height: 1.4; }
.tn-notes li::before { content: "!"; position: absolute; top: 6px; left: 10px; color: var(--orange); font: 400 0.95rem/1.3 var(--font-head); }
.tn-maxico { display: inline-block; padding: 0 6px; background: var(--yellow); color: var(--ink); font: 400 0.78em/1.5 var(--font-head); letter-spacing: 0.05em; }

@media (prefers-reduced-motion: reduce) { .tn-chip:hover span, .tn-faces a:hover { transform: none; } }

/* Link to the T.U.N.I.N.G. builder (tuning-build.php). */
.tn-build { margin-top: 14px !important; }
