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

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

.game-container {
    width: 100%;
    max-width: 620px;
    height: 100vh;
    max-height: 100vh;
    position: relative;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.game-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #184F32;
    background-size: cover;
    filter: blur(3px) brightness(0.75);
    z-index: 0;
}

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

/* Desktop centering */
@media (min-width: 768px) {
    .game-container {
        max-height: 95vh;
        height: 95vh;
        border-radius: 20px;
    }
}

.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: 48px;
    color: #FFD700;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.8);
    margin-bottom: 60px;
    letter-spacing: 2px;
}

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

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

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

.player-name {
    font-size: 16px;
    color: #4CAF50;
    font-weight: bold;
}

.btn-start {
    background: linear-gradient(180deg, #4CAF50 0%, #388E3C 100%);
    color: white;
    font-size: 28px;
    font-weight: bold;
    padding: 18px 80px;
    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: 40px;
}

.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: 15px 20px;
    background: rgba(0, 0, 0, 0.5);
}

.score-info {
    display: flex;
    justify-content: space-around;
    gap: 40px;
    max-width: 300px;
    margin: 0 auto;
}

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

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

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

.game-board {
    position: relative;
    flex: 1;
    padding: 20px 15px;
    overflow-y: auto;
}

.deck-area {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 30px;
}

.undo-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.undo-button:hover {
    transform: scale(1.1);
}

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

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

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

#undoCount {
    color: white;
    font-size: 20px;
    font-weight: bold;
    margin-top: 5px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

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

.deck-pile:hover {
    transform: translateY(-5px);
}

.deck-pile:active {
    transform: translateY(-2px);
}

.deck-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;
}

.discard-pile {
    width: 80px;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.discard-pile img {
    width: 100%;
    height: 110px;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
}

.card-value {
    color: white;
    font-size: 24px;
    font-weight: bold;
    margin-top: 8px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.columns-wrapper {
    position: relative;
}

.columns-area {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.column {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    padding: 10px 5px;
    min-height: 200px;
    height: 100%;
    min-width: 70px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    display: flex;
    flex-direction: column;
}

.column:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.02);
}

.column.busted {
    background: rgba(255, 0, 0, 0.3);
    border-color: rgba(255, 0, 0, 0.6);
    cursor: not-allowed;
}

.column.completed {
    background: rgba(0, 255, 0, 0.3);
    border-color: rgba(0, 255, 0, 0.6);
}

.column-sum {
    text-align: center;
    font-size: 24px;
    font-weight: bold;
    color: white;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.column.busted .column-sum {
    color: #FF5252;
}

.column.completed .column-sum {
    color: #4CAF50;
}

.column-cards {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    padding-top: 5px;
}

.column-cards img {
    width: 50px;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.game-footer {
    padding: 15px 20px;
    background: rgba(0, 0, 0, 0.5);
    text-align: center;
}

.btn-menu {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 18px;
    font-weight: bold;
    padding: 12px 40px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 25px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-menu:hover {
    background: rgba(255, 255, 255, 0.3);
}

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

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

.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: 18px;
    margin-bottom: 10px;
}

.final-score .value {
    font-size: 48px;
    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: 20px;
    font-weight: bold;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.new-best-score input {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border: 2px solid #4CAF50;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
    text-align: center;
}

.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: 22px;
    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;
}

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

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

/* Current card indicator */
.current-card {
    animation: pulse 0.5s ease-in-out;
}

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

/* 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: 32px;
    font-weight: bold;
    padding: 30px 60px;
    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);
}

/* Joker effect */
.joker-effect {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 36px;
    font-weight: bold;
    padding: 30px 60px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    animation: jokerPop 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;
    }
}

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

/* Column shake animation for regular 21 */
.column-shake {
    animation: columnShake 0.5s ease-in-out;
}

@keyframes columnShake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

/* Tutorial Hints */
.tutorial-hint {
    position: absolute;
    bottom: 30px;
    width: 300px; 
    max-width: 90%;
    /* left: 50%; */
    /* transform: translateX(-50%); */
    background: #E5E5E5;
    color: #15291F;
    text-align: center;
    padding: 10px 20px;
    border-radius: 15px;
    font-size: 18px;
    font-weight: 500;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    animation: hintFadeIn 0.5s ease-out;
    z-index: 50;
    overflow: hidden;
}

#hintText {
    margin: 0;
    line-height: 1.4;
}
@media(max-width: 420px){
    .tutorial-hint {
        font-size: 12px;
        padding: 8px 15px;
    }
}

@keyframes hintFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Animated Hand Gesture */
.hand-gesture {
    position: absolute;
    top: 50%;
    left: 25%;
    transform: translate(-50%, -50%);
    z-index: 100;
    pointer-events: none;
    animation: handTap 2s ease-in-out infinite;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.8));
}

.hand-gesture.hidden {
    display: none;
}

@keyframes handTap {
    0%, 100% {
        left: 25%;
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.9;
    }
    25% {
        left: 25%;
        transform: translate(-50%, -50%) scale(0.9);
        opacity: 1;
    }
    33% {
        left: 50%;
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.9;
    }
    58% {
        left: 50%;
        transform: translate(-50%, -50%) scale(0.9);
        opacity: 1;
    }
    66% {
        left: 75%;
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.9;
    }
    91% {
        left: 75%;
        transform: translate(-50%, -50%) scale(0.9);
        opacity: 1;
    }
}


/* Larger screens - bigger game elements for 420px-620px */
@media (min-width: 768px)  {
    .game-title {
        font-size: 56px;
    }
    
    .best-score-display {
        max-width: 300px;
        padding: 25px;
    }
    
    .best-score-display p:nth-child(2) {
        font-size: 52px;
    }
    
    .btn-start {
        font-size: 32px;
        padding: 20px 100px;
    }
    
    .score-item .label {
        font-size: 16px;
    }
    
    .score-item .value {
        font-size: 32px;
    }
    
    .deck-pile, .discard-pile {
        width: 100px;
        height: 140px;
    }
    
    .deck-pile {
        background-size: cover;
    }
    
    .discard-pile img {
        height: 140px;
    }
    
    .card-value {
        font-size: 28px;
        margin-top: 10px;
    }
    
    .undo-button svg {
        width: 42px;
        height: 42px;
    }
    
    #undoCount {
        font-size: 24px;
    }

    .deck-area {
        margin-bottom: 80px !important;
    }
    
    .deck-count {
        font-size: 16px;
        padding: 4px 10px;
    }
    
    .column {
        min-width: 100px;
        min-height: 250px;
        padding: 12px 8px;
        border-radius: 12px;
    }
    
    .column-sum {
        font-size: 28px;
        margin-bottom: 12px;
    }
    
    .column-cards img {
        width: 70px;
    }
    
    .tutorial-hint {
        font-size: 20px;
        padding: 15px 25px;
        max-width: 450px;
    }
    
    .hand-gesture svg {
        width: 70px;
        height: 70px;
    }
    
    .game-over-title, .busted-title {
        font-size: 48px;
    }
    
    .final-score {
        max-width: 300px;
        padding: 25px;
    }
    
    .final-score .label {
        font-size: 20px;
    }
    
    .final-score .value {
        font-size: 54px;
    }
    
    .btn-restart {
        font-size: 24px;
        padding: 16px 70px;
    }
    
    .btn-menu {
        font-size: 20px;
        padding: 14px 50px;
    }
    
    .celebration-message, .joker-effect {
        font-size: 36px;
        padding: 35px 70px;
    }
    
    .busted-message p {
        font-size: 22px;
    }
}

@media (max-width: 768px) {
    .joker-effect,.celebration-message {
        font-size: 24px;
        padding: 20px 10px;
        text-align: center;
        min-width:250px;
        max-width:98%;
    }
}

/* Responsive adjustments */
@media (max-width: 380px) {
    .column-cards img {
        width: 45px;
    }
    
    .deck-pile, .discard-pile {
        width: 70px;
        height: 95px;
    }
    
    
    
    .tutorial-hint {
        font-size: 16px;
        padding: 12px 15px;
    }
    
    .hand-gesture svg {
        width: 50px;
        height: 50px;
    }
}
