:root {
    --bg-color: #050510;
    --accent-primary: #00f2ff;
    --accent-secondary: #ff00e5;
    --accent-stack: #22c55e;
    --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-green: 0 0 10px rgba(34, 197, 94, 0.52), 0 0 20px rgba(34, 197, 94, 0.35);
}

* {
    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-stack);
    border: 1px solid rgba(34, 197, 94, 0.55);
    border-radius: 50px;
    padding: 8px 16px;
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    box-shadow: var(--neon-green);
    transition: all 0.25s ease;
}

.hub-back:hover {
    color: var(--bg-color);
    background: var(--accent-stack);
    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.4;
    animation: move 20s 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-stack);
    top: 40%;
    left: 15%;
    opacity: 0.28;
    animation-delay: -9s;
}

@keyframes move {
    0% {
        transform: translate(0, 0) scale(1);
    }
    100% {
        transform: translate(88px, 44px) scale(1.08);
    }
}

.game-container {
    width: 100%;
    max-width: min(96vw, 920px);
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 20px;
    z-index: 1;
}

.hud {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    padding: 15px 20px;
    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.3);
    gap: 12px;
}

.hud-stack-main {
    align-items: center;
}

.stack-hud-part {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.label {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 1.6px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 8px;
    text-align: center;
    max-width: 200px;
    line-height: 1.35;
}

.stack-height-label {
    font-size: 0.58rem;
    font-weight: 800;
    letter-spacing: 0.35em;
    color: rgba(255, 255, 255, 0.4);
}

.value {
    font-family: 'Space Mono', monospace;
    font-size: 1.6rem;
    font-weight: 700;
}

.p1-score .value {
    color: var(--accent-primary);
    text-shadow: var(--neon-shadow);
}

.p2-score .value {
    color: var(--accent-secondary);
    text-shadow: var(--neon-pink);
}

.stack-timer-hub {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 0 8px;
}

.brand-stack {
    font-size: 1rem;
    font-weight: 900;
    letter-spacing: 0.38em;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-stack), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 11px rgba(34, 197, 94, 0.4));
}

.timer-label {
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.45em;
    color: rgba(255, 255, 255, 0.38);
}

.timer-value {
    font-family: 'Space Mono', monospace;
    font-size: 2.6rem;
    font-weight: 800;
    color: var(--accent-stack);
    text-shadow: var(--neon-green);
    line-height: 1;
    letter-spacing: 0.04em;
}

.canvas-wrapper-stack {
    position: relative;
    width: 100%;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid var(--glass-border);
    border-radius: 20px;
    overflow-x: auto;
    overflow-y: hidden;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
}

.stack-split {
    display: flex;
    flex-flow: row nowrap;
    justify-content: center;
    align-items: center;
    gap: 0;
    padding: 14px 12px 18px;
    width: max-content;
    max-width: 100%;
    flex-shrink: 0;
}

.player-lane {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 12px;
}

.preview-wrap {
    display: flex;
    flex-shrink: 0;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 70px;
}

.preview-caption {
    font-family: 'Space Mono', monospace;
    font-size: 0.58rem;
    letter-spacing: 0.42em;
    color: rgba(255, 255, 255, 0.4);
}

.preview-canvas {
    display: block;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.58);
}

#p1-board,
#p2-board {
    width: 240px;
    aspect-ratio: 1 / 2;
    height: auto;
    max-height: 85vh;
    flex-shrink: 0;
    display: block;
}

.board-divider {
    flex-shrink: 0;
    align-self: stretch;
    width: 2px;
    margin: 0 8px;
    min-height: 200px;
    background: linear-gradient(
        180deg,
        transparent,
        rgba(34, 197, 94, 0.35) 22%,
        rgba(255, 255, 255, 0.12),
        rgba(34, 197, 94, 0.35) 78%,
        transparent
    );
    border-radius: 2px;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 5, 16, 0.9);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 40px;
    transition: opacity 0.28s ease;
    z-index: 10;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay h1,
.overlay h2 {
    font-size: clamp(1.55rem, 6vw, 2.85rem);
    margin-bottom: 18px;
    letter-spacing: 0.38em;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-stack), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.overlay p {
    color: rgba(255, 255, 255, 0.74);
    margin-bottom: 28px;
    font-size: 1.06rem;
    letter-spacing: 0.045em;
    line-height: 1.62;
}

.dual-scores {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-top: 10px;
}

.score-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 15px 25px;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.score-label {
    font-size: 0.8rem;
    font-weight: 900;
    margin-bottom: 5px;
    opacity: 0.6;
}

.score-box span:last-child {
    font-family: 'Space Mono', monospace;
    font-size: 2.5rem;
    font-weight: 700;
}

.p1-color span:last-child {
    color: var(--accent-primary);
    text-shadow: var(--neon-shadow);
}

.p2-color span:last-child {
    color: var(--accent-secondary);
    text-shadow: var(--neon-pink);
}

button {
    background: transparent;
    border: 2px solid var(--accent-stack);
    color: var(--accent-stack);
    padding: 15px 40px;
    font-size: 1.1rem;
    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-green);
}

button:hover {
    background: var(--accent-stack);
    color: var(--bg-color);
    transform: scale(1.05);
    box-shadow: 0 0 22px rgba(34, 197, 94, 0.65);
}

.controls-hint {
    display: flex;
    justify-content: center;
    gap: 24px;
    flex-wrap: wrap;
    opacity: 0.4;
    font-size: 0.8rem;
    letter-spacing: 2px;
}

/* Sehr schmale Displays: optional untereinander */
@media (max-width: 520px) {
    .canvas-wrapper-stack {
        overflow-x: hidden;
    }

    .stack-split {
        flex-direction: column;
        width: 100%;
    }

    .board-divider {
        width: min(240px, 80vw);
        min-height: 0;
        height: 2px;
        margin: 10px auto;
        align-self: center;
        background: linear-gradient(
            90deg,
            transparent,
            rgba(34, 197, 94, 0.35) 18%,
            rgba(255, 255, 255, 0.14),
            rgba(34, 197, 94, 0.35) 82%,
            transparent
        );
    }

    .player-lane {
        justify-content: center;
        width: 100%;
    }
}
