/* Base Styles */
body {
    margin: 0;
    padding: 0;
    background-color: #121212;
    color: white;
    font-family: sans-serif;
    display: flex;
    justify-content: center;
    touch-action: manipulation;
    user-select: none;
}

.game-container {
    width: 100%;
    max-width: 500px;
    padding: 10px;
    position: relative; 
}

/* Top Bar and Title Layout */
#top-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 10px 5px 0 5px;
    margin-bottom: 15px;
}

#game-title {
    margin: 0;
    font-family: 'Audiowide', sans-serif;
    font-size: 1.8rem;
    line-height: 1.1;
    color: white;
    text-align: left;
}

/* Dropdown Menu Structure */
#menu-wrapper {
    position: relative;
}

#menu-btn {
    font-size: 1.8rem;
    cursor: pointer;
    color: white;
    line-height: 1.1;
    padding: 0 10px;
}

#dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 10px;
    background-color: rgba(34, 34, 34, 0.98);
    border: 2px solid #555;
    border-radius: 8px;
    min-width: 140px;
    z-index: 30;
    box-shadow: 0 4px 10px rgba(0,0,0,0.8);
    overflow: hidden;
}

#dropdown-menu.hidden {
    display: none;
}

.dropdown-item {
    padding: 12px 15px;
    color: white;
    cursor: pointer;
    border-bottom: 1px solid #444;
    font-size: 1.1rem;
    text-align: right;
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:active {
    background-color: #555;
}

/* Header (Deck and Messages) */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 0 5px;
}

#deck-container {
    width: 80px; 
    aspect-ratio: 533 / 764; /* Updated for new PNG dimensions */
    flex-shrink: 0; 
}

#message-board {
    font-size: 1.1rem;
    line-height: 1.4;
}

/* Grid and Cards */
.grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

.card-slot {
    aspect-ratio: 533 / 764; /* Updated for new PNG dimensions */
    background-color: #333;
    border: 2px dashed #555;
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    cursor: pointer;
}

.card {
    width: 100%;
    height: 100%;
    background-color: transparent; /* Changed from white to support rounded corner PNGs */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 4px;
    box-sizing: border-box;
    box-shadow: 1px 1px 3px rgba(0,0,0,0.5);
    transition: transform 0.1s ease-out, box-shadow 0.1s ease-out;
}

.card-back {
    background-image: url('./img/Back Red.png');
}

.selected {
    transform: scale(1.05) rotate(3deg);
    box-shadow: 3px 6px 12px rgba(0,0,0,0.8);
    z-index: 5;
}

/* Modals (Shared positioning) */
#inline-game-over, #stats-overlay, #about-overlay, #instructions-overlay {
    position: absolute;
    top: 120px; 
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    text-align: center;
    background-color: rgba(34, 34, 34, 0.98);
    border-radius: 8px;
    padding: 20px;
    color: white;
    box-shadow: 0 4px 15px rgba(0,0,0,0.8);
    box-sizing: border-box;
}

/* Wide Modals */
#stats-overlay, #about-overlay, #instructions-overlay { 
    width: 90%;
    max-width: 400px;
    border: 2px solid #555; 
}

/* Specific Instructions Formatting */
.instructions-text {
    text-align: left;
    font-size: 0.95rem;
    line-height: 1.4;
}

.instructions-text p {
    margin: 10px 0;
}

.instructions-text ul {
    margin: 5px 0 10px 0;
    padding-left: 25px;
}

.instructions-text li {
    margin-bottom: 5px;
}

/* Narrow Game Over Modal */
#inline-game-over { 
    width: 190px; 
    padding: 15px 10px; 
    border: 2px solid #ff4444; 
}
#inline-game-over.victory { border-color: #44ff44; }

#inline-cards-remaining {
    margin: -10px 0 15px 0;
    font-size: 0.9rem;
    color: #aaa;
}

#inline-cards-remaining.hidden {
    display: none;
}

#inline-game-over.hidden, #stats-overlay.hidden, #about-overlay.hidden, #instructions-overlay.hidden { display: none; }

#inline-title {
    margin: 0 0 5px 0;
    font-size: 1.5rem;
    color: #ff4444;
}

#inline-game-over.victory #inline-title { color: #44ff44; }

#inline-desc {
    margin: 0 0 20px 0;
    font-size: 1.1rem;
}

#inline-restart-btn {
    background-color: white;
    color: black;
    border: none;
    padding: 10px 20px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 5px;
    cursor: pointer;
    font-family: inherit;
}

#stats-overlay h2, #about-overlay h2, #instructions-overlay h2 {
    margin-top: 0;
    font-family: 'Audiowide', sans-serif;
}

#about-overlay p {
    margin: 10px 0;
    line-height: 1.4;
}

/* Animations */
.animate-shake {
    animation: shake 0.3s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.animate-vanish {
    animation: vanish 0.2s forwards;
}

@keyframes vanish {
    to {
        opacity: 0;
        transform: scale(0.5);
    }
}

.flying-card {
    position: fixed;
    z-index: 100;
    transition: transform 0.1s linear;
    pointer-events: none; 
    margin: 0;
    transform-origin: top left;
}