/* Coin flip button styling */
#coin_flip_button {
    background: linear-gradient(45deg, #FFD700, #FFA500);
    color: #000;
    border: none;
    border-radius: 10px;
    padding: 10px 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: bold;
    font-size: 0.9em;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.3);
}

#coin_flip_button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.5);
}

#coin_flip_button span {
    white-space: nowrap;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
}

.modal_content {
    background-color: oklch(25% 0.01 285.823);
    color: oklch(97% 0 0);
    margin: 5% auto;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    overflow: hidden;
}

.lightmode .modal_content {
    background-color: oklch(97% 0.005 285.823);
    color: oklch(14.1% 0 0);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.modal_header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal_header h2 {
    margin: 0;
    font-size: 1.5em;
}

.close_button {
    font-size: 2em;
    cursor: pointer;
    color: #aaa;
    transition: color 0.2s;
}

.close_button:hover {
    color: #fff;
}

.lightmode .close_button:hover {
    color: #000;
}

.player_inputs {
    display: flex;
    gap: 20px;
    margin-bottom: 25px;
    justify-content: center;
    flex-wrap: wrap;
}

.player_input {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.player_input label {
    font-weight: bold;
    margin-bottom: 8px;
    font-size: 1.1em;
}

.player_input input {
    padding: 10px 15px;
    border: 2px solid #4CAF50;
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.1);
    color: inherit;
    font-size: 1em;
    text-align: center;
    min-width: 150px;
}

.lightmode .player_input input {
    background-color: rgba(0, 0, 0, 0.05);
}

.player_input input:focus {
    outline: none;
    border-color: #81C784;
    box-shadow: 0 0 8px rgba(129, 199, 132, 0.5);
}

#start_flip_button {
    display: block;
    margin: 0 auto;
    margin-bottom: 30px;
    padding: 12px 30px;
    background: linear-gradient(45deg, #FFD700, #FFA500);
    border: none;
    border-radius: 12px;
    font-size: 1.2em;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, max-height 0.3s ease, opacity 0.3s ease, margin 0.3s ease;
    color: #000;
    max-height: 100px;
    opacity: 1;
}

#start_flip_button.hidden {
    max-height: 0;
    opacity: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
    overflow: hidden;
}

#start_flip_button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.4);
}

#flip_again_button {
    display: block;
    margin: 20px auto 0 auto;
    padding: 10px 20px;
    background: linear-gradient(45deg, #4CAF50, #81C784);
    border: none;
    border-radius: 10px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, max-height 0.3s ease, opacity 0.3s ease, margin 0.3s ease;
    color: white;
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    padding-top: 0;
    padding-bottom: 0;
    overflow: hidden;
}

#flip_again_button.visible {
    max-height: 100px !important;
    opacity: 1 !important;
    margin-top: 20px !important;
    padding-top: 10px !important;
    padding-bottom: 10px !important;
}

#flip_again_button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

/* Animated coin styles */
#coin_container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    margin: 20px 0;
    perspective: 1000px;
}

#animated_coin {
    width: 120px;
    height: 120px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.1s;
}

.coin_side {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9em;
    text-align: center;
    border: 4px solid #FFD700;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

.coin_heads {
    background: linear-gradient(45deg, #4CAF50, #81C784);
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    backface-visibility: hidden;
}

.coin_tails {
    background: linear-gradient(45deg, #2196F3, #64B5F6);
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    transform: rotateY(180deg);
    backface-visibility: hidden;
}

.player_name {
    padding: 5px;
    word-break: break-word;
    line-height: 1.2;
    transform-style: preserve-3d;
}

/* Fix backwards text on tails side by counter-rotating the text */
.coin_tails .player_name {
    transform: rotateY(180deg) scaleX(-1);
}

/* Flip animations */
@keyframes flipToHeads {
    0% { transform: rotateY(0deg); }
    100% { transform: rotateY(1800deg); }
}

@keyframes flipToTails {
    0% { transform: rotateY(0deg); }
    100% { transform: rotateY(1980deg); }
}

.flip-heads {
    animation: flipToHeads 3s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.flip-tails {
    animation: flipToTails 3s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

#flip_result {
    text-align: center;
    font-size: 1.4em;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 20px;
    transition: max-height 0.3s ease, opacity 0.3s ease, margin 0.3s ease;
    max-height: 100px;
    opacity: 1;
    overflow: hidden;
}

#flip_result:empty {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
}

.winner-announcement {
    background: linear-gradient(45deg, #4CAF50, #81C784);
    color: white;
    padding: 15px 25px;
    border-radius: 12px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
    animation: celebration 0.5s ease-in-out;
}

@keyframes celebration {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}
