@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;600;700&family=Rajdhani:wght@400;500;600;700&family=Russo+One&display=swap');

:root {
    --card-width: min(160px, 28vw);
    --card-height: calc(var(--card-width) * 1.7);
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Rajdhani', sans-serif;
    background: #1a1a1a;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
}

.menu {
    background: rgba(42, 42, 42, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.menu h1, 
#gameContainer h1 {
    font-family: 'Russo One', sans-serif;
    font-size: clamp(2.5rem, 8vw, 4rem);
    text-align: center;
    letter-spacing: 4px;
    margin-bottom: 2rem;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3),
                 0 0 20px rgba(41, 128, 185, 0.2),
                 0 0 30px rgba(41, 128, 185, 0.1);
    background: linear-gradient(180deg, #ffffff, #a0a0a0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: url('/static/background1.avif') no-repeat center center;
    background-size: cover;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.name-input-container {
    margin: 20px 0;
    text-align: center;
}

.vs-battle-container h2,
#gameBoard h2,
.rematch-dialog h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(1.5rem, 5vw, 2rem);
    text-align: center;
    letter-spacing: 2px;
    margin: 1.5rem 0;
    color: #fff;
    text-shadow: 0 0 10px rgba(41, 128, 185, 0.5);
}


#playerName {
    padding: 8px 12px;
    font-size: 1em;
    border: 2px solid #3498db;
    border-radius: 5px;
    width: 200px;
    max-width: 100%;
    transition: border-color 0.3s ease;
}

#playerName:focus {
    outline: none;
    border-color: #2980b9;
}

.player-name,
.status {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 600;
    font-size: clamp(1.1rem, 3.5vw, 1.4rem);
    letter-spacing: 1px;
}

/* Enhanced button base styles */
.menu-buttons button, 
.button {
    display: block;
    width: 90%;
    margin: 1.5rem auto;
    padding: clamp(0.8rem, 3vw, 1rem);
    background: rgba(74, 74, 74, 0.8);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: white;
    font-size: clamp(1rem, 4vw, 1.2rem);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Hover effect */
.menu-buttons button:hover,
.button:hover:not(:disabled) {
    background: rgba(41, 128, 185, 0.9);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Active/Click effect */
.menu-buttons button:active,
.button:active:not(:disabled) {
    transform: translateY(1px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* Shine effect on hover */
.menu-buttons button::before,
.button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -75%;
    width: 50%;
    height: 100%;
    background: linear-gradient(
        to right,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.3) 100%
    );
    transform: skewX(-25deg);
    transition: all 0.75s;
}

.menu-buttons button:hover::before,
.button:hover::before {
    animation: shine 0.75s;
}

@keyframes shine {
    100% {
        left: 125%;
    }
}

/* Entry animation for buttons */
.menu-buttons button {
    opacity: 0;
    transform: translateY(20px);
    animation: slideIn 0.5s forwards;
}

.menu-buttons button:nth-child(1) { animation-delay: 0.2s; }
.menu-buttons button:nth-child(2) { animation-delay: 0.3s; }
.menu-buttons button:nth-child(3) { animation-delay: 0.4s; }

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

/* Pulsing effect for important buttons */
@keyframes pulse {
    0% {
        box-shadow: 0 4px 15px rgba(41, 128, 185, 0);
    }
    50% {
        box-shadow: 0 4px 25px rgba(41, 128, 185, 0.4);
    }
    100% {
        box-shadow: 0 4px 15px rgba(41, 128, 185, 0);
    }
}

.menu-buttons button:first-child {
    animation: slideIn 0.5s forwards, pulse 2s infinite;
}

/* Disabled state */
.button:disabled {
    background: rgba(42, 42, 42, 0.5);
    cursor: not-allowed;
    opacity: 0.7;
    transform: none;
    box-shadow: none;
}

.game-container {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('/static/background2.avif') no-repeat center center;
    background-size: cover;
    height: 100vh;
    height: 100dvh;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

#gameBoard {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

.loading {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(1.2rem, 4vw, 1.6rem);
    letter-spacing: 2px;
}

.loading:after {
    content: '...';
    animation: loading 1.5s infinite;
    display: inline-block;
    width: 1.5em;
    text-align: left;
}

.error-message {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 500;
    color: #ff4444;
    text-shadow: 0 0 8px rgba(255, 68, 68, 0.3);
}

@keyframes loading {
    0% { content: '.'; }
    33% { content: '..'; }
    66% { content: '...'; }
}

.card {
    width: var(--card-width);
    height: var(--card-height);
    margin: 10px;
    position: relative;
    cursor: pointer;
    perspective: 1000px;
    border-radius: 10px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2),
                0 4px 8px rgba(0,0,0,0.1),
                0 0 20px rgba(52, 152, 219, 0.1);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.card:hover {
    box-shadow: 0 12px 24px rgba(0,0,0,0.3),
                0 6px 12px rgba(0,0,0,0.2),
                0 0 30px rgba(52, 152, 219, 0.2);
    transform: translateY(-2px);
}

.played-card .card {
    box-shadow: 0 16px 32px rgba(0,0,0,0.3),
                0 8px 16px rgba(0,0,0,0.2),
                0 0 40px rgba(52, 152, 219, 0.3);
}

/* .card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    border-radius: 10px;
} */

.card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-family: 'Orbitron', sans-serif;
    font-weight: 600;
    letter-spacing: 1px;
}

.card-front {
    background: linear-gradient(45deg, #2c3e50, #3498db);
    color: white;
    font-size: 1.5em;
}

.card-back {
    transform: rotateY(180deg);
    background: white;
}

.card-front img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
}

#status {
    font-family: 'Rajdhani', sans-serif;
    font-size: clamp(1.1rem, 3.5vw, 1.3rem);
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* Initial reveal animation */
@keyframes revealCard {
    0% {
        transform: rotateY(180deg);
        opacity: 0;
    }
    100% {
        transform: rotateY(0);
        opacity: 1;
    }
}

.card.revealing {
    animation: revealCard 0.5s ease-out forwards;
}

/* Move to battle area animation */
@keyframes moveToPlay {
    0% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
    100% {
        transform: scale(1.1) translateY(0);
        opacity: 1;
    }
}

.battle-card {
    animation: moveToPlay 0.3s ease-out forwards;
}

/* Win/Lose animations */
@keyframes winCard {
    0% {
        transform: scale(1.1);
    }
    50% {
        transform: scale(1.3) rotate(5deg);
    }
    100% {
        transform: scale(1.1) rotate(0);
    }
}

@keyframes loseCard {
    0% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(0) rotate(15deg);
        opacity: 0;
    }
}

@keyframes stalemateCard {
    0% {
        transform: scale(1.1);
    }
    25% {
        transform: scale(1.1) translateX(-10px) rotate(-3deg);
    }
    75% {
        transform: scale(1.1) translateX(10px) rotate(3deg);
    }
    100% {
        transform: scale(1.1) translateX(0) rotate(0);
    }
}

.card.winning {
    animation: winCard 0.6s ease-out forwards;
}

.card.losing {
    animation: loseCard 0.6s ease-out forwards;
}

.card.stalemate {
    animation: stalemateCard 0.8s ease-in-out forwards;
}

.status {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    padding: 1rem;
    font-family: 'Rajdhani', sans-serif;
    font-size: clamp(1rem, 3vw, 1.2rem);
    font-weight: 400;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px);
    z-index: 10;
}

.cards {
    margin-top: auto;
    width: 100%;
    padding: 20px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 60px;
}

.battle-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 20px;
    flex: 0 0 auto;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.player-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: var(--card-height);
}

.player-name {
    width: 100%;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 5px;
    min-height: 1.5em;
}

.played-card {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 10px 0;
}

.rematch-dialog {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #2a2a2a;
    padding: clamp(1.5rem, 5vw, 2rem);
    border-radius: 10px;
    text-align: center;
    z-index: 100;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    width: min(90vw, 400px);
}

.rematch-dialog h2 {
    font-size: clamp(1.2rem, 4vw, 1.5rem);
    margin-top: 0;
}

.rematch-buttons {
    display: flex;
    gap: clamp(0.5rem, 2vw, 1rem);
    margin-top: 1rem;
    justify-content: center;
}

.rematch-button {
    padding: clamp(0.4rem, 2vw, 0.5rem) clamp(1rem, 4vw, 1.5rem);
    font-size: clamp(0.9rem, 3vw, 1rem);
}

.result-text {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(1.4rem, 5vw, 1.8rem);
    margin-bottom: 1rem;
    color: #4CAF50;
    text-shadow: 0 0 10px rgba(76, 175, 80, 0.3);
}

.result-text.lost {
    color: #f44336;
    text-shadow: 0 0 10px rgba(244, 67, 54, 0.3);
}

.vs-battle-container {
    display: none;
    text-align: center;
    background: #2a2a2a;
    padding: clamp(1.5rem, 5vw, 2rem);
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    background: url('/static/background1.avif') no-repeat center center;
    width: min(90vw, 400px);
    position: relative;
}

.battle-code {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(1.8rem, 6vw, 2.5rem);
    letter-spacing: 3px;
    color: #4CAF50;
    text-shadow: 0 0 10px rgba(76, 175, 80, 0.3);
    margin: 1.5rem 0;
    font-weight: 700;
}

.code-input {
    font-size: clamp(1rem, 3.5vw, 1.2rem);
    padding: 0.5rem;
    width: min(200px, 80%);
    text-align: center;
    background: #3a3a3a;
    border: 2px solid #4a4a4a;
    color: white;
    border-radius: 5px;
    margin: 1rem 0;
}

input[type="text"],
.code-input {
    font-family: 'Rajdhani', sans-serif;
    font-size: clamp(1rem, 3.5vw, 1.2rem);
    letter-spacing: 1px;
    font-weight: 500;
}

.card-type {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.back-button {
    position: absolute;
    top: clamp(0.5rem, 2vw, 1rem);
    left: clamp(0.5rem, 2vw, 1rem);
    padding: clamp(0.3rem, 1.5vw, 0.5rem) clamp(0.6rem, 2vw, 1rem);
    font-size: clamp(0.8rem, 3vw, 1rem);
    font-family: 'Rajdhani', sans-serif;
    font-weight: 600;
    letter-spacing: 1px;
}

.back-button:hover {
    background: #5a5a5a;
}

@media (max-width: 768px) {
    .card {
        width: 90px;
        height: 156px;
        margin: 3px;
    }

    .battle-area {
        padding: 10px;
        gap: 5px;
    }

    .player-area {
        padding: 0 5px;
    }

    .player-name {
        font-size: clamp(0.8rem, 3vw, 1rem);
    }

    .cards {
        gap: 5px;
        padding: 5px;
        margin-top: 100px;
        margin-bottom: 40px;
    }

    /* Ensure cards fit in viewport */
    .game-container {
        height: 100vh;
        overflow: hidden;
    }
}

/* CELEBRATION STUFF */
.celebration-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 99;
    display: none;
}

.rose {
    position: absolute;
    width: 30px;
    height: 30px;
    background: url('/static/rose.svg') no-repeat center center;
    background-size: contain;
    filter: drop-shadow(0 0 10px rgba(255,64,129,0.5));
}

.rose.small { 
    width: 25px; 
    height: 25px; 
}
.rose.medium { 
    width: 40px; 
    height: 40px; 
}
.rose.large { 
    width: 55px; 
    height: 55px; 
}

.win-text {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Russo One', sans-serif;
    font-size: 8rem;
    color: #fff;
    text-shadow: 0 0 20px rgba(255,64,129,0.8),
                 0 0 40px rgba(255,64,129,0.6),
                 0 0 60px rgba(255,64,129,0.4);
    opacity: 0;
    animation: winTextAppear 4s forwards;
    z-index: 100;
}

@keyframes winTextAppear {
    0% { 
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    20% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }
    80% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
}

@keyframes roseFloat {
    0% {
        transform: translateY(120vh) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-20vh) rotate(720deg);
        opacity: 0;
    }
}

@keyframes roseSway {
    0% { margin-left: -100px; }
    50% { margin-left: 100px; }
    100% { margin-left: -100px; }
}

.rose.floating {
    animation: roseFloat var(--float-duration, 4s) linear forwards,
               roseSway var(--sway-duration, 3s) ease-in-out infinite;
}