@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@300;400;500;700&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --blue: #2196F3;
    --red: #f44336;
    --green: #00ff41;
    --bg: #080a0c;
    --surface: #0d1117;
    --surface2: #161b22;
    --border: #1a2030;
    --text: #c9d1d9;
    --text-dim: #484f58;
    --text-muted: #30363d;
}

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: 'Orbitron', 'JetBrains Mono', sans-serif;
}

canvas#matrix-bg {
    position: fixed;
    inset: 0;
    width: 100%; height: 100%;
    z-index: 0;
    opacity: 0.04;
    pointer-events: none;
}

canvas#particles {
    position: fixed;
    inset: 0;
    width: 100%; height: 100%;
    z-index: 10;
    pointer-events: none;
}

/* ── Ticker ── */
.ticker-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 24px;
    overflow: hidden;
    z-index: 20;
    pointer-events: none;
}

.ticker-track {
    display: flex;
    gap: 48px;
    align-items: center;
    height: 100%;
    white-space: nowrap;
    will-change: transform;
    animation: ticker-scroll 60s linear infinite;
}

.ticker-item {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 1.5px;
    flex-shrink: 0;
    text-transform: lowercase;
}

.ticker-item.blue {
    color: var(--blue);
}

.ticker-item.red {
    color: var(--red);
}

@keyframes ticker-scroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-100%); }
}

/* ── Layout ── */
.app {
    position: relative;
    z-index: 1;
    height: 100vh;
    max-width: 100%;
    margin: 0;
    padding: 16px 0 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr minmax(180px, 0.4fr);
    grid-template-areas:
        "choice heatmap"
        "graph  graph";
    gap: 0;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--green), transparent);
    opacity: 0.15;
}

/* ── Choice Card ── */
.choice-card {
    grid-area: choice;
    padding: 0 40px;
    text-align: center;
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.choice-card::before { display: none; }

.choice-top {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 8px;
}

.choice-top h1 {
    font-family: 'Orbitron', sans-serif;
    font-size: 2.8rem;
    font-weight: 900;
    letter-spacing: 1.2rem;
    color: var(--green);
    text-shadow: 0 0 40px rgba(0,255,65,0.3);
}

.choice-question {
    color: var(--text-dim);
    font-size: 0.95rem;
    margin: 6px 0 28px;
}

.pills-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 48px;
}

.pill-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 5px;
    transition: all 0.3s cubic-bezier(.4,0,.2,1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 8px;
}

.pill-blue { color: var(--blue); }
.pill-blue:hover { text-shadow: 0 0 30px rgba(33,150,243,0.6); transform: scale(1.08); }

.pill-red { color: var(--red); }
.pill-red:hover { text-shadow: 0 0 30px rgba(244,67,54,0.6); transform: scale(1.08); }

.pill-btn:active { transform: scale(0.95); }
.pill-btn.selected { text-decoration: underline; text-underline-offset: 6px; }

.pill-icon { width: 32px; height: 16px; flex-shrink: 0; transform: rotate(-45deg); }

.pill-sep { width: 1px; height: 48px; background: var(--border); }

/* ── Matrix Status ── */
.matrix-status {
    position: absolute;
    left: 0;
    right: 0;
    top: 56%;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.95rem;
    letter-spacing: 3px;
    color: #fff;
    text-align: center;
    z-index: 2;
    pointer-events: none;
}

/* ── Cooldown Area ── */
.cooldown-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
}

.cooldown-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    letter-spacing: 2px;
    color: #fff;
}

.cooldown-text.ready { color: #fff; }

/* ── Graph Areas ── */
.graph-area {
    grid-area: graph;
    display: flex;
    flex-direction: column;
}

.graph-headers {
    display: flex;
    justify-content: space-between;
    padding: 0 8px;
    margin-bottom: 12px;
}

.graph-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.graph-header-right {
    justify-content: flex-end;
    text-align: right;
}

.gh-label {
    font-size: 0.65rem;
    letter-spacing: 2px;
    text-transform: none;
    font-weight: 500;
    color: var(--text-dim);
}
.gh-label.blue { color: rgba(33,150,243,0.6); }
.gh-label.red { color: rgba(244,67,54,0.6); }

.gh-sub {
    font-size: 0.6rem;
    color: var(--text);
    letter-spacing: 1px;
}

.gh-total {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1;
    margin-top: 4px;
}
.gh-total.blue { color: var(--blue); }
.gh-total.red { color: var(--red); }

.total-pill-icon {
    width: 20px;
    height: 10px;
    vertical-align: middle;
    margin-right: 2px;
    transform: rotate(-45deg);
}

.total-suffix {
    font-size: 0.7rem;
    letter-spacing: 2px;
    opacity: 0.5;
    margin-left: 4px;
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 1px;
    flex: 1;
    min-height: 0;
}

.bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    height: 100%;
    justify-content: flex-end;
}


.bar-fill {
    width: 100%;
    min-height: 3px;
    border-radius: 2px 2px 0 0;
    transition: height 0.8s cubic-bezier(.4,0,.2,1);
}
.bar-fill.blue { background: linear-gradient(to top, #0a2a4a, #0d47a1); }
.bar-fill.red { background: linear-gradient(to top, #4a0a0a, #8b1a1a); }
.bar-fill.empty { background: transparent; }

.bar-col {
    position: relative;
}

.bar-col::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1c2128;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.55rem;
    color: var(--text);
    white-space: nowrap;
    z-index: 30;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
}

.bar-col:hover::after {
    opacity: 1;
}

.bar-col:hover .bar-fill {
    opacity: 0.8;
    filter: brightness(1.3);
}

/* ── Heatmap ── */
.heatmap-area {
    grid-area: heatmap;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.heatmap-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 14px;
}

.heatmap-grid { display: flex; gap: 4px; }
.heatmap-week { display: flex; flex-direction: column; gap: 4px; }

.heatmap-cell {
    width: 16px;
    height: 16px;
    border-radius: 2px;
    background: var(--surface2);
    position: relative;
    transition: box-shadow 0.3s;
}

.heatmap-cell.blue-1 { background: rgba(33,150,243,0.25); }
.heatmap-cell.blue-2 { background: rgba(33,150,243,0.45); }
.heatmap-cell.blue-3 { background: rgba(33,150,243,0.65); }
.heatmap-cell.blue-4 { background: rgba(33,150,243,0.9); }
.heatmap-cell.red-1 { background: rgba(244,67,54,0.25); }
.heatmap-cell.red-2 { background: rgba(244,67,54,0.45); }
.heatmap-cell.red-3 { background: rgba(244,67,54,0.65); }
.heatmap-cell.red-4 { background: rgba(244,67,54,0.9); }
.heatmap-cell.mix-1 { background: linear-gradient(135deg, rgba(33,150,243,0.4), rgba(244,67,54,0.4)); }
.heatmap-cell.mix-2 { background: linear-gradient(135deg, rgba(33,150,243,0.6), rgba(244,67,54,0.6)); }
.heatmap-cell.mix-3 { background: linear-gradient(135deg, rgba(33,150,243,0.8), rgba(244,67,54,0.8)); }

.heatmap-cell:hover {
    outline: 1px solid var(--text-dim);
    outline-offset: 1px;
}

.heatmap-cell .tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1c2128;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.55rem;
    color: var(--text);
    white-space: nowrap;
    z-index: 10;
    pointer-events: none;
}

.heatmap-cell:hover .tooltip { display: block; }

.heatmap-labels {
    display: flex;
    gap: 4px;
    flex-direction: column;
    margin-right: 8px;
}

.heatmap-labels span {
    height: 16px;
    font-size: 0.55rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    display: flex;
    align-items: center;
}

.heatmap-legend {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 10px;
    font-size: 0.5rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.heatmap-legend .leg-box {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

/* ── Username Link ── */
.username-link {
    color: var(--green);
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.username-link:hover {
    opacity: 0.7;
}

/* ── Name Modal ── */
.name-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.name-modal-overlay.open {
    display: flex;
}

.name-modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    min-width: 280px;
}

.name-modal-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 4px;
    color: var(--green);
}

.name-input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 14px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    color: var(--text);
    letter-spacing: 1px;
    text-align: center;
    outline: none;
    width: 100%;
}

.name-input:focus {
    border-color: var(--green);
}

.name-save {
    background: none;
    border: 1px solid var(--green);
    border-radius: 6px;
    padding: 8px 24px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--green);
    cursor: pointer;
    transition: all 0.2s;
}

.name-save:hover {
    background: rgba(0,255,65,0.1);
}

/* ── Animations ── */
@keyframes flashWarn {
    0% { color: #ffc107 !important; text-shadow: 0 0 16px rgba(255,193,7,0.7); }
    100% { color: var(--text-dim) !important; text-shadow: none; }
}
.flash-warn { animation: flashWarn 5s ease-out forwards; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
.card { animation: fadeIn 0.5s cubic-bezier(.4,0,.2,1) both; }

/* ── Responsive ── */
@media (max-width: 700px) {
    html, body {
        overflow: auto;
        height: auto;
    }

    /* Ticker */
    .ticker-bar { height: 20px; }
    .ticker-item { font-size: 0.6rem; letter-spacing: 1px; }
    .ticker-track { gap: 24px; }

    /* Stack layout */
    .app {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        grid-template-areas: "choice" "heatmap" "graph";
        height: auto;
        min-height: 100vh;
        padding: 28px 14px 24px;
        gap: 18px;
    }

    /* Matrix status: hide from top, show inside flow */
    .matrix-status {
        position: relative;
        top: auto;
        left: auto;
        right: auto;
        font-size: 0.65rem;
        letter-spacing: 1.5px;
        padding: 4px 14px 0;
        margin-top: -8px;
    }

    /* Choice */
    .choice-card { padding: 10px 16px; min-height: auto; }
    .choice-top h1 { font-size: 1.5rem; letter-spacing: 0.5rem; }
    .choice-question { font-size: 0.78rem; margin: 4px 0 18px; }
    .pills-row { gap: 24px; }
    .pill-btn { font-size: 0.85rem; letter-spacing: 3px; padding: 10px 6px; gap: 6px; }
    .pill-icon { width: 24px; height: 12px; }
    .pill-sep { height: 36px; }

    /* Cooldown */
    .cooldown-area { margin-top: 14px; }
    .cooldown-text { font-size: 0.6rem; letter-spacing: 1px; }

    /* Heatmap */
    .heatmap-area { padding: 14px 10px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .heatmap-title { font-size: 0.5rem; letter-spacing: 2px; margin-bottom: 10px; }
    .heatmap-grid { gap: 3px; }
    .heatmap-week { gap: 3px; }
    .heatmap-cell { width: 8px; height: 8px; }
    .heatmap-labels span { height: 8px; font-size: 0.4rem; }
    .heatmap-labels { margin-right: 4px; }
    .heatmap-legend { font-size: 0.42rem; gap: 3px; margin-top: 8px; }
    .heatmap-legend .leg-box { width: 8px; height: 8px; }

    /* Graph */
    .graph-area { min-height: 160px; padding: 0 4px; }
    .graph-headers {
        flex-direction: column;
        gap: 10px;
        padding: 0 4px;
        margin-bottom: 8px;
    }
    .graph-headers > div:last-child { text-align: left; }
    .gh-label { font-size: 0.52rem; letter-spacing: 1px; white-space: nowrap; }
    .gh-total { font-size: 1.1rem; }
    .total-suffix { font-size: 0.55rem; letter-spacing: 1px; }
    .bar-chart { min-height: 140px; }
    .bar-col::after { font-size: 0.45rem; padding: 3px 5px; }

    /* Name modal */
    .name-modal { min-width: auto; width: calc(100vw - 40px); max-width: 320px; padding: 22px 20px; gap: 14px; }
    .name-modal-title { font-size: 0.6rem; letter-spacing: 3px; }
    .name-input { font-size: 0.8rem; padding: 10px 12px; }
    .name-save { font-size: 0.6rem; padding: 8px 20px; }
}
