/**
 * Lightning Casino - Roulette Game Styles
 *
 * European roulette wheel and betting table.
 * Requires casino.css to be loaded first for shared variables and layout.
 */

/* ========================================
   ROULETTE CONTAINER
   ======================================== */
.roulette-container {
    background: var(--bg-card);
    border-radius: 24px;
    padding: 2rem;
    border: 1px solid var(--border);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
}

/* ========================================
   ROULETTE WHEEL
   ======================================== */
.wheel-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    position: relative;
}

.wheel-wrapper {
    position: relative;
    width: 280px;
    height: 280px;
}

/* The wheel itself */
.roulette-wheel {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    position: relative;
    background: radial-gradient(circle at center,
        #1a1a1a 0%,
        #1a1a1a 18%,
        #2d333b 19%,
        #1c2128 100%
    );
    box-shadow:
        0 0 0 6px #2d333b,
        0 0 0 8px rgba(247, 147, 26, 0.3),
        0 0 40px rgba(0, 0, 0, 0.6),
        inset 0 0 30px rgba(0, 0, 0, 0.5);
    transition: transform 0.1s linear;
    will-change: transform;
}

/* Outer rim with numbers */
.wheel-numbers {
    position: absolute;
    inset: 0;
    border-radius: 50%;
}

.wheel-number {
    position: absolute;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    transform-origin: center center;
    pointer-events: none;
    z-index: 2;
}

.wheel-number.red {
    background: radial-gradient(circle, #dc2626, #991b1b);
    border-radius: 3px;
}

.wheel-number.black {
    background: radial-gradient(circle, #1f2937, #111827);
    border-radius: 3px;
}

.wheel-number.green {
    background: radial-gradient(circle, #16a34a, #15803d);
    border-radius: 3px;
}

/* Center hub */
.wheel-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 40%, #3d4250 0%, #1c2128 100%);
    box-shadow:
        0 0 0 3px rgba(247, 147, 26, 0.2),
        0 4px 12px rgba(0, 0, 0, 0.6),
        inset 0 2px 4px rgba(255, 255, 255, 0.1);
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wheel-center-inner {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f7931a, #e8820a);
    box-shadow: 0 0 10px rgba(247, 147, 26, 0.4);
}

/* Ball marker (arrow/pointer at top) */
.wheel-pointer {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 16px solid #f7931a;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

/* Ball (hidden — pointer triangle shows result) */
.roulette-ball {
    display: none;
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #fff, #d1d5db);
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.5),
        inset 0 -1px 2px rgba(0, 0, 0, 0.2);
    z-index: 8;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.roulette-ball.visible {
    opacity: 1;
}

/* Spin animation */
.roulette-wheel.spinning {
    animation: wheelSpin 3s cubic-bezier(0.17, 0.67, 0.12, 0.99) forwards;
}

@keyframes wheelSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(var(--spin-degrees, 1800deg)); }
}

/* Glow effect during spin */
.wheel-wrapper.spinning .roulette-wheel {
    box-shadow:
        0 0 0 6px #2d333b,
        0 0 0 8px rgba(247, 147, 26, 0.5),
        0 0 60px rgba(247, 147, 26, 0.2),
        inset 0 0 30px rgba(0, 0, 0, 0.5);
}

/* Result display below wheel */
.wheel-result {
    text-align: center;
    height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.wheel-result-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.4s ease;
}

.wheel-result-number.show {
    opacity: 1;
    transform: scale(1);
}

.wheel-result-number.red {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    box-shadow: 0 4px 16px rgba(220, 38, 38, 0.4);
}

.wheel-result-number.black {
    background: linear-gradient(135deg, #374151, #1f2937);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.wheel-result-number.green {
    background: linear-gradient(135deg, #16a34a, #15803d);
    box-shadow: 0 4px 16px rgba(22, 163, 74, 0.4);
}

.wheel-result-text {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.2;
    min-height: 1.32rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.wheel-result-text.show {
    opacity: 1;
}

.wheel-result-text.win {
    color: var(--success, #22c55e);
    text-shadow: 0 0 15px rgba(34, 197, 94, 0.5);
}

.wheel-result-text.lose {
    color: var(--text-secondary, #6b7280);
}

.wheel-result-text.big-win {
    color: #f7931a;
    text-shadow: 0 0 20px rgba(247, 147, 26, 0.5);
    animation: jackpot-glow 0.5s ease-in-out infinite alternate;
}

/* ========================================
   BETTING TABLE
   ======================================== */
.betting-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Chip selector */
.chip-selector {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

.chip-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.2);
    background: linear-gradient(135deg, #374151, #1f2937);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.chip-btn::before {
    content: '';
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    border: 2px dashed rgba(255, 255, 255, 0.15);
    pointer-events: none;
}

.chip-btn:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    filter: brightness(1.2);
}

.chip-btn.selected {
    border-color: #f7931a;
    box-shadow: 0 2px 12px rgba(247, 147, 26, 0.5), 0 4px 12px rgba(0, 0, 0, 0.4);
}

.chip-btn[data-value="1"] { background: linear-gradient(135deg, #6b7280, #4b5563); }
.chip-btn[data-value="10"] { background: linear-gradient(135deg, #2563eb, #1d4ed8); }
.chip-btn[data-value="100"] { background: linear-gradient(135deg, #16a34a, #15803d); }
.chip-btn[data-value="1000"] { background: linear-gradient(135deg, #dc2626, #b91c1c); }
.chip-btn[data-value="5000"] { background: linear-gradient(135deg, #7c3aed, #6d28d9); }

/* Betting table grid */
.betting-table {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

/* Number grid - top row is zero, then 3 columns x 12 rows */
.bt-zero {
    display: flex;
    justify-content: center;
}

.bt-numbers {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 2px;
}

.bt-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
    border-radius: 4px;
    min-height: 36px;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.bt-cell:hover {
    filter: brightness(1.3);
    z-index: 2;
}

.bt-cell:active {
    transform: scale(0.95);
}

.bt-cell.red {
    background: linear-gradient(180deg, #dc2626, #b91c1c);
}

.bt-cell.black {
    background: linear-gradient(180deg, #374151, #1f2937);
}

.bt-cell.green {
    background: linear-gradient(180deg, #16a34a, #15803d);
}

.bt-cell.zero-cell {
    grid-row: 1 / 4;
    writing-mode: vertical-lr;
    text-orientation: mixed;
    font-size: 1rem;
    min-width: 32px;
    background: linear-gradient(180deg, #16a34a, #15803d);
}

.bt-cell.zero-cell .chip-indicator {
    writing-mode: horizontal-tb;
}

/* Chip indicator on a bet cell */
.bt-cell .chip-indicator {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #f7931a;
    color: rgba(255, 255, 255, 0.92);
    font-size: 0.55rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    z-index: 5;
    pointer-events: none;
    border: 1.5px solid rgba(255, 255, 255, 0.3);
}

/* Winning number highlight */
.bt-cell.winning {
    animation: cellWin 1s ease-in-out 3;
    z-index: 3;
}

@keyframes cellWin {
    0%, 100% { box-shadow: none; }
    50% { box-shadow: 0 0 16px rgba(247, 147, 26, 0.8), inset 0 0 8px rgba(247, 147, 26, 0.3); }
}

/* Dolly marker — the translucent glass puck dealers place on the winning number */
.roulette-dolly {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.15) 60%, rgba(255, 255, 255, 0.05));
    border: 2px solid rgba(255, 255, 255, 0.7);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), inset 0 1px 2px rgba(255, 255, 255, 0.4);
    z-index: 5;
    pointer-events: none;
    animation: dollyDrop 0.35s ease-out;
}

@keyframes dollyDrop {
    0% { transform: scale(0.3) translateY(-12px); opacity: 0; }
    60% { transform: scale(1.1) translateY(0); opacity: 1; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

@media (max-width: 600px) {
    .roulette-dolly {
        width: 16px;
        height: 16px;
    }
}

@media (max-width: 400px) {
    .roulette-dolly {
        width: 14px;
        height: 14px;
        border-width: 1.5px;
    }
}

/* Outside bets row */
.bt-outside {
    display: grid;
    gap: 2px;
}

.bt-outside-halves {
    grid-template-columns: repeat(6, 1fr);
}

.bt-outside-thirds {
    grid-template-columns: repeat(3, 1fr);
}

.bt-outside-cols {
    grid-template-columns: repeat(3, 1fr);
}

.bt-outside-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
    border-radius: 4px;
    min-height: 32px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.bt-outside-cell:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(247, 147, 26, 0.3);
}

.bt-outside-cell:active {
    transform: scale(0.97);
}

.bt-outside-cell.red-bet {
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}

.bt-outside-cell.black-bet {
    color: #9ca3af;
    border-color: rgba(156, 163, 175, 0.3);
}

.bt-outside-cell .chip-indicator {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #f7931a;
    color: rgba(255, 255, 255, 0.92);
    font-size: 0.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    z-index: 5;
    pointer-events: none;
    border: 1.5px solid rgba(255, 255, 255, 0.3);
}

.bt-outside-cell.winning {
    animation: cellWin 1s ease-in-out 3;
}

/* ========================================
   CONTROLS
   ======================================== */
.roulette-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
}

.roulette-spin-btn {
    flex: 1;
    max-width: 400px;
    padding: 1rem 2rem;
    font-size: 1.25rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    background: linear-gradient(135deg, var(--primary, #f7931a) 0%, var(--primary-dark, #e8820a) 100%);
    color: rgba(255, 255, 255, 0.92);
    box-shadow:
        0 4px 20px rgba(247, 147, 26, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.roulette-spin-btn::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.roulette-spin-btn:hover::before {
    left: 100%;
}

.roulette-spin-btn:hover {
    transform: translateY(-2px);
    box-shadow:
        0 6px 30px rgba(247, 147, 26, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.roulette-spin-btn:active {
    transform: translateY(0);
}

.roulette-spin-btn:disabled {
    background: var(--bg-elevated, #21262d);
    color: var(--text-secondary, #6b7280);
    cursor: not-allowed;
    box-shadow: none;
}

.roulette-spin-btn:disabled::before {
    display: none;
}

.roulette-spin-btn.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Clear bets and undo buttons */
.btn-clear-bets,
.btn-undo-bet {
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-clear-bets:hover,
.btn-undo-bet:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.btn-clear-bets:disabled,
.btn-undo-bet:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Total bet display */
.total-bet-display {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-secondary, #6b7280);
    margin-top: 0.25rem;
}

.total-bet-display .total-amount {
    color: #f7931a;
    font-weight: 700;
}

/* ========================================
   RULES TEXT & BALANCE NOTE
   ======================================== */
.rules-text {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary, #6b7280);
    margin-bottom: 0.5rem;
    letter-spacing: 0.02em;
}

.balance-note {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary, #6b7280);
    margin: 0;
}

@media (max-width: 480px) {
    .rules-text {
        font-size: 0.65rem;
    }

    .balance-note {
        font-size: 0.65rem;
    }
}

/* Sound toggle: uses shared .sound-toggle from casino.css (bottom-right, absolute) */

/* ========================================
   RESPONSIVE
   ======================================== */

/* Sidebar hiding handled by shared rules in platform.css */

@media (max-width: 768px) {
    .roulette-container {
        padding: 1rem;
        border-radius: 16px;
    }

    .wheel-wrapper {
        width: 220px;
        height: 220px;
    }

    .wheel-number {
        width: 18px;
        height: 18px;
        font-size: 0.5rem;
    }

    .wheel-center {
        width: 44px;
        height: 44px;
    }

    .wheel-center-inner {
        width: 18px;
        height: 18px;
    }

    .chip-btn {
        width: 40px;
        height: 40px;
        font-size: 0.6rem;
    }

    .bt-cell {
        padding: 6px 2px;
        font-size: 0.7rem;
        min-height: 30px;
    }

    .bt-outside-cell {
        padding: 6px 2px;
        font-size: 0.65rem;
        min-height: 28px;
    }

    .roulette-spin-btn {
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .wheel-wrapper {
        width: 180px;
        height: 180px;
    }

    .wheel-number {
        width: 14px;
        height: 14px;
        font-size: 0.4rem;
    }

    .wheel-center {
        width: 36px;
        height: 36px;
    }

    .wheel-center-inner {
        width: 14px;
        height: 14px;
    }

    .chip-btn {
        width: 36px;
        height: 36px;
        font-size: 0.55rem;
        border-width: 2px;
    }

    .bt-cell {
        padding: 4px 1px;
        font-size: 0.6rem;
        min-height: 26px;
    }

    .bt-cell.zero-cell {
        font-size: 0.75rem;
        min-width: 24px;
    }

    .bt-outside-cell {
        padding: 4px 1px;
        font-size: 0.55rem;
        min-height: 24px;
    }

    .roulette-spin-btn {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }

    .btn-clear-bets,
    .btn-undo-bet {
        padding: 0.625rem 0.75rem;
        font-size: 0.7rem;
    }
}

/* ========== LANDSCAPE MODE - Roulette wheel sizing ========== */
/* Header/banner/ticker hiding handled by shared rules in platform.css */
@media (max-height: 500px) and (orientation: landscape) {
    .roulette-container { padding: 0.5rem; border-radius: 12px; }
    .wheel-wrapper { width: 140px; height: 140px; }
}

/* ========== iPhone Portrait - Compact wheel ========== */
@media (max-width: 480px) and (max-height: 740px) {
    .wheel-wrapper { width: 160px; height: 160px; }
    .wheel-number { width: 12px; height: 12px; font-size: 0.35rem; }
    .chip-btn { width: 32px; height: 32px; font-size: 0.5rem; }
}
