/* Motion and interaction layer, loaded after style.css. */

.bg-grain { position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(900px 500px at 85% -10%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 70%),
    radial-gradient(700px 500px at -10% 30%, rgb(142 78 198 / .07), transparent 70%); }
main, footer { position: relative; z-index: 1; }
.up { color: var(--good); } .down { color: var(--bad); }

/* hero */
.hero { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 32px; align-items: center; padding: 48px 0 16px; }
.grad { background: linear-gradient(90deg, var(--accent), #f0a35e 45%, #e5484d); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-cta { display: flex; gap: 12px; margin-top: 26px; flex-wrap: wrap; }
.hero-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 28px; }
.hero-stats div { border-left: 2px solid var(--line); padding-left: 12px; }
.hero-stats b { display: block; font: 600 22px var(--mono); }
.hero-stats span { font-size: 12px; color: var(--muted); }
.hero-arena { position: relative; }
#arena { width: 100%; aspect-ratio: 1 / 1; display: block; max-height: 540px; }
.arena-hint { text-align: center; font: 11px var(--mono); color: var(--muted); margin: 6px 0 0; }
.btn { transition: transform .15s, filter .15s, box-shadow .2s; }
.btn:not(.ghost):hover { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
.btn:active { transform: scale(.97); }
.btn.big { padding: 14px 22px; font-size: 15px; width: 100%; justify-content: center; }

/* reveal */
[data-reveal] { opacity: 0; transform: translateY(18px); transition: opacity .7s ease, transform .7s cubic-bezier(.2,.8,.2,1); }
[data-reveal].shown { opacity: 1; transform: none; }

/* replay bar */
.replay { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 8px 6px 6px; margin-bottom: 14px; }
.icon-btn { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--accent); color: #17150f; font: 700 13px var(--sans); cursor: pointer; flex-shrink: 0; display: grid; place-items: center; }
.icon-btn:hover { filter: brightness(1.1); }
#scrub { flex: 1; accent-color: var(--accent); min-width: 0; }
.replay-time { font-size: 12px; color: var(--ink-2); min-width: 150px; text-align: right; }
.chip-btn { font: 500 12px var(--sans); color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip-btn.on { color: var(--ink); border-color: var(--ink-2); }
.chip-btn i { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--muted)); opacity: .35; }
.chip-btn.on i { opacity: 1; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); display: inline-block; animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 60%, transparent); } 100% { box-shadow: 0 0 0 8px transparent; } }

/* cards */
.card { cursor: pointer; transition: transform .25s cubic-bezier(.2,.8,.2,1), border-color .25s, box-shadow .25s; will-change: transform; }
.card::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s;
  background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 0%), color-mix(in srgb, var(--c) 18%, transparent), transparent 70%); }
.card:hover, .card:focus-visible { border-color: color-mix(in srgb, var(--c) 55%, var(--line)); box-shadow: 0 18px 40px -20px color-mix(in srgb, var(--c) 60%, transparent); outline: none; }
.card:hover::after { opacity: 1; }
.card-sub { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 20px; }
.mark { font: 11px var(--mono); color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.card-open { display: block; margin-top: 12px; font: 600 12px var(--mono); color: var(--c); opacity: 0; transform: translateX(-6px); transition: .25s; }
.card:hover .card-open, .card:focus-visible .card-open { opacity: 1; transform: none; }

/* battle map */
.map-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; overflow-x: auto; }
.battle { display: grid; gap: 6px; min-width: 560px; }
.bm-row { display: grid; grid-template-columns: 110px repeat(5, minmax(0, 1fr)); gap: 6px; align-items: stretch; }
.bm-head span { font: 600 12px var(--mono); color: var(--ink-2); text-align: center; display: flex; flex-direction: column; }
.bm-head small { font-weight: 400; color: var(--muted); font-size: 11px; }
.bm-agent { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.bm-agent i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.bm-cell { border-radius: 8px; padding: 8px 6px; text-align: center; font: 600 13px var(--mono); background: var(--surface-2); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; transition: transform .15s; }
.bm-cell small { font-weight: 400; font-size: 11px; }
.bm-cell.flat { color: var(--muted); justify-content: center; }
.bm-cell.win { background: color-mix(in srgb, var(--good) calc(var(--heat) * 38% + 6%), var(--surface-2)); }
.bm-cell.lose { background: color-mix(in srgb, var(--bad) calc(var(--heat) * 38% + 6%), var(--surface-2)); }
.bm-cell:not(.flat):hover { transform: scale(1.05); border-color: var(--ink-2); }

/* chart draw-in */
.chart svg.draw path.line:not([stroke-dasharray]) { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.6s cubic-bezier(.3,.7,.2,1) forwards; animation-delay: var(--d); }
@keyframes draw { to { stroke-dashoffset: 0; } }
.legend i.you { background: repeating-linear-gradient(90deg, var(--accent) 0 4px, transparent 4px 7px); }

/* lab */
.lab { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 14px; }
.lab-form, .lab-result { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.field > span { font-size: 13px; color: var(--ink-2); display: flex; justify-content: space-between; }
.field b { font-family: var(--mono); color: var(--ink); }
.field input:not([type]) { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; color: var(--ink); font: 15px var(--sans); padding: 10px 12px; }
.field input:not([type]):focus { outline: none; border-color: var(--accent); }
.field input[type="range"] { accent-color: var(--accent); }
.styles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.style-opt { text-align: left; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; color: var(--ink); cursor: pointer; font: inherit; transition: border-color .2s, transform .15s; }
.style-opt b { display: block; font-size: 14px; }
.style-opt span { font-size: 12px; color: var(--muted); }
.style-opt:hover { transform: translateY(-1px); }
.style-opt.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.params { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.mk { display: flex; gap: 6px; flex-wrap: wrap; }
.mk-opt { font: 600 12px var(--mono); padding: 6px 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); cursor: pointer; }
.mk-opt.on { color: var(--ink); border-color: var(--accent); }
.toggles { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.switch { display: inline-flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); cursor: pointer; position: relative; }
.switch input { position: absolute; opacity: 0; }
.switch i { width: 34px; height: 20px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); position: relative; transition: .2s; flex-shrink: 0; }
.switch i::after { content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); top: 2px; left: 2px; transition: .2s; }
.switch input:checked + i { background: color-mix(in srgb, var(--accent) 30%, var(--surface-2)); border-color: var(--accent); }
.switch input:checked + i::after { left: 16px; background: var(--accent); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch.small { font-size: 12px; }
.progress { height: 4px; background: var(--surface-2); border-radius: 2px; margin-top: 12px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #e5484d); transition: width .15s; }
.lab-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 12px; color: var(--ink-2); min-height: 300px; }
.lab-empty p { max-width: 380px; }
.lab-empty-mark { width: 72px; height: 72px; border-radius: 50%; border: 2px dashed var(--line); display: grid; place-items: center; font: 700 30px var(--mono); color: var(--muted); animation: spin 14s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.lab-rank { display: flex; align-items: center; gap: 16px; animation: pop .6s cubic-bezier(.2,1.4,.4,1); }
.lab-rank-n { font: 700 54px var(--mono); line-height: 1; color: var(--accent); }
.lab-rank.gold .lab-rank-n { text-shadow: 0 0 24px color-mix(in srgb, var(--accent) 70%, transparent); }
.lab-rank b { display: block; font-size: 20px; }
.lab-rank span { font-size: 13px; color: var(--muted); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.lab-nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 20px 0; }
.lab-nums b { display: block; font: 600 18px var(--mono); }
.lab-nums span { font-size: 12px; color: var(--muted); }
.lab-board { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 6px; }
.lab-board li { position: relative; display: flex; justify-content: space-between; padding: 8px 12px; border-radius: 8px; background: var(--surface-2); overflow: hidden; font-size: 14px; }
.lab-board li i { position: absolute; left: 0; top: 0; bottom: 0; width: var(--w); background: color-mix(in srgb, var(--c) 22%, transparent); animation: grow 1s cubic-bezier(.2,.8,.2,1); }
.lab-board li span, .lab-board li b { position: relative; z-index: 1; }
.lab-board li b { font-family: var(--mono); }
.lab-board li.you { outline: 1px solid var(--accent); }
@keyframes grow { from { width: 0; } }
.lab-share { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* feed */
.filters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.hour { transition: border-color .2s; }
.hour:hover { border-color: color-mix(in srgb, var(--ink-2) 40%, var(--line)); }
.hour[open] { border-color: var(--ink-2); }
.chev { margin-left: auto; color: var(--muted); transition: transform .2s; font-size: 18px; }
.hour[open] .chev { transform: rotate(90deg); }
.hour-body { animation: fadeIn .35s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } }
.act b { font-weight: 600; }
.hash { grid-column: 1 / -1; color: var(--muted); margin: 0; font-family: var(--mono); }
.hash code { color: var(--ink-2); }

/* drawer */
.drawer { position: fixed; inset: 0; z-index: 30; pointer-events: none; }
.drawer-scrim { position: absolute; inset: 0; background: rgb(0 0 0 / .55); opacity: 0; transition: opacity .3s; backdrop-filter: blur(2px); }
.drawer-panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: var(--surface); border-left: 1px solid var(--line); padding: 28px 24px; overflow-y: auto; transform: translateX(100%); transition: transform .4s cubic-bezier(.2,.8,.2,1); }
.drawer.open { pointer-events: auto; }
.drawer.open .drawer-scrim { opacity: 1; }
.drawer.open .drawer-panel { transform: none; }
.drawer-close { position: absolute; top: 18px; right: 18px; background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
#drawer-body h3 { margin: 22px 0 10px; font-size: 13px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .08em; }
.dr-head { display: flex; gap: 14px; align-items: center; }
.dr-head h2 { font-size: 28px; }
.dr-orb { width: 54px; height: 54px; border-radius: 50%; background: var(--c); display: grid; place-items: center; font: 700 24px var(--sans); color: #0f0f0e; box-shadow: 0 0 30px color-mix(in srgb, var(--c) 60%, transparent); }
.dr-equity { display: flex; align-items: baseline; gap: 12px; margin-top: 14px; }
.dr-equity .equity { margin: 0; font-size: 30px; }
.dr-spark .spark { height: 80px; }
.dr-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.dr-stats div { background: var(--surface-2); border-radius: 10px; padding: 10px; }
.dr-stats b { display: block; font: 600 15px var(--mono); }
.dr-stats span { font-size: 11px; color: var(--muted); }
table.log { width: 100%; border-collapse: collapse; font: 12px var(--mono); }
table.log th, table.log td { text-align: left; padding: 6px; border-bottom: 1px solid var(--line); }
table.log th { color: var(--muted); font-weight: 400; }
.dr-actions { display: flex; gap: 10px; margin-top: 20px; }

/* toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 40; display: flex; flex-direction: column; gap: 8px; max-width: min(360px, calc(100vw - 32px)); }
.toast { background: #0b0b0a; border: 1px solid var(--line); border-left: 3px solid var(--c); border-radius: 10px; padding: 12px 14px; font-size: 14px; box-shadow: 0 10px 30px rgb(0 0 0 / .5); transform: translateX(120%); transition: transform .4s cubic-bezier(.2,.8,.2,1); }
.toast.in { transform: none; }

/* vote */
.vote-opt { transition: transform .15s, border-color .2s; }
.vote-opt:hover { transform: translateY(-2px); }
.vote-orb { width: 30px; height: 30px; border-radius: 50%; background: var(--c); display: grid; place-items: center; color: #0f0f0e; font-weight: 700; margin-bottom: 8px; }
.vote-opt .bar i { transition: width .8s cubic-bezier(.2,.8,.2,1); }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .hero-arena { max-width: 460px; margin: 0 auto; width: 100%; }
  .lab { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
  .replay-time { display: none; }
  .dr-stats { grid-template-columns: repeat(2, 1fr); }
  .params, .styles { grid-template-columns: 1fr; }
  .lab-nums { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  [data-reveal] { opacity: 1; transform: none; }
}
