/* ===== CSS Variables ===== */
:root {
    --primary-blue: #1e5799;
    --primary-yellow: #ffd700;
    --primary-red: #e63946;
    --glow-yellow: rgba(255, 215, 0, 0.6);
    --glow-blue: rgba(30, 87, 153, 0.6);
    --shadow-dark: rgba(0, 0, 0, 0.3);
}

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    min-height: 100vh;
    overflow: hidden;
}

/* ===== Game Container ===== */
.game-container {
    width: 100vw;
    height: 100vh;
    background-image: url('assets/bg.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
}

/* ===== Header ===== */
.game-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    z-index: 10;
}

/* ===== Shuffle Button ===== */
.shuffle-button {
    position: relative;
    padding: 18px 80px;
    font-family: 'Bangers', cursive;
    font-size: 42px;
    letter-spacing: 4px;
    color: #fff;
    background: linear-gradient(180deg, #4a90d9 0%, #1e5799 50%, #0d3a6e 100%);
    border: 5px solid #ffd700;
    border-radius: 50px;
    cursor: pointer;
    box-shadow:
        0 6px 0 #0a2a4f,
        0 8px 20px rgba(0, 0, 0, 0.4),
        inset 0 2px 10px rgba(255, 255, 255, 0.3);
    text-shadow:
        2px 2px 0 #0d3a6e,
        -1px -1px 0 #0d3a6e,
        1px -1px 0 #0d3a6e,
        -1px 1px 0 #0d3a6e;
    transition: all 0.15s ease;
    overflow: hidden;
}

.shuffle-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

.shuffle-button:hover::before {
    left: 100%;
}

.shuffle-button:hover {
    transform: translateY(-2px);
    box-shadow:
        0 8px 0 #0a2a4f,
        0 12px 30px rgba(0, 0, 0, 0.5),
        inset 0 2px 10px rgba(255, 255, 255, 0.3),
        0 0 30px var(--glow-yellow);
}

.shuffle-button:active {
    transform: translateY(4px);
    box-shadow:
        0 2px 0 #0a2a4f,
        0 4px 10px rgba(0, 0, 0, 0.4),
        inset 0 2px 10px rgba(255, 255, 255, 0.3);
}

.shuffle-button.shuffling {
    animation: buttonPulse 0.3s ease infinite;
    pointer-events: none;
}

@keyframes buttonPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

/* ===== Controls Hint ===== */
.controls-hint {
    font-size: 14px;
    color: #fff;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
    opacity: 0.8;
}

.controls-hint kbd {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    font-family: inherit;
}

/* ===== Pokeball Grid ===== */
.pokeball-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 8px;
    max-width: 900px;
    width: 100%;
    padding: 20px;
    flex: 1;
    align-content: center;
}

/* ===== Pokeball Item ===== */
.pokeball {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    cursor: pointer;
    transition: transform 0.2s ease;
    animation: float 3s ease-in-out infinite;
}

.pokeball:nth-child(odd) {
    animation-delay: -1.5s;
}

.pokeball:nth-child(3n) {
    animation-delay: -0.75s;
}

.pokeball:nth-child(4n) {
    animation-delay: -2.25s;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

.pokeball:hover {
    animation-play-state: paused;
    transform: scale(1.15);
    z-index: 5;
    filter: drop-shadow(0 0 15px var(--glow-yellow));
}

.pokeball-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

/* ===== Revealed State ===== */
.pokeball.revealed {
    animation: none;
    cursor: default;
    transform: scale(1);
    z-index: 1;
    transition: transform 0.2s ease, z-index 0.2s;
}

.pokeball.revealed:hover {
    transform: scale(1.5);
    z-index: 10;
    filter: drop-shadow(0 0 15px var(--glow-yellow));
}

.pokeball:not(.revealed):hover {
    transform: scale(1.5);
    filter: drop-shadow(0 0 15px var(--glow-yellow));
}

.pokeball.revealing {
    animation: revealBounce 0.5s ease forwards;
}

@keyframes revealBounce {
    0% {
        transform: scale(1);
    }

    30% {
        transform: scale(1.6) rotate(10deg);
    }

    50% {
        transform: scale(1.55) rotate(-5deg);
    }

    70% {
        transform: scale(1.52) rotate(3deg);
    }

    100% {
        transform: scale(1.5) rotate(0deg);
    }
}

/* ===== Number Overlay ===== */
.pokeball-number {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    /* Default scale 1 when ball is normal size */
    font-family: 'Bangers', cursive;
    font-size: clamp(18px, 3vw, 32px);
    color: #1a1a2e;
    text-shadow:
        1px 1px 0 #fff,
        -1px -1px 0 #fff,
        1px -1px 0 #fff,
        -1px 1px 0 #fff;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.2s ease;
    pointer-events: none;
    z-index: 2;
}

/* Counteract parent scaling when hovered */
.pokeball.revealed:hover .pokeball-number {
    transform: translate(-50%, -50%) scale(0.667);
}

.pokeball.revealed .pokeball-number {
    opacity: 1;
}

/* ===== Shuffle Animation ===== */
.pokeball.shuffling {
    animation: shuffleShake 0.1s ease infinite;
}

@keyframes shuffleShake {

    0%,
    100% {
        transform: translate(0, 0) rotate(0deg);
    }

    25% {
        transform: translate(-3px, 2px) rotate(-3deg);
    }

    50% {
        transform: translate(3px, -2px) rotate(3deg);
    }

    75% {
        transform: translate(-2px, -3px) rotate(-2deg);
    }
}

/* ===== Status Bar ===== */
.status-bar {
    display: flex;
    gap: 40px;
    padding: 15px 30px;
    background: linear-gradient(180deg, rgba(30, 87, 153, 0.9) 0%, rgba(13, 58, 110, 0.95) 100%);
    border: 3px solid #ffd700;
    border-radius: 30px;
    box-shadow:
        0 4px 15px rgba(0, 0, 0, 0.3),
        inset 0 1px 5px rgba(255, 255, 255, 0.2);
    margin-top: 20px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-label {
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
}

.status-value {
    color: #ffd700;
    font-weight: 700;
    font-size: 16px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

/* ===== Responsive Adjustments ===== */
@media (max-width: 900px) {
    .pokeball-grid {
        grid-template-columns: repeat(7, 1fr);
        gap: 6px;
    }

    .shuffle-button {
        padding: 14px 50px;
        font-size: 32px;
    }
}

@media (max-width: 600px) {
    .pokeball-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 5px;
    }

    .shuffle-button {
        padding: 12px 40px;
        font-size: 26px;
    }

    .status-bar {
        flex-direction: column;
        gap: 10px;
        padding: 12px 20px;
    }
}

/* ===== Login Modal ===== */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.login-modal {
    background: linear-gradient(180deg, #2a5298 0%, #1e3c72 100%);
    border: 4px solid #ffd700;
    border-radius: 20px;
    padding: 40px;
    max-width: 400px;
    width: 90%;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 40px rgba(255, 215, 0, 0.3);
    animation: modalIn 0.4s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.9);
    }

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

.login-title {
    font-family: 'Bangers', cursive;
    font-size: 36px;
    color: #ffd700;
    text-align: center;
    margin-bottom: 30px;
    text-shadow:
        2px 2px 0 #1a1a2e,
        -1px -1px 0 #1a1a2e;
    letter-spacing: 2px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-label {
    color: #fff;
    font-weight: 600;
    font-size: 14px;
}

.form-input {
    padding: 14px 18px;
    border: 2px solid rgba(255, 215, 0, 0.4);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    font-size: 16px;
    font-family: 'Outfit', sans-serif;
    transition: all 0.3s ease;
}

.form-input:focus {
    outline: none;
    border-color: #ffd700;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}

.form-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.login-button {
    padding: 16px;
    font-family: 'Bangers', cursive;
    font-size: 24px;
    letter-spacing: 2px;
    color: #fff;
    background: linear-gradient(180deg, #e63946 0%, #9d0208 100%);
    border: 3px solid #ffd700;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow:
        0 4px 0 #6a040f,
        0 6px 15px rgba(0, 0, 0, 0.3);
    margin-top: 10px;
}

.login-button:hover {
    transform: translateY(-2px);
    box-shadow:
        0 6px 0 #6a040f,
        0 10px 20px rgba(0, 0, 0, 0.4),
        0 0 20px rgba(255, 215, 0, 0.4);
}

.login-button:active {
    transform: translateY(2px);
    box-shadow:
        0 2px 0 #6a040f,
        0 3px 10px rgba(0, 0, 0, 0.3);
}

.login-error {
    color: #ff6b6b;
    font-size: 14px;
    text-align: center;
    padding: 10px;
    background: rgba(255, 0, 0, 0.2);
    border-radius: 8px;
    display: none;
}

.login-error.show {
    display: block;
    animation: shake 0.4s ease;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-10px);
    }

    50% {
        transform: translateX(10px);
    }

    75% {
        transform: translateX(-5px);
    }
}

.game-container.hidden {
    display: none;
}