/* ===== RESET & BASE ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #1a1a2e;
    font-family: 'Press Start 2P', monospace;
    color: #e0d8c0;
    image-rendering: pixelated;
}

.hidden {
    display: none !important;
}

/* ===== GAME WRAPPER ===== */
#game-wrapper {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #16213e;
}

/* ===== CANVAS ===== */
#game-canvas {
    display: block;
    background: #fdf6e3;
    border: 4px solid #2c2c2c;
    box-shadow:
        0 0 0 2px #5c4a3a,
        0 0 40px rgba(0, 0, 0, 0.5),
        inset 0 0 60px rgba(0, 0, 0, 0.05);
    image-rendering: pixelated;
}

/* ===== SCORE HUD ===== */
#score-hud {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 10;
    background: rgba(26, 26, 46, 0.85);
    border: 3px solid #4a4a6a;
    border-radius: 4px;
    padding: 8px 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

#score-left,
#score-right {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.player-label {
    font-size: 8px;
    color: #8a8aaa;
    letter-spacing: 1px;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
}

#score-left .player-label {
    color: #6a9fdb;
}

#score-right .player-label {
    color: #db6a6a;
}

.score-value {
    font-size: 28px;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

#score-p1 {
    color: #7ab8ff;
}

#score-p2 {
    color: #ff7a7a;
}

#score-divider {
    font-size: 24px;
    color: #6a6a8a;
    padding: 0 4px;
}

/* ===== OVERLAYS ===== */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    background: rgba(10, 10, 30, 0.92);
}

#menu-bg-canvas,
#matchmaking-bg-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.menu-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    padding: 40px;
    animation: fadeSlideIn 0.5s ease-out;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== TITLE ===== */
.game-title {
    font-size: 42px;
    letter-spacing: 4px;
    text-shadow:
        0 0 10px rgba(122, 184, 255, 0.5),
        0 4px 0 #1a1a2e,
        0 5px 0 #0a0a1e;
    animation: titlePulse 3s ease-in-out infinite;
}

.title-note {
    color: #7ab8ff;
}

.title-pong {
    color: #ff7a7a;
}

@keyframes titlePulse {

    0%,
    100% {
        text-shadow: 0 0 10px rgba(122, 184, 255, 0.5), 0 4px 0 #1a1a2e, 0 5px 0 #0a0a1e;
    }

    50% {
        text-shadow: 0 0 20px rgba(122, 184, 255, 0.8), 0 0 20px rgba(255, 122, 122, 0.4), 0 4px 0 #1a1a2e, 0 5px 0 #0a0a1e;
    }
}

.game-subtitle {
    font-size: 11px;
    color: #8a8aaa;
    letter-spacing: 3px;
    margin-top: -10px;
}

/* ===== BUTTONS ===== */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    max-width: 420px;
}

.pixel-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 13px;
    padding: 16px 28px;
    background: linear-gradient(180deg, #3a5a8a 0%, #2a4a7a 100%);
    color: #e0e8f0;
    border: 3px solid #5a7aaa;
    border-bottom: 5px solid #1a3a5a;
    border-right: 4px solid #1a3a5a;
    border-radius: 4px;
    cursor: pointer;
    text-align: center;
    transition: all 0.1s ease;
    letter-spacing: 1px;
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
    image-rendering: pixelated;
    position: relative;
    overflow: hidden;
}

.pixel-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.4s ease;
}

.pixel-btn:hover::after {
    left: 100%;
}

.pixel-btn:hover {
    background: linear-gradient(180deg, #4a6a9a 0%, #3a5a8a 100%);
    border-color: #6a8aba;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(58, 90, 138, 0.4);
}

.pixel-btn:active {
    transform: translateY(2px);
    border-bottom-width: 3px;
    border-right-width: 3px;
    box-shadow: none;
}

.pixel-btn.btn-secondary {
    background: linear-gradient(180deg, #4a4a5a 0%, #3a3a4a 100%);
    border-color: #6a6a7a;
    border-bottom-color: #2a2a3a;
    border-right-color: #2a2a3a;
}

.pixel-btn.btn-secondary:hover {
    background: linear-gradient(180deg, #5a5a6a 0%, #4a4a5a 100%);
    border-color: #7a7a8a;
    box-shadow: 0 6px 20px rgba(74, 74, 90, 0.4);
}

.btn-icon {
    margin-right: 12px;
}

.pixel-svg {
    display: inline-block;
    vertical-align: middle;
    margin-top: -4px;
    shape-rendering: geometricPrecision;
}

/* ===== MENU NICK ===== */
.menu-nick-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 320px;
}

.menu-nick-input {
    text-align: center;
}

/* ===== CONTROLS HINT ===== */
.controls-hint {
    display: flex;
    gap: 32px;
    margin-top: 8px;
}

.controls-hint p {
    font-size: 9px;
    color: #6a6a8a;
}

kbd {
    display: inline-block;
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    padding: 3px 6px;
    background: #2a2a4a;
    border: 2px solid #4a4a6a;
    border-bottom: 3px solid #3a3a5a;
    border-radius: 3px;
    color: #aaaacc;
}

/* ===== MATCHMAKING ===== */
.match-title {
    font-size: 20px;
    color: #7ab8ff;
    text-shadow: 0 0 10px rgba(122, 184, 255, 0.3);
}

#matchmaking-nick-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 320px;
}

.nick-label {
    font-size: 10px;
    color: #8a8aaa;
}

.nick-input {
    font-family: 'Press Start 2P', monospace;
    font-size: 11px;
    padding: 12px 16px;
    width: 100%;
    background: #2a2a4a;
    border: 3px solid #4a4a6a;
    border-radius: 4px;
    color: #e0e8f0;
}

.nick-input::placeholder {
    color: #6a6a8a;
}

.nick-input:focus {
    outline: none;
    border-color: #7ab8ff;
}

#matchmaking-search-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 100%;
    max-width: 320px;
}

.loader {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.paper-ball-spin {
    width: 48px;
    height: 48px;
    border: 4px solid #4a4a6a;
    border-top-color: #7ab8ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.match-status {
    font-size: 10px;
    color: #8a8aaa;
    text-align: center;
    line-height: 1.8;
}

/* ===== GAME OVER ===== */
.gameover-title {
    font-size: 28px;
    color: #ffd700;
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.4), 0 4px 0 #1a1a2e;
}

.gameover-winner {
    font-size: 14px;
    color: #e0d8c0;
}

.gameover-score {
    font-size: 36px;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* ===== PAUSE ===== */
.pause-title {
    font-size: 28px;
    color: #aaaacc;
    text-shadow: 0 4px 0 #1a1a2e;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .game-title {
        font-size: 28px;
    }

    .game-subtitle {
        font-size: 9px;
    }

    .pixel-btn {
        font-size: 11px;
        padding: 12px 20px;
    }

    .controls-hint {
        flex-direction: column;
        gap: 8px;
        align-items: center;
    }

    #score-hud {
        padding: 6px 16px;
    }

    .score-value {
        font-size: 22px;
    }
}

@media (max-width: 480px) {
    .game-title {
        font-size: 20px;
    }

    .pixel-btn {
        font-size: 9px;
        padding: 10px 16px;
    }

    .menu-content {
        padding: 20px;
        gap: 16px;
    }
}