:root {
    --bg-body: #1a1a2e;
    --bg-card: #16213e;
    --bg-control: #0f0f23;
    --accent: #4cc9f0;
    --text: #eee;
    --text-muted: #888;
    --text-dim: #aaa;
    --border: #444;
    --label-width: 250px;
}
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body {
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-body);
    color: var(--text);
    padding: 20px;
}
h1 {
    text-align: center;
    margin-bottom: 10px;
}
.page-nav {
    text-align: center;
    margin-bottom: 20px;
}
.page-nav a {
    color: var(--accent);
    text-decoration: none;
    font-size: 14px;
}
.page-nav a:hover {
    text-decoration: underline;
}
.container {
    max-width: 1400px;
    margin: 0 auto;
}
.chart-wrapper {
    position: relative;
}
.chart-controls {
    position: absolute;
    bottom: 0;
    right: 10px;
    display: flex;
    gap: 10px;
    background: var(--bg-control);
    padding: 6px 8px;
    border-radius: 6px;
}
.control-group {
    display: flex;
    gap: 5px;
    align-items: center;
}
.control-group:not(:last-child) {
    padding-right: 10px;
    border-right: 1px solid var(--border);
}
.zoom-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.zoom-btn:hover {
    background: var(--bg-body);
}
.zoom-level {
    color: var(--text-muted);
    font-size: 12px;
    padding: 0 8px;
}
.size-slider {
    display: flex;
    align-items: center;
    gap: 8px;
}
.size-option,
.sort-option {
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
}
.size-option.active,
.sort-option.active {
    color: var(--accent);
    font-weight: bold;
}
.slider-input {
    width: 60px;
    height: 4px;
    appearance: none;
    background: var(--bg-card);
    border-radius: 2px;
    cursor: pointer;
}
.slider-input::-webkit-slider-thumb {
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
}
.slider-input::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}
.filter-select {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
    max-width: 150px;
}
.filter-select:focus {
    outline: none;
    border-color: var(--accent);
}
.chart-container {
    background: var(--bg-card);
    border-radius: 0 0 8px 8px;
    overflow-x: auto;
    overflow-y: visible;
}
.year-header-wrapper {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--bg-card);
    overflow: hidden;
    border-radius: 8px 8px 0 0;
    padding-bottom: 40px;
}
.chart {
    height: auto;
    position: relative;
}
.year-header {
    display: flex;
    background: var(--bg-card);
    height: 40px;
    align-items: center;
}
.year-header-spacer {
    width: var(--label-width);
    flex-shrink: 0;
    background: var(--bg-card);
}
.year-header-timeline {
    flex: 1;
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
    padding-right: 100px;
}
.year-header-label {
    position: absolute;
    transform: translateX(-50%);
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    font-weight: bold;
}
.row {
    display: flex;
    align-items: stretch;
    min-height: 50px;
}
.row-label {
    width: var(--label-width);
    flex-shrink: 0;
    font-size: 14px;
    padding-right: 15px;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: sticky;
    left: 0;
    background: var(--bg-card);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}
.row-count {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-body);
    padding: 2px 6px;
    border-radius: 10px;
}
.row-timeline {
    flex: 1;
    position: relative;
    height: 40px;
    padding-right: 100px;
}
.episode {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    top: 50%;
    cursor: pointer;
    transition:
        transform 0.2s,
        box-shadow 0.2s;
    border: 2px solid rgba(255, 255, 255, 0.3);
}
.episode:hover {
    transform: translate(-50%, -50%) scale(1.5);
    box-shadow: 0 0 15px currentColor;
    z-index: 100;
}
.row-line {
    position: absolute;
    height: 3px;
    top: 50%;
    transform: translateY(-50%);
    border-radius: 2px;
    opacity: 0.5;
}
.year-lines {
    position: absolute;
    top: 0;
    left: var(--label-width);
    right: 0;
    bottom: 0;
    pointer-events: none;
    padding-right: 100px;
}
.year-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(255, 255, 255, 0.1);
}
.tooltip {
    position: fixed;
    background: var(--bg-control);
    border: 1px solid var(--border);
    padding: 12px;
    border-radius: 8px;
    font-size: 13px;
    max-width: 400px;
    pointer-events: none;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}
.tooltip-thumbnail {
    width: 150px;
    border-radius: 4px;
    margin-bottom: 10px;
}
.tooltip-title {
    font-weight: bold;
    margin-bottom: 8px;
    line-height: 1.3;
}
.tooltip-serie {
    color: var(--accent);
    font-size: 12px;
    margin-bottom: 8px;
}
.tooltip-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-bottom: 8px;
    color: var(--text-dim);
    font-size: 12px;
}
.tooltip-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}
.tooltip-players {
    color: var(--accent);
    font-size: 12px;
    margin-bottom: 8px;
    line-height: 1.4;
}
.tooltip-description {
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.4;
    max-height: 120px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 6;
    -webkit-box-orient: vertical;
}
.stats {
    margin-bottom: 30px;
    padding: 15px;
    background: var(--bg-card);
    border-radius: 8px;
}
.stats h3 {
    margin-bottom: 15px;
}
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}
.stat-card {
    background: var(--bg-body);
    padding: 15px;
    border-radius: 6px;
}
.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: var(--accent);
}
.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 5px;
}

/* Series-specific styles */
.series-row {
    display: flex;
    align-items: stretch;
    min-height: 50px;
}
.series-label {
    width: var(--label-width);
    flex-shrink: 0;
    font-size: 14px;
    padding-right: 15px;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: sticky;
    left: 0;
    background: var(--bg-card);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    cursor: pointer;
}
.series-label:hover span:first-child {
    color: var(--accent);
}
.series-count {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-body);
    padding: 2px 6px;
    border-radius: 10px;
}
.series-timeline {
    flex: 1;
    position: relative;
    height: 40px;
    padding-right: 100px;
}
.series-line {
    position: absolute;
    height: 3px;
    top: 50%;
    transform: translateY(-50%);
    border-radius: 2px;
    opacity: 0.5;
}

/* Player-specific styles */
.player-row {
    display: flex;
    align-items: stretch;
    min-height: 50px;
}
.player-label {
    width: var(--label-width);
    flex-shrink: 0;
    font-size: 14px;
    padding-right: 15px;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: sticky;
    left: 0;
    background: var(--bg-card);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    cursor: pointer;
}
.player-label:hover span:first-child {
    color: var(--accent);
}
.player-count {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-body);
    padding: 2px 6px;
    border-radius: 10px;
}
.player-timeline {
    flex: 1;
    position: relative;
    height: 40px;
    padding-right: 100px;
}
.player-line {
    position: absolute;
    height: 3px;
    top: 50%;
    transform: translateY(-50%);
    border-radius: 2px;
    opacity: 0.5;
}

@media (max-width: 768px) {
    :root {
        --label-width: 100px;
    }
    .row-label,
    .series-label {
        font-size: 11px;
        padding-right: 8px;
        white-space: normal;
        line-height: 1.2;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }
    .player-label {
        font-size: 11px;
        padding-right: 8px;
    }
    .row-count,
    .player-count,
    .series-count {
        display: none;
    }
    .chart-wrapper {
        display: flex;
        flex-direction: column;
    }
    .chart-controls {
        position: static;
        flex-wrap: wrap;
        justify-content: center;
        order: 1;
        margin-top: 10px;
        gap: 12px 8px;
    }
    .control-group:not(:last-child) {
        border-right: none;
        padding-right: 0;
    }
    .year-header-wrapper {
        padding-bottom: 10px;
    }
}
