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

:root {
    --card-width: 80px;
    --card-height: 112px;
    --card-radius: 6px;
    --table-color: #1a5f3c;
    --table-pattern: repeating-linear-gradient(
        45deg,
        #1a5f3c,
        #1a5f3c 10px,
        #1e7045 10px,
        #1e7045 20px
    );
    
    --suit-spades: #9b59b6;
    --suit-clubs: #f39c12;
    --suit-diamonds: #e74c3c;
    --suit-hearts: #ff7675;
    --suit-green-spades: #55efc4;
    --suit-green-clubs: #00b894;
    --suit-blue-diamonds: #74b9ff;
    --suit-blue-hearts: #a29bfe;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--table-pattern);
    min-height: 100vh;
    overflow-x: hidden;
}

.game-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 15px;
}

.game-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    padding: 15px 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    backdrop-filter: blur(10px);
}

.game-header h1 {
    color: #fff;
    font-size: 1.8rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.game-info {
    display: flex;
    gap: 25px;
}

.info-item {
    color: #fff;
    font-size: 1.1rem;
}

.info-item .label {
    opacity: 0.8;
}

.controls {
    display: flex;
    gap: 10px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
}

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

.btn.primary {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    border: none;
}

.difficulty-selector {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    color: #fff;
}

.difficulty-selector select {
    padding: 8px 15px;
    border-radius: 6px;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    background: #fff;
    color: #333;
}

.difficulty-hint {
    font-size: 0.85rem;
    opacity: 0.7;
}

.table-area {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    padding: 15px;
}

.top-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    min-height: 120px;
}

.stock-area {
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-stack.stock {
    width: var(--card-width);
    height: var(--card-height);
    cursor: pointer;
    position: relative;
}

.card-stack.stock .card-back {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    border-radius: var(--card-radius);
    border: 2px solid rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-stack.stock .card-back::before {
    content: '♠';
    font-size: 2rem;
    color: rgba(255, 255, 255, 0.3);
}

.card-stack.stock:hover .card-back {
    background: linear-gradient(135deg, #34495e 0%, #2c3e50 100%);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.stock-count {
    color: #fff;
    font-size: 1.2rem;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.spacer {
    flex: 1;
}

.completed-area {
    display: flex;
    gap: 8px;
    min-width: 300px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.completed-slot {
    width: calc(var(--card-width) * 0.6);
    height: calc(var(--card-height) * 0.6);
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: var(--card-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.1);
}

.completed-card {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #ffd700 0%, #ffb700 100%);
    border-radius: calc(var(--card-radius) * 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    animation: complete-pop 0.5s ease;
}

@keyframes complete-pop {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.tableau {
    display: grid;
    grid-template-columns: repeat(14, 1fr);
    gap: 8px;
    min-height: 400px;
}

.tableau-column {
    position: relative;
    min-height: var(--card-height);
    background: rgba(0, 0, 0, 0.1);
    border-radius: var(--card-radius);
    padding: 5px;
}

.tableau-column.drag-over {
    background: rgba(76, 175, 80, 0.2);
    box-shadow: inset 0 0 10px rgba(76, 175, 80, 0.5);
}

.card {
    width: var(--card-width);
    height: var(--card-height);
    background: #fff;
    border-radius: var(--card-radius);
    position: absolute;
    cursor: grab;
    user-select: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 6px;
    font-weight: bold;
    overflow: hidden;
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
    z-index: 100 !important;
}

.card.dragging {
    cursor: grabbing;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    z-index: 1000 !important;
}

.card.face-down {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    cursor: default;
}

.card.face-down::before {
    content: '';
    position: absolute;
    inset: 8px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 5px,
        rgba(255, 255, 255, 0.05) 5px,
        rgba(255, 255, 255, 0.05) 10px
    );
}

.card .card-corner {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
}

.card .card-corner.bottom {
    align-self: flex-end;
    transform: rotate(180deg);
}

.card .card-rank {
    font-size: 1.3rem;
}

.card .card-suit-small {
    font-size: 0.9rem;
}

.card .card-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
}

.card .card-suit-large {
    font-size: 3rem;
}

.card[data-suit="spades"] {
    color: var(--suit-spades);
    border: 2px solid var(--suit-spades);
    background: linear-gradient(135deg, #f5e6fa 0%, #e8d4f0 100%);
}

.card[data-suit="clubs"] {
    color: var(--suit-clubs);
    border: 2px solid var(--suit-clubs);
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
}

.card[data-suit="diamonds"] {
    color: var(--suit-diamonds);
    border: 2px solid var(--suit-diamonds);
    background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
}

.card[data-suit="hearts"] {
    color: var(--suit-hearts);
    border: 2px solid var(--suit-hearts);
    background: linear-gradient(135deg, #ffebee 0%, #ff8a80 100%);
}

.card[data-suit="green-spades"] {
    color: var(--suit-green-spades);
    border: 2px solid var(--suit-green-spades);
    background: linear-gradient(135deg, #e0f7fa 0%, #b2ebf2 100%);
}

.card[data-suit="green-clubs"] {
    color: var(--suit-green-clubs);
    border: 2px solid var(--suit-green-clubs);
    background: linear-gradient(135deg, #e0f2f1 0%, #b2dfdb 100%);
}

.card[data-suit="blue-diamonds"] {
    color: var(--suit-blue-diamonds);
    border: 2px solid var(--suit-blue-diamonds);
    background: linear-gradient(135deg, #e3f2fd 0%, #90caf9 100%);
}

.card[data-suit="blue-hearts"] {
    color: var(--suit-blue-hearts);
    border: 2px solid var(--suit-blue-hearts);
    background: linear-gradient(135deg, #ede7f6 0%, #d1c4e9 100%);
}

.card.highlight {
    box-shadow: 0 0 0 3px #ffeb3b, 0 4px 12px rgba(0, 0, 0, 0.4);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 3px #ffeb3b, 0 4px 12px rgba(0, 0, 0, 0.4); }
    50% { box-shadow: 0 0 0 5px #ffeb3b, 0 6px 20px rgba(0, 0, 0, 0.5); }
}

.card.valid-drop {
    box-shadow: 0 0 0 3px #4caf50, 0 4px 12px rgba(0, 0, 0, 0.4);
}

.card-stack {
    position: relative;
}

.card-stack .card {
    position: absolute;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    color: #fff;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modal-appear 0.3s ease;
}

@keyframes modal-appear {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-content h2 {
    font-size: 2rem;
    margin-bottom: 20px;
}

.modal-content p {
    font-size: 1.2rem;
    margin-bottom: 15px;
    opacity: 0.9;
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 25px;
}

.card-legend {
    margin-top: 20px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

.card-legend h3 {
    color: #fff;
    margin-bottom: 10px;
    font-size: 1rem;
}

.legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #fff;
    font-size: 0.9rem;
}

.legend-suit {
    width: 24px;
    height: 32px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.legend-suit.spades { background: var(--suit-spades); }
.legend-suit.clubs { background: var(--suit-clubs); }
.legend-suit.diamonds { background: var(--suit-diamonds); }
.legend-suit.hearts { background: var(--suit-hearts); }
.legend-suit.green-spades { background: var(--suit-green-spades); }
.legend-suit.green-clubs { background: var(--suit-green-clubs); }
.legend-suit.blue-diamonds { background: var(--suit-blue-diamonds); }
.legend-suit.blue-hearts { background: var(--suit-blue-hearts); }

@keyframes deal-card {
    from {
        opacity: 0;
        transform: translateY(-50px) rotate(-10deg);
    }
    to {
        opacity: 1;
        transform: translateY(0) rotate(0);
    }
}

.card {
    animation: deal-card 0.2s ease-out;
}

@keyframes move-card {
    transition: all 0.2s ease;
}

@media (max-width: 900px) {
    :root {
        --card-width: 60px;
        --card-height: 84px;
    }
    
    .game-header {
        flex-direction: column;
        text-align: center;
    }
    
    .game-info {
        justify-content: center;
    }
    
    .tableau {
        gap: 4px;
    }
}

@media (max-width: 600px) {
    :root {
        --card-width: 45px;
        --card-height: 63px;
    }
    
    .game-header h1 {
        font-size: 1.3rem;
    }
    
    .btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
    
    .completed-area {
        min-width: auto;
    }
}

.hint-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1500;
}

.hint-glow {
    animation: hint-pulse 1s ease-in-out infinite;
}

@keyframes hint-pulse {
    0%, 100% {
        filter: brightness(1);
        transform: scale(1);
    }
    50% {
        filter: brightness(1.5);
        transform: scale(1.05);
    }
}

.drag-ghost .card {
    position: absolute;
    width: var(--card-width);
    height: var(--card-height);
    background: #fff;
    border-radius: var(--card-radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 6px;
    font-weight: bold;
    overflow: hidden;
}

.drag-ghost .card.red {
    color: #c41e3a;
}

.drag-ghost .card.black {
    color: #2c2c2c;
}
