/* RS ダメージ計算機 — サイバー／ダークテーマ
   色の役割: シアン=結果・主役 ／ バイオレット=ヒント・注記 ／ ライム=操作・演算子 ／ アンバー=注意バッジ */
:root {
  --bg: #111a30;
  --bg-2: #162238;
  --surface: rgba(30, 43, 70, .9);
  --surface-2: rgba(42, 58, 92, .8);
  --blk: rgba(40, 55, 90, .82);
  --input: #182540;
  --fg: #f2f6fc;
  --fg-2: #d3dced;
  --muted: #9aa9c2;
  --faint: #6b7a96;
  --line: rgba(145, 180, 245, .26);
  --line-2: rgba(145, 180, 245, .16);
  --line-3: rgba(145, 180, 245, .45);
  --cyan: #38d9f5;   --cyan-soft: rgba(56, 217, 245, .12);  --cyan-line: rgba(56, 217, 245, .38);  --cyan-ink: #8ae9fb;
  --violet: #9d8cff; --violet-soft: rgba(157, 140, 255, .13); --violet-line: rgba(157, 140, 255, .4); --violet-ink: #c3b8ff;
  --lime: #b3f05a;   --lime-soft: rgba(179, 240, 90, .12);   --lime-line: rgba(179, 240, 90, .38);  --lime-ink: #cdf78a;
  --amber: #f5b342;  --amber-soft: rgba(245, 179, 66, .13);  --amber-line: rgba(245, 179, 66, .4);  --amber-ink: #ffd07a;
  --blue: #5b9cf6;
  --ring: rgba(179, 240, 90, .35);
  --tone-a: var(--cyan); --tone-b: var(--blue); --tone-c: var(--amber); --tone-d: var(--violet); --tone-e: var(--lime);
  --shadow: 0 0 0 1px rgba(56, 217, 245, .04), 0 20px 50px -30px rgba(0, 0, 0, .9);
  --glow-cyan: 0 0 18px rgba(56, 217, 245, .35);
  --sans: "Geist", "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  --mono: "Geist Mono", "SFMono-Regular", Consolas, Menlo, monospace;
  --disp: "Orbitron", "Geist", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; color-scheme: dark; }
body {
  margin: 0; position: relative; min-height: 100vh;
  background:
    radial-gradient(900px 500px at 10% -10%, rgba(56, 217, 245, .2), transparent 65%),
    radial-gradient(800px 500px at 100% 0%, rgba(157, 140, 255, .22), transparent 65%),
    radial-gradient(700px 400px at 50% 110%, rgba(179, 240, 90, .1), transparent 65%),
    var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  padding-inline: 16px;
  padding-block: 0 88px;
  overflow-x: hidden;
}
/* 流れるグリッド + 走査線 */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(rgba(56, 217, 245, .07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 217, 245, .07) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at 50% 0%, #000 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 0%, #000 20%, transparent 75%);
  animation: grid-drift 40s linear infinite;
}
@keyframes grid-drift { to { background-position: 48px 48px; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0% { text-shadow: 0 0 0 rgba(56, 217, 245, 0); } 35% { text-shadow: 0 0 22px rgba(56, 217, 245, .75); } 100% { text-shadow: var(--glow-cyan); } }
@keyframes blink { 50% { opacity: .35; } }
@keyframes flicker { 0%, 100% { opacity: 1; } 92% { opacity: 1; } 93% { opacity: .55; } 94% { opacity: 1; } 97% { opacity: .7; } }

a { color: inherit; }
h1, h2 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
button { font-family: inherit; }
::selection { background: rgba(56, 217, 245, .35); }

.wrap { max-width: 1040px; margin: 0 auto; position: relative; z-index: 1; }

/* ---------- header ---------- */
.top { padding-block: 20px 14px; animation: rise .5s ease-out both; }
.top .home { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 10px; font-size: 12.5px; font-weight: 500; color: var(--muted); text-decoration: none; transition: color .15s, transform .2s; }
.top .home:hover { color: var(--cyan-ink); transform: translateX(-3px); }
.top .ttl-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 16px; }
.top .credit { margin: 0; font-size: 12.5px; color: var(--fg-2); }
.top .credit a { color: var(--cyan-ink); font-weight: 600; text-decoration: none; border-bottom: 1px solid var(--cyan-line); transition: color .15s, border-color .15s, text-shadow .15s; }
.top .credit a:hover { color: var(--cyan); border-color: var(--cyan); text-shadow: var(--glow-cyan); }
.top h1 { font-family: var(--disp); font-size: 18px; letter-spacing: .06em; display: flex; align-items: center; gap: 12px; text-shadow: var(--glow-cyan); animation: flicker 7s linear infinite; }
.top h1 .dot { width: 10px; height: 10px; border-radius: 2px; background: var(--cyan); box-shadow: 0 0 12px var(--cyan), 0 0 0 4px var(--cyan-soft); transform: rotate(45deg); animation: blink 2.4s ease-in-out infinite; }

/* ---------- switches ---------- */
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding-bottom: 16px; animation: rise .5s .08s ease-out both; }
.sw { display: flex; align-items: center; gap: 8px; }
.sw .k { font-family: var(--disp); font-size: 10.5px; font-weight: 500; letter-spacing: .14em; color: var(--muted); }
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: rgba(6, 10, 20, .7); border: 1px solid var(--line); }
.seg button {
  appearance: none; border: 0; background: transparent; color: var(--muted);
  font-size: 13px; font-weight: 500; padding: 6px 14px; border-radius: 7px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; position: relative;
  transition: background .2s, color .2s, box-shadow .2s;
}
.seg button[aria-pressed="true"] { background: var(--cyan-soft); color: var(--cyan-ink); box-shadow: inset 0 0 0 1px var(--cyan-line), var(--glow-cyan); }
.seg button:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--ring); }
.seg button:disabled { cursor: default; color: var(--faint); }
.seg .soon { font-size: 10px; font-weight: 600; letter-spacing: .06em; padding: 1px 6px; border-radius: 999px; border: 1px solid var(--line-3); color: var(--faint); }
.bar .ghost { margin-left: auto; }
.ghost {
  appearance: none; background: transparent; border: 1px solid var(--line-3); color: var(--fg-2);
  font-size: 12.5px; font-weight: 500; padding: 6px 12px; border-radius: 8px; cursor: pointer;
  transition: background .2s, border-color .2s, color .2s, box-shadow .2s;
}
.ghost:hover { border-color: var(--lime-line); color: var(--lime-ink); box-shadow: 0 0 14px rgba(179, 240, 90, .2); }
.ghost:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--ring); }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.stack { display: grid; gap: 16px; min-width: 0; }

/* ---------- card / fields ---------- */
.card {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: rise .55s .12s ease-out both;
}
/* カード四隅のマーカー */
.card::after {
  content: ""; position: absolute; inset: 6px; border-radius: 10px; pointer-events: none;
  background:
    linear-gradient(var(--cyan-line), var(--cyan-line)) top left / 14px 1px no-repeat,
    linear-gradient(var(--cyan-line), var(--cyan-line)) top left / 1px 14px no-repeat,
    linear-gradient(var(--cyan-line), var(--cyan-line)) bottom right / 14px 1px no-repeat,
    linear-gradient(var(--cyan-line), var(--cyan-line)) bottom right / 1px 14px no-repeat;
  opacity: .8;
}
.blocks { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 16px; }
.blk.g-hit { grid-column: 1 / -1; }
.blk { --tone: var(--tone-a); position: relative; background: var(--blk); border: 1px solid var(--line-3); border-left: 3px solid var(--tone); border-radius: 12px; padding: 12px 14px 14px; box-shadow: inset 0 1px 0 rgba(255,255,255,.04); }
.blk::before { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; background: linear-gradient(135deg, color-mix(in srgb, var(--tone) 10%, transparent), transparent 45%); }
.blk > * { position: relative; }
.g-enemy { --tone: var(--tone-b); }
.g-mul { --tone: var(--tone-c); }
.g-lb { --tone: var(--tone-d); }
.g-hit { --tone: var(--tone-e); }
.grp { margin: 0 0 10px; display: flex; align-items: center; gap: 8px; font-family: var(--disp); font-size: 12px; font-weight: 700; letter-spacing: .16em; color: var(--fg); }
.grp::before { content: ""; flex: none; width: 8px; height: 8px; background: var(--tone); transform: rotate(45deg); box-shadow: 0 0 10px var(--tone); }
.grp::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--tone), transparent 70%); opacity: .5; }
.fields { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px 14px; }
.w2 { grid-column: span 2; }
.w3 { grid-column: span 3; }
.w6 { grid-column: span 6; }
/* ラベルが折り返しても入力欄の高さは揃える（下揃え） */
.field { display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; min-width: 0; }
.field label, .field .lbl { display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; font-size: 13px; font-weight: 500; line-height: 1.4; color: var(--fg); }
.field label > .info, .field .lbl > .info { margin-top: 1px; }
.field input[type="number"] {
  width: 100%; height: 34px; font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums;
  padding: 0 10px; border-radius: 8px; border: 1px solid rgba(150, 185, 245, .45); background: var(--input); color: #fff;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.4);
  transition: border-color .2s, box-shadow .2s, background .2s;
  -moz-appearance: textfield;
}
.field input::-webkit-outer-spin-button, .field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.field input::placeholder { color: var(--faint); }
.field input:hover { border-color: rgba(179, 240, 90, .6); }
.field input:focus-visible { outline: none; border-color: var(--lime); box-shadow: inset 0 1px 2px rgba(0,0,0,.4), 0 0 0 3px var(--ring), 0 0 18px rgba(179, 240, 90, .25); background: #0a1222; }
.field input:disabled { background: var(--surface-2); color: var(--muted); }
.range { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 6px; }
.range span { color: var(--muted); font-size: 12px; }
.unit { position: relative; }
.unit input { padding-right: 28px !important; }
.unit::after {
  content: attr(data-unit); position: absolute; right: 0; top: 1px; bottom: 1px; width: 24px;
  display: flex; align-items: center; justify-content: center;
  border-left: 1px solid var(--line-3); border-radius: 0 8px 8px 0; background: rgba(130, 165, 230, .14);
  font-family: var(--mono); font-size: 11px; font-weight: 600; color: var(--fg-2); pointer-events: none;
}

/* info expander（ヒント = バイオレット） */
.info {
  appearance: none; flex: none; width: 18px; height: 18px; padding: 0; border-radius: 50%;
  border: 1px solid var(--violet-line); background: var(--violet-soft); color: var(--violet-ink);
  font-family: var(--mono); font-size: 11px; font-weight: 600; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color .2s, border-color .2s, background .2s, transform .25s, box-shadow .2s;
}
.info:hover { color: #0b1220; background: var(--violet); border-color: var(--violet); transform: rotate(15deg) scale(1.1); box-shadow: 0 0 12px rgba(157, 140, 255, .6); }
.info[aria-expanded="true"] { color: #0b1220; background: var(--violet); border-color: var(--violet); box-shadow: 0 0 12px rgba(157, 140, 255, .6); }
.info:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.src { grid-column: 1 / -1; background: rgba(157, 140, 255, .16); border: 1px solid var(--violet-line); border-left: 3px solid var(--violet); border-radius: 8px; padding: 10px 14px 8px; font-size: 12.5px; color: var(--fg); animation: rise .3s ease-out both; }
.src .t { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-family: var(--disp); font-size: 10.5px; font-weight: 500; letter-spacing: .1em; color: var(--violet-ink); margin-bottom: 6px; }
.src .t em { font-style: normal; font-family: var(--mono); letter-spacing: 0; font-weight: 500; color: var(--fg-2); }
.src ul { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0 20px; }
.src li { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 3px 0; border-bottom: 1px dotted var(--violet-line); }
.src li span:last-child { font-family: var(--mono); font-size: 12px; font-weight: 500; color: var(--violet-ink); white-space: nowrap; }

.checks { display: flex; flex-wrap: wrap; gap: 10px 22px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); background: rgba(10, 16, 32, .55); border-radius: 14px 14px 0 0; }
.check { display: inline-flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; transition: color .2s; }
.check:has(input:checked) { color: var(--fg); }
/* トグル: OFF=暗いトラックに OFF の文字、ON=ライムで塗りつぶし ON の文字 */
.check input {
  appearance: none; -webkit-appearance: none; flex: none; margin: 0;
  width: 46px; height: 26px; border-radius: 999px; background: #4a5670; border: 0; cursor: pointer;
  position: relative; transition: background .25s, box-shadow .25s;
}
.check input::before {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.45);
  transition: transform .25s cubic-bezier(.2,.8,.2,1);
}
.check input:checked { background: var(--lime); box-shadow: 0 0 14px rgba(179, 240, 90, .4); }
.check input:checked::before { transform: translateX(20px); }
.check input:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.check input:disabled { opacity: .4; cursor: default; }
.check:has(input:disabled) { color: var(--faint); cursor: default; }

/* step badge（計算の流れ・計算式で共通） */
.no {
  flex: none; min-width: 28px; height: 26px; padding: 0 8px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(6, 10, 20, .7); color: var(--fg-2); border: 1px solid var(--line-3);
  font-family: var(--disp); font-size: 14px; font-weight: 700; line-height: 1;
}

/* 計算の流れ */
.flow { border-bottom: 1px solid var(--line-2); border-radius: 14px 14px 0 0; }
.flow summary { cursor: pointer; list-style: none; padding: 12px 18px; font-family: var(--disp); font-size: 11.5px; letter-spacing: .14em; font-weight: 500; color: var(--fg-2); display: flex; align-items: center; gap: 8px; }
.flow summary::-webkit-details-marker { display: none; }
.flow summary::after { content: "+"; margin-left: auto; font-family: var(--mono); font-size: 14px; color: var(--muted); transition: transform .3s; }
.flow[open] summary::after { content: "−"; }
.flow summary:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--ring); }
.flow ol { margin: 0; padding: 0 18px 14px; list-style: none; display: grid; gap: 8px; }
@media (min-width: 901px) { .flow ol { grid-template-columns: 1fr 1fr; } .flow ol .step.hl { grid-column: 1 / -1; } }
.step { background: rgba(6, 10, 20, .5); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: grid; gap: 6px; transition: border-color .2s, box-shadow .2s; }
.flow ol.anim .step { animation: rise .45s ease-out both; }
.step:hover { border-color: var(--line-3); }
.step .h { display: flex; align-items: center; gap: 8px; min-width: 0; }
.step .ttl { font-size: 13px; font-weight: 600; }
.step .note { margin-left: auto; font-family: var(--mono); font-size: 12px; font-weight: 500; color: var(--fg-2); white-space: nowrap; }
.step .flag { font-size: 10.5px; font-weight: 600; color: var(--amber-ink); background: var(--amber-soft); border: 1px solid var(--amber-line); border-radius: 999px; padding: 0 7px; white-space: nowrap; box-shadow: 0 0 10px rgba(245, 179, 66, .25); }
.terms { margin: 0; padding: 0; list-style: none; }
.terms li { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; align-items: baseline; column-gap: 4px; padding: 3px 0; font-size: 12.5px; color: var(--fg-2); }
.terms li + li { border-top: 1px dotted var(--line); }
.terms b { font-size: 14px; line-height: 1; font-weight: 600; color: var(--lime); }
.terms em { font-style: normal; font-family: var(--mono); font-weight: 600; color: var(--fg); font-variant-numeric: tabular-nums; white-space: nowrap; }
.terms small { grid-column: 2 / -1; font-family: var(--mono); font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }
.terms li.off, .terms li.off b, .terms li.off em { color: var(--faint); font-weight: 500; }
.res { display: grid; gap: 2px; padding-top: 6px; border-top: 1px solid var(--line-2); }
.eq { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: baseline; column-gap: 8px; font-size: 11.5px; color: var(--muted); }
.eq .lhs { font-family: var(--mono); font-size: 11px; text-align: right; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.eq b::before { content: "= "; font-weight: 400; color: var(--muted); }
.eq b { font-family: var(--mono); font-size: 13.5px; font-weight: 600; color: var(--fg); font-variant-numeric: tabular-nums; white-space: nowrap; }
.step.hl { border-color: var(--cyan-line); background: var(--cyan-soft); box-shadow: inset 0 0 30px rgba(56, 217, 245, .06), 0 0 20px rgba(56, 217, 245, .12); }
.step.hl .no { background: var(--cyan); color: #06131a; border-color: var(--cyan); box-shadow: 0 0 12px rgba(56, 217, 245, .6); }
.step.hl .terms li + li, .step.hl .res { border-color: var(--cyan-line); }
.step.hl .eq b { font-size: 16px; }
.step.hl .eq.max b { color: var(--cyan); text-shadow: var(--glow-cyan); }

.chain { padding: 8px 18px 12px; overflow-x: auto; }
.chain table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.chain thead th { font-family: var(--mono); font-size: 10.5px; font-weight: 500; color: var(--muted); text-align: right; padding: 4px 0 6px 8px; }
.chain thead th:first-child { text-align: left; padding-left: 0; }
.chain tbody th { text-align: left; font-weight: 500; color: var(--fg-2); padding: 7px 0; line-height: 1.35; }
.chain tbody td { text-align: right; padding: 7px 0 7px 8px; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--fg-2); }
.chain tbody tr + tr { border-top: 1px solid var(--line-2); }
.chain tr.hl th, .chain tr.hl td { color: var(--cyan-ink); font-weight: 600; }
.chain .x { display: block; font-family: var(--mono); font-size: 10.5px; font-weight: 400; color: var(--muted); }

/* ---------- reference ---------- */
.ref { margin-top: 28px; border-top: 1px solid var(--line); animation: rise .5s .3s ease-out both; }
.ref details { border-bottom: 1px solid var(--line); }
.ref summary { cursor: pointer; padding: 12px 0; font-family: var(--disp); font-size: 12px; letter-spacing: .14em; font-weight: 500; color: var(--fg-2); list-style: none; display: flex; align-items: center; gap: 8px; }
.ref summary::-webkit-details-marker { display: none; }
.ref summary::before { content: "+"; font-family: var(--mono); color: var(--muted); width: 12px; }
.ref details[open] summary::before { content: "−"; }
.ref .credit { margin: 4px 0 12px; font-size: 13px; color: var(--fg-2); }
.ref .credit a { color: var(--cyan-ink); font-weight: 600; text-decoration: none; border-bottom: 1px solid var(--cyan-line); transition: color .15s, border-color .15s, text-shadow .15s; }
.ref .credit a:hover { color: var(--cyan); border-color: var(--cyan); text-shadow: var(--glow-cyan); }
.ref .tag { font-family: var(--sans); font-size: 11px; font-weight: 600; letter-spacing: .04em; color: var(--cyan-ink); background: var(--cyan-soft); border: 1px solid var(--cyan-line); border-radius: 999px; padding: 0 8px; }
.fsteps { margin: 0; padding: 4px 0 20px; list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 12px; }
.fsteps li { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 8px 10px; background: var(--surface); box-shadow: var(--shadow); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; align-content: start; transition: border-color .2s, transform .2s; }
.fsteps li:hover { border-color: var(--line-3); transform: translateY(-2px); }
.fsteps .no { min-width: 34px; height: 30px; font-size: 16px; }
.fsteps .ttl { font-size: 15px; font-weight: 600; }
.fsteps .fx { grid-column: 1 / -1; font-size: 14px; line-height: 1.5; color: var(--fg); display: grid; gap: 6px; overflow-wrap: anywhere; }
.fsteps .fx > div { padding-left: 1.4em; text-indent: -1.4em; }
.fsteps .fx b { display: inline-block; width: 1.4em; text-indent: 0; font-size: 18px; line-height: 1; font-weight: 600; color: var(--lime); vertical-align: -1px; }
.fsteps .fx > div:first-child { font-weight: 500; }
.fsteps .nt { display: inline-block; text-indent: 0; margin-left: 4px; font-size: 11.5px; font-weight: 500; color: var(--violet-ink); background: var(--violet-soft); border: 1px solid var(--violet-line); border-radius: 999px; padding: 0 8px; }
.fsteps .def { display: block; text-indent: 0; margin-top: 4px; padding: 8px 10px; border-radius: 8px; background: rgba(6, 10, 20, .6); font-size: 13px; color: var(--fg-2); }
.fsteps .fx > div:has(.def) { padding-left: 0; text-indent: 0; }
footer { margin-top: 28px; padding-block: 12px; font-size: 11.5px; color: var(--muted); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; position: relative; z-index: 1; }
footer a:hover { color: var(--cyan-ink); }

/* ---------- 最終ダメージバー（上部に追従） ---------- */
.dbar {
  position: sticky; top: 0; z-index: 10; margin: 0 0 16px;
  display: grid; grid-template-columns: auto 1fr 1fr auto; align-items: center; gap: 12px 28px;
  padding: 12px 18px; border-radius: 14px; border: 1px solid var(--cyan-line);
  background: linear-gradient(90deg, rgba(56, 217, 245, .14), rgba(30, 43, 70, .92) 40%);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow); overflow: hidden; animation: rise .5s .1s ease-out both;
  transition: box-shadow .25s, border-radius .25s;
}
.dbar.stuck { border-radius: 0 0 14px 14px; box-shadow: 0 12px 30px -14px rgba(0, 0, 0, .9), 0 0 24px rgba(56, 217, 245, .12); }
/* 計算中インジケータ（上端を走る細い線） */
.dbar::before { content: ""; position: absolute; left: 0; top: 0; height: 2px; width: 0; opacity: 0; background: linear-gradient(90deg, var(--cyan), var(--lime)); box-shadow: 0 0 10px var(--cyan); pointer-events: none; }
.dbar.busy::before { animation: busy .5s ease-out; }
.dbar.busy .tag { animation: blink .25s step-end 2; }
@keyframes busy { 0% { width: 0; opacity: 1; } 80% { width: 100%; opacity: 1; } 100% { width: 100%; opacity: 0; } }
.dbar .mode { display: flex; flex-direction: column; gap: 4px; }
.dbar .k { font-family: var(--disp); font-size: 10px; font-weight: 500; letter-spacing: .16em; color: var(--muted); white-space: nowrap; }
.dbar .tag { align-self: flex-start; font-size: 12px; font-weight: 600; color: var(--cyan-ink); padding: 2px 10px; border-radius: 999px; border: 1px solid var(--cyan-line); background: var(--cyan-soft); white-space: nowrap; }
.dbar .st { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.dbar .l { flex: none; font-size: 12px; font-weight: 600; color: var(--fg-2); padding: 2px 8px; border-radius: 999px; background: rgba(10, 16, 32, .5); border: 1px solid var(--line-3); }
.dbar .num { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex-wrap: wrap; }
.dbar .v { font-family: var(--mono); font-size: 28px; font-weight: 600; line-height: 1.1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.kk { font-family: var(--mono); font-size: 15px; font-weight: 500; color: var(--fg-2); font-variant-numeric: tabular-nums; }
.dbar .max .l { color: #06131a; background: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 12px rgba(56, 217, 245, .5); }
.dbar .max .v { color: var(--cyan); text-shadow: var(--glow-cyan); }
.dbar .max .kk { color: var(--cyan-ink); }
.dbar .min .v { font-size: 16px; color: var(--fg-2); }
.dbar .min .kk { font-size: 12px; color: var(--muted); }
.dbar .v.pulse { animation: pulse .6s ease-out; }

/* ---------- ページ遷移（ワープ） ---------- */
.warp { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; pointer-events: none; opacity: 0; background: radial-gradient(circle at 50% 50%, rgba(56, 217, 245, .25), var(--bg) 70%); transition: opacity .25s; }
.warp .ring { position: absolute; width: 12vmax; height: 12vmax; border-radius: 50%; border: 2px solid var(--cyan); box-shadow: 0 0 24px var(--cyan); opacity: 0; }
.warp .ring:nth-child(2) { border-color: var(--violet); box-shadow: 0 0 24px var(--violet); }
.warp .ring:nth-child(3) { border-color: var(--lime); box-shadow: 0 0 24px var(--lime); }
.warp .txt { font-family: var(--disp); font-size: 13px; letter-spacing: .5em; color: var(--cyan-ink); text-shadow: var(--glow-cyan); opacity: 0; }
.warp-out .warp { opacity: 1; pointer-events: auto; }
.warp-out .warp .ring { animation: ring-out .65s ease-out forwards; }
.warp-out .warp .ring:nth-child(2) { animation-delay: .1s; }
.warp-out .warp .ring:nth-child(3) { animation-delay: .2s; }
.warp-out .warp .txt { animation: blink .5s ease-in-out infinite, rise .3s ease-out both; }
.warp-out .wrap { animation: zoom-away .65s ease-in forwards; }
@keyframes ring-out { from { transform: scale(.2); opacity: 1; } to { transform: scale(12); opacity: 0; } }
@keyframes zoom-away { to { transform: scale(1.06); opacity: 0; filter: blur(6px); } }

/* ページ間のクロスフェード（対応ブラウザのみ） */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: 220ms ease-in both fade-out; }
::view-transition-new(root) { animation: 320ms ease-out both fade-in; }
@keyframes fade-out { to { opacity: 0; } }
@keyframes fade-in { from { opacity: 0; transform: scale(.985); } }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  body { padding-bottom: 40px; }
  .blocks { grid-template-columns: 1fr; }
  .dbar { grid-template-columns: 1fr 1fr; gap: 8px 16px; padding: 10px 14px; margin: 0 -16px 14px; border-radius: 0; border-left: 0; border-right: 0; }
  .dbar.stuck { border-radius: 0; }
  .dbar .mode { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 10px; }
  .dbar .st { flex-direction: column; align-items: flex-start; gap: 2px; }
  .dbar .v { font-size: 24px; }
  .dbar .min { display: none; }
}
@media (min-width: 901px) { body { padding-bottom: 40px; } }
@media (max-width: 480px) {
  .top { padding-block: 18px 12px; }
  .bar .ghost { margin-left: 0; }
  .blocks { padding: 12px; gap: 10px; }
  .blk { padding: 10px 12px 12px; }
  .fields { gap: 10px; }
  .fields .w2, .fields .w3 { grid-column: span 3; }
  .fields .field:has(#str) { grid-column: span 6; }
  .src ul { grid-template-columns: 1fr; }
  .checks { padding: 12px 14px 14px; flex-direction: column; gap: 10px; }
  .chain, .flow summary { padding-left: 14px; padding-right: 14px; }
  .flow ol { padding-left: 14px; padding-right: 14px; }
  .fsteps li { padding: 12px 14px; }
}

[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .top, .bar, .card, .ref, .src, .step { opacity: 1; transform: none; }
}
