/* Coin Flip Duel - Premium Casino Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --gold:        #ffd700;
    --gold-light:  #ffd700;
    --gold-mid:    #c8a000;
    --gold-dark:   #8a6a00;
    --gold-shine:  #fff8dc;
    --silver:      #e8e8e8;
    --silver-mid:  #b0b0b0;
    --silver-dark: #787878;
    --bg-body:     #0a0a0f;
    --bg-card:     #12100a;
    --text-white:  #f0ead6;
    --text-muted:  #6b6555;
    --win-green:   #3ddc84;
    --lose-red:    #e04040;
    --amber:       #e08020;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: transparent;
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100dvh - 3.5rem);
}

/* ============ SCREENS ============ */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: #06050a;
    color: var(--text-white);
    z-index: 1000;
}

.screen.hidden { display: none; }

.loading-spinner {
    width: 54px;
    height: 54px;
    border: 3px solid rgba(255, 215, 0, 0.15);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

#loading-screen p {
    margin-top: 18px;
    color: var(--gold-mid);
    font-size: 15px;
    letter-spacing: 1px;
}

.login-content { text-align: center; }
.login-icon { font-size: 56px; margin-bottom: 18px; }
.login-content h2 { color: var(--gold); margin-bottom: 8px; }
.login-content p { color: var(--text-muted); }

/* ============ GAME CONTAINER ============ */
#game-container {
    width: 100%;
    max-width: 480px;
    height: 100%;
    max-height: 860px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 12px;
    position: relative;
}

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

/* ============ HEADER ============ */
#game-header {
    width: 100%;
    padding: 8px 12px;
    display: flex;
    justify-content: center;
}

.balance-display {
    background: linear-gradient(180deg, rgba(255,215,0,0.1) 0%, rgba(184,134,11,0.05) 100%);
    border: 1px solid rgba(255,215,0,0.3);
    border-radius: 20px;
    padding: 7px 20px;
    display: flex;
    align-items: center;
    gap: 7px;
}

.balance-label { color: var(--text-muted); font-size: 12px; letter-spacing: 0.5px; }

#balance-value {
    color: var(--gold-light);
    font-size: 20px;
    font-weight: 700;
    min-width: 70px;
    text-align: right;
}

.balance-currency { color: var(--gold-dark); font-size: 11px; }

/* ============ STREAK DISPLAY ============ */
#streak-display {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 16px;
    background:
        linear-gradient(180deg, rgba(224,128,32,0.12) 0%, rgba(224,128,32,0.04) 100%) padding-box,
        linear-gradient(180deg, #e08020 0%, #7a4010 50%, #e08020 100%) border-box;
    border: 1px solid transparent;
    border-radius: 18px;
    margin: 4px 0;
    animation: streakPulse 2s ease-in-out infinite;
}

#streak-display.hidden { display: none; }

@keyframes streakPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(224,128,32,0.2); }
    50%       { box-shadow: 0 0 20px rgba(224,128,32,0.45); }
}

.streak-flame {
    font-size: 20px;
    animation: flameWiggle 0.6s ease-in-out infinite;
}

@keyframes flameWiggle {
    0%, 100% { transform: rotate(-6deg); }
    50%       { transform: rotate(6deg); }
}

.streak-text {
    color: var(--text-white);
    font-size: 13px;
    letter-spacing: 0.3px;
}

.streak-text strong {
    color: var(--amber);
    font-size: 17px;
}

.streak-bonus {
    color: var(--gold);
    font-size: 13px;
    font-weight: 700;
    background: rgba(0, 0, 0, 0.35);
    padding: 2px 8px;
    border-radius: 10px;
}

/* ============ COIN SECTION ============ */
#coin-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    position: relative;
    padding: 16px;
}

.coin-surface {
    position: relative;
    width: 220px;
    height: 220px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Outer decorative ring around the coin area */
.coin-surface::before {
    content: '';
    position: absolute;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: transparent;
    border: 2px solid rgba(200, 150, 12, 0.18);
    box-shadow:
        0 0 30px rgba(200, 150, 12, 0.08),
        inset 0 0 30px rgba(0, 0, 0, 0.4);
    pointer-events: none;
}

.coin-container {
    perspective: 900px;
    width: 155px;
    height: 155px;
}

.coin {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.1s ease-out;
}

.coin.flipping { transition: none; }

/* Coin faces */
.coin-face {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    backface-visibility: hidden;
}

/* HEADS — gold coin */
.coin-heads {
    background: radial-gradient(ellipse at 38% 36%, #fff8c8 0%, var(--gold) 35%, var(--gold-mid) 60%, var(--gold-dark) 100%);
    box-shadow:
        0 0 0 4px #8a6a00,
        0 0 0 7px #c8960c,
        0 0 0 10px #5a4200,
        0 12px 32px rgba(0, 0, 0, 0.6),
        inset 0 3px 8px rgba(255, 255, 255, 0.4),
        inset 0 -4px 10px rgba(0, 0, 0, 0.3);
}

/* TAILS — silver coin */
.coin-tails {
    background: radial-gradient(ellipse at 38% 36%, #ffffff 0%, var(--silver) 35%, var(--silver-mid) 60%, var(--silver-dark) 100%);
    box-shadow:
        0 0 0 4px #606060,
        0 0 0 7px #aaaaaa,
        0 0 0 10px #404040,
        0 12px 32px rgba(0, 0, 0, 0.6),
        inset 0 3px 8px rgba(255, 255, 255, 0.5),
        inset 0 -4px 10px rgba(0, 0, 0, 0.25);
    transform: rotateY(180deg);
}

.coin-icon {
    font-size: 46px;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

.coin-tails .coin-icon { color: #3a3a3a; }

.coin-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: rgba(0, 0, 0, 0.55);
    margin-top: 5px;
    text-shadow: 0 1px 0 rgba(255,255,255,0.4);
}

/* Coin shadow */
.coin-shadow {
    position: absolute;
    bottom: 6px;
    width: 110px;
    height: 18px;
    background: radial-gradient(ellipse, rgba(0,0,0,0.5) 0%, transparent 70%);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.coin-shadow.elevated {
    width: 70px;
    height: 8px;
    opacity: 0.25;
}

/* ============ RESULT DISPLAY ============ */
#result-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 100;
    animation: resultPopup 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#result-display.hidden { display: none; }

@keyframes resultPopup {
    0%   { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1);   opacity: 1; }
}

.result-text {
    display: block;
    font-size: 40px;
    font-weight: 800;
    letter-spacing: 2px;
    text-shadow: 0 2px 12px rgba(0,0,0,0.7);
}

.result-text.win  { color: var(--win-green); }
.result-text.lose { color: var(--lose-red); }

.result-amount {
    display: block;
    font-size: 26px;
    font-weight: 700;
    color: var(--gold);
    margin-top: 4px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.6);
}

/* ============ MESSAGE DISPLAY ============ */
#message-display {
    position: absolute;
    bottom: 240px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(180,20,40,0.85);
    backdrop-filter: blur(6px);
    padding: 8px 22px;
    border-radius: 10px;
    border: 1px solid rgba(220,60,60,0.6);
    z-index: 100;
    white-space: nowrap;
}

#message-display.hidden { display: none; }

#message-text {
    color: var(--text-white);
    font-size: 13px;
    letter-spacing: 0.3px;
}

/* ============ SIDE SELECTION ============ */
#side-selection {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
}

.side-btn {
    flex: 1;
    max-width: 145px;
    padding: 14px 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    position: relative;
}

.side-btn:hover:not(:disabled) {
    background: rgba(255,255,255,0.06);
    transform: translateY(-1px);
}

/* HEADS selected — gold border */
.side-btn[data-side="heads"].selected {
    background:
        linear-gradient(180deg, rgba(255,215,0,0.1) 0%, rgba(138,106,0,0.05) 100%) padding-box,
        linear-gradient(180deg, var(--gold) 0%, var(--gold-dark) 50%, var(--gold) 100%) border-box;
    border: 2px solid transparent;
    border-radius: 14px;
    box-shadow: 0 0 18px rgba(255,215,0,0.25), inset 0 0 12px rgba(255,215,0,0.04);
}

/* TAILS selected — silver border */
.side-btn[data-side="tails"].selected {
    background:
        linear-gradient(180deg, rgba(200,200,200,0.1) 0%, rgba(100,100,100,0.05) 100%) padding-box,
        linear-gradient(180deg, #d0d0d0 0%, #606060 50%, #d0d0d0 100%) border-box;
    border: 2px solid transparent;
    border-radius: 14px;
    box-shadow: 0 0 18px rgba(200,200,200,0.2), inset 0 0 12px rgba(200,200,200,0.04);
}

.side-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.side-icon { font-size: 34px; }

.side-name {
    color: var(--text-white);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 1px;
}

.side-hint {
    color: var(--text-muted);
    font-size: 11px;
    letter-spacing: 0.3px;
}

.vs-text {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1px;
    flex-shrink: 0;
}

/* ============ BET CONTROLS ============ */
#bet-controls {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px 12px;
}

.bet-label {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
}

.bet-buttons { display: flex; gap: 7px; }

.bet-btn {
    width: 50px;
    height: 34px;
    background:
        linear-gradient(180deg, #1a1508 0%, #0d0a04 100%) padding-box,
        linear-gradient(180deg, #6a5000 0%, #2a1e00 50%, #6a5000 100%) border-box;
    border: 1px solid transparent;
    border-radius: 8px;
    color: #a08040;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.18s ease;
    letter-spacing: 0.3px;
}

.bet-btn:hover:not(:disabled):not(.active) {
    color: var(--gold);
    box-shadow: 0 0 8px rgba(255,215,0,0.2);
}

.bet-btn.active {
    background: linear-gradient(180deg, var(--gold-mid) 0%, var(--gold-dark) 100%);
    color: #0d0a04;
    border-color: var(--gold);
    box-shadow: 0 0 12px rgba(255,215,0,0.35);
}

.bet-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ============ FLIP BUTTON ============ */
#flip-button {
    width: 195px;
    height: 52px;
    background:
        linear-gradient(180deg, #c8960c 0%, #7a5800 40%, #c8960c 100%) padding-box,
        linear-gradient(180deg, var(--gold-shine) 0%, #8a6a00 50%, var(--gold-shine) 100%) border-box;
    border: 1px solid transparent;
    border-radius: 26px;
    cursor: pointer;
    box-shadow:
        0 6px 22px rgba(200,150,12,0.4),
        inset 0 1px 0 rgba(255,255,255,0.25),
        inset 0 -2px 0 rgba(0,0,0,0.3);
    transition: all 0.2s ease;
    margin: 8px 0;
}

#flip-button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow:
        0 10px 32px rgba(200,150,12,0.55),
        inset 0 1px 0 rgba(255,255,255,0.3);
}

#flip-button:active:not(:disabled) {
    transform: translateY(1px);
    box-shadow: 0 3px 12px rgba(200,150,12,0.35);
}

#flip-button:disabled {
    background: linear-gradient(180deg, #2a2520 0%, #1a1510 100%);
    border-color: #3a3020;
    box-shadow: none;
    cursor: not-allowed;
}

.flip-text {
    color: #0a0700;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 3px;
    text-shadow: 0 1px 0 rgba(255,255,255,0.25);
}

#flip-button:disabled .flip-text {
    color: #4a4030;
}

#flip-button.pulse {
    animation: buttonPulse 2s ease-in-out infinite;
}

@keyframes buttonPulse {
    0%, 100% { box-shadow: 0 6px 22px rgba(200,150,12,0.4); }
    50%       { box-shadow: 0 6px 36px rgba(200,150,12,0.7); }
}

/* ============ GAME TITLE ============ */
.game-title {
    padding: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.title-text {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

/* ============ PARTICLES ============ */
#particles-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

.particle {
    position: absolute;
    font-size: 22px;
    animation: particleFall 2s ease-out forwards;
}

@keyframes particleFall {
    0%   { opacity: 1; transform: translateY(0) rotate(0deg) scale(1); }
    100% { opacity: 0; transform: translateY(100vh) rotate(720deg) scale(0.5); }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 400px) {
    .coin-container { width: 135px; height: 135px; }
    .coin-icon { font-size: 38px; }
    .side-btn { padding: 11px 8px; }
    .side-icon { font-size: 28px; }
    .side-name { font-size: 13px; }
    .bet-btn { width: 44px; height: 30px; font-size: 12px; }
    #flip-button { width: 160px; height: 46px; }
    .flip-text { font-size: 15px; }
}

@media (max-height: 700px) {
    #coin-section { padding: 8px; }
    .coin-container { width: 125px; height: 125px; }
    #side-selection { padding: 8px 12px; }
    .side-btn { padding: 10px 8px; }
    #flip-button { margin: 4px 0; }
}
