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

:root {
    --casino-green: #0a4d2e;
    --casino-dark: #0a1e1a;
    --casino-gold: #d4af37;
    --casino-light-gold: #f4d03f;
    --casino-red: #c41e3a;
    --text-light: #f0f0f0;
    --text-dark: #1a1a1a;
    --shadow: rgba(0, 0, 0, 0.5);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--casino-dark) 0%, var(--casino-green) 100%);
    color: var(--text-light);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Card Decorations */
.card-decoration {
    position: fixed;
    font-size: 8rem;
    opacity: 0.05;
    z-index: 0;
    pointer-events: none;
    animation: floatCard 20s infinite ease-in-out;
}

.card-1 { top: 10%; left: 5%; color: var(--text-light); animation-delay: 0s; }
.card-2 { top: 20%; right: 10%; color: var(--casino-red); animation-delay: 2s; }
.card-3 { bottom: 15%; left: 15%; color: var(--casino-red); animation-delay: 4s; }
.card-4 { top: 60%; right: 5%; color: var(--text-light); animation-delay: 6s; }
.card-5 { bottom: 30%; right: 20%; color: var(--text-light); animation-delay: 8s; }
.card-6 { top: 40%; left: 10%; color: var(--casino-red); animation-delay: 10s; }

@keyframes floatCard {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-30px) rotate(5deg); }
}

.app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

/* Header */
.header {
    background: rgba(10, 30, 26, 0.95);
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid var(--casino-gold);
    box-shadow: 0 4px 20px var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.logo {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--casino-gold);
    text-shadow: 2px 2px 4px var(--shadow);
    animation: glow 2s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% { text-shadow: 2px 2px 4px var(--shadow), 0 0 10px rgba(212, 175, 55, 0.3); }
    50% { text-shadow: 2px 2px 4px var(--shadow), 0 0 20px rgba(212, 175, 55, 0.6); }
}

.timer {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--casino-light-gold);
    font-family: 'Courier New', monospace;
    padding: 0.5rem 1rem;
    background: rgba(212, 175, 55, 0.1);
    border-radius: 8px;
    border: 2px solid var(--casino-gold);
}

.casino-bank {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    background: rgba(212, 175, 55, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 2px solid var(--casino-gold);
    transition: all 0.3s;
}

.casino-bank:hover {
    background: rgba(212, 175, 55, 0.2);
    transform: scale(1.05);
}

.bank-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--casino-light-gold);
    letter-spacing: 1px;
}

.bank-amount {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--casino-gold);
    transition: all 0.3s;
}

.bank-amount::before {
    content: '💰 ';
}

/* Screens */
.screen {
    display: none;
    flex: 1;
    padding: 2rem;
}

.screen.active {
    display: block;
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Setup Screen */
.setup-container {
    max-width: 500px;
    margin: 0 auto;
    background: rgba(10, 30, 26, 0.95);
    padding: 2.5rem;
    border-radius: 16px;
    box-shadow: 0 8px 32px var(--shadow);
    border: 2px solid var(--casino-gold);
    animation: slideIn 0.5s ease-out;
}

@keyframes slideIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.setup-container h2 {
    text-align: center;
    color: var(--casino-gold);
    margin-bottom: 2rem;
    font-size: 2rem;
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--casino-light-gold);
    font-weight: 600;
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--casino-gold);
    border-radius: 8px;
    background: rgba(212, 175, 55, 0.1);
    color: var(--text-light);
    font-size: 1rem;
    transition: all 0.3s;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--casino-light-gold);
    background: rgba(212, 175, 55, 0.2);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.3);
}

.player-name-input {
    margin-bottom: 0.5rem;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-transaction,
.btn-win,
.btn-lose,
.btn-blackjack {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--casino-gold), var(--casino-light-gold));
    color: var(--text-dark);
    width: 100%;
    margin-top: 1rem;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.6);
}

.btn-primary:active {
    transform: translateY(0);
    animation: pulse 0.3s ease-in-out;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(0.95); }
}

.btn-secondary {
    background: rgba(212, 175, 55, 0.2);
    color: var(--casino-gold);
    border: 2px solid var(--casino-gold);
    margin-top: 0.5rem;
    width: 100%;
}

.btn-secondary:hover {
    background: rgba(212, 175, 55, 0.3);
    transform: scale(1.02);
}

/* Ranking Banner */
.ranking-banner {
    background: rgba(10, 30, 26, 0.95);
    border: 2px solid var(--casino-gold);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 4px 15px var(--shadow);
    animation: slideDown 0.5s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.rank-item {
    text-align: center;
    padding: 0.5rem 1rem;
}

.rank-position {
    font-size: 2rem;
    margin-bottom: 0.25rem;
}

.rank-name {
    color: var(--casino-light-gold);
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.rank-chips {
    color: var(--casino-gold);
    font-weight: bold;
    font-size: 1.1rem;
}

/* Game Screen */
.players-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.player-card {
    background: rgba(10, 30, 26, 0.95);
    border: 2px solid var(--casino-gold);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 8px 32px var(--shadow);
    transition: all 0.3s;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    animation: cardAppear 0.5s ease-out backwards;
}

@keyframes cardAppear {
    from { opacity: 0; transform: scale(0.8) rotateY(90deg); }
    to { opacity: 1; transform: scale(1) rotateY(0); }
}

.player-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(212, 175, 55, 0.1), transparent);
    transform: rotate(45deg);
    animation: shine 3s infinite;
}

@keyframes shine {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

.player-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 12px 40px rgba(212, 175, 55, 0.4);
    border-color: var(--casino-light-gold);
}

.player-name {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--casino-gold);
    margin-bottom: 1rem;
    text-align: center;
    position: relative;
    z-index: 1;
}

.player-chips {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--text-light);
    text-align: center;
    margin: 1rem 0;
    position: relative;
    z-index: 1;
    animation: chipPulse 2s ease-in-out infinite;
}

@keyframes chipPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.player-chips::before {
    content: '🎲 ';
    font-size: 2rem;
}

.player-stats {
    display: flex;
    justify-content: space-around;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(212, 175, 55, 0.3);
    position: relative;
    z-index: 1;
}

.stat {
    text-align: center;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--casino-light-gold);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: bold;
    margin-top: 0.25rem;
}

.stat-value.positive {
    color: #4caf50;
    animation: flash 1s ease-in-out;
}

.stat-value.negative {
    color: var(--casino-red);
}

@keyframes flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Actions Bar */
.actions-bar {
    display: flex;
    gap: 1rem;
    position: sticky;
    bottom: 0;
    background: rgba(10, 30, 26, 0.95);
    padding: 1rem;
    border-top: 2px solid var(--casino-gold);
    box-shadow: 0 -4px 20px var(--shadow);
    backdrop-filter: blur(10px);
}

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

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFade 0.3s ease-out;
}

@keyframes modalFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--casino-dark);
    border: 3px solid var(--casino-gold);
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px var(--shadow);
    animation: modalSlide 0.3s ease-out;
}

.modal-large {
    max-width: 900px;
}

@keyframes modalSlide {
    from { transform: translateY(-50px) scale(0.9); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 2px solid var(--casino-gold);
    background: rgba(212, 175, 55, 0.05);
}

.modal-header h2 {
    color: var(--casino-gold);
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    color: var(--casino-gold);
    font-size: 2rem;
    cursor: pointer;
    transition: all 0.3s;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: var(--casino-light-gold);
    transform: rotate(90deg) scale(1.2);
}

.modal-body {
    padding: 1.5rem;
}

/* Transaction Modal */
.transaction-type {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.btn-transaction {
    flex: 1;
    min-width: 80px;
    background: rgba(212, 175, 55, 0.1);
    color: var(--casino-gold);
    border: 2px solid var(--casino-gold);
    padding: 0.75rem;
}

.btn-transaction.active {
    background: var(--casino-gold);
    color: var(--text-dark);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.5);
}

/* Bet Mode */
.bet-mode, .transfer-mode {
    margin-bottom: 1rem;
}

.bet-info, .transfer-info {
    text-align: center;
    color: var(--casino-light-gold);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.quick-bet-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.quick-bet-btn {
    padding: 0.75rem;
    border: 2px solid var(--casino-gold);
    background: rgba(212, 175, 55, 0.1);
    color: var(--casino-gold);
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.quick-bet-btn:hover {
    background: var(--casino-gold);
    color: var(--text-dark);
    transform: scale(1.05);
}

.current-bet {
    text-align: center;
    padding: 1rem;
    background: rgba(76, 175, 80, 0.2);
    border: 2px solid #4caf50;
    border-radius: 8px;
    margin: 1rem 0;
    font-size: 1.2rem;
    color: #4caf50;
}

.bet-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.btn-win, .btn-lose, .btn-blackjack {
    flex: 1;
    padding: 1rem;
}

.btn-win {
    background: linear-gradient(135deg, #4caf50, #66bb6a);
    color: white;
    border: 2px solid #4caf50;
}

.btn-lose {
    background: linear-gradient(135deg, var(--casino-red), #d32f2f);
    color: white;
    border: 2px solid var(--casino-red);
}

.btn-blackjack {
    background: linear-gradient(135deg, var(--casino-gold), var(--casino-light-gold));
    color: var(--text-dark);
    border: 2px solid var(--casino-gold);
}

.btn-win:hover, .btn-lose:hover, .btn-blackjack:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

/* Transfer Mode */
.transfer-select {
    margin-bottom: 1rem;
}

/* Chip Buttons */
.chip-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.chip-btn {
    aspect-ratio: 1;
    border: 3px solid var(--casino-gold);
    border-radius: 50%;
    background: linear-gradient(135deg, var(--casino-gold), var(--casino-light-gold));
    color: var(--text-dark);
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.4);
}

.chip-btn:hover {
    transform: scale(1.15) rotate(15deg);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.6);
}

.chip-btn:active {
    transform: scale(0.95);
    animation: chipClick 0.3s ease-in-out;
}

@keyframes chipClick {
    0%, 100% { transform: scale(0.95); }
    50% { transform: scale(1.1); }
}

.custom-amount {
    margin-bottom: 1rem;
}

.transaction-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(212, 175, 55, 0.1);
    border: 2px solid var(--casino-gold);
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 1.5rem;
    font-weight: bold;
}

/* History */
.history-item {
    background: rgba(212, 175, 55, 0.1);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    border-left: 4px solid var(--casino-gold);
    transition: all 0.3s;
    animation: historySlide 0.3s ease-out;
}

@keyframes historySlide {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

.history-item:hover {
    background: rgba(212, 175, 55, 0.2);
    transform: translateX(5px);
}

.history-time {
    font-size: 0.75rem;
    color: var(--casino-light-gold);
    margin-bottom: 0.5rem;
}

.history-text {
    color: var(--text-light);
}

.history-amount {
    font-weight: bold;
}

.history-amount.positive {
    color: #4caf50;
}

.history-amount.negative {
    color: var(--casino-red);
}

/* Game History */
.game-history-preview {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid rgba(212, 175, 55, 0.3);
}

.game-history-item {
    background: rgba(212, 175, 55, 0.1);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    border-left: 4px solid var(--casino-gold);
    cursor: pointer;
    transition: all 0.3s;
}

.game-history-item:hover {
    background: rgba(212, 175, 55, 0.2);
    transform: translateX(5px);
}

.game-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.game-date {
    color: var(--casino-light-gold);
    font-size: 0.9rem;
}

.game-duration {
    color: var(--casino-gold);
    font-weight: bold;
}

.game-players {
    font-size: 0.85rem;
    color: var(--text-light);
}

.game-winner {
    font-size: 0.9rem;
    color: #4caf50;
    font-weight: bold;
    margin-top: 0.25rem;
}

.delete-game-btn {
    background: var(--casino-red);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 0.5rem;
}

.delete-game-btn:hover {
    background: #d32f2f;
    transform: scale(1.05);
}

/* Chart */
#fortuneChart {
    max-height: 400px;
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 1rem;
    }

    .header-left, .header-right {
        flex-direction: column;
        gap: 0.5rem;
    }

    .logo {
        font-size: 1.5rem;
    }

    .players-grid {
        grid-template-columns: 1fr;
    }

    .chip-buttons {
        grid-template-columns: repeat(2, 1fr);
    }

    .actions-bar {
        flex-direction: column;
    }

    .transaction-type {
        flex-direction: column;
    }

    .bet-actions {
        flex-direction: column;
    }

    .ranking-banner {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--casino-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--casino-gold);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--casino-light-gold);
}
