:root {
    --card-width: 60px;
    --card-height: 90px;
    --gap: 10px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #1a1a1a;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

#game-container {
    width: 100%;
    max-width: 420px;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: var(--gap);
    box-sizing: border-box;
    padding-bottom: 70px; 
}

#info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--gap);
}

#turn-counter {
    background-color: #333;
    padding: 5px 10px;
    border-radius: 5px;
}

#timer {
    font-size: 1.5em;
    font-weight: bold;
    color: #fff;
    background-color: #4CAF50;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s;
}

#timer.warning {
    color: #fff;
    background-color: #f44336;
    transform: scale(1.2);
}

.player-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--gap);
}

.score-board {
    display: flex;
    align-items: center;
    gap: var(--gap);
    background-color: rgba(0,0,0,0.2);
    padding: 5px 15px;
    border-radius: 20px;
}

.score {
    font-size: 1.2em;
    font-weight: bold;
}

.hand {
    display: flex;
    justify-content: center;
    gap: var(--gap);
    min-height: calc(var(--card-height) + 20px);
    padding-bottom: 5px;
}

#play-area {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--gap);
    position: relative;
}

#message-box {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 15px 25px;
    border-radius: 10px;
    font-size: 1.5em;
    font-weight: bold;
    z-index: 10;
    text-align: center;
    white-space: pre-wrap;
    pointer-events: none;
}

.card, .card-slot {
    width: var(--card-width);
    height: var(--card-height);
    border-radius: 5px;
    background-color: #555;
    background-size: cover;
    background-position: center;
    transition: transform 0.3s ease-in-out, box-shadow 0.3s;
    flex-shrink: 0;
}

.card.bonus {
    box-shadow: 0 0 15px 5px gold;
}

.card.back {
    background-image: url('back.png');
}
.card[data-value="1"] { background-image: url('1.png'); }
.card[data-value="2"] { background-image: url('2.png'); }
.card[data-value="3"] { background-image: url('3.png'); }
.card[data-value="4"] { background-image: url('4.png'); }
.card[data-value="Joker"] { background-image: url('joker.png'); }

#player-hand .card.playable {
    cursor: pointer;
}

#player-hand .card.playable:hover {
    transform: translateY(-10px);
    box-shadow: 0 0 15px 5px #00aaff;
}

.card.selected {
    transform: translateY(-20px) scale(1.1);
    box-shadow: 0 0 20px 8px #00f6ff !important;
}

#control-area {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: var(--gap);
    padding: 0 10px;
}

#swap-ability-button {
    background-color: #20c997;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8em;
    font-weight: bold;
    line-height: 1.2;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

#swap-ability-button:disabled {
    background-color: #555;
    cursor: not-allowed;
    opacity: 0.6;
}

#graveyard-display {
    position: relative;
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.7);
}

#graveyard-count {
    position: absolute;
    bottom: 3px;
    right: 3px;
    background: rgba(0,0,0,0.7);
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.9em;
    font-weight: bold;
}

#modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

#modal-content {
    background: #444;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    max-width: 90%;
}

#modal-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin: 20px 0;
}

#modal-body p {
    margin: 0;
}

.modal-card-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--gap);
}

#modal-body .card:hover {
    transform: scale(1.1);
}

#modal-footer button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    margin-top: 10px;
}
#modal-footer button:hover {
    background-color: #0056b3;
}

.hidden {
    display: none !important;
}

@media (max-width: 380px) {
    :root {
        --card-width: 50px;
        --card-height: 75px;
        --gap: 5px;
    }
}

