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

:root {
    --site-max-width: clamp(80rem, 90vw, 2200px);
    --site-max-width-wide: clamp(1400px, 92vw, 2800px);
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #111827;
    color: white;
    line-height: 1.6;
}

/* Header */
header {
    background-color: #1f2937;
    padding: 1rem;
    display: flex;
    align-items: center;
}

header a {
    color: white;
    text-decoration: none;
}

header a:hover {
    color: #fbbf24;
}

header > a {
    font-size: 1.125rem;
    font-weight: bold;
}

header > a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

nav {
    margin-left: 1.5rem;
}

nav ul {
    display: flex;
    list-style: none;
    gap: 1.5rem;
}

nav a {
    transition: color 0.2s;
    white-space: nowrap;
}

/* Five menu entries, the switch and the search share a narrower header */
@media (max-width: 1180px) {
    nav {
        margin-left: 1rem;
    }

    nav ul {
        gap: 1rem;
    }
}

/* Tablet, before the burger menu: logo without its name, switch without its label */
@media (min-width: 769px) and (max-width: 1024px) {
    header > a {
        font-size: 0;
    }

    nav ul {
        gap: 0.85rem;
    }

    .spoiler-toggle-text {
        display: none;
    }

    header input[type="text"] {
        width: 9rem;
    }
}

nav a.nav-active {
    color: #fbbf24;
}

.flex-grow {
    flex-grow: 1;
}

input[type="text"] {
    padding: 0.5rem;
    border-radius: 0.375rem;
    border: none;
    color: black;
    width: 16rem;
}

/* Main Content */
main {
    padding: 1.5rem;
    max-width: var(--site-max-width);
    margin: 0 auto;
}

/* Read by search engines and screen readers, not shown (pages whose design has no title) */
.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

h1 {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 1rem;
}

/* Tournament List */
#tournament-list {
    list-style: none;
}

#tournament-list > li {
    background-color: #1f2937;
    padding: 1.25rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    margin-bottom: 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

#tournament-list > li:hover {
    background-color: #374151;
}

.tournament-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 0.75rem;
}

.tournament-info {
    flex: 1;
}

.tournament-title {
    font-size: 1.25rem;
    font-weight: bold;
    color: #fbbf24;
    margin-bottom: 0.25rem;
}

.tournament-game {
    color: #d1d5db;
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.status-ongoing {
    background-color: #059669;
    color: white;
}

.status-upcoming {
    background-color: #2563eb;
    color: white;
}

.status-finished {
    background-color: #4b5563;
    color: white;
}

.tournament-details {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    font-size: 0.875rem;
}

.detail-label {
    color: #9ca3af;
}

.detail-value {
    color: white;
    font-weight: 600;
}

/* Match card links: one row on wide screens, split on phones */
.match-card-media,
.match-card-meta {
    display: contents;
}

/* Loading state */
.loading {
    text-align: center;
    color: #9ca3af;
    padding: 3rem;
}

#games-grid > .loading,
#players-list > .loading {
    grid-column: 1 / -1;
}

/* Games Grid */
#games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(clamp(288px, 18vw, 320px), 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.game-card {
    background-color: #1f2937;
    padding: 1rem;
    border-radius: 0.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.2s, background-color 0.2s;
}

.game-card:hover {
    background-color: #374151;
    transform: translateY(-4px);
}

.game-card img {
    width: min(100%, 256px);
    aspect-ratio: 256 / 360;
    height: auto;
    object-fit: cover;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

.game-card h3 {
    color: #fbbf24;
    font-weight: bold;
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.game-card p {
    color: #d1d5db;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.game-card a {
    color: #60a5fa;
    font-size: 0.875rem;
    text-decoration: none;
}

.game-card a:hover {
    text-decoration: underline;
}

/* Players List */
#players-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    align-items: stretch;
    gap: 1rem;
    margin-top: 2rem;
}

.player-card {
    background-color: #1f2937;
    padding: 1.25rem;
    border-radius: 0.5rem;
    height: 100%;
    /* Let the grid column constrain the card so long game names get truncated instead of overflowing */
    min-width: 0;
    display: flex;
    flex-direction: column;
    transition: background-color 0.2s;
}

.player-card:hover {
    background-color: #374151;
}

/* The players page renders thousands of cards: let the browser skip layout
   and painting for the ones far off screen. */
#players-list .player-card {
    content-visibility: auto;
    contain-intrinsic-size: auto 300px;
    /* Square by default, taller when the games list needs it (narrow columns on ultrawide screens) */
    width: 100%;
    height: auto;
}

.player-card h3 {
    color: #fbbf24;
    font-weight: bold;
    font-size: 1.125rem;
    margin-bottom: 0.75rem;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.player-stats {
    display: flex;
    gap: 1.5rem;
    font-size: 0.875rem;
    color: #9ca3af;
    margin-top: auto;
}

.player-stats span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Ensure tournament/status badges are inline and not absolutely positioned */
.tournament-header .status-badge,
.tournament-header .inline-status-badge,
.p-6 .status-badge,
.p-6 .inline-status-badge,
#tournaments-grid .status-badge,
#tournaments-grid .inline-status-badge,
#tournament-status .status-badge {
        position: static !important;
        top: auto !important;
        right: auto !important;
        transform: none !important;
        display: inline-flex;
        align-items: center;
        margin-left: 0.75rem;
        box-shadow: 0 1px 0 rgba(0,0,0,0.12);
}

/* Small screens: slightly smaller badge */
@media (max-width: 640px) {
    .tournament-header .status-badge,
    .tournament-header .inline-status-badge,
    #tournament-status .status-badge {
        padding: 0.25rem 0.5rem;
        font-size: 0.8rem;
        margin-left: 0.5rem;
    }
}

/* Racetime button (used in tournament and player views) */
.btn-racetime {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    color: #C2CECF;
    background: #222222;
    border: 1px solid #C2CECF;
    text-decoration: none;
    margin-right: 0.5rem;
}
.btn-racetime img { width: 16px; height: 16px; }

/* SpeedRunsLive wordmark, cropped from the 700x125 logo to its 514x75 lettering
   (offset 94,27); set --srl-logo-height to size it */
.srl-logo {
    --srl-logo-height: 16px;
    display: inline-block;
    flex-shrink: 0;
    height: var(--srl-logo-height);
    width: calc(var(--srl-logo-height) * 514 / 75);
    background: url('/assets/speedrunslive.png') no-repeat;
    background-size: calc(var(--srl-logo-height) * 700 / 75) auto;
    background-position: calc(var(--srl-logo-height) * -94 / 75) calc(var(--srl-logo-height) * -27 / 75);
}

.player-links a { margin-right: 0.5rem; }

/* Twitch button (purple) */
.btn-twitch {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    color: #9344ff;
    background: #222222;
    border: 1px solid #9344ff;
    text-decoration: none;
    margin-right: 0.5rem;
}
.btn-twitch img { width: 16px; height: 16px; }


/* Site logo (favicon) used next to the site title in the header */
.site-logo {
    width: 32px;
    height: 32px;
    margin-right: 0.25rem;
    vertical-align: middle;
    display: inline-block;
    border-radius: 6px;
    object-fit: cover;
}

/* ========================================
   SPOILER MODE - Toggle Button & Styles
   ======================================== */

.spoiler-toggle-container {
    display: flex;
    align-items: center;
    margin-right: 1rem;
}

.spoiler-toggle {
    display: inline-flex;
    align-items: center;
    position: relative;
    height: 1.75rem;
    /* Room for the knob on the left (off) or on the right (on) */
    padding: 0 0.6rem 0 1.85rem;
    border-radius: 2rem;
    border: none;
    background: #4b5563;
    cursor: pointer;
    font-size: 0.7rem;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.spoiler-toggle:hover {
    background: #6b7280;
}

/* On: results are hidden, the switch takes the accent color */
.spoiler-toggle.active {
    background: #fbbf24;
    padding: 0 1.85rem 0 0.6rem;
}

.spoiler-toggle.active:hover {
    background: #f59e0b;
}

.spoiler-toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-weight: 600;
    color: white;
    pointer-events: none;
}

.spoiler-toggle.active .spoiler-toggle-label {
    color: #111827;
}

.spoiler-toggle-knob {
    position: absolute;
    width: 1.35rem;
    height: 1.35rem;
    background: white;
    border-radius: 50%;
    top: 50%;
    left: 0.2rem;
    transform: translateY(-50%);
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.spoiler-toggle.active .spoiler-toggle-knob {
    left: calc(100% - 1.55rem);
}

.games-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    padding: 0 1rem;
}

.games-filter {
    flex: 1 1 18rem;
    max-width: 28rem;
    background: #374151;
    color: #f3f4f6;
    border: 1px solid #4b5563;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.games-filter::placeholder {
    color: #9ca3af;
}

.games-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    margin-bottom: 1.5rem;
    padding: 0 1rem;
    color: #9ca3af;
    font-size: 0.85rem;
}

.games-legend-keys {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
}

/* Spoiler content - hidden when spoiler mode is active */
body.spoiler-mode .spoiler-content {
    position: relative;
    color: transparent !important;
    background: #374151 !important;
    border-radius: 0.25rem;
    user-select: none;
}

body.spoiler-mode .spoiler-content * {
    visibility: hidden !important;
}

body.spoiler-mode .spoiler-content::after {
    content: '???';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #6b7280;
    font-weight: bold;
    visibility: visible !important;
}

/* Hide entire spoiler blocks (like winner sections) */
body.spoiler-mode .spoiler-block {
    display: none !important;
}

/* Hide bracket and matches list in spoiler mode */
body.spoiler-mode #bracket-container .bracket-container {
    display: none !important;
}

body.spoiler-mode #matches-list > *:not(.spoiler-message) {
    display: none !important;
}

/* Show spoiler message for matches */
body.spoiler-mode #matches-list::before {
    content: 'Matchs masqués en mode anti-spoiler';
    display: block;
    color: #9ca3af;
    font-style: italic;
    padding: 2rem;
    text-align: center;
    background: #1f2937;
    border-radius: 0.5rem;
}

/* Show group stage info in spoiler mode */
body.spoiler-mode .spoiler-groups-container {
    display: block !important;
}

/* Normalize winner styling when spoiler mode is active */
body.spoiler-mode .spoiler-winner {
    color: white !important;
    font-weight: normal !important;
}

/* Normalize bracket winner background when spoiler mode is active */
body.spoiler-mode .spoiler-bracket-winner {
    background-color: #1f2937 !important;
}

/* Blur effect for spoiler images/avatars */
body.spoiler-mode .spoiler-blur {
    filter: blur(8px);
}

/* Hide spoiler text inline */
body.spoiler-mode .spoiler-text {
    color: transparent !important;
    background: linear-gradient(90deg, #374151, #4b5563) !important;
    border-radius: 0.2rem;
    padding: 0 0.25rem;
}

body.spoiler-mode .spoiler-text::before {
    content: '???';
    color: #6b7280;
}

/* ========================================
   FOOTER STYLES
   ======================================== */

.site-footer {
    background-color: #1f2937;
    border-top: 1px solid #374151;
    padding: 2.5rem 1.5rem 1.5rem;
    margin-top: auto;
}

.footer-container {
    max-width: var(--site-max-width);
    margin: 0 auto;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 3rem;
}

/* Language Selector */
.footer-language {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.footer-language-label {
    font-size: 0.75rem;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.language-select {
    background-color: #161b22;
    border: 1px solid #30363d;
    border-radius: 0.375rem;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    color: #c9d1d9;
    font-size: 0.875rem;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%238b949e'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1rem;
    min-width: 140px;
}

.language-select:hover {
    border-color: #8b949e;
}

.language-select:focus {
    outline: none;
    border-color: #fbbf24;
    box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.2);
}

/* Footer Sections */
.footer-sections {
    display: flex;
    gap: 4rem;
    flex-wrap: wrap;
}

.footer-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.footer-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: #f0f6fc;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.footer-section a {
    color: #8b949e;
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s;
}

.footer-section a:hover {
    color: #fbbf24;
}

/* Footer Bottom */
.footer-bottom {
    max-width: var(--site-max-width);
    margin: 2rem auto 0;
    padding-top: 1.5rem;
    border-top: 1px solid #21262d;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-copyright {
    color: #8b949e;
    font-size: 0.75rem;
}

.footer-social {
    display: flex;
    gap: 1rem;
}

.footer-social a {
    color: #8b949e;
    transition: color 0.2s;
}

.footer-social a:hover {
    color: #fbbf24;
}

/* Footer Actions Container */
.footer-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* Ko-fi Button */
.footer-kofi-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 6px 12px;
    height: 36px;
    border-radius: 0.5rem;
    background-color: transparent;
    color: #e5e7eb;
    font-weight: 600;
    font-size: 0.9rem;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease, color 0.25s ease;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid #30363d;
}

.kofi-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.footer-kofi-btn:hover {
    transform: translateY(-2px) scale(1.07);
    border-color: #ff5e5b;
    color: #ff5e5b;
    box-shadow: 0 6px 18px rgba(255, 94, 91, 0.12);
    background-color: rgba(255, 94, 91, 0.03);
}

.footer-kofi-btn:active {
    transform: scale(0.98);
}

/* Filter Button Styles */
.filter-btn {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 600;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
}

.filter-btn.active {
    background-color: rgb(234, 179, 8);
    color: black;
}

.filter-btn:not(.active) {
    background-color: rgb(55, 65, 81);
    color: white;
}

.filter-btn:not(.active):hover {
    background-color: rgb(75, 85, 99);
}

/* Ensure social icons align vertically within the footer actions */
.footer-actions {
    display: flex;
    align-items: center;
}

.footer-actions > a.footer-kofi-btn {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
}

.footer-social {
    display: flex;
    align-items: center;
}

.footer-social a {
    display: inline-flex;
    align-items: center;
}

.footer-social svg,
.kofi-icon {
    vertical-align: middle;
    display: block;
}

/* Responsive Footer */
@media (max-width: 768px) {
    .footer-actions {
        gap: 1rem;
    }
    
    /* Taller touch target */
    .footer-kofi-btn {
        width: auto;
        height: 44px;
        padding: 6px 12px;
    }

    .footer-container {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .footer-sections {
        gap: 2rem;
    }

    .footer-section {
        min-width: 140px;
    }

    .footer-bottom {
        flex-direction: column;
        text-align: center;
    }
}

/* ========================================
   STREAMS PAGE STYLES
   ======================================== */

.streams-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(clamp(280px, 24vw, 360px), 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.stream-card {
    display: block;
    background-color: #1f2937;
    border-radius: 0.5rem;
    overflow: hidden;
    color: inherit;
    text-decoration: none;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stream-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}

.stream-thumbnail {
    position: relative;
    aspect-ratio: 16/9;
    background-color: #111827;
}

.stream-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.stream-live-badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    background-color: #ef4444;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.stream-live-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    background-color: white;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.stream-viewers {
    position: absolute;
    bottom: 0.5rem;
    left: 0.5rem;
    background-color: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
}

.stream-info {
    padding: 1rem;
}

.stream-title {
    color: #f0f6fc;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    display: -webkit-box;
    /* Prefer standard property when available, keep -webkit fallback */
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.stream-channel {
    color: #fbbf24;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.stream-game {
    color: #8b949e;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    line-height: 1;
    vertical-align: middle;
}

.stream-game .game-link {
    display: inline-block;
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    color: #60a5fa;
    transition: color 0.2s;
}

.stream-game .game-link:hover {
    color: #fbbf24;
}

.no-streams {
    text-align: center;
    color: #8b949e;
    padding: 4rem 2rem;
    background-color: #1f2937;
    border-radius: 0.5rem;
}

/* ========================================
   ABOUT PAGE STYLES
   ======================================== */

.about-hero {
    text-align: center;
    padding: 3rem 1rem;
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    border-radius: 0.5rem;
    margin-bottom: 2rem;
}

.about-hero h1 {
    font-size: 2.5rem;
    color: #fbbf24;
    margin-bottom: 1rem;
}

.about-hero p {
    color: #9ca3af;
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto;
}

.about-section {
    background-color: #1f2937;
    padding: 2rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
}

.about-section h2 {
    color: #fbbf24;
    font-size: 1.5rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.about-section p {
    color: #d1d5db;
    line-height: 1.8;
    margin-bottom: 1rem;
}

.about-section p:last-child {
    margin-bottom: 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.stat-card {
    background-color: #111827;
    padding: 1.5rem;
    border-radius: 0.5rem;
    text-align: center;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: #fbbf24;
    display: block;
}

.stat-label {
    color: #9ca3af;
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.feature-card {
    background-color: #111827;
    padding: 1.5rem;
    border-radius: 0.5rem;
}

.feature-card h3 {
    color: #f0f6fc;
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.feature-card p {
    color: #9ca3af;
    font-size: 0.9rem;
    margin: 0;
}

/* ========================================
   RESOURCES PAGE STYLES
   ======================================== */

.resources-intro {
    text-align: center;
    padding: 2rem;
    background-color: #1f2937;
    border-radius: 0.5rem;
    margin-bottom: 2rem;
}

.resources-intro p {
    color: #9ca3af;
    max-width: 700px;
    margin: 0 auto;
}

.resources-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(clamp(260px, 24vw, 320px), 1fr));
    gap: 1.5rem;
}

.resource-card {
    background-color: #1f2937;
    padding: 1.5rem;
    border-radius: 0.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.resource-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.resource-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.resource-logo {
    width: 48px;
    height: 48px;
    border-radius: 0.5rem;
    object-fit: contain;
    background-color: #111827;
    padding: 0.5rem;
}

.resource-name {
    color: #fbbf24;
    font-size: 1.25rem;
    font-weight: 600;
}

.resource-description {
    color: #9ca3af;
    font-size: 0.9rem;
    line-height: 1.6;
    flex-grow: 1;
    margin-bottom: 1rem;
}

.resource-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: #60a5fa;
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s;
}

.resource-link:hover {
    color: #fbbf24;
}

/* ========================================
   TERMS PAGE STYLES
   ======================================== */

.terms-content {
    background-color: #1f2937;
    padding: 2.5rem;
    border-radius: 0.5rem;
}

.terms-content h1 {
    color: #fbbf24;
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.terms-updated {
    color: #8b949e;
    font-size: 0.875rem;
    margin-bottom: 2rem;
}

.terms-content h2 {
    color: #f0f6fc;
    font-size: 1.25rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.terms-content p {
    color: #d1d5db;
    line-height: 1.8;
    margin-bottom: 1rem;
}

.terms-content ul {
    color: #d1d5db;
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.terms-content li {
    margin-bottom: 0.5rem;
}

.terms-content a {
    color: #60a5fa;
    text-decoration: none;
}

.terms-content a:hover {
    text-decoration: underline;
}

/* ========================================
   RESPONSIVE STYLES - Mobile First
   ======================================== */

/* Utility classes for responsive layouts */
.main-container {
    max-width: var(--site-max-width-wide);
    margin: 2rem auto;
    padding: 1rem;
}

/* Densité fluide: les grilles gagnent des colonnes progressivement */

.home-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 2rem;
}

/* Introduction banner for first-time visitors */
.home-hero {
    position: relative;
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    border: 1px solid #374151;
    border-radius: 0.75rem;
    padding: 2rem 2.5rem;
    margin-bottom: 2.5rem;
}

.home-hero-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 2rem;
    height: 2rem;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #9ca3af;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

.home-hero-close:hover {
    background: #374151;
    color: #f3f4f6;
}

.home-hero-title {
    color: #fbbf24;
    font-size: 1.75rem;
    font-weight: bold;
    margin: 0 2rem 0.75rem 0;
}

.home-hero-text {
    color: #d1d5db;
    font-size: 1.05rem;
    line-height: 1.6;
    max-width: 52rem;
    margin: 0 0 1.5rem 0;
}

.home-hero-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 2rem;
    margin-bottom: 1.5rem;
}

.home-hero-stats a {
    color: #9ca3af;
    text-decoration: none;
}

.home-hero-stats a:hover {
    color: #f3f4f6;
}

.home-hero-stats strong {
    color: #f3f4f6;
    font-size: 1.35rem;
}

.home-hero-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
}

.home-hero-btn {
    display: inline-block;
    padding: 0.6rem 1.25rem;
    border-radius: 0.5rem;
    border: 1px solid #4b5563;
    color: #f3f4f6;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s, border-color 0.2s;
}

.home-hero-btn:hover {
    background: #374151;
}

.home-hero-btn-primary {
    background: #fbbf24;
    border-color: #fbbf24;
    color: #111827;
}

.home-hero-btn-primary:hover {
    background: #f59e0b;
    border-color: #f59e0b;
}

.home-hero-link {
    color: #60a5fa;
    text-decoration: underline;
}

.home-hero-link:hover {
    color: #fbbf24;
}

/* Live streams on the home page */
.home-live {
    margin-bottom: 2.5rem;
}

.home-live-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem 1rem;
}

.home-live-header a {
    color: #60a5fa;
    text-decoration: none;
    font-size: 0.9rem;
}

.home-live-header a:hover {
    color: #fbbf24;
}

/* Four streams on one row on a wide screen */
.home-live-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
    margin-top: 0;
}

@media (max-width: 640px) {
    .home-hero {
        padding: 1.25rem;
    }

    .home-hero-title {
        font-size: 1.3rem;
    }

    .home-hero-text {
        font-size: 0.95rem;
    }

    .home-hero-stats {
        gap: 0.5rem 1.25rem;
    }

    /* Two small streams per row, so the races stay close */
    .home-live .home-live-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.75rem;
    }

    .home-live-grid .stream-info {
        padding: 0.5rem 0.6rem;
    }

    .home-live-grid .stream-title {
        font-size: 0.75rem;
    }

    .home-live-grid .stream-game {
        display: none;
    }

    .home-live-header .section-title {
        margin-bottom: 0.25rem;
    }

    .home-live-header {
        margin-bottom: 0.75rem;
    }
}

.section-title {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 1.5rem;
    color: #ffffff;
}

.card-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.two-column-grid {
    display: grid;
    /* minmax(0, …) lets a column shrink below its longest unbreakable line */
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 2rem;
}

.detail-header {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    background: #1f2937;
    padding: 2rem;
    border-radius: 0.5rem;
}

.detail-header-vertical {
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.info-card {
    background: #374151;
    padding: 1rem;
    border-radius: 0.5rem;
}

.tabs-container {
    border-bottom: 2px solid #374151;
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* Prevent flex wrapping to ensure horizontal scroll */
    flex-wrap: nowrap;
}

.tabs-container::-webkit-scrollbar {
    display: none;
}

/* Mobile: wrap tabs on multiple lines instead of scrolling */
@media (max-width: 768px) {
    .tabs-container {
        flex-wrap: wrap;
        overflow-x: visible;
        gap: 0.5rem;
        border-bottom: none;
        padding-bottom: 0.5rem;
    }
    
    .tabs-container .tab-btn {
        flex: 1 1 calc(50% - 0.25rem);
        min-width: 0;
        text-align: center;
        padding: 0.6rem 0.75rem;
        font-size: 0.8rem;
        border: 1px solid #374151;
        border-radius: 0.5rem;
        margin-bottom: 0;
    }
    
    .tabs-container .tab-btn.active {
        border-color: #fbbf24;
        background: rgba(251, 191, 36, 0.1);
    }
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: center;
}

.filter-buttons {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.filter-buttons::-webkit-scrollbar {
    display: none;
}

.tournaments-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(clamp(280px, 23vw, 340px), 1fr));
    gap: 1rem;
}

.tournament-hover-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.races-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(clamp(320px, 28vw, 380px), 1fr));
    gap: 1rem;
}

.pagination-container {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

/* Detail pages */
.detail-page {
    max-width: 1200px;
}

.detail-section {
    margin-bottom: 2rem;
}

.detail-section h2 {
    margin-bottom: 1rem;
}

/* Player detail */
.player-header {
    align-items: center;
}

.player-header .avatar-wrap {
    width: 200px;
    height: 200px;
    flex: 0 0 200px;
    border-radius: 50%;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
    background: #374151;
}

.player-header .avatar-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.player-header .player-info {
    flex: 1;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.player-header .player-info h1 {
    font-size: 2rem;
    font-weight: bold;
    color: #fbbf24;
    margin-bottom: 0.5rem;
}

.player-header .player-links {
    color: #60a5fa;
    margin-bottom: 1rem;
    min-height: 2.5rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.player-games-summary {
    margin-top: 0.35rem;
    padding-top: 0.5rem;
    border-top: 1px solid transparent;
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    grid-template-rows: repeat(var(--game-summary-rows, 1), minmax(0, auto));
    grid-auto-flow: column;
    gap: 0.25rem 0.45rem;
    min-height: 4.8rem;
    align-content: start;
}

.player-games-summary.is-visible {
    border-top-color: #374151;
}

.player-games-summary.cols-1 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
}

.player-games-summary.cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.player-games-summary.cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.player-games-summary-title {
    color: #9ca3af;
    font-size: 0.8rem;
    margin-bottom: 0.35rem;
}

.player-games-summary-row {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.25rem;
    font-size: 0.75rem;
    min-width: 0;
    width: 100%;
}

.player-games-summary-row a {
    color: #60a5fa;
    text-decoration: none;
    transition: color 0.2s;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 0 1 auto;
    max-width: calc(100% - 2.8rem);
    min-width: 0;
}

.player-games-summary-row a:hover {
    color: #fbbf24;
}

.player-games-summary-row .count {
    color: #10b981;
    font-weight: 700;
    flex: 0 0 auto;
}

/* Player page: race and tournament result cards */
.result-card {
    position: relative;
    background: #1f2937;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    transition: background 0.2s;
}

.result-card:hover {
    background: #374151;
}

.result-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.25rem;
}

.result-card-head h3 {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: 0.95rem;
    color: #fbbf24;
}

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

/* The whole card opens the race or tournament */
.result-card-link::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
}

.result-card-result {
    flex: 0 0 auto;
    font-weight: bold;
    font-size: 0.875rem;
    color: #10b981;
    white-space: nowrap;
}

.result-card-result.is-gold { color: #fbbf24; }
.result-card-result.is-silver { color: #d1d5db; }
.result-card-result.is-bronze { color: #d97706; }
.result-card-result.is-muted { color: #9ca3af; font-weight: normal; }
.result-card-result.is-record { color: #93c5fd; }

.result-card-subtitle {
    color: #d1d5db;
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.result-card-team {
    color: #9ca3af;
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
}

/* Teammates' pages, above the card link */
.result-card-inner-link {
    position: relative;
    z-index: 1;
    color: #93c5fd;
    text-decoration: none;
}

.result-card-inner-link:hover {
    text-decoration: underline;
}

.result-card-meta {
    color: #9ca3af;
    font-size: 0.75rem;
}

.tournament-hover-card {
    transition: background 0.2s;
}

.tournament-hover-card:hover {
    background: #374151 !important;
}

/* Game detail */
/* The overview makes the text taller than the poster: the poster stays centered beside it */
.game-header {
    align-items: center;
}

.game-poster {
    width: 256px;
    height: 360px;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
    flex-shrink: 0;
}

.game-poster-missing {
    background: #1f2937;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    box-sizing: border-box;
    font-size: 2.5rem;
    font-weight: bold;
    color: #6b7280;
    text-transform: uppercase;
    text-align: center;
}

/* The id of a game without a cover stays on one line, cropped if too long */
.poster-missing-name {
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.game-info {
    flex: 1;
}

.game-info h1 {
    font-size: 2rem;
    font-weight: bold;
    color: #fbbf24;
    margin-bottom: 0.5rem;
}

.game-info h2 {
    color: #9ca3af;
    margin-bottom: 0.25rem;
    font-size: 1.25rem;
}

/* Glossary of the About page */
.glossary {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
    gap: 0.75rem 1.5rem;
    margin-top: 1rem;
}

.glossary-item {
    background: #111827;
    border-radius: 0.5rem;
    padding: 0.85rem 1rem;
    scroll-margin-top: 5rem;
}

.glossary dt {
    color: #fbbf24;
    font-weight: 600;
    margin-bottom: 0.3rem;
}

.glossary dd {
    color: #d1d5db;
    margin: 0;
    line-height: 1.5;
    font-size: 0.95rem;
}

#glossary {
    scroll-margin-top: 4rem;
}

/* Game overview, next to the poster */
.game-overview {
    margin-top: 1.25rem;
}

.game-overview-facts {
    color: #9ca3af;
    font-size: 0.9rem;
    margin: 0 0 1rem 0;
}

.game-overview-figures {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.75rem;
    margin-bottom: 1rem;
}

.game-overview-figures a {
    color: #9ca3af;
    text-decoration: none;
}

.game-overview-figures a:hover {
    color: #f3f4f6;
}

.game-overview-figures strong {
    color: #f3f4f6;
    font-size: 1.25rem;
}

.game-overview-tournament {
    color: #d1d5db;
    margin: 0 0 1.25rem 0;
}

.game-overview-tournament a {
    color: #60a5fa;
}

.game-overview-tournament a:hover {
    color: #fbbf24;
}

.game-overview-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.game-overview-actions button {
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

@media (max-width: 768px) {
    .game-overview-figures,
    .game-overview-actions {
        justify-content: center;
    }
}

/* Tabs */
.tabs-container .tab-btn {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-size: 1rem;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.tabs-container .tab-btn.active {
    color: #fbbf24;
    border-bottom-color: #fbbf24;
}

.tabs-container .tab-btn:hover {
    color: #fbbf24;
}

/* Game history tab: a vertical timeline */
.history-intro {
    color: #d1d5db;
    font-size: 1.05rem;
    line-height: 1.7;
    max-width: 52rem;
    margin-bottom: 2rem;
}

.history-timeline {
    list-style: none;
    margin: 0;
    padding: 0 0 0 1.75rem;
    border-left: 2px solid #374151;
    max-width: 52rem;
}

.history-event {
    position: relative;
    padding-bottom: 1.75rem;
}

.history-event::before {
    content: '';
    position: absolute;
    left: calc(-1.75rem - 7px);
    top: 0.35rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fbbf24;
    box-shadow: 0 0 0 4px #111827;
}

.history-date {
    color: #fbbf24;
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.04em;
}

.history-title {
    margin: 0.2rem 0 0.4rem;
    font-size: 1.15rem;
    color: #f3f4f6;
}

.history-text {
    margin: 0;
    color: #9ca3af;
    line-height: 1.65;
}

.history-sources-title {
    margin-top: 1rem;
    font-size: 1rem;
    color: #d1d5db;
}

.history-sources {
    padding-left: 1.25rem;
    color: #9ca3af;
    font-size: 0.875rem;
    line-height: 1.8;
}

.history-sources a {
    color: #60a5fa;
}

@media (max-width: 640px) {
    .history-timeline {
        padding-left: 1.25rem;
    }

    .history-event::before {
        left: calc(-1.25rem - 7px);
    }
}

/* Utility classes */
.text-muted {
    color: #9ca3af;
}

/* Detail cards */
.detail-card {
    background: #1f2937;
    padding: 2rem;
    border-radius: 0.5rem;
    margin-bottom: 2rem;
}

.detail-card h2 {
    color: #fbbf24;
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
}

/* Race detail */
.race-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    gap: 1rem;
}

.race-title-row h1 {
    font-size: 1.75rem;
    font-weight: bold;
    color: #fbbf24;
    margin-bottom: 0.5rem;
}

.race-goal {
    color: #d1d5db;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.race-info-text {
    font-size: 0.875rem;
    margin-bottom: 1rem;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.race-info-text a {
    word-break: break-all;
}

/* Seed hash shown as the game's icons (public/js/hash-icons.js) */
.hash-icons {
    font-style: normal;
}

/* Fixed height: a composite of two items (one of them) shows twice as wide */
.hash-icon {
    width: auto;
    height: 1.75rem;
    max-width: 4rem;
    margin: 0 0.1rem;
    object-fit: contain;
    vertical-align: middle;
}

/* Hash word without an image */
.hash-word {
    display: inline-block;
    margin: 0 0.1rem;
    padding: 0.05rem 0.35rem;
    border: 1px solid currentColor;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    line-height: 1.5rem;
    opacity: 0.85;
}

.race-links {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
}

.race-links a {
    word-break: break-word;
    max-width: 100%;
}

.race-stats-grid {
    margin-top: 1.5rem;
}

.info-label {
    color: #9ca3af;
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
}

.info-value {
    color: #fff;
    font-weight: 600;
}

.race-links {
    margin-top: 1.5rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.tournament-link-card {
    display: none;
    background: #374151;
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 2rem;
}

.tournament-link-card a {
    color: #fbbf24;
    text-decoration: none;
    font-weight: 600;
}

.tournament-link-card a:hover {
    text-decoration: underline;
}

/* Tournament detail */
.tournament-header-card {
    margin-bottom: 2rem;
}

.tournament-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.tournament-title-info {
    flex: 1;
}

.tournament-title-info h1 {
    font-size: 2rem;
    font-weight: bold;
    color: #fbbf24;
    margin-bottom: 0.5rem;
}

.tournament-game-name {
    font-size: 1.25rem;
    color: #d1d5db;
}

.tournament-stats-grid {
    margin-top: 1.5rem;
}

.info-value-lg {
    color: white;
    font-weight: bold;
    font-size: 1.125rem;
}

.tournament-description {
    margin-top: 1.5rem;
    display: none;
    /* Long links (Dropbox, Google Docs…) wrap instead of widening the page */
    overflow-wrap: anywhere;
}

.bracket-scroll {
    overflow-x: auto;
}

/* Grows past the page width up to the screen width, centred; no change when the bracket already fits */
.bracket-scroll-bleed {
    --bleed-width: max(100%, min(var(--bracket-width), 100vw - 3rem));
    width: var(--bleed-width);
    margin-left: calc((100% - var(--bleed-width)) / 2);
}

.bracket-wrapper:has(.bracket-scroll-bleed) {
    overflow-x: visible;
}

.tournament-description p:last-child {
    color: #d1d5db;
    line-height: 1.6;
}

.challonge-container {
    margin-top: 1rem;
    display: none;
}

/* Bracket, Mido's House and async buttons side by side, wrapping on narrow screens */
.tournament-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.tournament-links .challonge-container {
    margin-top: 0;
}

.challonge-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background-color: #1F2937;
    color: #f3865d;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: 2px solid #f3865d;
    text-decoration: none;
    transition: all 0.2s;
}

.challonge-btn:hover {
    background-color: #f3865d;
    color: #1F2937;
}

.challonge-btn img {
    width: 20px;
    height: 20px;
}

/* Start.gg button variant - gradient border and text */
.startgg-btn {
    background: #1F2937;
    color: #fff;
    border: 2px solid transparent;
    background-image: linear-gradient(#1F2937, #1F2937), linear-gradient(135deg, #47A1FF 0%, #FF3472 100%);
    background-origin: border-box;
    background-clip: padding-box, border-box;
    position: relative;
}

.startgg-btn span {
    background: linear-gradient(135deg, #47A1FF 0%, #FF3472 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.startgg-btn:hover {
    background-image: linear-gradient(135deg, #47A1FF 0%, #FF3472 100%), linear-gradient(135deg, #47A1FF 0%, #FF3472 100%);
    box-shadow: 0 4px 15px rgba(71, 161, 255, 0.3), 0 4px 15px rgba(255, 52, 114, 0.3);
}

.startgg-btn:hover span {
    background: #1F2937;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tabs-wrapper {
    margin-bottom: 2rem;
}

.tab-content-title {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 1rem;
}

.bracket-wrapper {
    width: 100%;
    overflow-x: auto;
}

.group-stages {
    margin-top: 3rem;
    display: none;
}

.participants-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Common page elements */
.page-subtitle {
    margin-bottom: 2rem;
}

.filter-select {
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    border: none;
    background: #374151;
    color: white;
    cursor: pointer;
    font-size: 0.875rem;
}

.stream-count {
    font-size: 0.875rem;
}

.no-streams-emoji {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.no-streams-title {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.no-streams-subtitle {
    font-size: 0.875rem;
}

.no-streams-subtitle a {
    color: #fbbf24;
}

/* Mobile menu toggle button */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1001;
    line-height: 1;
}

.mobile-menu-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: white;
    margin: 5px 0;
    transition: all 0.3s ease;
}

.mobile-menu-toggle.open span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-toggle.open span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.open span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* ======== Tablet and below (max-width: 1024px) ======== */
@media (max-width: 1024px) {
    /* Tournament details grid */
    .tournament-details {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Tournaments grid - 2 columns on tablet */
    .tournaments-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Two-column layouts */
    .two-column-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    /* Game detail tabs - scrollable */
    [style*="border-bottom:2px solid #374151"][style*="display:flex"][style*="gap:1rem"],
    [style*="border-bottom: 2px solid"][style*="display: flex"] {
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        flex-wrap: nowrap !important;
    }
    [style*="border-bottom:2px solid #374151"][style*="display:flex"][style*="gap:1rem"]::-webkit-scrollbar,
    [style*="border-bottom: 2px solid"]::-webkit-scrollbar {
        display: none;
    }

    /* Two-column layouts become single column */
    [style*="grid-template-columns:1fr 1fr"],
    [style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Tournament grid 2 columns on tablet */
    [style*="grid-template-columns:repeat(3,1fr)"],
    [style*="grid-template-columns: repeat(3, 1fr)"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ======== Mobile devices (max-width: 768px) ======== */
@media (max-width: 768px) {
    /* Utility classes responsive */
    .main-container {
        margin: 1rem auto;
        padding: 0.75rem;
    }

    .home-grid,
    .two-column-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 1.5rem;
    }

    .section-title {
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }

    .detail-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 1.25rem;
        gap: 1rem;
    }

    .info-grid {
        grid-template-columns: 1fr 1fr;
    }

    .tabs-container {
        gap: 0.5rem;
    }

    .filter-row {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-buttons {
        width: 100%;
        padding-bottom: 0.5rem;
    }

    .tournaments-grid {
        grid-template-columns: 1fr;
        justify-content: stretch;
    }

    .races-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .pagination-container {
        flex-wrap: wrap;
    }

    /* Player detail responsive */
    .player-header {
        flex-direction: column;
        text-align: center;
    }

    .player-header .avatar-wrap {
        width: 150px;
        height: 150px;
        flex: 0 0 150px;
    }

    .player-header .player-info {
        width: 100%;
    }

    .player-header .player-info h1 {
        font-size: 1.5rem;
    }

    /* Game detail responsive */
    .game-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .game-poster {
        width: 180px;
        height: 252px;
    }

    .game-info {
        width: 100%;
    }

    .game-info h1 {
        font-size: 1.5rem;
    }

    .game-info h2 {
        font-size: 1rem;
    }

    /* Detail cards responsive */
    .detail-card {
        padding: 1.25rem;
    }

    /* Race detail responsive */
    .race-title-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .race-title-row h1 {
        font-size: 1.35rem;
    }

    .race-goal {
        font-size: 1rem;
    }

    /* Tournament detail responsive */
    .tournament-title-row {
        flex-direction: column;
    }

    .tournament-title-info h1 {
        font-size: 1.5rem;
    }

    .tournament-game-name {
        font-size: 1rem;
    }

    .tab-content-title {
        font-size: 1.25rem;
    }

    .challonge-btn {
        padding: 0.4rem 0.75rem;
        font-size: 0.875rem;
    }

    /* Header */
    header {
        flex-wrap: wrap;
        padding: 0.75rem;
        gap: 0.5rem;
        position: relative;
    }

    header > a {
        font-size: 1rem;
    }

    .site-logo {
        width: 28px;
        height: 28px;
    }

    /* Show mobile menu toggle, top right, with the spoiler switch on its left */
    .mobile-menu-toggle {
        display: block;
        order: 1;
    }

    /* Hide search on mobile header (can be in menu) */
    header input[type="text"] {
        order: 3;
        width: 100%;
        margin-top: 0.5rem;
    }

    .flex-grow {
        display: none;
    }

    /* Navigation - collapsible */
    nav {
        display: none;
        width: 100%;
        margin-left: 0;
        order: 2;
    }

    nav.open {
        display: block;
    }

    nav ul {
        flex-direction: column;
        gap: 0;
        width: 100%;
    }

    nav ul li {
        width: 100%;
    }

    nav a {
        display: block;
        padding: 0.75rem 0.5rem;
        border-bottom: 1px solid #374151;
    }

    nav a:last-child {
        border-bottom: none;
    }

    /* Main content */
    main {
        padding: 1rem !important;
    }

    /* Home page two columns */
    [style*="display:grid"][style*="grid-template-columns:1fr 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }

    /* Tournament grid single column */
    [style*="grid-template-columns:repeat(3,1fr)"],
    [style*="grid-template-columns: repeat(3, 1fr)"],
    [style*="grid-template-columns:repeat(2,1fr)"],
    [style*="grid-template-columns: repeat(2, 1fr)"] {
        grid-template-columns: 1fr !important;
    }

    /* Race cards minmax adjustment */
    [style*="grid-template-columns:repeat(auto-fill,minmax(380px,1fr))"],
    [style*="grid-template-columns: repeat(auto-fill, minmax(380px, 1fr))"] {
        grid-template-columns: 1fr !important;
    }

    /* Tournament details grid */
    .tournament-details,
    [style*="grid-template-columns: repeat(auto-fit, minmax(200px, 1fr))"] {
        grid-template-columns: 1fr 1fr !important;
    }

    /* Filter buttons - scrollable horizontally */
    [style*="display:flex"][style*="gap:0.5rem"]:has(.filter-btn) {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.5rem;
    }

    /* Filters row */
    [style*="display:flex"][style*="flex-wrap:wrap"][style*="gap:1rem"][style*="margin-bottom"] {
        flex-direction: column;
        align-items: stretch !important;
    }

    /* Select dropdowns full width */
    select {
        width: 100%;
    }

    /* Tab buttons - wrap on multiple lines on mobile */
    [style*="border-bottom:"][style*="display:flex"][style*="gap:1rem"]:has(.tab-btn) {
        flex-wrap: wrap !important;
        overflow-x: visible !important;
        gap: 0.5rem !important;
        border-bottom: none !important;
        padding-bottom: 0.5rem;
    }

    [style*="border-bottom:"][style*="display:flex"][style*="gap:1rem"]:has(.tab-btn)::-webkit-scrollbar {
        display: none;
    }

    .tab-btn {
        flex: 1 1 calc(50% - 0.25rem) !important;
        min-width: 0 !important;
        max-width: calc(50% - 0.25rem) !important;
        text-align: center !important;
        padding: 0.6rem 0.75rem !important;
        font-size: 0.8rem !important;
        border: 1px solid #374151 !important;
        border-radius: 0.5rem !important;
        white-space: nowrap;
    }
    
    .tab-btn.active {
        border-color: #fbbf24 !important;
        background: rgba(251, 191, 36, 0.1) !important;
    }

    /* Player detail header */
    [style*="display:flex"][style*="gap:2rem"][style*="background:#1f2937"] {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center;
    }

    /* Player avatar */
    .avatar-wrap {
        width: 150px !important;
        height: 150px !important;
        flex: 0 0 150px !important;
    }

    /* Game detail poster and info */
    [style*="display:flex"][style*="gap:2rem"]:has(#game-poster) {
        flex-direction: column !important;
        align-items: center !important;
    }

    #game-poster,
    #game-poster-missing {
        width: 180px !important;
        height: 250px !important;
    }

    /* Page titles */
    h1 {
        font-size: 1.25rem;
    }

    h2 {
        font-size: 1.1rem;
    }

    /* Tournament header on detail page */
    [style*="display: flex"][style*="justify-content: space-between"][style*="align-items: start"] {
        flex-direction: column !important;
        gap: 1rem;
    }

    /* Status badges */
    .status-badge {
        align-self: flex-start;
    }

    /* About hero */
    .about-hero h1 {
        font-size: 1.75rem;
    }

    .about-hero p {
        font-size: 1rem;
    }

    /* About sections */
    .about-section {
        padding: 1.25rem;
    }

    /* Stat cards */
    .stat-value {
        font-size: 2rem;
    }

    /* Stats and features grids */
    .stats-grid,
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Resources grid */
    .resources-grid {
        grid-template-columns: 1fr;
    }

    /* Streams grid */
    .streams-grid {
        grid-template-columns: 1fr;
    }

    /* Search tabs */
    .search-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        padding-bottom: 0.5rem;
    }

    .search-tab {
        flex-shrink: 0;
    }

    /* Results grid */
    .results-grid {
        grid-template-columns: 1fr;
    }

    /* Games grid */
    #games-grid {
        grid-template-columns: repeat(2, 1fr);
        justify-content: stretch;
        gap: 1rem;
    }

    .game-card {
        padding: 1rem;
    }

    .game-card img {
        width: min(100%, 220px);
        aspect-ratio: 256 / 360;
        height: auto;
    }

    .game-card h3 {
        font-size: 1rem;
    }

    /* Players list: two columns, like the games grid */
    #players-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        justify-content: stretch;
    }

    /* Tournament list items */
    #tournament-list > li {
        padding: 1rem;
    }

    .tournament-title {
        font-size: 1.1rem;
    }

    /* Spoiler toggle */
    .spoiler-toggle-container {
        margin-left: auto;
        margin-right: 0.5rem;
    }

    .spoiler-toggle {
        height: 1.5rem;
        font-size: 0.6rem;
        padding: 0 0.5rem 0 1.55rem;
    }

    .spoiler-toggle.active {
        padding: 0 1.55rem 0 0.5rem;
    }

    /* Narrow header: the icon alone, the label stays in aria-label and the tooltip */
    .spoiler-toggle-text {
        display: none;
    }

    .spoiler-toggle-knob {
        width: 1.1rem;
        height: 1.1rem;
    }

    .spoiler-toggle.active .spoiler-toggle-knob {
        left: calc(100% - 1.3rem);
    }

    /* Footer adjustments */
    .footer-sections {
        gap: 1.5rem;
    }

    /* Terms page */
    .terms-content {
        padding: 1.25rem;
    }

    .terms-content h1 {
        font-size: 1.5rem;
    }
}

/* ======== Small mobile devices (max-width: 480px) ======== */
@media (max-width: 480px) {
    header {
        padding: 0.5rem;
    }

    header > a {
        font-size: 0.9rem;
    }

    .site-logo {
        width: 24px;
        height: 24px;
    }

    main {
        padding: 0.75rem !important;
    }

    /* Stats and features - single column */
    .stats-grid,
    .features-grid,
    .tournament-details,
    [style*="grid-template-columns: repeat(auto-fit, minmax(200px, 1fr))"] {
        grid-template-columns: 1fr !important;
    }

    /* Player stats row wrap */
    .player-stats {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    /* Buttons and badges smaller */
    .filter-btn,
    [style*="padding:0.5rem 1rem"] {
        padding: 0.4rem 0.75rem !important;
        font-size: 0.8rem !important;
    }

    /* Inputs smaller */
    input[type="text"] {
        padding: 0.4rem;
        font-size: 0.875rem;
    }

    /* Page titles */
    h1 {
        font-size: 1.1rem;
    }

    h2 {
        font-size: 1rem;
    }

    /* Card titles */
    .tournament-title,
    .game-card h3,
    .player-card h3 {
        font-size: 1rem;
    }

    /* Stat cards */
    .stat-card {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    /* Avatar smaller */
    .avatar-wrap {
        width: 120px !important;
        height: 120px !important;
        flex: 0 0 120px !important;
    }

    /* Game poster */
    #game-poster,
    #game-poster-missing {
        width: 150px !important;
        height: 210px !important;
    }

    /* Race/Tournament detail cards */
    [style*="background:#374151"][style*="padding:1rem"] {
        padding: 0.75rem !important;
    }

    /* About hero */
    .about-hero {
        padding: 2rem 1rem;
    }

    .about-hero h1 {
        font-size: 1.5rem;
    }

    /* Feature cards */
    .feature-card {
        padding: 1rem;
    }

    .feature-card h3 {
        font-size: 1rem;
    }

    /* Resource cards */
    .resource-card {
        padding: 1rem;
    }

    .resource-logo {
        width: 40px;
        height: 40px;
    }

    .resource-name {
        font-size: 1.1rem;
    }

    /* Stream cards */
    .stream-info {
        padding: 0.75rem;
    }

    .stream-title {
        font-size: 0.85rem;
    }

    /* Search page */
    .search-query {
        font-size: 1.5rem;
    }

    .result-card {
        padding: 0.75rem;
    }

    /* Challonge button */
    #challonge-link {
        padding: 0.4rem 0.75rem;
        font-size: 0.875rem;
    }
}

/* ======== Phones (max-width: 480px) ========
   No height condition: Safari's toolbar changes the viewport height while scrolling */
@media (max-width: 480px) {
    /* Games and players: two columns of cards */
    #games-grid,
    #players-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        justify-content: stretch;
        gap: 0.75rem;
        margin-top: 1rem;
    }

    #tournament-list > li {
        padding: 0.85rem;
        margin-bottom: 0.75rem;
    }

    .game-card {
        padding: 0.75rem 0.5rem;
    }

    .game-card h2 {
        font-size: 1rem !important;
        margin: 0.6rem 0 0.25rem 0 !important;
        overflow-wrap: anywhere;
    }

    .game-card p {
        font-size: 0.8rem !important;
        overflow-wrap: anywhere;
    }

    .game-card > div:has(> span[title]) {
        gap: 0.6rem !important;
        font-size: 0.75rem !important;
    }

    .game-card .official-link {
        font-size: 0.8rem;
    }

    #players-list .player-card {
        padding: 0.75rem 0.5rem !important;
        aspect-ratio: auto !important;
        contain-intrinsic-size: auto 240px;
    }

    #players-list .player-card h3 {
        font-size: 0.95rem !important;
        margin-bottom: 0.5rem !important;
        max-width: 100%;
        overflow-wrap: anywhere;
    }

    #players-list .player-card .rt-avatar {
        width: 80px !important;
        height: 80px !important;
        margin-bottom: 0.6rem !important;
    }

    /* Search, sort, count and legend stacked full width */
    .games-controls,
    .players-controls {
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.6rem !important;
        padding: 0 0.25rem !important;
        margin-bottom: 0.75rem !important;
    }

    .games-filter,
    .players-controls .search-container {
        flex: 0 0 auto;
        max-width: none !important;
        width: 100%;
    }

    .games-filter,
    #player-search {
        padding-top: 0.65rem !important;
        padding-bottom: 0.65rem !important;
        font-size: 1rem !important; /* below 16px iOS zooms in on focus */
    }

    .games-controls .sort-container,
    .players-controls > div:has(> select) {
        justify-content: space-between;
    }

    #sort-select,
    #player-sort {
        flex: 1 1 auto;
        min-width: 0;
        padding: 0.5rem 0.75rem !important;
    }

    .games-legend {
        flex-direction: column;
        align-items: center;
        gap: 0.25rem;
        padding: 0 0.25rem;
        margin-bottom: 0;
        text-align: center;
    }

    .games-legend-keys {
        justify-content: center;
    }

    #players-count {
        margin-bottom: 0 !important;
    }

    /* Game page: "Get started" alone, the other two buttons below it */
    .game-overview-actions {
        display: grid;
        grid-template-columns: repeat(2, auto);
        justify-content: center;
        gap: 0.6rem;
    }

    .game-overview-actions .home-hero-btn {
        padding: 0.55rem 0.9rem;
        text-align: center;
    }

    .game-overview-actions .home-hero-btn-primary {
        grid-column: 1 / -1;
        justify-self: center;
    }

    /* Tournament matches: links wrap and scores stay in the card */
    .match-card {
        padding: 0.75rem !important;
    }

    .match-card-head {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* Racetime link and state on the date's row, at the right; streams and VODs on the row below */
    .match-card-head {
        align-items: flex-start !important;
    }

    .match-card-links {
        display: contents !important;
    }

    .match-card-meta {
        display: flex;
        align-items: center;
        gap: 0.35rem;
        margin-left: auto;
    }

    .match-card-media {
        order: 1;
        display: flex;
        flex-wrap: wrap;
        gap: 0.35rem;
        width: 100%;
    }

    .match-card-media:empty {
        display: none;
    }

    .match-card .match-player-name {
        overflow-wrap: anywhere;
    }

    .match-card-score {
        flex-shrink: 0;
        margin-left: 0.75rem !important;
        gap: 1rem !important;
    }

    .match-manche {
        flex-wrap: wrap;
        gap: 0.35rem;
    }

    .match-manche-detail {
        flex-wrap: wrap;
        gap: 0.35rem 0.75rem !important;
        width: 100%;
    }

    .match-manche-detail > span {
        min-width: 0 !important;
    }

    /* Compare page: tournament of a race on its own line */
    .compare-race-tournament {
        display: block;
        margin-left: 0;
    }
}

/* ========================================
   COMPARE PLAYERS PAGE
   ======================================== */

/* Selector / Form */
.compare-selector {
    text-align: center;
    margin-bottom: 2rem;
}

.compare-selector h1 {
    font-size: 1.75rem;
    color: #fbbf24;
    margin-bottom: 0.5rem;
}

.compare-subtitle {
    color: #9ca3af;
    margin-bottom: 1.5rem;
}

.compare-form {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.compare-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 200px;
    flex: 1;
    max-width: 300px;
}

.compare-input-group label {
    font-size: 0.85rem;
    color: #9ca3af;
    font-weight: 600;
}

.compare-input-group input[type="text"] {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border-radius: 0.375rem;
    border: 1px solid #374151;
    background: #1f2937;
    color: white;
    font-size: 0.95rem;
}

.compare-input-group input[type="text"]::placeholder {
    color: #6b7280;
}

.compare-input-group input[type="text"]:focus {
    outline: none;
    border-color: #fbbf24;
    box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.2);
}

.compare-autocomplete-wrap {
    position: relative;
}

.compare-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #1f2937;
    border: 1px solid #374151;
    border-radius: 0 0 0.375rem 0.375rem;
    list-style: none;
    max-height: 240px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.compare-suggestions li {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    color: #d1d5db;
    font-size: 0.9rem;
    transition: background 0.15s;
}

.compare-suggestions li:hover {
    background: #374151;
    color: #fbbf24;
}

.compare-vs {
    font-size: 1.5rem;
    font-weight: bold;
    color: #6b7280;
    align-self: flex-end;
    padding-bottom: 0.4rem;
}

.compare-btn {
    padding: 0.6rem 1.5rem;
    background: #fbbf24;
    color: #111827;
    border: none;
    border-radius: 0.375rem;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    align-self: flex-end;
}

.compare-btn:hover {
    background: #f59e0b;
    transform: translateY(-1px);
}

/* Header: two players VS */
.compare-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2rem;
    background: #1f2937;
    padding: 2rem;
    border-radius: 0.5rem;
}

.compare-player-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    max-width: 250px;
}

.compare-avatar-wrap {
    display: block;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    background: #374151;
}

.compare-avatar-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.compare-player-name {
    font-size: 1.3rem;
    font-weight: bold;
    color: #fbbf24;
    text-decoration: none;
    transition: color 0.2s;
}

.compare-player-name:hover {
    color: #f59e0b;
}

.compare-vs-badge {
    font-size: 2rem;
    font-weight: 900;
    color: #6b7280;
    flex-shrink: 0;
}

/* Head-to-head bar */
.h2h-bar-container {
    max-width: 600px;
    margin: 0 auto;
}

.h2h-score {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.h2h-wins-left {
    font-size: 2.5rem;
    font-weight: 900;
    color: #3b82f6;
}

.h2h-draws {
    font-size: 0.9rem;
    color: #6b7280;
}

.h2h-wins-right {
    font-size: 2.5rem;
    font-weight: 900;
    color: #ef4444;
}

.h2h-bar {
    display: flex;
    height: 12px;
    border-radius: 6px;
    overflow: hidden;
    background: #374151;
}

.h2h-bar.mini {
    height: 6px;
    border-radius: 3px;
    margin-top: 0.5rem;
}

.h2h-bar-p1 {
    background: #3b82f6;
    transition: width 0.5s ease;
}

.h2h-bar-draw {
    background: #4b5563;
    transition: width 0.5s ease;
}

.h2h-bar-p2 {
    background: #ef4444;
    transition: width 0.5s ease;
}

.h2h-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 0.35rem;
    font-size: 0.85rem;
    color: #9ca3af;
}

.h2h-total {
    text-align: center;
    margin-top: 0.75rem;
    font-size: 0.9rem;
    color: #9ca3af;
}

/* Stats comparison grid */
.compare-stats-grid {
    max-width: 500px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.compare-stat-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1rem;
    background: #1f2937;
    padding: 0.75rem 1.25rem;
    border-radius: 0.5rem;
}

.compare-stat-val {
    font-size: 1.3rem;
    font-weight: 700;
    color: white;
}

.compare-stat-val.left {
    text-align: right;
}

.compare-stat-val.right {
    text-align: left;
}

.compare-stat-val.better {
    color: #10b981;
}

.compare-stat-val.worse {
    color: #6b7280;
}

.compare-stat-label {
    font-size: 0.85rem;
    color: #9ca3af;
    text-align: center;
    min-width: 80px;
}

/* Game breakdown cards */
.compare-game-card {
    display: block;
    background: #1f2937;
    padding: 1rem 1.25rem;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s;
}

a.compare-game-card:hover {
    background: #374151;
}

.compare-game-name {
    font-weight: 600;
    color: #fbbf24;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.compare-game-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.compare-game-count {
    color: #6b7280;
    font-size: 0.8rem;
}

.p1-color {
    color: #3b82f6;
    font-weight: 700;
}

.p2-color {
    color: #ef4444;
    font-weight: 700;
}

/* Race cards */
.compare-race-card {
    display: block;
    background: #1f2937;
    padding: 1rem 1.25rem;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    text-decoration: none;
    color: inherit;
    border-left: 3px solid transparent;
    transition: background 0.2s, border-color 0.2s;
}

.compare-race-card:hover {
    background: #374151;
}

.compare-race-card.p1-won {
    border-left-color: #3b82f6;
}

.compare-race-card.p2-won {
    border-left-color: #ef4444;
}

.compare-race-card.draw {
    border-left-color: #4b5563;
}

.compare-race-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.compare-race-game {
    font-weight: 600;
    color: #fbbf24;
    font-size: 0.85rem;
}

.compare-race-date {
    font-size: 0.8rem;
    color: #6b7280;
}

.compare-race-goal {
    font-size: 0.85rem;
    color: #9ca3af;
    margin-bottom: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.compare-race-results {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.compare-race-player {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.compare-race-player.left {
    justify-content: flex-start;
}

.compare-race-player.right {
    justify-content: flex-end;
}

.compare-race-player.winner {
    font-weight: 700;
}

.compare-race-time {
    font-size: 0.9rem;
    color: #d1d5db;
}

.compare-race-player.winner .compare-race-time {
    color: white;
}

/* Place badges */
.compare-place-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.8rem;
    font-weight: 600;
}

.compare-place-badge.gold {
    color: #fbbf24;
}

.compare-place-badge.silver {
    color: #d1d5db;
}

.compare-place-badge.bronze {
    color: #d97706;
}

.compare-place-badge.dnf {
    color: #ef4444;
}

.compare-place-badge.other {
    color: #9ca3af;
}

/* Common tournaments (compare page) */
.compare-tour-summary {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    color: #9ca3af;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.compare-tour-sep {
    color: #4b5563;
}

.compare-tour-card {
    background: #1f2937;
    padding: 1rem 1.25rem;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background 0.2s, border-color 0.2s;
}

.compare-tour-card.p1-won {
    border-left-color: #3b82f6;
}

.compare-tour-card.p2-won {
    border-left-color: #ef4444;
}

.compare-tour-card.draw {
    border-left-color: #4b5563;
}

.compare-tour-card:hover {
    background: #374151;
}

.compare-tour-card:hover a.compare-tour-match:hover {
    background: #4b5563;
}

.compare-tour-name {
    font-weight: 600;
    color: #fbbf24;
    font-size: 0.95rem;
    text-decoration: none;
}


.compare-tour-badge {
    flex-shrink: 0;
    font-size: 0.75rem;
    color: #9ca3af;
    border: 1px solid #4b5563;
    border-radius: 999px;
    padding: 0.1rem 0.5rem;
}

.compare-tour-badge.live {
    color: #10b981;
    border-color: #065f46;
}

.compare-tour-meta {
    font-size: 0.8rem;
    color: #6b7280;
    margin-bottom: 0.75rem;
}

.compare-tour-ranks {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: baseline;
    gap: 1rem;
}

.compare-tour-ranks .left {
    text-align: right;
}

.compare-tour-ranks-label {
    font-size: 0.8rem;
    color: #9ca3af;
    text-align: center;
    min-width: 80px;
}

.compare-tour-rank {
    font-size: 1.15rem;
    font-weight: 700;
    color: white;
}

.compare-tour-rank.better {
    color: #10b981;
}

.compare-tour-rank.worse,
.compare-tour-rank.none {
    color: #6b7280;
}

.compare-tour-of {
    font-size: 0.8rem;
    color: #6b7280;
    margin-left: 0.25rem;
}

.compare-tour-matches {
    margin-top: 0.75rem;
    border-top: 1px solid #374151;
    padding-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.compare-tour-match {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1rem;
    padding: 0.35rem 0.5rem;
    border-radius: 0.375rem;
    text-decoration: none;
    color: #d1d5db;
    border-left: 3px solid transparent;
}

a.compare-tour-match:hover {
    background: #374151;
}

.compare-tour-match.p1-won {
    border-left-color: #3b82f6;
}

.compare-tour-match.p2-won {
    border-left-color: #ef4444;
}

.compare-tour-score {
    font-weight: 600;
    color: #9ca3af;
}

.compare-tour-score.left {
    text-align: right;
}

.compare-tour-score.winner {
    color: white;
}

.compare-tour-round {
    font-size: 0.8rem;
    color: #9ca3af;
    text-align: center;
}

.compare-race-tournament {
    font-weight: 400;
    color: #9ca3af;
    font-size: 0.8rem;
    margin-left: 0.25rem;
}

/* Compare button — generic (used in compare page game cards etc.) */
.btn-compare {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    background: #374151;
    color: #d1d5db;
    border-radius: 0.375rem;
    text-decoration: none;
    font-size: 0.85rem;
    transition: background 0.2s, color 0.2s;
    border: 1px solid #4b5563;
}

.btn-compare:hover {
    background: #4b5563;
    color: #fbbf24;
}

/* Compare CTA — same line as section heading */
.stats-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.stats-section-header h2 {
    margin-bottom: 0;
}

.player-compare-action {
    display: flex;
}

.btn-compare--stats {
    padding: 0.4rem 0.9rem;
    font-size: 0.85rem;
    gap: 0.4rem;
}

@media (max-width: 768px) {
    .btn-compare--stats {
        font-size: 0.8rem;
        padding: 0.35rem 0.7rem;
    }
}

/* Mobile adjustments for compare page */
@media (max-width: 768px) {
    .compare-form {
        flex-direction: column;
        align-items: center;
    }

    .compare-input-group {
        max-width: 100%;
        width: 100%;
    }

    .compare-vs {
        align-self: center;
        padding-bottom: 0;
    }

    .compare-btn {
        width: 100%;
    }

    .compare-header {
        flex-direction: column;
        gap: 1rem;
        padding: 1.25rem;
    }

    .compare-vs-badge {
        font-size: 1.5rem;
    }

    .compare-avatar-wrap {
        width: 80px;
        height: 80px;
    }

    .compare-stat-row {
        padding: 0.6rem 0.75rem;
        gap: 0.5rem;
    }

    .compare-stat-val {
        font-size: 1rem;
    }

    .compare-stat-label {
        min-width: 50px;
    }

    .h2h-wins-left, .h2h-wins-right {
        font-size: 1.75rem;
    }
}

/* ======== Landscape mobile adjustments ======== */
@media (max-width: 768px) and (orientation: landscape) {
    .about-hero {
        padding: 1.5rem 1rem;
    }

    .about-hero h1 {
        font-size: 1.5rem;
    }

    .avatar-wrap {
        width: 100px !important;
        height: 100px !important;
        flex: 0 0 100px !important;
    }
}

/* ======== Print styles ======== */
@media print {
    header, nav, .mobile-menu-toggle, .spoiler-toggle-container, .site-footer {
        display: none !important;
    }

    main {
        max-width: 100% !important;
        padding: 0 !important;
    }

    body {
        background: white;
        color: black;
    }
}


/* Match cards: the player name links to the profile, the rest of the card to the race */
a.match-player-name,
a.player-link {
    transition: color 0.2s;
}

a.match-player-name:hover,
a.player-link:hover,
body.spoiler-mode a.spoiler-winner:hover {
    color: #fbbf24 !important;
}

a.match-player-name.match-winner:hover {
    color: #f59e0b !important;
}


/* Game page: leaderboards and categories tabs */
.leaderboard-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin: 1rem 0;
}

.leaderboard-toolbar select {
    max-width: 100%;
}

.leaderboard-note,
.leaderboard-source {
    font-size: 0.875rem;
    margin: 0.75rem 0;
}

.leaderboard-source a {
    color: #60a5fa;
}

.leaderboard-more {
    margin-top: 0.75rem;
}

.data-table-wrap {
    overflow-x: auto;
    background: #1f2937;
    border-radius: 0.5rem;
}

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

.data-table th,
.data-table td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid #374151;
}

.data-table th {
    color: #9ca3af;
    font-weight: 500;
    white-space: nowrap;
}

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

.data-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.data-table a.player-link {
    color: #e5e7eb;
    text-decoration: none;
}

/* Marathon runs: the default link blue is hard to read on the dark table */
.data-table a.vod-link {
    color: #fbbf24;
    text-decoration: none;
    font-weight: 500;
    white-space: nowrap;
    transition: color 0.2s;
}

.data-table a.vod-link:hover {
    color: #fde68a;
    text-decoration: underline;
}

.data-table tr.podium td:first-child {
    color: #fbbf24;
    font-weight: 600;
}

.link-button {
    background: none;
    border: none;
    padding: 0;
    color: #60a5fa;
    font: inherit;
    cursor: pointer;
    text-align: inherit;
}

.link-button:hover {
    color: #fbbf24;
    text-decoration: underline;
}

.goal-status {
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    background: #374151;
    color: #9ca3af;
    white-space: nowrap;
}

.goal-status.is-active {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.categories-section {
    margin: 1.5rem 0 2rem;
}

.categories-section h3 {
    color: #fbbf24;
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.category-card,
.setting-card {
    background: #1f2937;
    padding: 1rem;
    border-radius: 0.5rem;
}

.category-card {
    border-left: 3px solid #fbbf24;
}

.setting-card {
    margin-bottom: 0.75rem;
}

.category-card h4,
.setting-card h4 {
    color: #60a5fa;
    margin-bottom: 0.5rem;
}

.category-card h4 .english-name,
.setting-card h4 .english-name {
    color: #9ca3af;
    font-weight: normal;
}

.category-card p,
.setting-card p {
    color: #d1d5db;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.category-stats {
    color: #9ca3af;
    font-size: 0.8rem;
}

.category-goals {
    margin-top: 0.5rem;
    font-size: 0.8rem;
}

.setting-values {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.setting-value {
    background: #374151;
    color: #10b981;
    padding: 0.25rem 0.75rem;
    border-radius: 0.25rem;
    font-size: 0.8rem;
}

@media (max-width: 600px) {
    .data-table .col-optional {
        display: none;
    }

    .category-grid {
        grid-template-columns: 1fr;
    }
}

/* Tournament calendar tab */
.calendar-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.calendar-month-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #f9fafb;
    font-weight: 600;
    font-size: 1.15rem;
    min-width: 12rem;
}

.calendar-month-select {
    background: #1f2937;
    color: #f9fafb;
    border: 1px solid #374151;
    border-radius: 0.375rem;
    padding: 0.3rem 0.5rem;
    font: inherit;
    cursor: pointer;
}

.calendar-month-count {
    color: #9ca3af;
    font-size: 0.8rem;
    font-weight: normal;
    margin-top: 0.2rem;
}

.calendar-nav-btn {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 999px;
    border: 1px solid #374151;
    background: #111827;
    color: #e5e7eb;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}

.calendar-nav-btn:hover:not(:disabled) {
    border-color: #fbbf24;
    color: #fbbf24;
}

.calendar-nav-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    border: 1px solid #374151;
    border-radius: 0.5rem;
    overflow: hidden;
    background: #374151;
    gap: 1px;
}

.calendar-weekday {
    background: #111827;
    text-align: center;
    color: #9ca3af;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.5rem 0.25rem;
}

.calendar-cell {
    background: #1f2937;
    min-height: 7.5rem;
    padding: 0.35rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
}

.calendar-cell-outside {
    background: #161e2b;
}

.calendar-cell-past {
    background: #1a2230;
}

.calendar-cell-today {
    box-shadow: inset 0 0 0 2px #3b82f6;
}

.calendar-cell-header {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.calendar-cell-day {
    color: #6b7280;
    font-size: 0.8rem;
    font-weight: 600;
}

.calendar-cell-active .calendar-cell-day {
    color: #f9fafb;
}

.calendar-cell-today .calendar-cell-day {
    color: #60a5fa;
}

/* Full date, for the one-column layout on phones */
.calendar-cell-date {
    display: none;
}

.calendar-event {
    background: #111827;
    border-left: 3px solid #4b5563;
    border-radius: 0.25rem;
    padding: 0.3rem 0.4rem;
    font-size: 0.75rem;
    line-height: 1.3;
    min-width: 0;
}

.calendar-event-upcoming {
    border-left-color: #fbbf24;
}

.calendar-event-live {
    border-left-color: #dc2626;
}

.calendar-event-qualifier {
    border-left-color: #a855f7;
}

.calendar-event-tiebreak {
    border-left-color: #f97316;
}

.calendar-event-link {
    cursor: pointer;
}

.calendar-event-link:hover,
.calendar-event-link:focus-visible {
    background: #263244;
    outline: none;
}

.calendar-event-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.calendar-event-time {
    color: #fbbf24;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.calendar-cell-past .calendar-event-time {
    color: #d1d5db;
}

.calendar-event-streams {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    margin-left: auto;
}

.calendar-stream {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    padding: 0.05rem 0.25rem;
    border-radius: 0.2rem;
    border: 1px solid #9146ff;
    background: #2e1065;
    color: #e9d5ff;
    font-size: 0.6rem;
    font-weight: 600;
    text-decoration: none;
}

.calendar-stream img {
    width: 10px;
    height: 10px;
}

.calendar-stream-vod {
    background: #9146ff;
    color: #fff;
}

.calendar-stream-youtube {
    border-color: #ff0033;
    background: #450a0a;
    color: #fee2e2;
}

.calendar-stream-youtube.calendar-stream-vod {
    background: #cc0000;
    color: #fff;
}

.calendar-event-players {
    display: flex;
    flex-direction: column;
    color: #f9fafb;
    font-weight: 600;
    margin-top: 0.1rem;
}

.calendar-event-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calendar-vs {
    color: #6b7280;
    font-weight: normal;
    font-size: 0.65rem;
}

.calendar-event-meta {
    color: #9ca3af;
    font-size: 0.65rem;
    margin-top: 0.1rem;
    overflow-wrap: anywhere;
}

.calendar-badge {
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.05rem 0.35rem;
    border-radius: 999px;
}

.calendar-badge-live {
    background: #dc2626;
    color: #fff;
}

.calendar-badge-today {
    background: #3b82f6;
    color: #fff;
}

.calendar-timezone {
    color: #6b7280;
    font-size: 0.8rem;
    margin: 0.75rem 0 0;
}

@media (max-width: 1024px) {
    .calendar-cell {
        min-height: 6rem;
        padding: 0.25rem;
    }

    .calendar-event {
        padding: 0.25rem 0.3rem;
    }
}

/* Phones: the days with races one under the other, the full date as their title */
@media (max-width: 768px) {
    .calendar-grid {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        background: none;
        border: none;
        overflow: visible;
    }

    .calendar-weekday,
    .calendar-cell-outside,
    .calendar-cell-empty {
        display: none;
    }

    .calendar-cell {
        min-height: 0;
        padding: 0.75rem;
        border-radius: 0.5rem;
        gap: 0.5rem;
    }

    .calendar-cell-day {
        display: none;
    }

    .calendar-cell-date {
        display: inline;
        color: #d1d5db;
        font-weight: 600;
        font-size: 0.95rem;
    }

    .calendar-event {
        font-size: 0.875rem;
        padding: 0.5rem 0.6rem;
    }

    .calendar-event-players {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.35rem;
        align-items: baseline;
    }

    .calendar-event-name {
        white-space: normal;
    }

    .calendar-vs,
    .calendar-event-meta {
        font-size: 0.75rem;
    }

    .calendar-stream {
        font-size: 0.7rem;
        padding: 0.15rem 0.35rem;
    }

    .calendar-month-title {
        min-width: 0;
    }
}
