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

body {
    font-family: 'Arial', sans-serif;
    background: #111;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

.game-container {
    width: 100%;
    max-width: 100vw;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

.game-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #184F32;
    z-index: 0;
}

.game-container > * {
    position: relative;
    z-index: 1;
}

/* Desktop centering */
@media (min-width: 1024px) {
    .game-container {
        max-width: 1400px;
        max-height: 95vh;
        height: 95vh;
        border-radius: 20px;
        box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    }
}

.screen {
    display: none;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.screen.active {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.screen-content {
    text-align: center;
    padding: 20px;
    width: 100%;
}

/* Start Screen */
.game-title {
    font-size: 36px;
    color: #FFD700;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.8);
    margin-bottom: 40px;
    letter-spacing: 2px;
}

/* Difficulty Selection */
.difficulty-selection {
    margin: 30px auto;
    max-width: 400px;
}

.difficulty-selection h2 {
    color: white;
    font-size: 20px;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.difficulty-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.btn-difficulty {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 18px;
    font-weight: bold;
    padding: 15px 30px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.btn-difficulty:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
}

.btn-difficulty.selected {
    background: linear-gradient(180deg, #4CAF50 0%, #388E3C 100%);
    border-color: #4CAF50;
    transform: scale(1.05);
}

.best-score-display {
    background: rgba(0, 0, 0, 0.6);
    padding: 20px;
    border-radius: 15px;
    margin: 30px auto;
    max-width: 250px;
    color: white;
}

.best-score-display p:first-child {
    font-size: 16px;
    margin-bottom: 10px;
    opacity: 0.8;
}

.best-score-display p:nth-child(2) {
    font-size: 36px;
    font-weight: bold;
    color: #FFD700;
}

.btn-start {
    background: linear-gradient(180deg, #4CAF50 0%, #388E3C 100%);
    color: white;
    font-size: 24px;
    font-weight: bold;
    padding: 15px 60px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 30px;
}

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

.btn-start:active {
    transform: translateY(0);
}

/* Game Screen */
#gameScreen {
    display: none;
    flex-direction: column;
}

#gameScreen.active {
    display: flex;
}

.game-header {
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.score-info {
    display: flex;
    justify-content: flex-start;
    gap: 15px;
}

.control-buttons {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    flex-shrink: 0;
}

.btn-control {
    background: rgba(76, 175, 80, 0.7);
    border: 2px solid rgba(76, 175, 80, 0.9);
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
    flex-shrink: 0;
}

.btn-control:hover {
    background: rgba(76, 175, 80, 0.9);
    transform: scale(1.1);
}

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

.btn-control.muted {
    background: rgba(244, 67, 54, 0.7);
    border-color: rgba(244, 67, 54, 0.9);
}

.score-info {
    display: flex;
    justify-content: center;
    gap: 15px;
    grid-column: 2;
}

.score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.score-item .label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 11px;
}

.score-item .value {
    color: #FFD700;
    font-size: 18px;
    font-weight: bold;
}

.game-board {
    flex: 1;
    overflow-x: auto;
    overflow-y: auto;
    padding: 8px 3px;
    position: relative;
}

.columns-wrapper {
    min-width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.columns-area {
    display: flex;
    gap: 3px;
    padding: 3px;
    min-height: 300px;
    align-items: flex-start;
}

.column {
    min-width: 32px;
    width: 32px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 3px 1px;
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
    display: flex;
    flex-direction: column;
}

.column:hover {
    background: rgba(255, 255, 255, 0.1);
}

.column.can-drop {
    background: rgba(0, 255, 0, 0.15);
    border: 2px solid rgba(0, 255, 0, 0.5);
    border-radius: 6px;
}

.column.can-drop:hover {
    background: rgba(0, 255, 0, 0.25);
    border-color: rgba(0, 255, 0, 0.8);
}

.column.empty {
    border: 2px dashed rgba(255, 255, 255, 0.5);
    min-height: 80px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
}

.column.empty::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    pointer-events: none;
}

.card {
    width: 100%;
    margin-top: -22px;
    position: relative;
    cursor: pointer;
}

.card:first-child {
    margin-top: 0;
}

.card img {
    width: 100%;
    height: auto;
    border-radius: 3px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    display: block;
}

.card.movable {
    cursor: grab;
    position: relative;
}

.card.movable::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 2px solid rgba(255, 215, 0, 0.6);
    border-radius: 3px;
    pointer-events: none;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

.card.movable:hover {
    transform: translateY(-5px);
    filter: brightness(1.2);
    z-index: 10;
}

.card.movable:hover::after {
    border-color: rgba(255, 215, 0, 0.9);
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.6);
}

.card.selected {
    transform: translateY(-8px);
    filter: brightness(1.3);
    z-index: 100;
}

.card.selected::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 3px solid #FFD700;
    border-radius: 3px;
    pointer-events: none;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.8);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 15px rgba(255, 215, 0, 0.8); }
    50% { box-shadow: 0 0 25px rgba(255, 215, 0, 1); }
}

/* Drag and Drop States */
.card.dragging {
    opacity: 0.5;
    cursor: grabbing !important;
}

.column.drag-over {
    background: rgba(0, 255, 0, 0.3) !important;
    border: 3px solid rgba(0, 255, 0, 0.8) !important;
    border-radius: 6px;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.5);
}

.card.face-down {
    opacity: 0.9;
}

/* Game Footer - Stock Area */
.game-footer {
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.5);
}

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

.stock-pile {
    width: 60px;
    height: 82px;
    background: url('images/cards/backdesign.png') center center no-repeat;
    background-size: cover;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
    position: relative;
    transition: transform 0.2s;
}

.stock-pile:hover {
    transform: translateY(-3px);
}

.stock-pile:active {
    transform: translateY(-1px);
}

.stock-count {
    position: absolute;
    bottom: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 3px 8px;
    border-radius: 5px;
    font-size: 14px;
    font-weight: bold;
}

.btn-undo, .btn-menu {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 12px;
    font-weight: bold;
    padding: 8px 15px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-undo:hover, .btn-menu:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

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

.btn-undo.disabled:hover {
    transform: none;
}

/* Win Screen */
.win-title {
    font-size: 42px;
    color: #4CAF50;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.8);
    margin-bottom: 40px;
}

/* Game Over Screen */
.game-over-title {
    font-size: 42px;
    color: #FF5252;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.8);
    margin-bottom: 40px;
}

.final-score {
    background: rgba(0, 0, 0, 0.6);
    padding: 20px;
    border-radius: 15px;
    margin: 30px auto;
    max-width: 250px;
}

.final-score .label {
    color: rgba(255, 255, 255, 0.8);
    font-size: 16px;
    margin-bottom: 10px;
}

.final-score .value {
    font-size: 42px;
    font-weight: bold;
    color: #FFD700;
}

.new-best-score {
    background: rgba(76, 175, 80, 0.3);
    padding: 20px;
    border-radius: 15px;
    margin: 20px auto;
    max-width: 300px;
    border: 2px solid #4CAF50;
}

.new-best-score p {
    color: #FFD700;
    font-size: 18px;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.game-over-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 30px;
    align-items: center;
}

.btn-restart {
    background: linear-gradient(180deg, #4CAF50 0%, #388E3C 100%);
    color: white;
    font-size: 20px;
    font-weight: bold;
    padding: 15px 50px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    transition: transform 0.2s;
}

.btn-restart:hover {
    transform: translateY(-2px);
}

.btn-restart:active {
    transform: translateY(0);
}

/* Celebration effect */
.celebration-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 215, 0, 0.95);
    color: #fff;
    font-size: 24px;
    font-weight: bold;
    padding: 20px 40px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    animation: celebrationPop 2s ease-out;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

@keyframes celebrationPop {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }
    20% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 1;
    }
    25%, 75% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0;
    }
}

/* Tablet and larger phones landscape */
@media (min-width: 600px) {
    .game-title {
        font-size: 48px;
    }
    
    .columns-area {
        gap: 6px;
    }
    
    .column {
        min-width: 65px;
        width: 65px;
    }
    
    .card {
        margin-top: -45px;
    }
    
    .card:first-child {
        margin-top: 0;
    }
    
    .stock-pile {
        width: 85px;
        height: 115px;
    }
    
    .score-item .label {
        font-size: 14px;
    }
    
    .score-item .value {
        font-size: 24px;
    }
}

/* Desktop */
@media (min-width: 1024px) {
    .game-title {
        font-size: 56px;
    }
    
    .game-header {
        padding: 15px 20px;
    }
    
    .game-board {
        padding: 20px 15px;
    }
    
    .columns-area {
        gap: 8px;
    }
    
    .column {
        min-width: 80px;
        width: 80px;
        padding: 8px 4px;
    }
    
    .card {
        margin-top: -55px;
    }
    
    .card:first-child {
        margin-top: 0;
    }
    
    .stock-pile {
        width: 95px;
        height: 130px;
    }
    
    .score-item .label {
        font-size: 16px;
    }
    
    .score-item .value {
        font-size: 28px;
    }
    
    .btn-undo, .btn-menu {
        font-size: 16px;
        padding: 12px 24px;
    }
    
    .celebration-message {
        font-size: 32px;
        padding: 30px 60px;
    }
}

/* Small screens - more compact */
@media (max-width: 380px) {
    .column {
        min-width: 30px;
        width: 30px;
    }
    
    .card {
        margin-top: -20px;
    }
    
    .card:first-child {
        margin-top: 0;
    }
    
    .stock-pile {
        width: 55px;
        height: 75px;
    }
    
    .game-title {
        font-size: 26px;
    }
    
    .btn-difficulty {
        font-size: 15px;
        padding: 12px 20px;
    }
}

/* Landscape mode adjustments */
@media (max-height: 500px) and (orientation: landscape) {
    .game-header {
        padding: 5px 10px;
    }
    
    .game-footer {
        padding: 5px 10px;
    }
    
    .score-item .label {
        font-size: 10px;
    }
    
    .score-item .value {
        font-size: 16px;
    }
    
    .column {
        min-width: 45px;
        width: 45px;
    }
    
    .card {
        margin-top: -30px;
    }
    
    .card:first-child {
        margin-top: 0;
    }
    
    .stock-pile {
        width: 55px;
        height: 75px;
    }
    
    .btn-undo, .btn-menu {
        font-size: 12px;
        padding: 8px 15px;
    }
}

/* Help Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    animation: fadeIn 0.3s;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: linear-gradient(135deg, #1a5f3f 0%, #184F32 100%);
    padding: 30px;
    border-radius: 20px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
    position: relative;
    animation: slideDown 0.3s;
}

.modal-content h2 {
    color: #FFD700;
    text-align: center;
    font-size: 24px;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.help-text {
    color: white;
    line-height: 1.6;
    font-size: 16px;
}

.help-text p {
    margin-bottom: 10px;
}

.help-text ul {
    margin-left: 20px;
    list-style-type: disc;
}

.help-text li {
    margin-bottom: 8px;
}

.help-text strong {
    color: #FFD700;
}

.close-modal {
    position: absolute;
    right: 15px;
    top: 15px;
    font-size: 36px;
    font-weight: bold;
    color: #FFD700;
    cursor: pointer;
    transition: transform 0.2s;
    line-height: 1;
}

.close-modal:hover {
    transform: scale(1.2);
    color: white;
}

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

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

@media (max-width: 600px) {
    .modal-content {
        padding: 20px;
        max-height: 85vh;
    }
    
    .modal-content h2 {
        font-size: 20px;
    }
    
    .help-text {
        font-size: 14px;
    }
    
    .close-modal {
        font-size: 30px;
    }
    
    .btn-control {
        width: 32px;
        height:28px;
        height: 28px;
    }
    
    .btn-control svg {
        width: 16px;
        height: 16px;
    }
    
    .control-buttons {
        gap: 4px;
    }
    
    .score-info {
        gap: 10px;
    }
    
    .score-item .label {
        font-size: 10px;
    }
    
    .score-item .value {
        font-size: 16px;
    }
}

@media (max-width: 380px) {
    .btn-control {
        width: 26px;
        height: 26px;
    }
    
    .btn-control svg {
        width: 14px;
        height: 14px;
    }
    
    .control-buttons {
        gap: 3px;
    }
    
    .game-header {
        padding: 6px 8px;
        gap: 5px;
    }
}