:root {
    --bg: #0a090a;
    --card: rgba(255, 255, 255, .035);
    --card2: rgba(255, 255, 255, .06);
    --line: rgba(255, 255, 255, .08);
    --ink: #e8e6e6;
    --ink2: #a5a0a0;
    --muted: #6f6a6a;
    --red: #e42320;
    --red-deep: #a31612;
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: ParagraphFont, Arial, Helvetica, sans-serif;
    display: flex;
    flex-direction: column;
    overflow: hidden auto;
    user-select: none;
    -webkit-user-select: none;
}

/* ── header ─────────────────────────────── */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 22px 10px;
    max-width: 1060px;
    width: 100%;
    margin: 0 auto;
}

.brand { display: flex; align-items: center; gap: 12px; }

.dragon { width: 34px; height: 34px; border-radius: 8px; filter: drop-shadow(0 0 8px rgba(228, 35, 32, .35)); }

h1 {
    font-family: TitleFont, Arial, sans-serif;
    font-size: 22px;
    font-weight: 400;
    margin: 0;
    letter-spacing: .04em;
    text-transform: uppercase;
}

h1 span { color: var(--red); }

/* título + sub, sempre (pedido do mestre 23/07) */
.subline {
    margin: 1px 0 0;
    font-size: 12.5px;
    line-height: 1.35;
    color: var(--muted);
}

/* ── layout ─────────────────────────────── */
.stage {
    display: grid;
    grid-template-columns: minmax(230px, 340px) 1fr;
    gap: 18px;
    max-width: 1060px;
    width: 100%;
    margin: 0 auto;
    padding: 0 22px;
    flex: 1;
}

/* ── arena ──────────────────────────────── */
.arena {
    position: relative;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 18px 18px 56px;
    min-height: 300px;
    overflow: hidden;
}

.arena::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 42%, rgba(228, 35, 32, calc(.16 * var(--pulse, 0))), transparent 62%);
    transition: background .25s;
    pointer-events: none;
}

#mouse {
    width: min(72%, 240px);
    max-height: calc(100% - 40px);
}

#mouse path {
    fill: none;
    stroke: #4d4d4d;
    stroke-width: 1.06;
    transition: stroke .12s;
}

#mouse path.corner { stroke-width: .79; }

.progressWrap {
    position: absolute;
    left: 18px;
    right: 18px;
    bottom: 14px;
}

.progressLabel {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--ink2);
    margin-bottom: 6px;
    gap: 8px;
}

#progressPct { color: var(--ink); font-variant-numeric: tabular-nums; }

.meter {
    height: 6px;
    border-radius: 3px;
    background: rgba(228, 35, 32, .16);
    overflow: hidden;
}

.meterFill {
    height: 100%;
    width: 0%;
    border-radius: 3px;
    background: var(--red);
    transition: width .15s linear;
}

/* ── panel ──────────────────────────────── */
.panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
    justify-content: center;
}

.hero { padding: 4px 2px 0; }

.heroValue {
    font-family: TitleFont, Arial, sans-serif;
    font-size: clamp(46px, 7vw, 68px);
    line-height: 1;
    color: var(--ink);
}

.heroValue .unit {
    font-size: .38em;
    color: var(--red);
    margin-left: 8px;
    letter-spacing: .06em;
}

.heroLabel {
    color: var(--muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .12em;
    margin-top: 4px;
}

.tiles {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.tile {
    background: var(--card);
    border: 1px solid var(--line);
    border-left: 3px solid var(--red);
    border-radius: 10px;
    padding: 10px 12px;
    min-width: 0;
}

.tileLabel {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--muted);
    white-space: nowrap;
}

.tileValue {
    font-size: 21px;
    margin-top: 3px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.tileValue small { font-size: 12px; color: var(--ink2); }

/* ── result ─────────────────────────────── */
.resultCard {
    background: linear-gradient(120deg, rgba(228, 35, 32, .14), rgba(228, 35, 32, .04) 55%);
    border: 1px solid rgba(228, 35, 32, .35);
    border-radius: 12px;
    padding: 14px 16px;
    animation: pop .35s cubic-bezier(.2, 1.4, .4, 1);
}

@keyframes pop { from { transform: scale(.96); opacity: 0; } }

.resultTop { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }

.resultBadge {
    font-family: TitleFont, Arial, sans-serif;
    font-size: 24px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.resultHz { color: var(--red); font-size: 18px; font-variant-numeric: tabular-nums; }

.resultDesc { color: var(--ink2); font-size: 14px; margin: 6px 0 12px; }

.resultTip {
    color: #f0b429;
    background: rgba(240, 180, 41, .07);
    border: 1px solid rgba(240, 180, 41, .22);
    border-radius: 8px;
    padding: 8px 11px;
    font-size: 12.5px;
    line-height: 1.45;
    margin: 0 0 12px;
}

.resultActions { display: flex; gap: 10px; flex-wrap: wrap; }

.redBtn {
    background: var(--red);
    color: #fff;
    border: 0;
    border-radius: 8px;
    padding: 9px 16px;
    font-family: ParagraphFont, Arial, sans-serif;
    font-size: 14px;
    cursor: pointer;
}

.redBtn:hover { background: #f03330; }
.redBtn:active { background: var(--red-deep); }

.ghostBtn {
    background: transparent;
    color: var(--ink2);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 14px;
    font-family: ParagraphFont, Arial, sans-serif;
    font-size: 13px;
    cursor: pointer;
}

.ghostBtn:hover { color: var(--ink); border-color: rgba(255, 255, 255, .2); }

.iDot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid currentColor;
    font-size: 11px;
    font-style: normal;
    margin-right: 4px;
    vertical-align: -3px;
}

.browserNote {
    font-size: 12.5px;
    color: #f0b429;
    background: rgba(240, 180, 41, .08);
    border: 1px solid rgba(240, 180, 41, .25);
    border-radius: 8px;
    padding: 8px 12px;
}

/* ── chart ──────────────────────────────── */
.chartWrap {
    max-width: 1060px;
    width: 100%;
    margin: 14px auto 0;
    padding: 0 22px;
}

.chartTitle {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--muted);
    margin-bottom: 6px;
}

.chartBox {
    position: relative;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    height: 130px;
}

#chart { width: 100%; height: 100%; display: block; border-radius: 12px; }

.chartTip {
    position: absolute;
    pointer-events: none;
    background: #1c191c;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 5px 9px;
    font-size: 12px;
    color: var(--ink);
    white-space: nowrap;
    transform: translate(-50%, -130%);
    z-index: 3;
}

/* ── footer ─────────────────────────────── */
.foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    max-width: 1060px;
    width: 100%;
    margin: 0 auto;
    padding: 12px 22px 14px;
    font-size: 12.5px;
    color: var(--muted);
    flex-wrap: wrap;
}

.footBrand { font-family: TitleFont, Arial, sans-serif; letter-spacing: .18em; }

.tm { font-size: 8px; vertical-align: super; }

.foot a { color: var(--ink2); text-decoration: none; }
.foot a:hover { color: var(--red); }
.sep { margin: 0 8px; }

/* ── modal ──────────────────────────────── */
.modalBack {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .65);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    padding: 20px;
}

.modal {
    position: relative;
    background: #141114;
    border: 1px solid var(--line);
    border-top: 3px solid var(--red);
    border-radius: 14px;
    max-width: 520px;
    max-height: 84vh;
    overflow-y: auto;
    padding: 22px 26px;
    font-size: 14.5px;
    line-height: 1.55;
    color: var(--ink2);
}

.modal h2 {
    font-family: TitleFont, Arial, sans-serif;
    font-weight: 400;
    font-size: 18px;
    color: var(--ink);
    margin: 14px 0 6px;
}

.modal h2:first-of-type { margin-top: 0; }
.modal b { color: var(--ink); }
.modal ul { margin: 6px 0; padding-left: 20px; }
.modal li { margin: 3px 0; }

.modalClose {
    position: absolute;
    top: 10px;
    right: 14px;
    background: none;
    border: 0;
    color: var(--muted);
    font-size: 26px;
    cursor: pointer;
    line-height: 1;
}

.modalClose:hover { color: var(--ink); }

/* ── responsive ─────────────────────────── */
@media (max-height: 700px) {
    .arena { min-height: 214px; padding-bottom: 48px; }
    #mouse { width: min(52%, 170px); }
    .heroValue { font-size: 42px; }
    .chartBox { height: 112px; }
    .chartWrap { margin-top: 8px; }
    .stage { gap: 14px; }
    .panel { gap: 10px; }
    .topbar { padding-top: 10px; padding-bottom: 6px; }
    .foot { padding-top: 8px; padding-bottom: 10px; }
}

@media (max-width: 760px) {
    .stage { grid-template-columns: 1fr; }
    .arena { min-height: 240px; padding-bottom: 52px; }
    #mouse { width: min(46%, 160px); }
    .tiles { grid-template-columns: repeat(2, 1fr); }
    .heroValue { font-size: 52px; }
    .topbar { padding: 12px 16px 8px; }
    .stage, .chartWrap { padding: 0 16px; }
    .foot { justify-content: center; text-align: center; }
    body { overflow-y: auto; }
}

[hidden] { display: none !important; }

/* tooltips dos cards de métrica */
[data-tip] { position: relative; cursor: help; }

[data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 9px);
    /* --tipfix (app.js) desloca pra tooltip nunca vazar da janela/iframe */
    transform: translateX(calc(-50% + var(--tipfix, 0px)));
    background: #1c191c;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 8px;
    padding: 8px 11px;
    font-size: 12.5px;
    font-family: ParagraphFont, Arial, sans-serif;
    text-transform: none;
    letter-spacing: normal;
    color: var(--ink);
    width: min(210px, calc(100vw - 30px));
    white-space: normal;
    line-height: 1.45;
    text-align: left;
    z-index: 30;
    box-shadow: 0 8px 28px rgba(0, 0, 0, .55);
    pointer-events: none;
}

[data-tip]:hover::before {
    content: "";
    position: absolute;
    left: 50%;
    bottom: calc(100% + 4px);
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1c191c;
    z-index: 31;
    pointer-events: none;
}

/* pós-resultado em tela baixa: esconde o hero pra caber sem scroll */
@media (max-height: 700px) {
    body.isDone .hero { display: none; }
    body.isDone .resultCard { padding: 10px 14px; }
    body.isDone .resultDesc { margin-bottom: 8px; }
}

/* scrollbar tematizada (a cinza padrão destoa do dark) */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(228, 35, 32, .4); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: rgba(228, 35, 32, .65); }
html { scrollbar-width: thin; scrollbar-color: rgba(228, 35, 32, .4) transparent; }
