/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #1a0033 0%, #0f001a 25%, #000000 50%, #1a0033 75%, #2d004d 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    color: white;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow-x: hidden;
}

/* Decorative background elements */
body::before {
    content: '♠ ♥ ♦ ♣';
    position: fixed;
    inset: 0;
    font-size: 2rem;
    color: rgba(147, 51, 234, 0.08);
    pointer-events: none;
    z-index: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    align-content: space-around;
    animation: float 20s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-20px); }
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.game-container {
    max-width: 400px;
    width: 95%;
    background: rgba(20, 20, 20, 0.95);
    border-radius: 25px;
    backdrop-filter: blur(20px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
    padding: 1.5rem;
    position: relative;
    z-index: 1;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Back Button */
.back-button {
    position: absolute;
    top: 15px;
    left: 15px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    z-index: 10;
}

.back-button:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #ffd700;
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.back-button:active {
    transform: scale(0.95);
}

.back-button img {
    width: 20px;
    height: 20px;
    filter: brightness(0) invert(1);
    transition: filter 0.3s ease;
}

.back-button:hover img {
    filter: brightness(0) invert(1) sepia(1) saturate(5) hue-rotate(45deg);
}

/* Header Styles */
header {
    text-align: center;
    margin-bottom: 1.5rem;
}

header h1 {
    font-size: 1.8rem;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    font-weight: 700;
    letter-spacing: 1px;
}

.score-board {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
    flex-wrap: wrap;
}

.score {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.3rem 0.6rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    min-width: 65px;
    text-align: center;
}

.reset-btn {
    width: 30px;
    height: 30px;
    background: rgba(255, 69, 58, 0.8);
    border: 1px solid rgba(255, 69, 58, 0.3);
    border-radius: 10px;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.reset-btn:hover {
    background: rgba(255, 69, 58, 1);
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(255, 69, 58, 0.4);
}

.reset-btn:active {
    transform: scale(0.95);
}

/* Game Area */
.game-area {
    display: grid;
    grid-template-rows: auto auto auto;
    gap: 1rem;
    min-height: 300px;
}

/* Dealer and Player Sections */
.dealer-section,
.player-section,
.controls {
    background: rgba(30, 30, 30, 0.8);
    padding: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
}

.dealer-section h2,
.player-section h2 {
    font-size: 1.2rem;
    margin-bottom: 0.8rem;
    text-align: center;
    color: #ffd700;
    font-weight: 600;
}

.hand-info {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 0.8rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
}

/* Card Container */
.card-container {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 5px;
    min-height: 70px;
    align-items: center;
    padding: 0.5rem;
}

/* Card Styles */
.card {
    width: 50px;
    height: 70px;
    background: white;
    color: black;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 4px;
    font-weight: bold;
    font-size: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    transform: translateY(0);
    transition: all 0.3s ease;
    animation: cardDeal 0.5s ease-out;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.card:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 20px rgba(255, 255, 255, 0.2);
}

.card.hidden {
    background: linear-gradient(45deg, #2d4a22, #1a2e15);
    color: #ffd700;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 16px;
    border: 1px solid rgba(45, 74, 34, 0.8);
    position: relative;
    overflow: hidden;
}

.card.hidden::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        45deg,
        rgba(255, 215, 0, 0.1),
        rgba(255, 215, 0, 0.1) 2px,
        transparent 2px,
        transparent 6px
    );
}

.card-back {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

.card-pattern {
    font-size: 20px;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.card .card-value {
    font-size: 12px;
    font-weight: bold;
}

.card .card-suit {
    font-size: 14px;
    align-self: center;
}

.card.red {
    color: #ff4757;
}

.card.black {
    color: #2f3542;
}

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

.controls {
    text-align: center;
}

.game-status h3 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.buttons {
    display: flex;
    justify-content: center;
    gap: 0.8rem;
    flex-wrap: wrap;
}

/* Button Styles */
.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 90px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    inset: 0 -100% 0 -100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn:hover:not(:disabled)::before {
    left: 100%;
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
}

.btn.primary {
    background: linear-gradient(45deg, #00d2ff, #3a7bd5);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 210, 255, 0.3);
}

.btn.primary:hover:not(:disabled) {
    background: linear-gradient(45deg, #00bfff, #326bc7);
    box-shadow: 0 8px 25px rgba(0, 210, 255, 0.4);
}

.btn:not(.primary) {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn:not(.primary):hover:not(:disabled) {
    background: linear-gradient(45deg, #5a6fd8, #6a4190);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.btn:disabled {
    background: rgba(100, 100, 100, 0.3);
    color: rgba(255, 255, 255, 0.4);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    visibility: visible;
    transition: all 0.3s ease;
}

.modal.hidden {
    opacity: 0;
    visibility: hidden;
}

.modal-content {
    background: rgba(20, 20, 20, 0.95);
    border-radius: 20px;
    padding: 2rem;
    max-width: 350px;
    width: 90%;
    text-align: center;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
    transform: scale(1);
    transition: all 0.3s ease;
    animation: modalPop 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.modal.hidden .modal-content {
    transform: scale(0.8);
}

@keyframes modalPop {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(-50px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    margin-bottom: 1.5rem;
}

.result-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: bounce 1s ease;
}

@keyframes bounce {
    0%, 20%, 60%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    80% { transform: translateY(-5px); }
}

.modal-header h2 {
    font-size: 1.8rem;
    margin: 0;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.modal-body p {
    font-size: 1.1rem;
    margin: 0 0 1.5rem 0;
    line-height: 1.4;
    opacity: 0.9;
}

.modal-footer {
    margin-top: 1.5rem;
}

.modal-btn {
    padding: 12px 30px;
    font-size: 1rem;
    min-width: 120px;
    letter-spacing: 1px;
}

/* Win Theme */
.modal.win {
    background: rgba(0, 100, 0, 0.2);
}

.modal.win .modal-content {
    border: 2px solid rgba(0, 255, 0, 0.3);
    box-shadow: 0 0 30px rgba(0, 255, 0, 0.2);
}

.modal.win .result-icon::before {
    content: '🎉';
    font-size: 4rem;
    animation: celebrate 1s ease;
}

.modal.win .modal-header h2 {
    color: #00ff88;
    text-shadow: 0 0 20px rgba(0, 255, 136, 0.5);
}

.modal.win .modal-body p {
    color: #88ff88;
}

.modal.win .modal-btn {
    background: linear-gradient(45deg, #00d2ff, #3a7bd5);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 210, 255, 0.3);
}

.modal.win .modal-btn:hover {
    background: linear-gradient(45deg, #00bfff, #326bc7);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 210, 255, 0.4);
}

@keyframes celebrate {
    0%, 100% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(-10deg) scale(1.2); }
    75% { transform: rotate(10deg) scale(1.1); }
}

/* Loss Theme */
.modal.loss {
    background: rgba(100, 0, 0, 0.2);
}

.modal.loss .modal-content {
    border: 2px solid rgba(255, 0, 0, 0.3);
    box-shadow: 0 0 30px rgba(255, 0, 0, 0.2);
}

.modal.loss .result-icon::before {
    content: '😞';
    font-size: 4rem;
    animation: sadShake 1s ease;
}

.modal.loss .modal-header h2 {
    color: #ff4757;
    text-shadow: 0 0 20px rgba(255, 71, 87, 0.5);
}

.modal.loss .modal-body p {
    color: #ff8888;
}

.modal.loss .modal-btn {
    background: linear-gradient(45deg, #ff6b6b, #ee5a52);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

.modal.loss .modal-btn:hover {
    background: linear-gradient(45deg, #ff5252, #e04848);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.4);
}

@keyframes sadShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Draw Theme */
.modal.draw {
    background: rgba(50, 50, 50, 0.2);
}

.modal.draw .modal-content {
    border: 2px solid rgba(255, 215, 0, 0.3);
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.2);
}

.modal.draw .result-icon::before {
    content: '🤝';
    font-size: 4rem;
    animation: neutralPulse 1s ease;
}

.modal.draw .modal-header h2 {
    color: #ffd700;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

.modal.draw .modal-body p {
    color: #ffdd88;
}

.modal.draw .modal-btn {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.modal.draw .modal-btn:hover {
    background: linear-gradient(45deg, #5a6fd8, #6a4190);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

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

/* Footer */
footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.8rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-container { width: 98%; padding: 1rem; margin: 0.5rem; }
    .back-button { width: 35px; height: 35px; top: 12px; left: 12px; }
    .back-button img { width: 18px; height: 18px; }
    header h1 { font-size: 1.6rem; }
    .score-board { gap: 0.8rem; }
    .reset-btn { width: 25px; height: 25px; font-size: 0.8rem; }
    .score { min-width: 55px; padding: 0.25rem 0.5rem; font-size: 0.8rem; }
    .hand-info { gap: 1rem; font-size: 0.85rem; }
    .card { width: 45px; height: 65px; font-size: 9px; padding: 3px; }
    .card .card-suit { font-size: 12px; }
    .card-pattern { font-size: 16px; }
    .buttons { gap: 0.6rem; }
    .btn { min-width: 80px; padding: 10px 16px; font-size: 0.8rem; }
}

@media (max-width: 480px) {
    .game-container,
    .dealer-section,
    .player-section,
    .controls { padding: 0.8rem; }
    .game-container { border-radius: 20px; }
    .back-button { width: 32px; height: 32px; top: 10px; left: 10px; }
    .back-button img { width: 16px; height: 16px; }
    header h1 { font-size: 1.4rem; }
    .score-board { gap: 0.4rem; font-size: 0.75rem; }
    .score { min-width: 50px; padding: 0.2rem 0.4rem; }
    .reset-btn { width: 22px; height: 22px; font-size: 0.7rem; }
    .card { width: 40px; height: 55px; font-size: 8px; padding: 2px; }
    .card .card-suit { font-size: 10px; }
    .card-pattern { font-size: 14px; }
    .game-status h3 { font-size: 1rem; }
    .btn { min-width: 70px; padding: 8px 12px; font-size: 0.75rem; }
    .modal-content { padding: 1.5rem; max-width: 320px; }
    .modal-header h2 { font-size: 1.5rem; }
    .modal-body p { font-size: 1rem; }
    .result-icon::before { font-size: 3rem !important; }
}

@media (max-width: 350px) {
    .back-button { width: 28px; height: 28px; top: 8px; left: 8px; }
    .back-button img { width: 14px; height: 14px; }
    .score-board { gap: 0.3rem; font-size: 0.7rem; }
    .score { min-width: 45px; padding: 0.15rem 0.3rem; }
    .reset-btn { width: 20px; height: 20px; font-size: 0.6rem; }
    .card { width: 35px; height: 50px; font-size: 7px; }
    .card .card-suit { font-size: 9px; }
    .card-pattern { font-size: 12px; }
    .buttons { flex-direction: column; align-items: center; gap: 0.5rem; }
    .btn { width: 100%; max-width: 200px; }
}