:root {
    --bg: #fafafa;
    --bg-card: #ffffff;
    --text: #1a1a1a;
    --text-secondary: #555;
    --text-muted: #999;
    --border: #e5e5e5;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --red: #dc2626;
    --green: #16a34a;
    --blue: #2563eb;
    --purple: #7c3aed;
    --radius: 8px;
}

* { box-sizing: border-box; }

body {
    font-family: var(--font-body);
    margin: 0;
    padding: 0;
    background-color: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px 64px;
}

.header-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

/* Header */
.header {
    display: grid;
    gap: 18px;
    margin-bottom: 40px;
}

.banner-hero {
    position: relative;
    overflow: hidden;
    min-height: clamp(260px, 42vw, 420px);
    border-radius: 28px;
    border: 1px solid rgba(37, 99, 235, 0.14);
    box-shadow: 0 22px 55px rgba(15, 23, 42, 0.1);
    background:
        linear-gradient(135deg, rgba(15, 23, 42, 0.68) 0%, rgba(15, 23, 42, 0.28) 46%, rgba(15, 23, 42, 0.08) 100%);
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.header-link:hover .banner-hero,
.header-link:focus-visible .banner-hero {
    transform: translateY(-2px);
    box-shadow: 0 28px 60px rgba(15, 23, 42, 0.16);
}

.header-copy {
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    z-index: 2;
    max-width: min(560px, 100%);
}

.hero-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    padding: clamp(20px, 4vw, 34px);
    background:
        linear-gradient(90deg, rgba(15, 23, 42, 0.72) 0%, rgba(15, 23, 42, 0.46) 34%, rgba(15, 23, 42, 0.18) 60%, rgba(15, 23, 42, 0.02) 100%),
        linear-gradient(180deg, rgba(15, 23, 42, 0.08) 0%, rgba(15, 23, 42, 0.34) 100%);
}

.hero-kicker {
    width: fit-content;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.82);
    padding: 0.45rem 0.7rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.34);
    border: 1px solid rgba(255, 255, 255, 0.14);
}

.header h1 {
    font-family: var(--font-display);
    font-size: clamp(2.2rem, 5vw, 4.4rem);
    font-weight: 700;
    margin: 0;
    color: #fff;
    max-width: 11ch;
    line-height: 0.92;
    letter-spacing: -0.05em;
}

.header-subtitle {
    margin: 0;
    max-width: 44ch;
    color: rgba(255, 255, 255, 0.82);
    font-size: 1rem;
    line-height: 1.6;
}

.hero-banner {
    width: 100%;
    height: 100%;
    min-height: inherit;
    display: block;
    object-fit: cover;
    background: #fff;
}

/* Season Badge */
.season-badge {
    width: fit-content;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #f8fafc;
    background: rgba(37, 99, 235, 0.3);
    border: 1px solid rgba(191, 219, 254, 0.4);
    border-radius: 100px;
    padding: 4px 12px;
    white-space: nowrap;
}

.hero-bottom-fade {
    position: absolute;
    inset: auto 0 0;
    height: 22%;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0) 0%, rgba(15, 23, 42, 0.24) 100%);
    pointer-events: none;
}

@media (max-width: 720px) {
    .container {
        padding: 24px 16px 48px;
    }

    .header {
        gap: 14px;
    }

    .banner-hero {
        min-height: 320px;
        border-radius: 20px;
    }

    .hero-overlay {
        align-items: flex-end;
        padding: 18px;
        background:
            linear-gradient(180deg, rgba(15, 23, 42, 0.14) 0%, rgba(15, 23, 42, 0.58) 62%, rgba(15, 23, 42, 0.76) 100%);
    }

    .header h1 {
        max-width: none;
        font-size: clamp(2rem, 10vw, 2.9rem);
    }

    .header-subtitle {
        font-size: 0.94rem;
    }

    .hero-kicker {
        font-size: 0.64rem;
    }
}

/* Section Headings */
h2 {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin: 40px 0 4px;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

th {
    padding: 10px 16px;
    text-align: left;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background-color: #fafafa;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 10px 16px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

td:first-child {
    font-weight: 600;
    color: var(--text);
}

#stats-table td:first-child {
    min-width: 260px;
}

.model-link {
    color: inherit;
    text-decoration: none;
}

.game-participant {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.participant-role {
    color: var(--text-muted);
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background-color: #f8fafc;
}

/* Role colors in stats table */
#stats-table tbody td:nth-child(3) { font-weight: 600; color: var(--text); }
#stats-table tbody td:nth-child(4) { color: var(--red); }
#stats-table tbody td:nth-child(5) { color: var(--green); }
#stats-table tbody td:nth-child(6) { color: var(--blue); }

/* Game ID Link */
.game-id {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    cursor: pointer;
    color: var(--accent);
    text-decoration: none;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1;
    padding: 0.5rem 0.72rem;
    border-radius: 999px;
    border: 1px solid #bfdbfe;
    background:
        linear-gradient(180deg, #f8fbff 0%, #eef5ff 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
    transition: background-color 0.15s, border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.game-id::after {
    content: "Open";
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.18rem 0.42rem;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.1);
    color: var(--accent-hover);
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.game-id:hover {
    background: #dbeafe;
    border-color: #93c5fd;
    color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.12);
}

/* Loading */
.loading {
    text-align: center;
    padding: 32px 20px;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-radius: 50%;
    border-top-color: var(--accent);
    animation: spin 0.7s linear infinite;
    margin-bottom: 8px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Error */
.error {
    color: var(--red);
    padding: 16px;
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    text-align: center;
    font-weight: 600;
    font-size: 0.875rem;
}

/* Charts */
.chart-container {
    background-color: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    margin-bottom: 20px;
}

.chart {
    width: 100%;
    max-width: 100%;
    height: auto;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0; top: 0;
    width: 100%; height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(2px);
}

.modal-content {
    background-color: var(--bg-card);
    margin: 3% auto;
    padding: 24px;
    border: 1px solid var(--border);
    width: 90%;
    max-width: 1200px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.close {
    color: var(--text-muted);
    float: right;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    margin-top: -8px;
}

.close:hover { color: var(--text); }

/* Game Log */
.game-log {
    margin-top: 16px;
    padding: 16px;
    background-color: #f8fafc;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.round {
    margin-bottom: 16px;
    padding: 12px;
    background-color: var(--bg-card);
    border-radius: 6px;
    border: 1px solid #f0f0f0;
}

.round-title {
    font-weight: 600;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid #f0f0f0;
}

.round-section {
    font-weight: 600;
    margin-top: 12px;
    margin-bottom: 4px;
    padding-bottom: 3px;
    border-bottom: 1px dashed var(--border);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.elimination {
    margin: 6px 0;
    padding: 8px 10px;
    background-color: #fef2f2;
    border-left: 3px solid var(--red);
    border-radius: 4px;
    font-weight: 600;
    color: var(--red);
    font-size: 0.875rem;
}

.action {
    margin: 6px 0;
    padding: 10px;
    border-radius: 4px;
    border-left: 3px solid #e5e5e5;
    background-color: #fafafa;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.875rem;
    line-height: 1.5;
}

.action.mafia { color: var(--red); border-left-color: var(--red); }
.action.villager { color: var(--green); border-left-color: var(--green); }
.action.doctor { color: var(--blue); border-left-color: var(--blue); }

.mafia { color: var(--red); }
.villager { color: var(--green); }
.doctor { color: var(--blue); }

/* Game Info */
.game-info {
    margin-bottom: 16px;
    padding: 12px 16px;
    background-color: #f8fafc;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.participant {
    display: inline-block;
    margin-right: 8px;
    padding: 3px 8px;
    border-radius: 4px;
    margin-bottom: 4px;
    font-size: 0.8rem;
}

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

.game-row:hover {
    background-color: #f8fafc;
}

/* Footer */
footer {
    border-top: 1px solid var(--border) !important;
}

footer a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.8rem;
    transition: color 0.15s;
}

footer a:hover { color: var(--text-secondary); }

/* Responsive */
@media (max-width: 768px) {
    .container { padding: 20px 16px 40px; }
    .header { flex-wrap: wrap; gap: 12px; }
    .header h1 { font-size: 1.2rem; }
    .season-badge { margin-left: 0; }
    .logo { height: 40px; width: 40px; }
    th, td { padding: 8px 10px; font-size: 0.8rem; }
    table { display: block; overflow-x: auto; }
}
