/* Square Race Customizer Styles — rainbow theme, tools chrome */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&family=Poppins:wght@300;400;500;600&family=Orbitron:wght@400;600;700&display=swap');

:root {
    --rainbow: linear-gradient(90deg, #ff4d6d, #ff9f1c, #ffe66d, #2ec4b6, #38bdf8, #a78bfa, #f472b6);
    --primary-color: #38bdf8;
    --secondary-color: #a78bfa;
    --accent-color: #f472b6;
    --icon-color: #ffe66d;
    --background-dark: #121212;
    --background-darker: #07070d;
    --background-light: #1a1a1a;
    --text-light: #ffffff;
    --text-gray: #b3b3b3;
    --border-color: #333333;
    --success-color: #4ade80;
    --warning-color: #fbbf24;
    --error-color: #f87171;
    --border-radius: 10px;
    --glow-rgb: 56, 189, 248;
}

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

html {
    height: 100%;
}

body {
    font-family: 'Roboto', sans-serif;
    background:
        radial-gradient(900px 280px at 0% 0%, rgba(255, 77, 109, 0.18), transparent 55%),
        radial-gradient(800px 280px at 100% 0%, rgba(56, 189, 248, 0.16), transparent 50%),
        radial-gradient(700px 320px at 50% 100%, rgba(167, 139, 250, 0.18), transparent 55%),
        linear-gradient(135deg, #07070d, #12101a);
    color: var(--text-light);
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 16px;
    flex-wrap: nowrap;
    flex-shrink: 0;
    margin-bottom: 0;
    padding: 8px 14px;
    background: rgba(26, 26, 26, 0.7);
    border-radius: var(--border-radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.header-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.header-logo {
    width: 160px;
    max-width: 100%;
    height: auto;
    display: block;
}

.header-divider {
    width: 2px;
    align-self: stretch;
    flex-shrink: 0;
    background: linear-gradient(to bottom, rgba(255,255,255,0.1), rgba(255,255,255,0));
    border-radius: 999px;
}

.header h1 {
    font-size: 0.95rem;
    font-family: 'Orbitron', sans-serif;
    margin-bottom: 0;
    background: var(--rainbow);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
}

.header-overlay-url {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.header-overlay-url h3 {
    font-size: 0.95rem;
    font-family: 'Orbitron', sans-serif;
    margin: 0;
    flex-shrink: 0;
    white-space: nowrap;
    background: var(--rainbow);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-overlay-url h3 i {
    background: none;
    -webkit-background-clip: border-box;
    background-clip: border-box;
    -webkit-text-fill-color: var(--primary-color);
    color: var(--primary-color);
}

.container {
    display: flex;
    gap: 12px;
    max-width: 100%;
    margin: 0 auto;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    overflow: hidden;
}

.settings-panel {
    flex: 1;
    max-width: 34%;
    min-width: 360px;
    background: rgba(26, 26, 26, 0.8);
    border-radius: var(--border-radius);
    padding: 0 18px 18px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-height: none;
    height: 100%;
    min-height: 0;
    overflow-y: auto;
}

.preview-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: rgba(26, 26, 26, 0.8);
    border-radius: var(--border-radius);
    padding: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-height: none;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.panel-header-main {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px 16px;
    min-width: 0;
    flex: 1;
}

.panel-header h2 {
    font-size: 1.35rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    margin: 0;
}

.panel-header h2 i {
    color: var(--primary-color);
}

.preview-support-note {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
    margin: 0;
    padding: 5px 10px;
    font-size: 0.78rem;
    line-height: 1.35;
    color: var(--text-gray);
    background: color-mix(in srgb, var(--primary-color) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent-color) 35%, transparent);
    border-radius: 999px;
}

.preview-support-note i {
    color: var(--accent-color);
    font-size: 0.78rem;
}

.preview-support-note a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.preview-support-note a:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

.preview-support-note strong {
    color: var(--text-light);
    font-weight: 600;
}

.panel-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.panel-header-actions .connection-indicator {
    position: static;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(0, 0, 0, 0.45);
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: 0.03em;
    color: #aaa;
    border: 1px solid rgba(255, 255, 255, 0.1);
    white-space: nowrap;
}

.panel-header-actions .connection-indicator .sb-logo {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: block;
    object-fit: contain;
}

.panel-header-actions .connection-indicator .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #666;
    flex-shrink: 0;
}

.panel-header-actions .connection-indicator.connecting .status-dot {
    background: #fbbf24;
    animation: pulse-dot 1s infinite;
}

.panel-header-actions .connection-indicator.connected .status-dot {
    background: #4ade80;
    box-shadow: 0 0 8px #4ade80;
}

.panel-header-actions .connection-indicator.disconnected .status-dot {
    background: #f87171;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

.settings-section {
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(30, 30, 30, 0.6);
    border-radius: var(--border-radius);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.settings-section h3 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-light);
}

.settings-section h3 i {
    color: var(--accent-color);
}

.setting-group {
    margin-bottom: 20px;
    position: relative;
}

.setting-group::after {
    content: "";
    position: absolute;
    inset: -9px;
    border-radius: var(--border-radius);
    border: 1px solid rgba(var(--glow-rgb), 0.15);
    box-shadow: 0 0 18px rgba(var(--glow-rgb), 0.25);
    opacity: 0;
    transition: opacity 0.2s ease, border-color 0.2s ease;
    pointer-events: none;
}

.setting-group:hover::after {
    opacity: 1;
    border-color: rgba(var(--glow-rgb), 0.35);
}

.setting-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-gray);
}

.setting-hint {
    font-size: 11px;
    color: #888;
    margin: 4px 0 0 0;
}

.settings-section > .setting-hint {
    margin-bottom: 18px;
}

.setting-hint a {
    color: var(--accent-color);
}

.sub-group {
    margin-left: 18px;
    padding-left: 10px;
    border-left: 2px solid rgba(var(--glow-rgb), 0.35);
}

.style-select, input[type="color"], input[type="range"], input[type="date"] {
    width: 100%;
    padding: 12px;
    border-radius: var(--border-radius);
    background: rgba(40, 40, 40, 0.8);
    border: 1px solid var(--border-color);
    color: var(--text-light);
    font-size: 1rem;
}

input[type="range"] {
    padding: 0;
}

.value-display {
    display: inline-block;
    margin-top: 5px;
    padding: 5px 10px;
    background: var(--primary-color);
    border-radius: var(--border-radius);
    font-weight: 500;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 400;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
    cursor: pointer;
    flex-shrink: 0;
}

.number-input, .text-input {
    width: 100%;
    padding: 12px 15px;
    background: rgba(30, 30, 30, 0.8);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-light);
    font-size: 14px;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
}

.number-input:focus, .text-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--glow-rgb), 0.1);
}

.inline-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.inline-row .text-input,
.inline-row .number-input {
    flex: 1;
    min-width: 0;
}

.inline-row .test-button,
.inline-row .connect-button {
    flex-shrink: 0;
}

.refresh-button, .test-button, .connect-button, .race-button {
    padding: 12px 20px;
    border-radius: var(--border-radius);
    border: none;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.refresh-button {
    background: rgba(40, 40, 40, 0.8);
    color: var(--text-light);
    border: 1px solid var(--border-color);
}

.refresh-button:hover {
    background: rgba(60, 60, 60, 0.8);
    transform: translateY(-2px);
}

.test-button, .connect-button {
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    color: white;
    box-shadow: 0 4px 15px rgba(var(--glow-rgb), 0.3);
    white-space: nowrap;
}

.test-button:hover, .connect-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(var(--glow-rgb), 0.4);
}

.race-controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.race-button {
    width: 100%;
}

.race-button.primary {
    grid-column: 1 / -1;
    background: linear-gradient(90deg, var(--success-color), #22c55e);
    color: #052e16;
    font-size: 1.1rem;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(74, 222, 128, 0.35);
}

.race-button.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 222, 128, 0.45);
}

.race-button.secondary {
    background: rgba(40, 40, 40, 0.8);
    color: var(--text-light);
    border: 1px solid var(--border-color);
}

.race-button.secondary:hover {
    background: rgba(60, 60, 60, 0.8);
    transform: translateY(-2px);
}

.race-button.warning {
    background: linear-gradient(90deg, var(--warning-color), #f59e0b);
    color: #422006;
}

.preview-container {
    flex: 1;
    background: linear-gradient(135deg, #07070d, #14121c);
    border-radius: var(--border-radius);
    overflow: hidden;
    min-height: 0;
}

#game-preview {
    width: 100%;
    height: 100%;
    min-height: 0;
    border: 0;
    border-radius: var(--border-radius);
    background: #000;
    display: block;
}

.url-container {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 8px;
}

.url-input {
    flex: 1;
    padding: 12px 15px;
    background: rgba(30, 30, 30, 0.8);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-light);
    font-size: 14px;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
}

.url-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--glow-rgb), 0.1);
}

.generate-button, .copy-button {
    padding: 12px 16px;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    white-space: nowrap;
}

.generate-button {
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    color: white;
    box-shadow: 0 4px 15px rgba(var(--glow-rgb), 0.3);
}

.generate-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(var(--glow-rgb), 0.4);
}

.copy-button {
    background: linear-gradient(90deg, var(--success-color), #22c55e);
    color: white;
    box-shadow: 0 4px 15px rgba(74, 222, 128, 0.3);
}

.copy-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 222, 128, 0.4);
}

.copy-button:disabled {
    background: rgba(100, 100, 100, 0.5);
    color: rgba(255, 255, 255, 0.5);
    cursor: not-allowed;
    box-shadow: none;
}

.copy-button.copied {
    background: linear-gradient(90deg, var(--success-color), #16a34a);
    animation: pulse 0.3s ease;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.url-help {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-gray);
    font-style: italic;
}

.url-buttons {
    display: flex;
    gap: 10px;
    margin-top: 0;
    flex-shrink: 0;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.level-card {
    background: rgba(20, 20, 20, 0.8);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.level-card:hover {
    border-color: rgba(var(--glow-rgb), 0.5);
    transform: translateY(-2px);
}

.level-card.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 16px rgba(var(--glow-rgb), 0.35);
}

.level-card canvas {
    width: 100%;
    height: auto;
    aspect-ratio: 1600 / 920;
    border-radius: 6px;
    display: block;
    margin-bottom: 8px;
    background: #d4edda;
}

.level-card h4 {
    font-size: 0.9rem;
    margin-bottom: 4px;
    color: var(--accent-color);
}

.level-card p {
    font-size: 11px;
    color: #888;
    line-height: 1.3;
}

.level-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 6px;
    border-radius: 4px;
    z-index: 1;
}

.level-badge.builtin,
.level-badge.official {
    background: rgba(74, 222, 128, 0.2);
    color: var(--success-color);
}

.level-badge.custom {
    background: rgba(234, 179, 8, 0.25);
    color: var(--accent-color);
}

.level-badge.override {
    background: rgba(251, 191, 36, 0.25);
    color: var(--warning-color);
}

.level-author {
    color: var(--primary-color);
    font-size: 10px;
}

.level-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
    align-items: center;
}

.designer-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: #000;
    text-decoration: none;
    border-radius: var(--border-radius);
    font-weight: 600;
    font-size: 0.9rem;
    transition: transform 0.15s ease;
}

.designer-link:hover {
    transform: translateY(-1px);
    color: #000;
}

.viewer-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-family: 'Orbitron', sans-serif;
    color: var(--accent-color);
}

.viewer-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 180px;
    overflow-y: auto;
    padding: 4px;
}

.viewer-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(0,0,0,0.35);
}

.viewer-chip .dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

.podium-list, .history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.podium-row, .history-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(0,0,0,0.35);
    border-radius: var(--border-radius);
    border: 1px solid rgba(255,255,255,0.06);
    font-size: 13px;
}

.podium-row .place {
    font-family: 'Orbitron', sans-serif;
    color: var(--accent-color);
    min-width: 28px;
}

.podium-row .swatch, .history-row .swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
}

.history-row {
    flex-direction: column;
    align-items: flex-start;
}

.history-row .meta {
    font-size: 11px;
    color: #888;
}

.site-footer {
    position: relative;
    flex-shrink: 0;
    padding: 4px 14px;
    background: rgba(26, 26, 26, 0.8);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    overflow: visible;
    z-index: 100;
}

.footer-privacy {
    position: relative;
}

.footer-privacy-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(30, 30, 45, 0.8);
    color: #94a3b8;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    font-family: inherit;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.footer-privacy-toggle:hover,
.footer-privacy.is-open .footer-privacy-toggle {
    color: #e2e8f0;
    border-color: rgba(244, 114, 182, 0.55);
    background: rgba(244, 114, 182, 0.12);
}

.footer-privacy-panel {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    width: min(440px, calc(100vw - 40px));
    padding: 12px 14px;
    background: rgba(18, 22, 32, 0.97);
    border: 1px solid rgba(244, 114, 182, 0.28);
    border-left: 3px solid #f472b6;
    border-radius: 10px;
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(-50%) translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    z-index: 200;
}

.footer-privacy.is-open .footer-privacy-panel {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.footer-privacy-panel p {
    margin: 0;
    font-size: 12px;
    line-height: 1.55;
    color: #aab4c3;
}

.footer-privacy-panel strong {
    color: #f472b6;
}

.fa-ko-fi {
    position: relative;
}

.fa-ko-fi::before {
    content: "\f0f4";
    display: inline-block;
    font-size: 1.1em;
    line-height: 0.45em;
    margin: -0.45em 0 0 -0.2em;
    overflow-y: hidden;
    padding-top: 0.45em;
}

.fa-ko-fi::after {
    color: #000;
    content: "\f004";
    font-size: 50%;
    font-weight: 900;
    margin: 0.5em 0 0 -2em;
    position: absolute;
}

.footer-branding {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #94a3b8;
    font-family: 'Poppins', sans-serif;
}

.footer-branding a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

.footer-branding a:hover {
    color: var(--accent-color);
}

.footer-divider {
    width: 1px;
    height: 16px;
    background: linear-gradient(to bottom, transparent, rgba(148, 163, 184, 0.4), transparent);
}

.footer-socials {
    display: flex;
    align-items: center;
    gap: 8px;
}

.footer-socials a {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
    background: rgba(255, 255, 255, 0.04);
    font-size: 14px;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.footer-socials a img {
    width: 14px;
    height: 14px;
    display: block;
    filter: brightness(0) invert(1);
}

.footer-socials a:hover img {
    filter: none;
}

.footer-socials a.kick:hover img {
    filter: brightness(0);
}

.footer-socials a:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.footer-socials a.twitch:hover {
    background: #9146ff;
    color: #fff;
    border-color: #9146ff;
}

.footer-socials a.youtube:hover {
    background: #ff0000;
    color: #fff;
    border-color: #ff0000;
}

.footer-socials a.tiktok:hover {
    background: linear-gradient(135deg, #25f4ee, #fe2c55);
    color: #fff;
    border-color: #fe2c55;
}

.footer-socials a.kick:hover {
    background: #53fc18;
    color: #020617;
    border-color: #53fc18;
}

.footer-socials a.twitter:hover {
    background: #1da1f2;
    color: #fff;
    border-color: #1da1f2;
}

.footer-socials a.ko-fi:hover {
    background: #ff5e5b;
    color: #fff;
    border-color: #ff5e5b;
}

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(30, 30, 30, 0.5);
    border-radius: var(--border-radius);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: var(--border-radius);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) rgba(30, 30, 30, 0.5);
}

@media (max-width: 1200px) {
    body {
        height: auto;
        max-height: none;
        overflow: auto;
    }
    .container {
        flex-direction: column;
        overflow: visible;
    }
    .settings-panel, .preview-panel {
        width: 100%;
        max-width: 100%;
        height: auto;
        min-height: 480px;
    }
    .preview-container, #game-preview {
        min-height: 420px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    .header {
        flex-direction: column;
        align-items: stretch;
        flex-wrap: wrap;
    }
    .header-divider {
        width: 100%;
        height: 2px;
        align-self: auto;
    }
    .url-container {
        flex-direction: column;
        align-items: stretch;
    }
    .url-buttons {
        flex-direction: column;
        align-items: stretch;
    }
    .generate-button, .copy-button {
        justify-content: center;
    }
    .level-grid {
        grid-template-columns: 1fr;
    }
}


/* ─── v26: race bar + tabs ─── */
.race-bar {
    position: sticky;
    top: 0;
    z-index: 5;
    margin: 0 -18px 12px;
    padding: 16px 18px 14px;
    background: rgba(18, 18, 14, 0.96);
    border-bottom: 1px solid rgba(var(--glow-rgb), 0.25);
    backdrop-filter: blur(10px);
}
.race-bar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.race-bar-hint {
    font-size: 0.8rem;
    color: var(--text-gray);
}
.race-bar code, .setting-hint code {
    background: rgba(var(--glow-rgb), 0.15);
    color: var(--accent-color);
    padding: 1px 6px;
    border-radius: 5px;
    font-size: 0.85em;
}
.race-status {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-gray);
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.race-status.joining { color: var(--accent-color); border-color: rgba(var(--glow-rgb), 0.5); }
.race-status.countdown, .race-status.racing { color: #052e16; background: var(--success-color); border-color: var(--success-color); }
.race-status.results { color: #422006; background: var(--warning-color); border-color: var(--warning-color); }
.race-bar .race-controls-grid {
    grid-template-columns: 2fr 1.3fr 1.2fr 0.9fr;
}
.race-bar .race-button.primary { grid-column: auto; font-size: 1rem; }
.race-bar .race-button { padding: 11px 8px; font-size: 0.85rem; white-space: nowrap; }

.tab-bar {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    padding: 4px;
    margin-bottom: 14px;
    background: rgba(10, 10, 10, 0.6);
    border-radius: var(--border-radius);
    border: 1px solid rgba(255, 255, 255, 0.06);
}
.tab-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 2px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text-gray);
    font-family: 'Poppins', sans-serif;
    font-size: 0.72rem;
    cursor: pointer;
    transition: all 0.15s ease;
}
.tab-button i { font-size: 1rem; color: var(--icon-color); opacity: 0.7; }
.tab-button:hover { color: var(--text-light); background: rgba(255, 255, 255, 0.04); }
.tab-button.active {
    color: var(--text-light);
    background: rgba(var(--glow-rgb), 0.14);
    border-color: rgba(var(--glow-rgb), 0.45);
}
.tab-button.active i { opacity: 1; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: tabIn 0.15s ease; }
@keyframes tabIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.tab-panel .settings-section { margin-bottom: 14px; padding: 16px; }
.tab-panel .settings-section h3 { font-size: 1.05rem; margin-bottom: 14px; }
.tab-panel .setting-group label .value-display { float: right; margin-top: -3px; padding: 2px 9px; font-size: 0.8rem; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checkbox-label.compact { font-size: 0.85rem; margin: 0; }

details.collapsible > summary {
    cursor: pointer;
    font-size: 1.05rem;
    font-weight: 500;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 10px;
}
details.collapsible > summary::-webkit-details-marker { display: none; }
details.collapsible > summary i { color: var(--accent-color); }
details.collapsible > summary::after { content: '\25B8'; margin-left: auto; color: var(--text-gray); transition: transform 0.15s; }
details.collapsible[open] > summary::after { transform: rotate(90deg); }
details.collapsible[open] > summary { margin-bottom: 14px; }

.level-toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 8px;
}
.level-toolbar .style-select { flex: 1; }
.level-actions { margin-top: 14px; }
.level-badge.maze {
    right: auto;
    left: 8px;
    background: rgba(34, 211, 238, 0.2);
    color: #67e8f9;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
    gap: 6px;
}
.color-swatch {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 8px;
    border-radius: 8px;
    background: rgba(20, 20, 20, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.78rem;
    min-width: 0;
    flex-wrap: wrap;
}
.color-swatch .chip {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 2px solid;
    flex-shrink: 0;
}
.color-swatch .name { color: var(--text-light); }
.color-swatch .owner {
    width: 100%;
    font-size: 0.68rem;
    color: var(--accent-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.color-swatch.taken { border-color: rgba(var(--glow-rgb), 0.4); }

@media (max-width: 1100px) {
    .container { flex-direction: column; }
    .settings-panel { max-width: 100%; min-width: 0; max-height: none; }
}
