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

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --bg-card-light: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border: #334155;
    --shadow: rgba(0, 0, 0, 0.3);
    --heads-color: #f59e0b;
    --tails-color: #06b6d4;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 30px;
    animation: fadeInDown 0.6s ease;
}

header h1 {
    font-size: 3rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.main-content {
    display: grid;
    grid-template-columns: 300px 1fr 300px;
    gap: 20px;
    animation: fadeIn 0.8s ease;
}

@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

.left-panel, .right-panel, .center-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.balance-card, .stats-card, .probability-card, .history-card, .info-card, .actions-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 6px var(--shadow);
    border: 1px solid var(--border);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.balance-card:hover, .stats-card:hover, .probability-card:hover, .info-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 12px var(--shadow);
}

.balance-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.balance-amount {
    font-size: 2.5rem;
    font-weight: bold;
    background: linear-gradient(135deg, var(--success) 0%, #34d399 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stats-card h3, .probability-card h3, .history-card h3, .info-card h3 {
    margin-bottom: 16px;
    font-size: 1.2rem;
    color: var(--text-primary);
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.stat-item {
    text-align: center;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary);
}

.probability-item {
    margin-bottom: 16px;
}

.probability-item:last-child {
    margin-bottom: 0;
}

.probability-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.probability-bar {
    height: 20px;
    background: var(--bg-card-light);
    border-radius: 10px;
    overflow: hidden;
}

.probability-fill {
    height: 100%;
    transition: width 0.5s ease;
}

.probability-fill.heads {
    background: linear-gradient(90deg, var(--heads-color), #fbbf24);
}

.probability-fill.tails {
    background: linear-gradient(90deg, var(--tails-color), #22d3ee);
}

.history-list {
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-card-light);
    border-radius: 8px;
    margin-bottom: 8px;
    animation: slideInRight 0.3s ease;
}

.history-item:last-child {
    margin-bottom: 0;
}

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

.history-result.heads {
    color: var(--heads-color);
}

.history-result.tails {
    color: var(--tails-color);
}

.history-result.win {
    color: var(--success);
}

.history-result.lose {
    color: var(--danger);
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 20px;
}

.rules-list {
    list-style: none;
    color: var(--text-secondary);
}

.rules-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.rules-list li:last-child {
    border-bottom: none;
}

.info-text {
    color: var(--text-secondary);
    line-height: 1.6;
}

.coin-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 400px;
    perspective: 1000px;
}

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

.coin-face {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    font-weight: bold;
    backface-visibility: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.coin-heads {
    background: linear-gradient(135deg, var(--heads-color), #fbbf24);
    color: white;
    transform: rotateY(0deg);
}

.coin-tails {
    background: linear-gradient(135deg, var(--tails-color), #22d3ee);
    color: white;
    transform: rotateY(180deg);
}

.coin.flip-heads {
    animation: flipHeads 1.5s ease-in-out forwards;
}

.coin.flip-tails {
    animation: flipTails 1.5s ease-in-out forwards;
}

@keyframes flipHeads {
    0% { transform: rotateY(0deg) rotateX(0deg); }
    100% { transform: rotateY(1800deg) rotateX(360deg); }
}

@keyframes flipTails {
    0% { transform: rotateY(0deg) rotateX(0deg); }
    100% { transform: rotateY(1980deg) rotateX(360deg); }
}

.result-display {
    text-align: center;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 20px;
}

.result-display.show {
    animation: bounceIn 0.6s ease;
}

.result-display.win {
    color: var(--success);
}

.result-display.lose {
    color: var(--danger);
}

.controls {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 6px var(--shadow);
    border: 1px solid var(--border);
}

.mode-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.mode-btn {
    padding: 12px 20px;
    border: 2px solid var(--border);
    background: var(--bg-card-light);
    color: var(--text-primary);
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.mode-btn:hover {
    background: var(--bg-card);
    border-color: var(--primary);
}

.mode-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-color: var(--primary);
    color: white;
}

.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.input-group input {
    width: 100%;
    padding: 12px;
    background: var(--bg-card-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.input-hint {
    display: block;
    margin-top: 4px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.action-btn {
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.action-btn.primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.action-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(99, 102, 241, 0.4);
}

.action-btn.secondary {
    background: var(--bg-card-light);
    color: var(--text-primary);
    border: 1px solid var(--border);
    margin-bottom: 12px;
}

.action-btn.secondary:hover {
    background: var(--bg-card);
    border-color: var(--primary);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.choice-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 16px;
}

.choice-btn {
    padding: 20px;
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: var(--bg-card-light);
    color: var(--text-primary);
}

.choice-btn:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px var(--shadow);
}

.choice-btn.heads-btn {
    border-color: var(--heads-color);
}

.choice-btn.heads-btn:hover {
    background: var(--heads-color);
    color: white;
}

.choice-btn.tails-btn {
    border-color: var(--tails-color);
}

.choice-btn.tails-btn:hover {
    background: var(--tails-color);
    color: white;
}

.choice-icon {
    font-size: 2rem;
}

.continuous-progress {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 6px var(--shadow);
    border: 1px solid var(--border);
    margin-top: 20px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 1rem;
    color: var(--text-secondary);
}

.progress-bar {
    height: 30px;
    background: var(--bg-card-light);
    border-radius: 15px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transition: width 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.disclaimer {
    text-align: center;
    margin-top: 30px;
    padding: 20px;
    background: var(--bg-card);
    border-radius: 16px;
    color: var(--warning);
    font-size: 1.1rem;
    border: 2px solid var(--warning);
    animation: fadeIn 1s ease;
}

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

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

@keyframes bounceIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.history-list::-webkit-scrollbar {
    width: 8px;
}

.history-list::-webkit-scrollbar-track {
    background: var(--bg-card-light);
    border-radius: 4px;
}

.history-list::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    opacity: 1;
}
