﻿/* ═══════════════════════════════════════════════════
   TORK CoinFlip  ·  game.css  ·  Full Redesign
   ═══════════════════════════════════════════════════ */

/* ─── Page wrapper ───────────────────────────────── */
.game-wrapper {
    max-width: 1060px;
    margin: 0 auto;
    padding: 110px 20px 80px;
    position: relative;
    z-index: 10;
    box-sizing: border-box;
}

/* ─── Two-column grid ────────────────────────────── */
.game-layout {
    display: grid;
    grid-template-columns: minmax(0,1fr) 270px;
    gap: 20px;
    align-items: start;
}

.game-main  { min-width: 0; }
.game-sidebar { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* ─── Base card ──────────────────────────────────── */
.game-card {
    background: linear-gradient(160deg, #13131e 0%, #0e0e18 100%);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 24px;
    position: relative;
    overflow: hidden;
}

.game-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(245,184,0,0.04) 0%, transparent 60%);
    pointer-events: none;
}

/* ─── Sidebar cards ──────────────────────────────── */
.sidebar-card {
    background: linear-gradient(160deg, #13131e 0%, #0e0e18 100%);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 18px;
    padding: 22px 20px;
    position: relative;
    overflow: hidden;
    transition: border-color 0.3s;
}

.sidebar-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(245,184,0,0.3), transparent);
    pointer-events: none;
}

.sidebar-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-heading);
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    margin-bottom: 18px;
}

.sidebar-card-title i { color: var(--gold); opacity: 0.6; }

/* ══════════════════════════════════════════════════
   CONNECT CARD
   ══════════════════════════════════════════════════ */
.connect-card {
    padding: 64px 48px 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-height: 480px;
    justify-content: center;
}

.connect-glow {
    position: absolute;
    width: 500px; height: 500px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(245,184,0,0.08) 0%, transparent 65%);
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

/* Floating coin */
.connect-coin {
    width: 96px; height: 96px;
    border-radius: 50%;
    background:
        radial-gradient(ellipse at 36% 28%, rgba(255,255,255,0.55) 0%, transparent 32%),
        radial-gradient(ellipse at 68% 72%, rgba(0,0,0,0.18) 0%, transparent 30%),
        radial-gradient(ellipse at 50% 46%, #fff4a0 0%, #f5b800 28%, #c8920a 58%, #8a5e00 82%, #5a3a00 100%);
    box-shadow:
        inset -3px -4px 14px rgba(0,0,0,0.32),
        inset 3px 3px 10px rgba(255,255,255,0.3),
        0 0 0 3px #7a5500,
        0 0 0 5px rgba(200,146,10,0.5),
        0 16px 48px rgba(245,184,0,0.4),
        0 0 100px rgba(245,184,0,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 36px;
    animation: floatCoin 4s ease-in-out infinite;
    flex-shrink: 0;
    position: relative;
}

.connect-coin::before {
    content: '';
    position: absolute;
    inset: 6px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 32%, rgba(255,255,255,0.18), transparent 60%);
    pointer-events: none;
}

.connect-coin-inner {
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: 100%; border-radius: 50%;
    position: relative; z-index: 1;
}

.connect-coin-letter {
    font-family: var(--font-heading);
    font-size: 2.4rem;
    font-weight: 900;
    color: rgba(0,0,0,0.35);
    text-shadow: 0 2px 4px rgba(255,255,255,0.3);
    line-height: 1;
}

@keyframes floatCoin {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    30%       { transform: translateY(-10px) rotate(2deg); }
    70%       { transform: translateY(-6px) rotate(-1deg); }
}

.connect-title {
    font-family: var(--font-heading);
    font-size: 2.1rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #ffffff 30%, rgba(255,255,255,0.55) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.connect-desc {
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.7;
    max-width: 280px;
    margin-bottom: 36px;
}

.connect-main-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    max-width: 300px;
    padding: 17px 32px;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: #0a0800;
    background: linear-gradient(135deg, #ffe566 0%, #f5b800 45%, #c8920a 100%);
    box-shadow: 0 6px 32px rgba(245,184,0,0.35), inset 0 1px 0 rgba(255,255,255,0.3);
    transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), opacity 0.2s;
}

.connect-main-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 48px rgba(245,184,0,0.45), inset 0 1px 0 rgba(255,255,255,0.3);
}

.connect-main-btn:active { transform: translateY(0); }
.connect-main-btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none !important; }

.connect-badges {
    display: flex;
    gap: 8px;
    margin-top: 24px;
    justify-content: center;
    flex-wrap: wrap;
}

.connect-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 13px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.07);
    background: rgba(255,255,255,0.025);
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.03em;
}

.connect-badge i { font-size: 0.58rem; color: var(--gold); opacity: 0.8; }

/* ══════════════════════════════════════════════════
   GAME CARD — inner
   ══════════════════════════════════════════════════ */
#gameCard { padding: 0; }

/* Wallet info bar */
.wallet-info-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    background: rgba(34,212,122,0.04);
}

.wallet-addr-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.wallet-addr {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.wallet-disconnect {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid rgba(224,80,80,0.25);
    background: rgba(224,80,80,0.06);
    color: rgba(224,80,80,0.75);
    font-family: var(--font-heading);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.wallet-disconnect:hover {
    border-color: rgba(224,80,80,0.5);
    background: rgba(224,80,80,0.12);
    color: #e05050;
}

/* Phase wrapper */
#phaseChoose,
#phaseApproving,
#phaseCommitting,
#phasePending,
#phaseRevealing,
#phaseResult {
    padding: 36px 36px 32px;
}

/* ─── Phase hidden ───────────────────────────────── */
.phase-hidden { display: none !important; }

/* ─── Phase labels ───────────────────────────────── */
.phase-label {
    font-family: var(--font-heading);
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 8px;
    letter-spacing: -0.015em;
}

.phase-sub {
    font-size: 0.84rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.65;
    margin-bottom: 28px;
    max-width: 340px;
    margin-left: auto;
    margin-right: auto;
}

/* ─── Spinner ────────────────────────────────────── */
.tx-status-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 110px;
    margin-bottom: 8px;
}

.tx-spinner {
    width: 56px; height: 56px;
    border-radius: 50%;
    border: 2.5px solid rgba(245,184,0,0.1);
    border-top-color: var(--gold);
    border-right-color: rgba(245,184,0,0.45);
    animation: spin 0.85s linear infinite;
    position: relative;
}

.tx-spinner::after {
    content: '';
    position: absolute;
    inset: 9px;
    border-radius: 50%;
    border: 1.5px solid transparent;
    border-top-color: rgba(245,184,0,0.28);
    animation: spin 1.5s linear infinite reverse;
}

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

/* ══════════════════════════════════════════════════
   3D COIN
   ══════════════════════════════════════════════════ */
.coin-scene {
    display: flex;
    justify-content: center;
    perspective: 1200px;
    margin: 24px 0 28px;
}

.coin-3d {
    width: 150px; height: 150px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.9s cubic-bezier(0.4,0,0.2,1);
    will-change: transform;
}

.coin-face {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.coin-face span {
    font-family: var(--font-heading);
    font-size: 3rem;
    font-weight: 900;
    display: block;
    line-height: 1;
}

.coin-front {
    background:
        radial-gradient(ellipse at 36% 28%, rgba(255,255,255,0.5) 0%, transparent 32%),
        radial-gradient(ellipse at 68% 72%, rgba(0,0,0,0.18) 0%, transparent 30%),
        radial-gradient(ellipse at 50% 46%, #fff4a0 0%, #f5b800 28%, #c8920a 58%, #8a5e00 82%, #5a3a00 100%);
    box-shadow:
        inset -4px -5px 14px rgba(0,0,0,0.3),
        inset 4px 4px 10px rgba(255,255,255,0.28),
        0 0 0 4px #7a5500,
        0 0 0 7px rgba(200,146,10,0.45),
        0 0 0 9px #3a2000,
        0 12px 40px rgba(245,184,0,0.35),
        0 4px 16px rgba(0,0,0,0.5);
}

.coin-front::before {
    content: '';
    position: absolute;
    inset: 8px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, rgba(255,255,255,0.2), transparent 55%);
    pointer-events: none;
}

.coin-front span { 
    font-size: 3.2rem;
    color: rgba(80, 46, 0, 0.7);
    text-shadow:
        1px 1px 0 rgba(255,255,255,0.55),
        -1px -1px 0 rgba(0,0,0,0.25),
        0 2px 6px rgba(0,0,0,0.25);
    position: relative; z-index: 1;
}

.coin-back {
    background:
        radial-gradient(ellipse at 36% 28%, rgba(255,255,255,0.4) 0%, transparent 32%),
        radial-gradient(ellipse at 68% 72%, rgba(0,0,0,0.2) 0%, transparent 30%),
        radial-gradient(ellipse at 50% 46%, #f0f0f5 0%, #c8c8d4 25%, #9898a8 52%, #686878 75%, #404050 100%);
    box-shadow:
        inset -4px -5px 14px rgba(0,0,0,0.4),
        inset 4px 4px 10px rgba(255,255,255,0.2),
        0 0 0 4px #2a2a38,
        0 0 0 7px rgba(100,100,120,0.4),
        0 0 0 9px #18181f,
        0 12px 32px rgba(0,0,0,0.5),
        0 4px 16px rgba(0,0,0,0.5);
    transform: rotateY(180deg);
}

.coin-back span {
    font-size: 2.6rem;
    color: rgba(255,255,255,0.72);
    text-shadow:
        1px 1px 0 rgba(255,255,255,0.35),
        -1px -1px 0 rgba(0,0,0,0.45),
        0 2px 6px rgba(0,0,0,0.35);
    position: relative; z-index: 1;
}

.coin-3d.show-tails { transform: rotateY(180deg); }

@keyframes flipSpin    { 0% { transform: rotateY(0); } 100% { transform: rotateY(1440deg); } }
@keyframes pulseFloat  { 0%,100% { transform: scale(1) translateY(0); } 50% { transform: scale(1.05) translateY(-6px); } }

.coin-flip  { animation: flipSpin 1.9s ease-in-out infinite; }
.coin-pulse { animation: pulseFloat 1.6s ease-in-out infinite; }

.coin-glow-win  { filter: drop-shadow(0 0 32px rgba(34,212,122,0.7)) drop-shadow(0 0 10px rgba(34,212,122,0.4)); }
.coin-glow-lose { filter: drop-shadow(0 0 28px rgba(224,80,80,0.65)) drop-shadow(0 0 10px rgba(224,80,80,0.35)); }

/* ══════════════════════════════════════════════════
   SIDE CHOICE BUTTONS
   ══════════════════════════════════════════════════ */
.side-choices {
    display: flex;
    gap: 14px;
    justify-content: center;
    margin-bottom: 24px;
}

.side-btn {
    flex: 1;
    max-width: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 26px 16px 22px;
    border-radius: 18px;
    border: 1.5px solid rgba(255,255,255,0.07);
    background: rgba(255,255,255,0.018);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.28s var(--ease);
    outline: none;
    font-family: var(--font-heading);
    position: relative;
    overflow: hidden;
}

.side-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(245,184,0,0.06) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.3s;
}

.side-btn:hover::before { opacity: 1; }

.side-mini-coin {
    width: 72px; height: 72px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-weight: 900;
    font-size: 1.6rem;
    transition: transform 0.32s var(--ease-back), box-shadow 0.28s;
    will-change: transform;
}

.side-mini-heads {
    background:
        radial-gradient(ellipse at 36% 30%, rgba(255,255,255,0.5) 0%, transparent 34%),
        radial-gradient(ellipse at 50% 50%, #fff4a0 0%, #f5b800 30%, #c8920a 60%, #8a5e00 88%, #5a3a00 100%);
    color: rgba(80,46,0,0.75);
    text-shadow: 1px 1px 0 rgba(255,255,255,0.5), -1px -1px 0 rgba(0,0,0,0.2);
    box-shadow:
        inset -2px -3px 8px rgba(0,0,0,0.28),
        inset 2px 2px 6px rgba(255,255,255,0.28),
        0 0 0 2.5px #7a5500,
        0 0 0 4px rgba(200,146,10,0.4),
        0 6px 20px rgba(245,184,0,0.3);
}

.side-mini-tails {
    background:
        radial-gradient(ellipse at 36% 30%, rgba(255,255,255,0.38) 0%, transparent 34%),
        radial-gradient(ellipse at 50% 50%, #f0f0f5 0%, #c8c8d4 27%, #9898a8 54%, #686878 76%, #404050 100%);
    color: rgba(255,255,255,0.78);
    text-shadow: 1px 1px 0 rgba(255,255,255,0.3), -1px -1px 0 rgba(0,0,0,0.4);
    box-shadow:
        inset -2px -3px 8px rgba(0,0,0,0.38),
        inset 2px 2px 6px rgba(255,255,255,0.18),
        0 0 0 2.5px #2a2a38,
        0 0 0 4px rgba(100,100,120,0.35),
        0 6px 16px rgba(0,0,0,0.4);
}

.side-text {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: inherit;
}

.side-btn:hover {
    border-color: rgba(245,184,0,0.25);
    color: var(--text-secondary);
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0,0,0,0.22);
}

.side-btn:hover .side-mini-coin { transform: scale(1.1) rotate(-5deg); }

.side-btn.selected {
    border-color: var(--gold);
    background: rgba(245,184,0,0.06);
    color: var(--gold);
    transform: translateY(-4px);
    box-shadow: 0 0 0 1px rgba(245,184,0,0.2), 0 12px 36px rgba(245,184,0,0.12);
}

.side-btn.selected::before { opacity: 1; }
.side-btn.selected .side-mini-coin { transform: scale(1.12); }

/* ══════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════ */
.btn-wide {
    width: 100%;
    padding: 16px 24px;
    font-size: 0.95rem;
    justify-content: center;
    cursor: pointer;
    border: none;
    font-family: var(--font-heading);
    font-weight: 700;
    border-radius: 999px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.22s var(--ease);
    letter-spacing: 0.01em;
}

.btn-primary.btn-wide {
    background: linear-gradient(135deg, #ffe566 0%, #f5b800 45%, #c8920a 100%);
    color: #0a0800;
    box-shadow: 0 4px 24px rgba(245,184,0,0.3), inset 0 1px 0 rgba(255,255,255,0.25);
}

.btn-primary.btn-wide:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 36px rgba(245,184,0,0.42), inset 0 1px 0 rgba(255,255,255,0.25);
}

.btn-primary.btn-wide:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-ghost.btn-wide {
    background: rgba(255,255,255,0.04);
    border: 1.5px solid rgba(255,255,255,0.1);
    color: var(--text-secondary);
}

.btn-ghost.btn-wide:hover {
    border-color: rgba(245,184,0,0.25);
    background: rgba(245,184,0,0.04);
    color: var(--text-primary);
}

.game-wrapper .btn-ghost {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

/* ══════════════════════════════════════════════════
   PROGRESS BAR
   ══════════════════════════════════════════════════ */
.progress-bar {
    width: 100%;
    height: 5px;
    background: rgba(255,255,255,0.06);
    border-radius: 999px;
    margin: 12px 0 24px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--gold-dark), var(--gold-bright));
    border-radius: 999px;
    transition: width 1s ease;
    width: 0%;
    box-shadow: 0 0 10px rgba(245,184,0,0.5);
}

/* ══════════════════════════════════════════════════
   RESULT
   ══════════════════════════════════════════════════ */
.result-badge {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 900;
    text-align: center;
    letter-spacing: -0.02em;
    margin: 6px 0 10px;
}

.result-badge.win  { color: #22d47a; text-shadow: 0 0 32px rgba(34,212,122,0.4); }
.result-badge.lose { color: #e05050; text-shadow: 0 0 28px rgba(224,80,80,0.35); }

.result-amount {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 30px;
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ══════════════════════════════════════════════════
   BET TABLE (sidebar)
   ══════════════════════════════════════════════════ */
.bet-table { display: flex; flex-direction: column; gap: 0; }

.bet-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    font-size: 0.82rem;
    border-bottom: 1px solid rgba(255,255,255,0.045);
}

.bet-row:last-child { border-bottom: none; }

.bet-label { color: var(--text-muted); }

.bet-val {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary);
}

.bet-row-win  .bet-val { color: #22d47a; }
.bet-row-burn .bet-val { color: #f5a623; }

/* ══════════════════════════════════════════════════
   USER STATS (sidebar)
   ══════════════════════════════════════════════════ */
.ustats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 4px;
}

.ustat {
    background: rgba(255,255,255,0.025);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 12px;
    padding: 14px 10px;
    text-align: center;
}

.ustat-val {
    display: block;
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 5px;
}

.ustat-label {
    display: block;
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.ustat-win  .ustat-val { color: #22d47a; }
.ustat-loss .ustat-val { color: #e05050; }

/* ══════════════════════════════════════════════════
   TOAST
   ══════════════════════════════════════════════════ */
.toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(20,20,30,0.97);
    border: 1px solid rgba(245,184,0,0.2);
    color: var(--text-primary);
    padding: 13px 24px;
    border-radius: 999px;
    font-size: 0.84rem;
    font-weight: 500;
    font-family: var(--font-heading);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s var(--ease);
    z-index: 9999;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    max-width: calc(100vw - 40px);
    white-space: normal;
    text-align: center;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ══════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════ */
@media (max-width: 860px) {
    .game-layout {
        grid-template-columns: 1fr;
    }

    .game-sidebar {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 580px) {
    .game-wrapper { padding: 96px 14px 56px; }

    .connect-card { padding: 48px 24px 40px; }
    .connect-title { font-size: 1.7rem; }
    .connect-coin { width: 80px; height: 80px; }
    .connect-coin-letter { font-size: 2rem; }

    #phaseChoose, #phaseApproving, #phaseCommitting,
    #phasePending, #phaseRevealing, #phaseResult { padding: 28px 20px 24px; }

    .coin-3d { width: 120px; height: 120px; }
    .coin-face span { font-size: 2.5rem; }

    .side-choices { gap: 10px; }
    .side-mini-coin { width: 58px; height: 58px; font-size: 1.3rem; }
    .side-btn { padding: 20px 12px 18px; }

    .result-badge { font-size: 2rem; }

    .game-sidebar { display: flex; flex-direction: column; }
}
