/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #000000;
}

/* Warning page */
#warning-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #000000;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.5s ease-out;
}

#warning-page.fade-out {
    opacity: 0;
    pointer-events: none;
}

#warning-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

#warning-text {
    color: #ffffff;
    font-family: 'Author', sans-serif;
    font-weight: 300;
    font-size: 11px;
    letter-spacing: 2px;
    text-align: center;
}

#loading-bar-container {
    width: 80px;
    height: 2px;
    background-color: #333333;
    border-radius: 1px;
    overflow: hidden;
}

#loading-bar {
    width: 0%;
    height: 100%;
    background-color: #ffffff;
    border-radius: 1px;
    animation: load 4s ease-out forwards;
}

@keyframes load {
    0% {
        width: 0%;
    }
    100% {
        width: 100%;
    }
}

/* Global fade-out for canvas elements */
canvas.fade-out {
    opacity: 0 !important;
    transition: opacity 0.8s ease-out !important;
}

/* Container for Three.js canvas */
#container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    z-index: 1;
    pointer-events: none;
    /* Transform controlled by JS momentum - no CSS transition */
}

#container canvas {
    pointer-events: none;
}

/* Text overlay - now a canvas for particle text */
#text-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    pointer-events: none;
    z-index: 10;
    opacity: 1;
    will-change: transform;
    /* Transform controlled by JS momentum - no CSS transition */
}

#text-overlay.fade-in {
    opacity: 1;
}

/* Coming Soon text */
#coming-soon {
    position: fixed;
    top: 21.67%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ff0000;
    font-family: 'Author', sans-serif;
    font-weight: 300;
    font-size: 23.4px;
    text-align: center;
    pointer-events: none;
    z-index: 15;
    letter-spacing: 4px;
    opacity: 0;
    transition: opacity 2s ease-in;
    will-change: transform;
}

#coming-soon.fade-in {
    opacity: 1;
}

#coming-soon.fade-out {
    opacity: 0;
    transition: opacity 0.8s ease-out;
}

/* Coming Soon final text (white) */
#coming-soon-final {
    position: fixed;
    top: 21.67%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ffffff;
    font-family: 'Author', sans-serif;
    font-weight: 300;
    font-size: 23.4px;
    text-align: center;
    pointer-events: none;
    z-index: 15;
    letter-spacing: 4px;
    opacity: 0;
    transition: opacity 2s ease-in;
    will-change: transform;
}

#coming-soon-final.fade-in {
    opacity: 1;
}

#coming-soon-final.fade-out {
    opacity: 0;
    transition: opacity 0.8s ease-out;
}

/* Scroll prompt */
#scroll-prompt {
    position: fixed;
    bottom: 8vh;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 100;
    pointer-events: auto;
    cursor: pointer;
    opacity: 1;
    transition: opacity 0.8s ease-out;
}

#scroll-prompt.fade-out {
    pointer-events: none;
    opacity: 0;
}

#arrow-wedge {
    animation: pulse 2s ease-in-out infinite;
}

.scroll-label {
    font-family: 'Author', sans-serif;
    font-size: 7.5px;
    letter-spacing: 1px;
    color: #ffffff;
    text-align: center;
    margin-bottom: -4px;
    animation: pulse 2s ease-in-out infinite;
}

/* Second scroll prompt (appears after title) */
#scroll-prompt-2 {
    position: fixed;
    bottom: 8vh;
    left: 50%;
    transform: translate(-50%, calc(0% - 0px));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 100;
    pointer-events: none;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.8s ease-out;
    will-change: transform;
    /* Transform controlled by JS momentum - no CSS transition */
}

#scroll-prompt-2.fade-in {
    opacity: 1;
    pointer-events: auto;
    cursor: pointer;
}

#scroll-prompt-2.fade-out {
    opacity: 0;
    pointer-events: none;
}

#arrow-wedge-2 {
    animation: pulse 2s ease-in-out infinite;
}

#scroll-text {
    color: #ffffff;
    font-family: 'Author', sans-serif;
    font-weight: 300;
    font-size: 14px;
    letter-spacing: 3px;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.7;
        transform: translateY(0);
    }
    50% {
        opacity: 0.85;
        transform: translateY(3px);
    }
}

/* Third scroll prompt (upward arrow) */
#scroll-prompt-3 {
    position: fixed;
    top: 8vh;
    left: 50%;
    transform: translateX(-50%) rotate(180deg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 100;
    pointer-events: none;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.8s ease-out;
}

#scroll-prompt-3.fade-in {
    opacity: 1;
    pointer-events: auto;
    cursor: pointer;
}

#scroll-prompt-3.fade-out {
    opacity: 0;
    pointer-events: none;
}

#arrow-wedge-3 {
    animation: pulse-up 2s ease-in-out infinite;
}

@keyframes pulse-up {
    0%, 100% {
        opacity: 0.7;
        transform: translateY(0);
    }
    50% {
        opacity: 0.85;
        transform: translateY(-3px);
    }
}

/* Button page */
#button-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #000000;
    z-index: 25;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 2s ease-in;
}

#button-page.fade-in {
    opacity: 1;
}

#button-container {
    display: grid;
    grid-template-columns: auto auto auto auto;
    justify-content: space-between;
    align-items: center;
    row-gap: 40px;
    width: 400px;
    opacity: 1;
    transition: opacity 0.4s ease-out;
}

/* Column-specific text alignment */
#button-container .credit-button:nth-child(4n+1) {
    justify-self: start;
}

#button-container .credit-button:nth-child(4n+2),
#button-container .credit-button:nth-child(4n+3) {
    justify-self: center;
}

#button-container .credit-button:nth-child(4n+4) {
    justify-self: end;
}

#button-container.fade-out {
    opacity: 0;
}

/* Copyright notice */
#copyright {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.3);
    font-family: 'Author', sans-serif;
    font-weight: 300;
    font-size: 10px;
    letter-spacing: 1px;
    white-space: nowrap;
    z-index: 25;
    opacity: 0;
    transition: opacity 0.4s ease-out;
    pointer-events: none;
}

#button-page.fade-in #copyright {
    opacity: 1;
}

#button-container.fade-out ~ #copyright {
    opacity: 0;
}

.credit-button {
    color: #ffffff;
    font-family: 'Author', sans-serif;
    font-weight: 300;
    font-size: 23.4px;
    letter-spacing: 4px;
    text-decoration: none;
    cursor: pointer;
    pointer-events: auto;
    transition: opacity 0.3s ease;
}

.credit-button:hover {
    opacity: 0.7;
}

/* ===========================
   BRICK BREAKER GAME
   =========================== */

/* Game trigger (bottom-right corner) */
#game-trigger {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    z-index: 26;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

#game-trigger.visible {
    opacity: 1;
    pointer-events: auto;
}

#game-trigger:hover svg circle,
#game-trigger:hover svg rect {
    opacity: 0.6 !important;
    transition: opacity 0.2s ease;
}

/* Game container */
#game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #000000;
    z-index: -1;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
}

#game-container.game-hidden {
    opacity: 0;
    pointer-events: none;
    z-index: -1;
    transition: opacity 0.4s ease-out;
}

#game-container.game-visible {
    opacity: 1;
    pointer-events: auto;
    z-index: 30;
    transition: opacity 0.4s ease-in;
}

/* Game canvas */
#game-canvas {
    display: block;
    max-width: 90vw;
    max-height: 90vh;
    border: 3px solid rgba(255, 255, 255, 0.15);
    z-index: 30;
    position: relative;
    pointer-events: auto;
}

/* Ruler toggle button (outside canvas, bottom-right) */
#ruler-toggle {
    position: absolute;
    width: 28px;
    height: 28px;
    cursor: pointer;
    z-index: 31;
    color: rgba(255, 255, 255, 0.4);
    transition: color 0.2s ease;
    display: none;
}

#game-container.game-visible #ruler-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
}

#ruler-toggle:hover {
    color: rgba(255, 255, 255, 0.7);
}

#ruler-toggle.active {
    color: #ff0000;
}

/* Game overlay (for ESC hint and click-outside detection) */
#game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 26;
}

#game-hint {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.4);
    font-family: 'Author', sans-serif;
    font-weight: 300;
    font-size: 11px;
    letter-spacing: 2px;
    pointer-events: none;
    z-index: 31;
    display: none;
}

#game-container.game-visible #game-hint {
    display: block;
}

/* Timer and Records Display */
#records-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    flex-direction: column;
    align-items: center;
    gap: 6px;
    pointer-events: none;
    z-index: 31;
    display: none;
}

#game-container.game-visible #records-container {
    display: flex;
}

#global-best,
#session-best {
    color: rgba(255, 255, 255, 0.4);
    font-family: 'Author', sans-serif;
    font-weight: 300;
    font-size: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
}

#global-best {
    color: rgba(255, 255, 255, 0.6);
}

#game-timer {
    color: rgba(255, 255, 255, 0.9);
    font-family: 'Author', sans-serif;
    font-weight: 500;
    font-size: 14px;
    letter-spacing: 3px;
    font-variant-numeric: tabular-nums;
    margin-top: 4px;
}

/* New record animation */
#global-best.new-record,
#session-best.new-record {
    animation: recordPulse 0.5s ease-out 3;
    color: rgba(255, 255, 255, 1);
}

@keyframes recordPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.05);
    }
}

/* Mode selector styles */
.mode-selector {
    position: fixed;
    display: none;
    gap: 6px;
    z-index: 31;
}

#game-container.game-visible .mode-selector {
    display: flex;
}

.mode-button {
    padding: 4px 10px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.5);
    font-family: 'Author', sans-serif;
    font-weight: 300;
    font-size: 9px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 0;
}

.mode-button:hover {
    color: rgba(255, 255, 255, 0.8);
    border-color: rgba(255, 255, 255, 0.5);
}

.mode-button.active {
    color: #ffffff;
    border-color: #ffffff;
}

/* Italic lowercase n for n-body mode */
.italic-n {
    font-style: italic;
    text-transform: lowercase !important;
    font-size: 0.95em;
}

/* Lowercase text override for n-body mode */
.lowercase-text {
    text-transform: lowercase !important;
}

/* Mobile styles */
@media (max-width: 768px) {
    #text-overlay {
        font-size: 28px;
        letter-spacing: 1px;
        white-space: nowrap;
        padding: 0 20px;
    }

    #coming-soon,
    #coming-soon-final {
        font-size: 14px;
        letter-spacing: 1.5px;
        white-space: nowrap;
        padding: 0 20px;
    }

    #button-container {
        row-gap: 25px;
        width: 280px;
    }

    .credit-button {
        font-size: 16px;
        letter-spacing: 2px;
    }

    #copyright {
        font-size: 9px;
        bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    }

    /* Game mobile adjustments */
    #game-trigger {
        bottom: calc(15px + env(safe-area-inset-bottom, 0px));
        right: 15px;
        width: 35px;
        height: 35px;
    }

    #game-canvas {
        max-width: 95vw;
        max-height: 85vh;
    }

    #game-hint {
        font-size: 10px;
        letter-spacing: 1.5px;
        bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    }

    #records-container {
        gap: 4px;
    }

    #global-best,
    #session-best {
        font-size: 9px;
        letter-spacing: 1.5px;
    }

    #game-timer {
        font-size: 12px;
        letter-spacing: 2px;
    }
}
