:root {
    --bg-color: #1b5e20;
    --bg-gradient: radial-gradient(circle at center, rgb(34, 139, 74) 0%, rgb(20, 85, 48) 100%);
    --card-width: 100px;
    --card-height: 140px;
    --card-radius: 10px;
    --primary-color: #fff;
    --text-color: #333;
    --accent-color: rgb(212, 175, 55);
    /* Gold */
    --primary-btn-color: rgb(37, 99, 235);
    /* Blue */
    --utility-btn-gradient: linear-gradient(135deg, rgb(79, 70, 229), rgb(124, 58, 237));
    /* Purple Gradient */
    --input-bg: rgb(30, 41, 59);
    --input-border: rgb(51, 65, 85);
    --landing-container-bg: rgba(20, 85, 48, 0.85);
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --shadow-sm: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 8px 15px rgba(0, 0, 0, 0.2);
    --shadow-btn: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --font-main: 'Outfit', system-ui, sans-serif;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-main);
    background: var(--bg-gradient);
    color: white;
    height: 100vh;
    overflow: hidden;
    user-select: none;
}

#game-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    justify-content: space-between;
    padding: 20px;
    box-sizing: border-box;
}

/* Header */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    margin-bottom: 20px;
}

.game-header h1 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--accent-color);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.status-board {
    display: flex;
    gap: 15px;
    align-items: center;
}

#restart-btn {
    background: var(--accent-color);
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    color: #333;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s;
}

#restart-btn:hover {
    transform: scale(1.05);
}

/* Player Areas */
.player-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    min-height: 160px;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    background: rgba(0, 0, 0, 0.3);
    padding: 5px 15px;
    border-radius: 20px;
}

.avatar {
    font-size: 1.5rem;
}

.details {
    display: flex;
    flex-direction: column;
    font-size: 0.9rem;
}

.name {
    font-weight: bold;
    color: var(--accent-color);
}

/* Hands */
.hand {
    display: flex;
    justify-content: center;
    align-items: center;
    height: var(--card-height);
    margin-top: 10px;
    position: relative;
    perspective: 1000px;
}

.card {
    width: var(--card-width);
    height: var(--card-height);
    background: white;
    border-radius: var(--card-radius);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 10px;
    box-sizing: border-box;
    font-size: 1.2rem;
    font-weight: bold;
    position: relative;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), margin 0.3s;
    cursor: pointer;
    user-select: none;
    margin-left: -40px;
    /* Overlap */
}

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

.card:hover {
    transform: translateY(-20px) rotate(2deg) scale(1.1);
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.card.red {
    color: #e53935;
}

.card.black {
    color: #212121;
}

.card-top,
.card-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
}

.card-bottom {
    transform: rotate(180deg);
}

.card-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
}

.card-back {
    background: #1565c0;
    background-image: repeating-linear-gradient(45deg,
            hsla(0, 0%, 100%, .1),
            hsla(0, 0%, 100%, .1) 10px,
            transparent 10px,
            transparent 20px);
    border: 2px solid white;
    width: 100%;
    height: 100%;
    border-radius: var(--card-radius);
    box-sizing: border-box;
    position: absolute;
    top: 0;
    left: 0;
}

/* Opponent Hand (Hidden faces) */
#opponent-hand .card {
    cursor: default;
}

#opponent-hand .card:hover {
    transform: none;
}

/* Table Area */
#table-area {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
}

.card-stack {
    width: var(--card-width);
    height: var(--card-height);
    position: relative;
    border-radius: var(--card-radius);
}

#draw-pile {
    cursor: pointer;
}

#draw-pile .card-back {
    box-shadow: var(--shadow-md);
    transition: transform 0.2s;
}

#draw-pile:hover .card-back {
    transform: scale(1.05);
}

.discard-area {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#discard-pile {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

#discard-pile .card {
    margin-left: 0;
    cursor: default;
    transition: none;
}

#discard-pile .card:hover {
    transform: inherit;
    /* Keep the scattered rotation on hover */
}

#discard-pile .card.top-card {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

#suit-indicator {
    margin-top: 15px;
    /* Spacing from card */
    background: rgba(0, 0, 0, 0.6);
    padding: 5px 10px;
    border-radius: 10px;
    font-size: 0.9rem;
    pointer-events: none;
    /* Let clicks pass through if needed */
    z-index: 10;
}

/* Ensure the suit indicator display span has a visible processing */
#current-suit-display {
    text-transform: capitalize;
    font-weight: bold;
    color: var(--accent-color);
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal.hidden,
.hidden {
    display: none !important;
}

.modal-content {
    background: #fff;
    color: #333;
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    animation: popIn 0.3s ease-out;
}

@keyframes popIn {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.suit-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 20px;
}

.suit-btn {
    padding: 15px;
    font-size: 1.2rem;
    border: 2px solid #eee;
    background: white;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.suit-btn:hover {
    background: #f5f5f5;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.suit-btn.red {
    color: #e53935;
    border-color: #ffcdd2;
}

.suit-btn.black {
    color: #212121;
    border-color: #cfd8dc;
}

#play-again-btn {
    margin-top: 20px;
    padding: 10px 30px;
    font-size: 1.2rem;
    background: var(--bg-color);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
}

#message-area {
    position: absolute;
    top: -40px;
    width: 200px;
    text-align: center;
    color: var(--accent-color);
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    transition: opacity 0.5s ease;
}

/* Animations */
@keyframes deal {
    from {
        transform: translateY(-500px) rotate(180deg);
        opacity: 0;
    }

    to {
        transform: translateY(0) rotate(0);
        opacity: 1;
    }
}

.deal-anim {
    animation: deal 0.5s ease-out forwards;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

.shake {
    animation: shake 0.3s ease-in-out;
}

/* Rules Page Styles */
.rules-container {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    overflow-y: auto;
    padding: 0 20px 20px;

    /* Scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: var(--glass-border) transparent;
}

.rules-container::-webkit-scrollbar {
    width: 8px;
}

.rules-container::-webkit-scrollbar-thumb {
    background-color: var(--glass-border);
    border-radius: 4px;
}

.rules-content {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    padding: 30px;
    max-width: 800px;
    width: 100%;
    color: #eee;
    box-shadow: var(--shadow-md);
}

.rules-content section {
    margin-bottom: 25px;
}

.rules-content h2 {
    color: var(--accent-color);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
    margin-top: 0;
}

.rules-content ul {
    list-style-type: none;
    padding-left: 0;
}

.rules-content ul li {
    margin: 10px 0;
    padding-left: 20px;
    position: relative;
}

.rules-content ul li::before {
    content: '•';
    color: var(--accent-color);
    position: absolute;
    left: 0;
    font-weight: bold;
}

.nav-btn {
    background: white;
    color: #2e7d32;
    text-decoration: none;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: bold;
    transition: transform 0.2s, background 0.2s;
    display: inline-block;
}

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

    background: #f0f0f0;
}

.rules-btn {
    color: white;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 0.9rem;
    background: rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
}

.rules-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: white;
}

/* Multiplayer / Setup Styles */
.setup-section {
    margin-bottom: 20px;
    text-align: left;
}

.setup-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: var(--accent-color);
}

.setup-section input[type="number"] {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #ccc;
    font-size: 1rem;
    box-sizing: border-box;
}

.setup-hint {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 20px;
}

.small-text {
    font-size: 0.8rem;
    opacity: 0.7;
}

#start-game-btn {
    width: 100%;
    padding: 12px;
    background: var(--accent-color);
    background-color: #ffd700;
    border: none;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    color: #333;
}

#start-game-btn:hover {
    background-color: #ffca28;
}

/* Opponent Layout */
#opponents-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 10px;
    flex-wrap: wrap;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
}

.opponent-card {
    background: rgba(0, 0, 0, 0.3);
    padding: 10px 15px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
    transition: all 0.3s;
    border: 2px solid transparent;
}

.opponent-card.active-turn {
    border-color: var(--accent-color);
    background: rgba(255, 215, 0, 0.1);
    transform: scale(1.05);
}

.opponent-card .avatar {
    font-size: 2rem;
    margin-bottom: 5px;
}

.opponent-card .name {
    font-weight: bold;
    font-size: 0.9rem;
    margin-bottom: 5px;
    color: white;
}

.opponent-card .card-count {
    font-size: 0.8rem;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 10px;
}

/* Adjustments for multiple opponents */
.opponent-hand-mini {
    display: flex;
    margin-top: 5px;
}

.mini-card-back {
    width: 20px;
    height: 30px;
    background: #1565c0;
    border: 1px solid white;
    border-radius: 3px;
    margin-left: -15px;
}

/* Game Mode Buttons */
.mode-options {
    display: flex;
    gap: 10px;
}

.mode-btn {
    flex: 1;
    padding: 10px;
    background: transparent;
    border: 2px solid #ccc;
    border-radius: 8px;
    color: #ccc;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
}

.mode-btn:hover {
    border-color: white;
    color: white;
}

.mode-btn.selected {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: #333;
}

/* Discard Pile Container */
#discard-pile {
    position: relative;
    width: var(--card-width);
    height: var(--card-height);
    display: flex;
    justify-content: center;
    align-items: center;
}

#discard-pile .card {
    position: absolute;
    /* Crucial for stacking */
    margin: 0;
    cursor: default;
    transition: none;
    top: 0;
    left: 0;
    transform-origin: center center;
}

.flying-card {
    position: fixed;
    z-index: 9999;
    /* Slow 1.5s animation as requested */
    transition: transform 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    pointer-events: none;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.4);
}

/* Landing Page Overhaul */
.landing-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-gradient);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.landing-page.hidden {
    display: none !important;
}

.landing-card {
    background: var(--landing-container-bg);
    padding: 2.5rem;
    border-radius: 20px;
    width: 100%;
    max-width: 450px;
    text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.landing-header {
    margin-bottom: 2rem;
    position: relative;
}

.landing-title {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--accent-color);
    margin: 0 0 0.5rem 0;
    letter-spacing: -0.025em;
    text-transform: uppercase;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.landing-tagline {
    color: #cbd5e1;
    font-size: 0.95rem;
    margin: 0 0 1.5rem 0;
}

.utility-btn {
    display: inline-block;
    background: var(--utility-btn-gradient);
    color: white;
    padding: 0.5rem 1.25rem;
    border-radius: 9999px;
    font-weight: 600;
    font-size: 0.875rem;
    text-decoration: none;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    border: none;
    cursor: pointer;
}

.utility-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
}

.landing-body {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.landing-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    text-align: left;
}

.landing-label {
    color: #e2e8f0;
    font-size: 0.875rem;
    font-weight: 600;
    margin-left: 0.25rem;
}

.landing-input {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.landing-input:focus {
    border-color: var(--primary-btn-color);
}

.action-buttons-stack {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.primary-btn {
    width: 100%;
    background: var(--primary-btn-color);
    color: white;
    padding: 0.875rem;
    border-radius: 0.75rem;
    font-weight: 600;
    font-size: 1rem;
    border: none;
    cursor: pointer;
    box-shadow: var(--shadow-btn);
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

.primary-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.primary-btn.secondary-style {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: none;
}

.primary-btn.secondary-style:hover {
    background: rgba(255, 255, 255, 0.15);
}

.divider {
    display: flex;
    align-items: center;
    color: #94a3b8;
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0.5rem 0;
}

.divider::before,
.divider::after {
    content: "";
    flex: 1;
    border-bottom: 1px solid #334155;
}

.divider::before {
    margin-right: 1rem;
}

.divider::after {
    margin-left: 1rem;
}

.join-row {
    display: flex;
    gap: 0.5rem;
}

.join-row .landing-input {
    flex: 1;
}

.join-row .primary-btn {
    width: auto;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

/* Quick Match Button */
.primary-btn.quickmatch-style {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    font-size: 1.1rem;
    padding: 1rem;
}

.primary-btn.quickmatch-style:hover {
    background: linear-gradient(135deg, #fbbf24, #f87171);
}

.quickmatch-hint {
    color: #94a3b8;
    font-size: 0.8rem;
    margin: 0;
    text-align: center;
}