:root {
    --bg-color: #050510;
    --accent-primary: #00f2ff;
    --accent-secondary: #ff00e5;
    --accent-tetris: #a855f7;
    --text-color: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --neon-shadow: 0 0 10px rgba(0, 242, 255, 0.5), 0 0 20px rgba(0, 242, 255, 0.3);
    --neon-pink: 0 0 10px rgba(255, 0, 229, 0.5), 0 0 20px rgba(255, 0, 229, 0.3);
    --neon-purple: 0 0 10px rgba(168, 85, 247, 0.5), 0 0 20px rgba(168, 85, 247, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    overflow-y: auto;
}

.hub-back {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 50;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-decoration: none;
    color: var(--accent-tetris);
    border: 1px solid rgba(168, 85, 247, 0.55);
    border-radius: 50px;
    padding: 8px 16px;
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    box-shadow: var(--neon-purple);
    transition: all 0.25s ease;
}

.hub-back:hover {
    color: var(--bg-color);
    background: var(--accent-tetris);
    transform: translateY(-1px);
}

.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.3;
    animation: move 22s infinite alternate;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: var(--accent-primary);
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 480px;
    height: 480px;
    background: var(--accent-secondary);
    bottom: -130px;
    right: -120px;
    animation-delay: -5s;
}

.blob-3 {
    width: 380px;
    height: 380px;
    background: var(--accent-tetris);
    top: 35%;
    left: 15%;
    opacity: 0.22;
    animation-delay: -9s;
}

@keyframes move {
    0% {
        transform: translate(0, 0) scale(1);
    }
    100% {
        transform: translate(80px, 40px) scale(1.08);
    }
}

.game-container {
    width: 100%;
    max-width: min(96vw, 960px);
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px;
    z-index: 1;
}

.hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    gap: 12px;
}

.tetris-hud-part {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.p1-hud {
    align-items: flex-start;
}

.p2-hud {
    align-items: flex-end;
}

.label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 4px;
}

.rounds-indicator {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
}

.round-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.p1-hud .round-dot.won {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    box-shadow: 0 0 8px var(--accent-primary);
}

.p2-hud .round-dot.won {
    background: var(--accent-secondary);
    border-color: var(--accent-secondary);
    box-shadow: 0 0 8px var(--accent-secondary);
}

.stats-row {
    display: flex;
    gap: 14px;
}

.stat-item {
    font-size: 0.68rem;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.55);
}

.stat-item strong {
    font-family: 'Space Mono', monospace;
    font-size: 1rem;
    margin-left: 2px;
}

.p1-glow {
    color: var(--accent-primary);
    text-shadow: var(--neon-shadow);
}

.p2-glow {
    color: var(--accent-secondary);
    text-shadow: var(--neon-pink);
}

.tetris-timer-hub {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.brand-tetris {
    font-size: 1.1rem;
    font-weight: 900;
    letter-spacing: 0.35em;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-tetris), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 11px rgba(168, 85, 247, 0.45));
}

.timer-label {
    font-size: 0.55rem;
    font-weight: 800;
    letter-spacing: 0.35em;
    color: rgba(255, 255, 255, 0.38);
}

.timer-value {
    font-family: 'Space Mono', monospace;
    font-size: 1.5rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: 0.04em;
    opacity: 0.85;
}

.canvas-wrapper-tetris {
    position: relative;
    width: 100%;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    overflow-x: auto;
    overflow-y: hidden;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
}

.tetris-split {
    display: flex;
    flex-flow: row nowrap;
    justify-content: center;
    align-items: stretch;
    gap: 0;
    padding: 16px 12px;
    width: max-content;
    max-width: 100%;
    flex-shrink: 0;
}

.player-lane {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 16px;
    padding: 10px;
    transition: transform 0.1s ease;
}

.side-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex-shrink: 0;
}

.preview-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 70px;
}

.preview-caption {
    font-family: 'Space Mono', monospace;
    font-size: 0.55rem;
    letter-spacing: 0.28em;
    color: rgba(255, 255, 255, 0.35);
}

.preview-canvas {
    display: block;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.6);
    box-shadow: inset 0 0 10px rgba(255,255,255,0.02);
}

.board-container {
    position: relative;
    flex-shrink: 0;
}

#p1-board,
#p2-board {
    width: 240px;
    aspect-ratio: 1 / 2;
    height: auto;
    max-height: 75vh;
    display: block;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.07);
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.5);
}

.lane-p1 #p1-board {
    border-color: rgba(0, 242, 255, 0.15);
}

.lane-p2 #p2-board {
    border-color: rgba(255, 0, 229, 0.15);
}

.board-divider {
    flex-shrink: 0;
    align-self: stretch;
    width: 1px;
    margin: 0 8px;
    background: linear-gradient(
        180deg,
        transparent,
        rgba(168, 85, 247, 0.25) 20%,
        rgba(255, 255, 255, 0.08),
        rgba(168, 85, 247, 0.25) 80%,
        transparent
    );
}

/* Combo / Special text animations */
.combo-pop {
    position: absolute;
    top: 30%;
    left: 0;
    width: 100%;
    text-align: center;
    pointer-events: none;
    z-index: 5;
    font-size: 1.15rem;
    font-weight: 900;
    letter-spacing: 0.1em;
    text-shadow: 0 0 8px currentColor;
    opacity: 0;
    transform: translateY(10px) scale(0.9);
    transition: none;
}

.combo-pop.animate-p1 {
    color: #55eeff;
    animation: popUp 1.2s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

.combo-pop.animate-p2 {
    color: #ff55ee;
    animation: popUp 1.2s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

@keyframes popUp {
    0% {
        opacity: 0;
        transform: translateY(15px) scale(0.85);
    }
    15% {
        opacity: 1;
        transform: translateY(0) scale(1.1);
    }
    30% {
        transform: translateY(-2px) scale(1.0);
    }
    80% {
        opacity: 1;
        transform: translateY(-5px) scale(1.0);
    }
    100% {
        opacity: 0;
        transform: translateY(-20px) scale(0.9);
    }
}

/* Screens overlays */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 5, 16, 0.93);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 30px;
    transition: opacity 0.28s ease;
    z-index: 10;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay h1,
.overlay h2 {
    font-size: clamp(1.8rem, 5vw, 2.8rem);
    margin-bottom: 12px;
    font-weight: 900;
    letter-spacing: 0.25em;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-tetris), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 8px rgba(168, 85, 247, 0.3));
}

.overlay p {
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 20px;
    font-size: 0.95rem;
    letter-spacing: 0.03em;
    line-height: 1.5;
    max-width: 600px;
}

.controls-guide-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    width: 100%;
    max-width: 720px;
    margin-bottom: 24px;
}

.controls-guide-box {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    padding: 16px 20px;
    text-align: left;
}

.controls-guide-box h3 {
    font-size: 0.85rem;
    letter-spacing: 2px;
    margin-bottom: 10px;
    font-weight: 800;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 6px;
}

.controls-guide-box.p1-color h3 {
    color: var(--accent-primary);
    text-shadow: 0 0 6px rgba(0, 242, 255, 0.3);
}

.controls-guide-box.p2-color h3 {
    color: var(--accent-secondary);
    text-shadow: 0 0 6px rgba(255, 0, 229, 0.3);
}

.controls-guide-box ul {
    list-style: none;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.75);
}

.controls-guide-box li {
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}

.controls-guide-box li::before {
    content: "▫";
    margin-right: 8px;
    color: rgba(255, 255, 255, 0.3);
}

.alt-keys-note {
    font-size: 0.72rem;
    opacity: 0.6;
    margin-top: 8px;
    border-top: 1px dashed rgba(255,255,255,0.06);
    padding-top: 4px;
    list-style: none;
}
.alt-keys-note::before {
    content: "" !important;
}

.dual-scores {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 10px;
}

.score-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    padding: 12px 20px;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    min-width: 140px;
}

.score-label {
    font-size: 0.72rem;
    font-weight: 900;
    margin-bottom: 2px;
    opacity: 0.5;
    letter-spacing: 1px;
}

.final-score-val {
    font-family: 'Space Mono', monospace;
    font-size: 2.2rem;
    font-weight: 800;
    line-height: 1.1;
}

.sub-score-lbl {
    font-size: 0.6rem;
    opacity: 0.5;
    margin-top: 4px;
    letter-spacing: 0.5px;
}

.p1-color .final-score-val {
    color: var(--accent-primary);
    text-shadow: var(--neon-shadow);
}

.p2-color .final-score-val {
    color: var(--accent-secondary);
    text-shadow: var(--neon-pink);
}

button {
    background: transparent;
    border: 2px solid var(--accent-tetris);
    color: var(--accent-tetris);
    padding: 12px 36px;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 2px;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: var(--neon-purple);
}

button:hover {
    background: var(--accent-tetris);
    color: var(--bg-color);
    transform: scale(1.04);
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.65);
}

.controls-hint {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    opacity: 0.35;
    font-size: 0.72rem;
    letter-spacing: 1.5px;
    text-align: center;
}

/* Game shake animations */
@keyframes shakeP1 {
    0%, 100% { transform: translate(0, 0); }
    20%, 60% { transform: translate(-3px, 2px); }
    40%, 80% { transform: translate(3px, -2px); }
}

@keyframes shakeP2 {
    0%, 100% { transform: translate(0, 0); }
    20%, 60% { transform: translate(-3px, -2px); }
    40%, 80% { transform: translate(3px, 2px); }
}

.shake-p1 {
    animation: shakeP1 0.15s infinite;
}

.shake-p2 {
    animation: shakeP2 0.15s infinite;
}

/* Mobile & Narrow viewports */
@media (max-width: 800px) {
    .canvas-wrapper-tetris {
        overflow-x: hidden;
    }

    .tetris-split {
        flex-direction: column;
        width: 100%;
        align-items: center;
        gap: 16px;
    }

    .board-divider {
        width: 80%;
        height: 1px;
        align-self: center;
        min-height: 0;
        background: linear-gradient(
            90deg,
            transparent,
            rgba(168, 85, 247, 0.25) 20%,
            rgba(255, 255, 255, 0.08),
            rgba(168, 85, 247, 0.25) 80%,
            transparent
        );
    }

    .player-lane {
        width: 100%;
        justify-content: center;
        padding: 4px;
        gap: 8px;
    }

    .controls-guide-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .hud {
        flex-direction: column;
        gap: 10px;
        padding: 10px 14px;
    }

    .p1-hud, .p2-hud {
        align-items: center;
    }

    .stats-row {
        gap: 10px;
    }
}
