/**
 * 5 Lions Megaways - Game Styles
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --gold: #ffd700;
    --dark-gold: #b8860b;
    --red: #dc3545;
    --dark-red: #8b0000;
    --green: #28a745;
    --blue: #007bff;
    --purple: #6f42c1;
    --dark-bg: #1a1a2e;
    --darker-bg: #0f0f1a;
    --card-bg: #2d2d44;
    --text-light: #f8f9fa;
    --text-muted: #adb5bd;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--darker-bg) 0%, var(--dark-bg) 100%);
    color: var(--text-light);
    min-height: 100vh;
}

.game-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.game-header {
    text-align: center;
    margin-bottom: 20px;
}

.game-header h1 {
    font-size: 2.5rem;
    color: var(--gold);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    margin-bottom: 10px;
}

.header-info {
    display: flex;
    justify-content: center;
    gap: 30px;
    font-size: 1.1rem;
}

.ways-display {
    color: var(--gold);
    font-weight: bold;
}

.rtp-display {
    color: var(--text-muted);
}

/* Reel Container - Fixed dimensions for Megaways */
.reel-container {
    position: relative;
    background: linear-gradient(180deg, #2a1f5e 0%, #1a1040 100%);
    border: 4px solid var(--gold);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
}

.reels {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    height: 480px; /* Fixed height for all reels */
}

.reel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    height: 100%; /* Fill fixed container height */
    min-width: 80px;
    max-width: 140px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 6px;
    overflow: hidden; /* Contain symbols within fixed bounds */
}

/* Symbol Cells - Dynamic scaling within fixed reel height */
.symbol-cell {
    width: 100%;
    flex: 1; /* Equal distribution within reel */
    min-height: 0; /* Allow shrinking below content size */
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border-radius: 8px;
    position: relative;
    /* Use transform for animations to avoid layout shifts */
    transform-origin: center center;
    will-change: transform, opacity;
    /* Smooth transitions for size changes */
    transition: transform 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
}

/* Dynamic font sizing based on symbol count (set via CSS custom property) */
.symbol-cell .symbol-content {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: var(--symbol-font-size, 1.8rem);
}

/* Symbol images - scale to fit cell */
.symbol-cell .symbol-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
}

/* Symbol Colors */
.symbol-H1 {
    background: linear-gradient(135deg, #ffd700 0%, #ff8c00 100%);
    color: #8b0000;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.symbol-H2 {
    background: linear-gradient(135deg, #ff4500 0%, #dc143c 100%);
    color: #fff;
    box-shadow: 0 0 10px rgba(255, 69, 0, 0.5);
}

.symbol-H3 {
    background: linear-gradient(135deg, #32cd32 0%, #228b22 100%);
    color: #fff;
}

.symbol-H4 {
    background: linear-gradient(135deg, #1e90ff 0%, #0066cc 100%);
    color: #fff;
}

.symbol-H5 {
    background: linear-gradient(135deg, #8b4513 0%, #654321 100%);
    color: #ffd700;
}

.symbol-L1 {
    background: linear-gradient(135deg, #9932cc 0%, #6b238e 100%);
    color: #fff;
}

.symbol-L2 {
    background: linear-gradient(135deg, #4169e1 0%, #27408b 100%);
    color: #fff;
}

.symbol-L3 {
    background: linear-gradient(135deg, #20b2aa 0%, #008080 100%);
    color: #fff;
}

.symbol-L4 {
    background: linear-gradient(135deg, #cd853f 0%, #8b5a2b 100%);
    color: #fff;
}

.symbol-L5 {
    background: linear-gradient(135deg, #708090 0%, #4a5568 100%);
    color: #fff;
}

.symbol-L6 {
    background: linear-gradient(135deg, #696969 0%, #404040 100%);
    color: #fff;
}

.symbol-WILD {
    background: linear-gradient(135deg, #ffd700 0%, #ff6347 50%, #ffd700 100%);
    color: #8b0000;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.8);
    animation: wildPulse 1s infinite;
}

.symbol-SCATTER {
    background: linear-gradient(135deg, #fff 0%, #e0e0e0 50%, #fff 100%);
    color: #000;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.8);
}

.symbol-COIN {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4a 50%, #ffd700 100%);
    color: #8b4513;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.8);
}

/* Win animations - Transform-based for smooth, layout-stable effects */
@keyframes wildPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

@keyframes winPulse {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    }
    50% { 
        transform: scale(1.08);
        box-shadow: 0 0 20px rgba(255, 215, 0, 1);
    }
}

@keyframes fadeOut {
    0% { 
        opacity: 1; 
        transform: scale(1); 
    }
    100% { 
        opacity: 0; 
        transform: scale(0.3) translateY(-20px); 
    }
}

@keyframes dropIn {
    0% { 
        opacity: 0; 
        transform: translateY(-100%) scale(0.8); 
    }
    60% {
        opacity: 1;
        transform: translateY(5%) scale(1.02);
    }
    100% { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
    }
}

@keyframes symbolAppear {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.symbol-cell.winning {
    animation: winPulse 0.4s ease-in-out 3;
    z-index: 10;
}

.symbol-cell.removing {
    animation: fadeOut 0.25s ease forwards;
    pointer-events: none;
}

.symbol-cell.dropping {
    animation: dropIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.symbol-cell.appearing {
    animation: symbolAppear 0.3s ease forwards;
}

/* Win Overlay */
.win-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    z-index: 100;
}

.win-overlay.active {
    display: block;
}

.win-amount {
    font-size: 4rem;
    font-weight: bold;
    color: var(--gold);
    text-shadow: 
        0 0 10px var(--gold),
        0 0 20px var(--gold),
        0 0 40px var(--dark-gold);
    animation: winPulse 0.5s ease-in-out infinite;
}

/* Tumble Info */
.tumble-info {
    display: flex;
    justify-content: center;
    gap: 40px;
    padding: 10px;
    background: var(--card-bg);
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.tumble-info span {
    color: var(--text-muted);
}

.tumble-info span span {
    color: var(--gold);
    font-weight: bold;
}

/* Free Spins Display */
.free-spins-display {
    background: linear-gradient(135deg, var(--purple) 0%, #4a148c 100%);
    border: 3px solid var(--gold);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    text-align: center;
}

.fs-header {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--gold);
    margin-bottom: 10px;
}

.fs-info {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 10px;
}

.fs-level {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 10px;
    color: var(--gold);
}

.fs-multipliers {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.fs-multipliers span {
    color: var(--gold);
}

/* Controls */
.game-controls {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 20px;
    align-items: center;
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
}

.info-panel {
    display: flex;
    gap: 20px;
}

.info-item {
    text-align: center;
}

.info-item label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.info-item span {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--gold);
}

.win-display span {
    color: var(--green);
}

/* Bet Controls */
.bet-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.bet-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bet-group label {
    color: var(--text-muted);
}

.bet-adjuster {
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-adjust {
    width: 35px;
    height: 35px;
    border: none;
    border-radius: 5px;
    background: var(--dark-gold);
    color: #000;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-adjust:hover {
    background: var(--gold);
}

#betAmount {
    width: 80px;
    height: 35px;
    text-align: center;
    border: 2px solid var(--gold);
    border-radius: 5px;
    background: var(--darker-bg);
    color: var(--gold);
    font-size: 1.1rem;
    font-weight: bold;
}

.ante-toggle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.ante-toggle label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-light);
}

.ante-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--gold);
}

.ante-info {
    font-size: 0.8rem;
    color: var(--green);
}

/* Spin Button */
.spin-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.spin-button {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 4px solid var(--gold);
    background: linear-gradient(135deg, var(--red) 0%, var(--dark-red) 100%);
    color: var(--text-light);
    font-size: 1.3rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 20px rgba(220, 53, 69, 0.5);
}

.spin-button:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 8px 30px rgba(220, 53, 69, 0.7);
}

.spin-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.spin-button.fs-spin {
    background: linear-gradient(135deg, var(--purple) 0%, #4a148c 100%);
    box-shadow: 0 5px 20px rgba(111, 66, 193, 0.5);
}

.spin-button.fs-spin:hover:not(:disabled) {
    box-shadow: 0 8px 30px rgba(111, 66, 193, 0.7);
}

.spin-button.spinning {
    animation: spinPulse 0.5s ease infinite;
}

@keyframes spinPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(0.95); }
}

/* Auto Spin Controls */
.auto-spin-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 10px;
}

.auto-spin-button {
    padding: 8px 20px;
    border: 2px solid var(--gold);
    border-radius: 20px;
    background: var(--darker-bg);
    color: var(--gold);
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.auto-spin-button:hover:not(:disabled) {
    background: var(--gold);
    color: #000;
}

.auto-spin-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.auto-spin-button.active {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
    animation: autoPulse 1.5s ease-in-out infinite;
}

@keyframes autoPulse {
    0%, 100% { box-shadow: 0 0 5px rgba(40, 167, 69, 0.5); }
    50% { box-shadow: 0 0 15px rgba(40, 167, 69, 0.8); }
}

.auto-spin-select {
    padding: 8px 12px;
    border: 2px solid var(--gold);
    border-radius: 8px;
    background: var(--darker-bg);
    color: var(--gold);
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
}

.auto-spin-select:focus {
    outline: none;
    border-color: var(--text-light);
}

.auto-spin-status {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    padding: 8px 15px;
    background: rgba(40, 167, 69, 0.2);
    border: 1px solid var(--green);
    border-radius: 8px;
    font-size: 0.9rem;
}

.auto-spin-status span {
    color: var(--green);
}

.stop-auto-btn {
    padding: 5px 15px;
    border: 2px solid var(--red);
    border-radius: 15px;
    background: var(--red);
    color: #fff;
    font-size: 0.8rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.stop-auto-btn:hover {
    background: #ff4444;
    border-color: #ff4444;
}

.auto-spin-settings {
    display: flex;
    gap: 15px;
    margin-top: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.auto-setting {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
}

.auto-setting input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--gold);
}

.auto-setting:hover {
    color: var(--text-light);
}

/* Buy Features */
.buy-features {
    text-align: right;
}

.buy-features h3 {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.buy-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.buy-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 15px;
    border: 2px solid var(--gold);
    border-radius: 8px;
    background: var(--darker-bg);
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s;
}

.buy-btn:hover:not(:disabled) {
    background: var(--dark-gold);
    color: #000;
}

.buy-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.buy-btn .buy-name {
    font-size: 0.85rem;
}

.buy-btn .buy-cost {
    font-size: 1rem;
    font-weight: bold;
    color: var(--gold);
}

.buy-btn:hover .buy-cost {
    color: #000;
}

.buy-btn.mystery {
    border-color: var(--purple);
}

.buy-btn.mystery .buy-cost {
    color: var(--purple);
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--card-bg);
    border: 3px solid var(--gold);
    border-radius: 15px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    text-align: center;
}

.modal-content h2 {
    color: var(--gold);
    margin-bottom: 10px;
}

#modalMode {
    color: var(--purple);
    font-size: 1.2rem;
    margin-bottom: 20px;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.option-btn {
    padding: 15px 10px;
    border: 2px solid var(--gold);
    border-radius: 8px;
    background: var(--darker-bg);
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s;
}

.option-btn:hover {
    background: var(--dark-gold);
    color: #000;
}

.option-btn .spins {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--gold);
    display: block;
}

.option-btn .multipliers {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
    margin-top: 5px;
}

.option-btn:hover .spins,
.option-btn:hover .multipliers {
    color: #000;
}

.option-btn.mystery {
    grid-column: span 4;
    background: linear-gradient(135deg, var(--purple) 0%, #4a148c 100%);
    border-color: var(--purple);
}

/* Bottom Navigation */
.bottom-nav {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 15px;
    margin-top: 20px;
}

.paytable-toggle,
.history-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--card-bg) 0%, #1a1a2e 100%);
    color: var(--gold);
    text-decoration: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    border: 2px solid var(--gold);
    transition: all 0.3s ease;
    cursor: pointer;
}

.paytable-toggle:hover,
.history-link:hover {
    background: linear-gradient(135deg, var(--gold) 0%, var(--dark-gold) 100%);
    color: var(--dark-bg);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.4);
}

.paytable-toggle:active,
.history-link:active {
    transform: translateY(0);
}

.paytable-content {
    max-height: 80vh;
    overflow-y: auto;
    text-align: left;
}

.paytable-content h2 {
    margin-bottom: 20px;
}

.paytable-bet {
    font-size: 0.8em;
    color: var(--green);
    font-weight: normal;
}

.paytable-bet span {
    color: var(--gold);
    font-weight: bold;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    width: 35px;
    height: 35px;
    border: none;
    border-radius: 50%;
    background: var(--red);
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.paytable-section {
    margin-bottom: 25px;
}

.paytable-section h3 {
    color: var(--gold);
    margin-bottom: 15px;
    border-bottom: 1px solid var(--gold);
    padding-bottom: 5px;
}

.paytable-table {
    width: 100%;
    border-collapse: collapse;
}

/* Payout value cells */
.paytable-table td.pay-6,
.paytable-table td.pay-5,
.paytable-table td.pay-4,
.paytable-table td.pay-3 {
    font-weight: bold;
    color: var(--gold);
}

.paytable-table td.pay-6 {
    color: #ffd700;
}

.paytable-table td.pay-5 {
    color: #ffed4a;
}

.paytable-table td.pay-4 {
    color: #f0e68c;
}

.paytable-table td.pay-3 {
    color: #daa520;
}

/* Scatter table highlight */
.scatter-table td.pay-6 {
    color: #00ff00;
    font-size: 1.1em;
}

.paytable-table th,
.paytable-table td {
    padding: 10px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.paytable-table th {
    color: var(--gold);
}

.paytable-table td:first-child {
    text-align: left;
}

.symbol-icon {
    display: inline-block;
    width: 30px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    border-radius: 5px;
    margin-right: 10px;
    font-size: 1rem;
}

.special-symbols {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.special-item {
    display: flex;
    align-items: flex-start;
    gap: 15px;
}

.special-item .symbol-icon {
    width: 50px;
    height: 50px;
    line-height: 50px;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.special-item p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 5px;
}

/* Responsive */
@media (max-width: 768px) {
    .game-header h1 {
        font-size: 1.8rem;
    }
    
    .game-controls {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .info-panel {
        justify-content: center;
    }
    
    .buy-buttons {
        justify-content: center;
    }
    
    .spin-button {
        width: 100px;
        height: 100px;
        font-size: 1.1rem;
    }
    
    .reels {
        height: 360px; /* Smaller fixed height on mobile */
    }
    
    .reel {
        min-width: 50px;
        max-width: 100px;
        padding: 4px;
        gap: 3px;
    }
    
    .options-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .option-btn.mystery {
        grid-column: span 2;
    }
}

@media (max-width: 480px) {
    .reels {
        height: 300px;
        gap: 4px;
    }
    
    .reel {
        min-width: 40px;
        padding: 3px;
        gap: 2px;
    }
    
    .reel-container {
        padding: 10px;
    }
}
