* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #121212;
    color: #ffffff;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
}

.header {
    text-align: center;
    margin-bottom: 40px;
}

.header h1 {
    font-size: 3rem;
    font-weight: 400;
    color: #bb86fc;
    margin-bottom: 8px;
    letter-spacing: -1px;
}

.header p {
    font-size: 1.1rem;
    color: #b3b3b3;
    font-weight: 300;
}

.game-area {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 40px;
    align-items: start;
}

.main-section {
    background: #1e1e1e;
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.deck {
    width: 140px;
    height: 200px;
    cursor: pointer;
    perspective: 1000px;
    margin: 0 auto;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.deck:hover {
    transform: translateY(-4px);
}

.card-container {
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-container.flipped {
    transform: rotateY(180deg);
}

.card-back, .card-front {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    backface-visibility: hidden;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.card-back {
    background: linear-gradient(135deg, #3700b3, #6200ea);
    color: white;
    font-size: 3.5rem;
    border: 2px solid rgba(255,255,255,0.1);
}

.card-front {
    background: #ffffff;
    color: #000000;
    flex-direction: column;
    transform: rotateY(180deg);
    border: 2px solid #e0e0e0;
}

.card-value {
    font-size: 3rem;
    font-weight: 500;
    margin-bottom: 8px;
}

.card-suit {
    font-size: 2rem;
}

.effect-section {
    margin: 32px 0;
    text-align: center;
}

.effect-box {
    background: #2d2d2d;
    border-radius: 12px;
    padding: 24px;
    border-left: 4px solid #03dac6;
    margin-bottom: 24px;
}

.effect-title {
    font-size: 1.3rem;
    font-weight: 500;
    color: #03dac6;
    margin-bottom: 8px;
}

.effect-text {
    font-size: 1rem;
    color: #b3b3b3;
    line-height: 1.4;
}

.controls {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-bottom: 24px;
}

.btn {
    background: #bb86fc;
    color: #000000;
    border: none;
    padding: 16px 32px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 120px;
}

.btn:hover {
    background: #d0bcff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(187, 134, 252, 0.3);
}

.btn:active {
    transform: translateY(0);
}

.btn-secondary {
    background: #03dac6;
    color: #000000;
}

.btn-secondary:hover {
    background: #66fff9;
    box-shadow: 0 4px 12px rgba(3, 218, 198, 0.3);
}

.stats {
    background: #262626;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

.stat-item {
    margin: 8px 0;
    font-size: 1rem;
    color: #e0e0e0;
}

.stat-number {
    color: #03dac6;
    font-weight: 500;
}

.history {
    background: #1e1e1e;
    border-radius: 16px;
    padding: 24px;
    width: 280px;
}

.history h3 {
    color: #bb86fc;
    margin-bottom: 16px;
    font-size: 1.2rem;
    font-weight: 500;
}

.history-item {
    background: #2d2d2d;
    border-radius: 6px;
    padding: 12px;
    margin: 8px 0;
    text-align: center;
    color: #e0e0e0;
    font-family: monospace;
    font-size: 1.1rem;
}

/* Settings Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: #1e1e1e;
    margin: 2% auto;
    padding: 32px;
    border-radius: 16px;
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 16px 64px rgba(0,0,0,0.5);
    border: 1px solid #333;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 1px solid #333;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 500;
    color: #bb86fc;
}

.close {
    background: none;
    border: none;
    color: #b3b3b3;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.close:hover {
    background: #333;
    color: #fff;
}

.settings-section {
    margin-bottom: 32px;
}

.settings-section h3 {
    color: #03dac6;
    margin-bottom: 16px;
    font-size: 1.2rem;
    font-weight: 500;
}

.setting-item {
    background: #2d2d2d;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.setting-label {
    flex: 1;
}

.setting-label strong {
    color: #e0e0e0;
    display: block;
    margin-bottom: 4px;
}

.setting-label span {
    color: #b3b3b3;
    font-size: 0.9rem;
}

.setting-control {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toggle {
    position: relative;
    width: 48px;
    height: 24px;
    background: #666;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.toggle.active {
    background: #bb86fc;
}

.toggle::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    top: 2px;
    left: 2px;
    transition: transform 0.2s;
}

.toggle.active::after {
    transform: translateX(24px);
}

.count-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.count-btn {
    background: #03dac6;
    border: none;
    color: #000;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
}

.count-btn:hover {
    background: #66fff9;
    transform: scale(1.1);
}

.count-btn:disabled {
    background: #666;
    color: #999;
    cursor: not-allowed;
    transform: none;
}

.count-display {
    min-width: 32px;
    text-align: center;
    color: #e0e0e0;
    font-weight: 500;
}

.deck-summary {
    background: #262626;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}

.deck-summary strong {
    color: #03dac6;
    font-size: 1.2rem;
}

@media (max-width: 768px) {
    .game-area {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    
    .history {
        width: 100%;
    }
    
    .controls {
        flex-direction: column;
        align-items: center;
    }
}