* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #87ceeb;
    color: #0f172a;
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container {
    width: 100%;
    max-width: 600px;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.screen.active {
    opacity: 1;
    pointer-events: all;
}

/* Start Screen */
#start-screen {
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, #87ceeb, #38bdf8);
}

#start-screen h1 {
    font-size: 2.5rem;
    margin-bottom: 20px;
    color: #0284c7;
    text-shadow: 1px 1px 3px rgba(255,255,255,0.6);
}

#start-screen p {
    font-size: 1.1rem;
    margin-bottom: 15px;
    line-height: 1.4;
    max-width: 80%;
}

button {
    background-color: #0284c7;
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1.2rem;
    border-radius: 8px;
    font-weight: bold;
    box-shadow: 0 4px 6px rgba(0,0,0,0.15);
    cursor: pointer;
    margin-top: 20px;
    transition: transform 0.1s;
}

button:active {
    transform: scale(0.95);
}

.small-btn {
    padding: 5px 12px;
    font-size: 0.9rem;
    background-color: #0369a1;
    margin-top: 0;
}

/* Play Screen */
#play-screen {
    padding: 10px;
    display: flex;
    flex-direction: column;
}

#header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 5px 0;
    flex: 0 0 auto;
    width: 100%;
}

.top-bar {
    display: flex;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    padding: 0 5px;
    margin-bottom: 5px;
}

.score-board {
    display: flex;
    flex-direction: column;
    font-size: 0.9rem;
    font-weight: bold;
    color: #0284c7;
    background: rgba(255,255,255,0.6);
    padding: 5px 10px;
    border-radius: 10px;
    border: 2px solid #7dd3fc;
    min-width: 80px;
}

.deck-info {
    display: flex;
    align-items: center;
    font-size: 1.2rem;
    font-weight: bold;
    background: rgba(255,255,255,0.6);
    padding: 5px 10px;
    border-radius: 20px;
    border: 2px solid #7dd3fc;
}

#deck-icon {
    width: 30px;
    height: auto;
    margin-right: 10px;
}

#message-area {
    margin-top: 10px;
    min-height: 48px;
    font-size: 1rem;
    color: #0f172a;
    text-align: center;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

#dealer-hand-container {
    flex: 0 0 auto;
    display: flex;
    justify-content: center;
    gap: 4px;
    padding: 10px;
    min-height: 90px;
}

#dealer-hand-container .card {
    width: 15%;
    max-width: 60px;
}

#dealer-hand-container .card-name {
    font-size: 0.45rem;
}

#dealer-hand-container .card-theme {
    font-size: 0.35rem;
}

#center-play-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(255,255,255,0.4);
    border-radius: 12px;
    margin: 5px 10px;
    border: 2px dashed #7dd3fc;
}

#shown-card-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

#hand-container {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 4px;
    padding: 10px;
    min-height: 90px;
}

#hand-container .card {
    width: 15%;
    max-width: 60px;
    position: relative;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s;
}

#hand-container .card:hover {
    transform: scale(1.6) translateY(-5px);
    z-index: 10;
    box-shadow: 0 10px 20px rgba(0,0,0,0.4);
}

#hand-container .card:active {
    transform: scale(1.4) translateY(-2px);
}

#hand-container .card-name {
    font-size: 0.45rem;
}

#hand-container .card-theme {
    font-size: 0.35rem;
}

/* Cards */
.card {
    width: 28%; /* Fit 3 per row comfortably */
    max-width: 100px;
    aspect-ratio: 2.5 / 3.5;
    background-color: #f7fafc;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 5px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 2px solid transparent;
}

.card:active {
    transform: scale(0.95);
}

.card.face-down {
    background-image: url('card_back.png');
    background-size: cover;
    background-position: center;
    border: 2px solid #2d3748;
}

.card.face-down > * {
    display: none;
}

.card.disabled {
    opacity: 0.6;
    pointer-events: none;
}

.card.highlight {
    border-color: #48bb78;
    box-shadow: 0 0 15px #48bb78;
    animation: pulseWin 1s infinite alternate;
}

@keyframes pulseWin {
    from { transform: scale(1); }
    to { transform: scale(1.05); }
}

.card-icon {
    width: 50%;
    height: 50%;
    object-fit: contain;
    margin-bottom: 5px;
}

.card-theme {
    font-size: 0.65rem;
    color: #4a5568;
    text-transform: uppercase;
    font-weight: bold;
    margin-bottom: 2px;
}

.card-name {
    font-size: 0.75rem;
    color: #1a202c;
    text-align: center;
    font-weight: bold;
    line-height: 1.1;
}

/* Modals */
.modal {
    background: rgba(0,0,0,0.85);
    z-index: 100;
    justify-content: center;
    align-items: center;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #f0f9ff;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    width: 90%;
    max-width: 400px;
    border: 2px solid #7dd3fc;
    color: #0f172a;
}

.modal-content.scrollable {
    max-height: 85vh;
    overflow-y: auto;
}

#reference-container {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
    margin: 15px 0;
}

#reference-container .card {
    width: 22%;
    max-width: 65px;
    pointer-events: none;
    padding: 2px;
}

#reference-container .card-name {
    font-size: 0.55rem;
}

#reference-container .card-theme {
    font-size: 0.45rem;
}

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

.modal-content h2.win-text { color: #48bb78; }
.modal-content h2.lose-text { color: #e53e3e; }

.scrollable-cards {
    max-height: 45vh;
    overflow-y: auto;
    margin: 15px 0;
}

.scrollable-cards h3 {
    font-size: 1rem;
    margin: 10px 0 5px;
    color: #0284c7;
    text-align: center;
}

.card-row {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
    margin-bottom: 10px;
}

.card-row .card {
    width: 22%;
    max-width: 65px;
    pointer-events: none;
    padding: 2px;
}

.card-row .card-name { font-size: 0.55rem; }
.card-row .card-theme { font-size: 0.45rem; }