/* ── Reset & Tokens ─────────────────────────────── */
:root {
    --bg:       #08080C;
    --surface:  #0E0E14;
    --border:   #1A1A24;
    --orange:   #FF6B00;
    --cyan:     #00E5FF;
    --text:     #C8C8D0;
    --text-dim: #8585A0;
    --text-bright: #F0F0F4;
    --card-bg:  #0C0C12;
    --font-display: 'Orbitron', sans-serif;
    --font-mono: 'DM Mono', monospace;
}

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

/* ── Noise Overlay ──────────────────────────────── */
.noise {
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    opacity: 0.035;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px;
    mix-blend-mode: overlay;
}

/* ── Body ───────────────────────────────────────── */
body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-mono);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── Header ─────────────────────────────────────── */
header {
    position: relative;
    padding: 2rem 2rem 0;
    max-width: 1280px;
    margin: 0 auto;
}

.header-inner {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 2rem;
    padding-bottom: 1.25rem;
}

.logo-block {
    position: relative;
    padding-left: 1rem;
}

.logo-accent {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--orange);
    border-radius: 2px;
    box-shadow: 0 0 12px var(--orange), 0 0 30px rgba(255, 107, 0, 0.3);
}

header h1 {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: 2.2rem;
    letter-spacing: 0.08em;
    color: var(--text-bright);
    line-height: 1;
}

.logo-sub {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.25em;
    color: var(--text-dim);
    margin-top: 0.4rem;
}

.header-stripe {
    height: 1px;
    background: linear-gradient(90deg, var(--orange), var(--orange) 30%, var(--border) 30%, var(--border));
}

/* ── Mode Nav ───────────────────────────────────── */
.mode-nav {
    display: flex;
    gap: 2px;
}

.mode-btn {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    padding: 0.6rem 1.4rem;
    cursor: pointer;
    transition: all 0.2s ease;
    clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
}

.mode-btn:first-child {
    clip-path: polygon(0 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
}

.mode-btn:last-child {
    clip-path: polygon(8px 0, 100% 0, 100% 100%, 0 100%);
}

.mode-btn:hover {
    color: var(--text);
    background: #141420;
}

.mode-btn.active {
    background: var(--orange);
    color: var(--bg);
    border-color: var(--orange);
}

.mode-indicator {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: transparent;
    transition: background 0.2s;
}

.mode-btn.active .mode-indicator {
    background: rgba(255, 255, 255, 0.4);
}

/* ── Grid ───────────────────────────────────────── */
.grid[hidden] {
    display: none;
}
.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem;
    padding-top: 1.5rem;
}

/* ── Cards ──────────────────────────────────────── */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    animation: cardIn 0.5s ease both;
    animation-delay: calc(var(--i, 0) * 0.07s);
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 107, 0, 0.15), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}

.card:hover::before {
    opacity: 1;
}

.card:hover {
    border-color: #252535;
}

@keyframes cardIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.full-width {
    grid-column: 1 / -1;
}

/* ── Card Header ────────────────────────────────── */
.card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.card-tag {
    font-family: var(--font-display);
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--orange);
    background: rgba(255, 107, 0, 0.12);
    border: 1px solid rgba(255, 107, 0, 0.15);
    padding: 0.2rem 0.6rem;
    clip-path: polygon(4px 0, 100% 0, calc(100% - 4px) 100%, 0 100%);
}

.card h2 {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-dim);
    letter-spacing: 0.02em;
}

/* ── Charts ─────────────────────────────────────── */
.chart-wrap {
    position: relative;
}

.chart-wrap canvas {
    width: 100% !important;
}

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 768px) {
    header {
        padding: 1.5rem 1rem 0;
    }

    .header-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .grid {
        grid-template-columns: 1fr;
        padding: 1rem;
    }

    header h1 {
        font-size: 1.6rem;
    }

    .history-view {
        padding: 1rem;
    }

    .history-controls {
        flex-direction: column;
    }
}

/* ── History View ──────────────────────────────── */
.history-view {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.5rem 2rem 2rem;
}

.history-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.history-input,
.history-select {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    padding: 0.55rem 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.history-input:focus,
.history-select:focus {
    border-color: var(--orange);
}

.history-input {
    flex: 1;
}

.history-select {
    cursor: pointer;
}

.history-select option {
    background: var(--surface);
    color: var(--text);
}

.history-table-wrap {
    overflow-x: auto;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.history-table th {
    font-family: var(--font-display);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--text-dim);
    text-align: left;
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.history-table td {
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.history-row {
    cursor: pointer;
    transition: background 0.15s;
}

.history-row:hover {
    background: rgba(255, 255, 255, 0.02);
}

.history-row.expanded {
    background: rgba(255, 107, 0, 0.04);
}

.col-date {
    color: var(--text-dim);
}

.col-score {
    font-weight: 500;
    color: var(--text-bright);
}

.col-mvp {
    color: var(--text-dim);
}

.mode-tag {
    font-family: var(--font-display);
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    padding: 0.15rem 0.5rem;
}

.result-badge {
    display: inline-block;
    font-family: var(--font-display);
    font-size: 0.6rem;
    font-weight: 900;
    letter-spacing: 0.05em;
    padding: 0.15rem 0.5rem;
    border-radius: 2px;
}

.badge-win {
    background: rgba(0, 229, 255, 0.15);
    color: var(--cyan);
    border: 1px solid rgba(0, 229, 255, 0.25);
}

.badge-loss {
    background: rgba(255, 60, 60, 0.15);
    color: #ff3c3c;
    border: 1px solid rgba(255, 60, 60, 0.25);
}

.forfeit-tag {
    font-family: var(--font-display);
    font-size: 0.5rem;
    font-weight: 700;
    color: var(--text-dim);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    padding: 0.1rem 0.35rem;
    margin-left: 0.4rem;
    vertical-align: middle;
}

/* ── Detail Row ────────────────────────────────── */
.detail-row td {
    padding: 0 1rem 0.8rem;
    background: rgba(255, 107, 0, 0.02);
    border-bottom: 1px solid var(--border);
}

.detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin-top: 0.4rem;
}

.detail-table th {
    font-family: var(--font-display);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    text-align: left;
    padding: 0.4rem 0.7rem;
    border-bottom: 1px solid var(--border);
}

.detail-table td {
    padding: 0.4rem 0.7rem;
    color: var(--text);
    border-bottom: none;
}

.detail-table tbody tr {
    transition: background 0.15s;
}

.detail-table tbody tr:hover {
    background: rgba(255, 107, 0, 0.06);
}

.detail-table .player-name {
    color: var(--text-bright);
    font-weight: 500;
}

/* ── Pagination ────────────────────────────────── */
.history-pagination {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 1rem;
    justify-content: center;
}

.page-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 0.4rem 0.7rem;
    cursor: pointer;
    transition: all 0.15s;
}

.page-btn:hover:not([disabled]) {
    color: var(--text);
    border-color: #252535;
}

.page-btn.active {
    background: var(--orange);
    color: var(--bg);
    border-color: var(--orange);
}

.page-btn[disabled] {
    opacity: 0.3;
    cursor: default;
}

.page-info {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-left: 0.75rem;
}

/* ── Streaks Display ───────────────────────────── */
.streaks-display {
    container-type: inline-size;
    display: flex;
    gap: clamp(1.5rem, 6cqi, 4rem);
    justify-content: center;
    align-items: center;
    padding: 1.5rem 0;
}

.streak-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.streak-circle {
    width: min(190px, 36cqi);
    height: min(190px, 36cqi);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid;
    flex-shrink: 1;
}

.streak-circle-win {
    border-color: rgba(0, 229, 255, 0.5);
    background: rgba(0, 229, 255, 0.10);
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.1), inset 0 0 20px rgba(0, 229, 255, 0.05);
}

.streak-circle-loss {
    border-color: rgba(255, 60, 60, 0.5);
    background: rgba(255, 60, 60, 0.10);
    box-shadow: 0 0 20px rgba(255, 60, 60, 0.1), inset 0 0 20px rgba(255, 60, 60, 0.05);
}

.streak-value {
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 7cqi, 2.4rem);
    font-weight: 900;
    line-height: 1;
}

.streak-circle-win .streak-value {
    color: var(--cyan);
}

.streak-circle-loss .streak-value {
    color: #ff3c3c;
}

.streak-label {
    font-family: var(--font-display);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--text-dim);
}

/* ── Scrollbar ──────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg);
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #2a2a3a;
}

/* ── Upload Page ──────────────────────────────── */
.upload-container {
    max-width: 640px;
    margin: 0 auto;
    padding: 1.5rem 2rem 2rem;
}

/* Nav anchor links match buttons */
a.mode-btn {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Auth form */
.auth-form {
    display: flex;
    gap: 0.5rem;
}

.upload-input {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    padding: 0.55rem 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.upload-input:focus {
    border-color: var(--orange);
}

.upload-btn {
    background: var(--orange);
    border: 1px solid var(--orange);
    color: var(--bg);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    padding: 0.55rem 1.4rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.upload-btn:hover {
    background: #ff8533;
    border-color: #ff8533;
}

.upload-error {
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: #ff3c3c;
}

/* Drop zone */
.drop-zone {
    border: 2px dashed var(--border);
    padding: 3rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--orange);
    background: rgba(255, 107, 0, 0.04);
}

.drop-zone-icon {
    font-size: 2rem;
    color: var(--text-dim);
    margin-bottom: 0.75rem;
    transition: color 0.25s;
}

.drop-zone:hover .drop-zone-icon,
.drop-zone.drag-over .drop-zone-icon {
    color: var(--orange);
}

.drop-zone-text {
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--text);
}

.drop-zone-sub {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 0.3rem;
}

/* File list */
.file-list {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.file-entry {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.75rem 1rem;
    animation: cardIn 0.3s ease both;
    transition: border-color 0.3s;
}

.file-entry[data-status="success"] {
    border-color: rgba(0, 229, 255, 0.4);
}

.file-entry[data-status="error"] {
    border-color: rgba(255, 60, 60, 0.4);
}

.file-entry[data-status="duplicate"] {
    border-color: rgba(255, 107, 0, 0.4);
}

.file-entry-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.file-entry-name {
    font-size: 0.8rem;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.file-entry-status {
    font-family: var(--font-display);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    white-space: nowrap;
    flex-shrink: 0;
}

.file-entry[data-status="success"] .file-entry-status {
    color: var(--cyan);
}

.file-entry[data-status="error"] .file-entry-status {
    color: #ff3c3c;
}

.file-entry[data-status="duplicate"] .file-entry-status {
    color: var(--orange);
}

/* Progress bar */
.file-progress-track {
    height: 3px;
    background: var(--border);
    overflow: hidden;
}

.file-progress-bar {
    height: 100%;
    width: 0;
    background: var(--orange);
    transition: width 0.2s;
}

.file-progress-bar.complete {
    background: var(--cyan);
}

.file-entry[data-status="error"] .file-progress-bar {
    background: #ff3c3c;
}

.file-entry[data-status="duplicate"] .file-progress-bar {
    background: var(--orange);
}

/* Upload responsive */
@media (max-width: 768px) {
    .upload-container {
        padding: 1rem;
    }

    .auth-form {
        flex-direction: column;
    }

    .drop-zone {
        padding: 2rem 1rem;
    }
}
