
:root {
    --connecting-message: "Searching For Game...";
}

#deck-builder-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 30000;
    align-items: center;
    justify-content: center;
}

#deck-builder-modal>div {
    background: #0b215a;
    padding: 30px;
    border-radius: 10px;
    max-width: 500px;
    margin: auto;
    border-style: solid;
    border-color: #ffcd00;
    border-width: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
#deck-builder-modal>div>button {
    margin-top: 5%;
    width: 100%;
    padding: 3%;
    border-radius: 8px;
    background-color: white;
    border: none;
    font-family: 'Noto Sans', sans-serif;
    font-weight: bold;
    color: black;
    cursor: pointer;
}

#deck-opponent {
    margin-bottom: 8px;
    font-weight: 600;
}

#deck-builder-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 10px;
}

#deck-card-count {
    font-weight: 600;
}

#submit-deck-button:disabled {
    background-color: grey;
    cursor: not-allowed;
}

/* Connection status styles */
#connection-status {
    position: fixed;
    z-index: 1005;
}

.status-connected {
    visibility: hidden;
}

.status-connecting {
    background: #0b215a;
    position: relative;
    width: 100vw;
    height: 100vh;
    display: block;
    align-items: center;
    justify-content: center;
    overflow: hidden;

}
#connection-status.status-connecting {
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 0;
    border-radius: 0;
}
.status-connecting>* {
    position: relative;
    z-index: 1002;
}

.status-connecting .loader {
    visibility: visible;
    position: absolute;
    top: 55%;
    left: 49.43%;
    transform: translate(-50%, -49.43%);
}

.loader {
    width: 48px;
    height: 48px;
    border: 5px solid #FFF;
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
    opacity: 100;
}

.loader::after {
    content: '';
    box-sizing: border-box;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 5px solid transparent;
    border-bottom-color: #ffcd00;
}

@keyframes rotation {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.status-connecting::after {
    content: var(--connecting-message, "Searching For Game...");
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-image: url(https://raw.githubusercontent.com/MiniKielbyM/monomon/refs/heads/main/Assets/blue-section-stripes.webp);
    background-size: cover;
    background-position: center;
    color: rgb(0, 0, 0);
    font-size: 24px;
    font-weight: bold;
    z-index: 1001;
}

.status-disconnected {
    top: 10px;
    left: 10px;
    padding: 10px 15px;
    border-radius: 5px;
    color: black;
    background-color: #f44336;
    visibility: hidden;
}

.status-disconnected .loader {
    visibility: hidden;
}

.status-waiting {
    top: 10px;
    left: 10px;
    padding: 10px 15px;
    border-radius: 5px;
    color: black;
    background-color: #2196F3;
    visibility: hidden;
}

.status-waiting .loader {
    visibility: hidden;
}

.status-connected .loader {
    visibility: hidden;
}

/* Game messages */
#game-messages {
    position: fixed;
    top: 60px;
    left: 10px;
    right: 10px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: black;
    border-radius: 5px;
    z-index: 1000;
    display: none;
}

/* Player info */
#player-info {
    position: fixed;
    bottom: 10px;
    left: 10px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: black;
    border-radius: 5px;
    z-index: 1000;
}

#turn-status {
    font-weight: bold;
    padding: 5px;
    border-radius: 3px;
    margin-top: 5px;
}

.your-turn {
    background-color: #4CAF50;
    color: black;
}

.opponent-turn {
    background-color: #FF9800;
    color: black;
}

/* Username input */
#username-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0b215a;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

#username-modal::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url(https://raw.githubusercontent.com/MiniKielbyM/monomon/refs/heads/main/Assets/blue-section-stripes.webp);
    background-size: cover;
    z-index: -1;
}

#username-form {
    position: relative;
    background: linear-gradient(135deg, #f09666, #d693b5, #8bb9b9);
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    border-style: solid;
    border-color: #ffcd00;
    border-width: 10px;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.73);
    overflow: hidden;
}

#username-form::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url(https://raw.githubusercontent.com/MiniKielbyM/monomon/refs/heads/main/Assets/bottom-texture.webp);
    background-size: cover;
    pointer-events: none;
    z-index: 1;

}


#username-form>* {
    position: relative;
    z-index: 1;
}

#username-input {
    padding: 10px;
    margin: 10px;
    color: black;
    border: none;
    font-weight: bold;
    border-radius: 8px;
    font-size: 16px;
}

#join-button {
    padding: 10px 20px;
    background-color: rgb(156, 49, 53);
    color: black;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-family: "Noto Sans", sans-serif;
    font-size: 16px;
    transition: background 0.3s;
    z-index: 10;
}

#join-button:hover {
    background: rgb(117, 37, 40);
}

/* Deck count display */
.deck-count {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: black;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    pointer-events: none;
    z-index: 10;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.deck {
    position: relative;
}

/* Coin Flip Modal */
#coin-flip-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 3000;
}

#coin-flip-container {
    background: white;
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

#coin-flip-title {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 20px;
    color: #333;
}

#coin {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    margin: 20px auto;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s;
}

.coin-side {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    color: black;
    backface-visibility: hidden;
}

.coin-heads {
    background: linear-gradient(45deg, #FFD700, #FFA500);
    transform: rotateY(0deg);
}

.coin-tails {
    background: linear-gradient(45deg, #C0C0C0, #808080);
    transform: rotateY(180deg);
}

.coin-spinning {
    animation: coinSpin 2s ease-in-out;
}

.coin-result-heads {
    transform: rotateY(0deg);
}

.coin-result-tails {
    transform: rotateY(180deg);
}

@keyframes coinSpin {
    0% {
        transform: rotateY(0deg);
    }

    25% {
        transform: rotateY(450deg);
    }

    50% {
        transform: rotateY(900deg);
    }

    75% {
        transform: rotateY(1350deg);
    }

    100% {
        transform: rotateY(1800deg);
    }
}

#coin-result {
    font-size: 20px;
    font-weight: bold;
    margin-top: 20px;
    color: #333;
    opacity: 0;
    transition: opacity 0.5s;
}

.result-visible {
    opacity: 1 !important;
}

/* Card shake animation for damage */
.card.shake {
    animation: shake 0.4s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shake {

    10%,
    90% {
        transform: translateX(-2px);
    }

    20%,
    80% {
        transform: translateX(4px);
    }

    30%,
    50%,
    70% {
        transform: translateX(-8px);
    }

    40%,
    60% {
        transform: translateX(8px);
    }
}

/* Card glow for selectable state */
.card.selectable {
    box-shadow: 0 0 16px 4px #ffd700, 0 0 4px 2px #fff;
    border: 2px solid #ffd700;
    cursor: pointer;
    z-index: 20;
    transition: box-shadow 0.2s, border 0.2s;
}


/* Card heal animation */
.card.heal {
    animation: healFlash 0.7s;
}

@keyframes healFlash {
    0% {
        box-shadow: 0 0 0 0 #7fff7f;
    }

    30% {
        box-shadow: 0 0 24px 8px #7fff7f;
    }

    100% {
        box-shadow: 0 0 0 0 #7fff7f;
    }
}

:root {
    --card-size: 24.77%;
}

html,
body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    height: 100%;
    width: 100%;
    touch-action: none;
    user-select: none;
    -ms-touch-action: none;
    -webkit-user-select: none;
    font-family: 'Exo 2';
    letter-spacing: 2.5px;
    text-shadow: -4px -2px 0 #fff, -4px -1px 0 #fff, -4px 0 0 #fff, -4px 1px 0 #fff, -4px 2px 0 #fff, -3px -3px 0 #fff, -3px -2px 0 #fff, -3px -1px 0 #fff, -3px 0 0 #fff, -3px 1px 0 #fff, -3px 2px 0 #fff, -3px 3px 0 #fff, -2px -4px 0 #fff, -2px -3px 0 #fff, -2px -2px 0 #fff, -2px -1px 0 #fff, -2px 0 0 #fff, -2px 1px 0 #fff, -2px 2px 0 #fff, -2px 3px 0 #fff, -2px 4px 0 #fff, -1px -4px 0 #fff, -1px -3px 0 #fff, -1px -2px 0 #fff, -1px -1px 0 #fff, -1px 0 0 #fff, -1px 1px 0 #fff, -1px 2px 0 #fff, -1px 3px 0 #fff, -1px 4px 0 #fff, 0 -4px 0 #fff, 0 -3px 0 #fff, 0 -2px 0 #fff, 0 -1px 0 #fff, 0 0 0 #fff, 0 1px 0 #fff, 0 2px 0 #fff, 0 3px 0 #fff, 0 4px 0 #fff, 1px -4px 0 #fff, 1px -3px 0 #fff, 1px -2px 0 #fff, 1px -1px 0 #fff, 1px 0 0 #fff, 1px 1px 0 #fff, 1px 2px 0 #fff, 1px 3px 0 #fff, 1px 4px 0 #fff, 2px -4px 0 #fff, 2px -3px 0 #fff, 2px -2px 0 #fff, 2px -1px 0 #fff, 2px 0 0 #fff, 2px 1px 0 #fff, 2px 2px 0 #fff, 2px 3px 0 #fff, 2px 4px 0 #fff, 3px -3px 0 #fff, 3px -2px 0 #fff, 3px -1px 0 #fff, 3px 0 0 #fff, 3px 1px 0 #fff, 3px 2px 0 #fff, 3px 3px 0 #fff, 4px -2px 0 #fff, 4px -1px 0 #fff, 4px 0 0 #fff, 4px 1px 0 #fff, 4px 2px 0 #fff;
    background-color: #0b215a
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    scrollbar-gutter: stable;
}

body::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url(https://raw.githubusercontent.com/MiniKielbyM/monomon/refs/heads/main/Assets/blue-section-stripes.webp);
    background-size: cover;
    pointer-events: none;
    z-index: 0;
}

#aspect-box {
    height: 100%;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #ffffff00;
    position: relative;
    font-size: 1.2em;
    color: #333;
    max-width: 100%;
    max-height: 100%;
    box-sizing: border-box;
}

#sixteenbynine {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    visibility: hidden;
    aspect-ratio: 16 / 9;
}

#sixteenbynine #player-zone {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5em;
    color: #666;
    height: 65%;
    width: 100%;
    position: absolute;
    bottom: 0;
    left: 0;
}

#sixteenbynine #opponent-zone {
    width: 100%;
    height: 65%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5em;
    color: #666;
    position: absolute;
    top: 0;
    left: 0;
}

#sixteenbynine .card {
    aspect-ratio: 8 / 11;
    height: var(--card-size);
    width: auto;
    background-image: url('../blank_card.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center;
    border-radius: 3%;
    transition: transform 0.2s;
    position: absolute;
    text-align: center;
    display: flex;
    color: transparent;
    justify-content: center;
    align-items: center;
}

#sixteenbynine .card:hover {
    transform: scale(1.25);
    transition: transform 0.2s;
    cursor: pointer;
    z-index: 10;
}

#sixteenbynine #player-zone .card.active {
    bottom: calc((var(--card-size) * 2) + 15%);
    z-index: 10;
    text-overflow: clip;
}

#sixteenbynine #player-zone .bench {
    position: absolute;
    bottom: calc(var(--card-size) + 10%);
    height: var(--card-size);
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 2%;
    width: 100%;
    left: 0;
}

#sixteenbynine .bench .card {
    position: relative;
    height: 100%;
    z-index: 2;
}

#sixteenbynine .hand-outer {
    position: absolute;
    bottom: 5%;
    height: var(--card-size);
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    overflow: visible;
}

#sixteenbynine .hand-inner {
    position: relative;
    height: 100%;
    width: 59%;
    bottom: -12.5%;
    display: flex;
    overflow-y: visible;
    justify-content: center;
    align-items: flex-end;
    overflow: visible;
}

#sixteenbynine .hand {
    position: relative;
    height: 125%;
    width: 100%;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    overflow-x: auto;
    overflow-y: visible;
    scrollbar-gutter: stable;
    scrollbar-width: none;
    padding-left: 2%;
    padding-right: 2%;
    gap: 3.418%;
    box-sizing: border-box;
}

#sixteenbynine .hand .card {
    height: 80%;
    z-index: 2;
    bottom: 10%;
    padding: 0;
    margin: 0;
    flex-shrink: 0;
    position: relative;
}

#sixteenbynine .prize-zone.one {
    position: absolute;
    top: 25%;
    left: 0;
    height: var(--card-size);
    width: 100%;
    display: flex;
    gap: 0%;
}

#sixteenbynine .prize-zone.two {
    position: absolute;
    top: 40%;
    left: 0;
    height: var(--card-size);
    width: 100%;
    display: flex;
    gap: 0%;
}

#sixteenbynine .prize-zone.three {
    position: absolute;
    top: 55%;
    left: 0;
    height: var(--card-size);
    width: 100%;
    display: flex;
    gap: 0%;
}

#sixteenbynine .prize-zone .card {
    background-image: url('https://images.pokemontcg.io');
    height: 100%;
    z-index: 2;
    position: relative;
    left: 5%;

}

#sixteenbynine .prize-zone .card:hover {
    transform: none;
    cursor: default;
}

#sixteenbynine .deck.player {
    position: absolute;
    bottom: calc(var(--card-size) + 10%);
    right: 6%;
    height: var(--card-size);
    width: auto;
    aspect-ratio: 8 / 11;
    background-image: url('https://images.pokemontcg.io');
    background-size: cover;
    background-position: center;
    font-size: 50%;
    color: #666;
    z-index: 1;

}

#sixteenbynine .discard.player {
    position: absolute;
    bottom: 5%;
    right: 10.5%;
    height: var(--card-size);
    width: auto;
    aspect-ratio: 8 / 11;
    border-color: #666;
    box-sizing: border-box;
    font-size: 50%;
    color: #666;
    z-index: 1;
}

#sixteenbynine .lost-zone.player {
    position: absolute;
    bottom: 5%;
    background-image: url('../blank_card.png');
    right: 1.5%;
    height: var(--card-size);
    width: auto;
    aspect-ratio: 8 / 11;
    border-color: #666;
    box-sizing: border-box;
    font-size: 50%;
    color: #666;
    z-index: 1;
}

#sixteenbynine .card.empty {
    font-size: 50%;
    color: #666;
    background-image: url('../blank_card.png');
    opacity: 0.75;
}

#sixteenbynine .card.faceDown {
    background-image: url('https://images.pokemontcg.io');
    opacity: 1;
}


#sixteenbynine #opponent-zone .card {
    transform: rotate(180deg);
}

#sixteenbynine .opp.active {
    position: absolute;
    top: calc(var(--card-size) + 10%);
    transform: rotate(180deg);
    z-index: 10;
    text-overflow: clip;
}

#sixteenbynine #opponent-zone .bench {
    position: absolute;
    top: 5%;
    height: var(--card-size);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 2%;
    width: 100%;
    left: 0;
    background-color: rgba(255, 255, 255, 0);
}

#sixteenbynine #opponent-zone .card:hover {
    transform: scale(1.25) rotate(180deg);
    transition: transform 0.2s;
    cursor: pointer;
}

#sixteenbynine .card.empty:hover {
    transform: none;
    cursor: default;
}

#sixteenbynine #opponent-zone .card.empty:hover {
    transform: rotate(180deg);
    cursor: default;
}

#sixteenbynine .deck.opp {
    position: absolute;
    top: calc(var(--card-size) + 10%);
    left: 6%;
    height: var(--card-size);
    width: auto;
    aspect-ratio: 8 / 11;
    background-image: url('https://images.pokemontcg.io');
    background-size: cover;
    background-position: center;
    font-size: 0.5em;
    color: #666;
    z-index: 1;
    transform: rotate(180deg);
}

#sixteenbynine .discard.opp {
    position: absolute;
    top: 5%;
    left: 10.5%;
    height: var(--card-size);
    width: auto;
    aspect-ratio: 8 / 11;
    border-color: #666;
    box-sizing: border-box;
    font-size: 50%;
    color: #666;
    z-index: 1;
}

#sixteenbynine .lost-zone.opp {
    position: absolute;
    top: 5%;
    background-image: url('../blank_card.png');
    left: 1.5%;
    height: var(--card-size);
    width: auto;
    aspect-ratio: 8 / 11;
    border-color: #666;
    box-sizing: border-box;
    font-size: 50%;
    color: #666;
    z-index: 1;
}

#sixteenbynine #opponent-zone .prize-zone {
    display: flex;
    justify-content: flex-end;
    /* align row to right */
    gap: 0;
}

#sixteenbynine #opponent-zone .prize-zone .card {
    position: relative;
    right: 5%;
    /* mirror of player’s left: 5% */
    left: auto;
}

#sixteenbynine #opponent-zone .prize-zone .card:hover {
    transform: rotate(180deg);
    cursor: default;

}

#sixteenbynine .overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 20;
    display: none;
}

#sixteenbynine .overlay {
    display: flex;
    justify-content: center;
    align-items: center;
    color: black;
    font-size: 2em;
    text-align: center;
    padding: 20px;
    box-sizing: border-box;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0);
    z-index: 20;
    gap: 1%;
}

#sixteenbynine .overlay::after {
    content: "";
    position: absolute;
    top: -100vh;
    left: -100vw;
    width: 1000vw;
    height: 1000vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: -1;
}

#sixteenbynine .overlay .card {
    position: relative;
    height: 50%;
    width: auto;
    aspect-ratio: 8 / 11;
    background-image: url('../blank_card.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center;
    border-radius: 3%;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

#sixteenbynine .overlay .card:hover {
    transform: none;
    cursor: default;
}

#sixteenbynine .overlay .options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1%;
}

#sixteenbynine .overlay .options .option {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid white;
    border-radius: 10px;
    padding: 10px;
    box-sizing: border-box;
    cursor: pointer;
    transition: background 0.3s, transform 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#sixteenbynine .overlay .options .option:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

/* Mobile touch support */
.card {
    /* Prevent text selection during drag */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;

    /* Improve touch handling */
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

/* Ensure draggable cards work on mobile */
.card.player {
    /* Allow touch events */
    pointer-events: auto;
}

/* Improve touch feedback */
.card.player:active {
    transform: scale(1.02);
    transition: transform 0.1s;
}

/* Reset transform when not active */
.card.player:not(:active) {
    transform: scale(1);
    transition: transform 0.1s;
}