:root {
    --primary-color: #1b42a9;
    --secondary-color: #2c3e50;
    --accent-color: #f1c40f;
    --text-color: #ffffff;
    --bg-gradient: linear-gradient(to bottom, #1a2a6c, #b21f1f, #fdbb2d);
    /* Fallback */
    --card-width: 100px;
    /* Slightly smaller to fit mobile better */
    --card-height: 140px;
    --font-main: 'Outfit', sans-serif;
}

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

body {
    font-family: var(--font-main);
    background-color: #c0392b;
    /* Red felt */
    background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23962d22' fill-opacity='0.4' fill-rule='evenodd'%3E%3Cpath d='M0 38.59l2.83-2.83 1.41 1.41L1.41 40H0v-1.41zM0 1.4l2.83 2.83 1.41-1.41L1.41 0H0v1.41zM38.59 40l-2.83-2.83 1.41-1.41L40 38.59V40h-1.41zM40 1.41l-2.83 2.83-1.41-1.41L38.59 0H40v1.41zM20 18.6l2.83-2.83 1.41 1.41L21.41 20l2.83 2.83-1.41 1.41L20 21.41l-2.83 2.83-1.41-1.41L18.59 20l-2.83-2.83 1.41-1.41L20 18.59z'/%3E%3C/g%3E%3C/svg%3E");
    color: var(--text-color);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* Hide new bg layers */
.bg-layer,
.bg-overlay {
    display: none;
}

#app {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Glassmorphism Utilities */
.glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

.glass-dark {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    z-index: 10;
}

.logo h1 {
    font-size: 24px;
    font-weight: 900;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 10px;
}

.timer {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-color);
    background: rgba(255, 255, 255, 0.9);
    padding: 6px 12px;
    border-radius: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    min-width: 40px;
    text-align: center;
}

#menu-btn {
    margin-bottom: 6px;
}

.top-bar {
    height: 80px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    padding-top: 20px;
    /* Status bar space */
    z-index: 20;
    background: rgba(0, 0, 0, 0.1);
}

.game-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 20px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.icon-box {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
}

.icon-box:active {
    background: rgba(255, 255, 255, 0.3);
}

/* Scores */
.score-board {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 10px;
    z-index: 10;
}

.score-pill {
    background: rgba(255, 255, 255, 0.9);
    color: var(--primary-color);
    padding: 8px 20px;
    border-radius: 12px;
    text-align: center;
    min-width: 80px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.score-pill .label {
    font-size: 10px;
    color: #666;
    text-transform: uppercase;
    font-weight: 600;
}

.score-pill .value {
    font-size: 18px;
    font-weight: 700;
}

/* Game Area */
#game-board {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding-bottom: 20px;
    position: relative;
}

.computer-area {
    height: 160px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 12px;
    /* 12px below score board */
}

.center-area {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
}

.player-area {
    height: 180px;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding-bottom: 0;
    margin-bottom: 100px;
    margin-bottom: calc(100px + env(safe-area-inset-bottom));
    /* Moved up to clear floating controls */
}

/* Cards */
.hand {
    display: flex;
    gap: 10px;
    perspective: 1000px;
}

.card {
    width: var(--card-width);
    height: var(--card-height);
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    position: relative;
    transition: transform 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    transform-origin: center bottom;
    background: white;
    /* Default bg */
}

.card-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 10px;
    pointer-events: none;
}

.card.selected {
    transform: translateY(-20px) scale(1.05);
    box-shadow: 0 10px 25px rgba(27, 66, 169, 0.4);
    border: 2px solid var(--primary-color);
    z-index: 10;
}

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

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

@keyframes slideInBottom {
    from {
        transform: translateY(200px);
        opacity: 0;
    }

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

.card.enter-top {
    animation: slideInTop 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.card.enter-bottom {
    animation: slideInBottom 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Deck & Discard */
.deck-container,
.discard-container {
    position: relative;
    width: var(--card-width);
    height: var(--card-height);
}

.deck-label {
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

/* Controls */
.controls-bar {
    position: fixed;
    bottom: 30px;
    bottom: calc(30px + env(safe-area-inset-bottom));
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 20px;
    z-index: 100;
    pointer-events: none;
    padding-bottom: 0;
}

.controls-bar .btn {
    pointer-events: auto;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

.btn {
    padding: 12px 30px;
    border-radius: 16px;
    font-weight: 600;
    font-size: 16px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

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

.btn.primary {
    background: var(--primary-color);
    color: white;
}

.btn.primary:disabled {
    background: #94a3b8;
    cursor: not-allowed;
    opacity: 0.7;
}

.btn.secondary {
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn.secondary:disabled {
    border-color: #94a3b8;
    color: #94a3b8;
    cursor: not-allowed;
}

/* Toast Message / Turn Indicator */
.toast {
    position: absolute;
    top: 180px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    padding: 10px 24px;
    border-radius: 30px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
    z-index: 50;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Menu & Overlays */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(5px);
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    background: white;
    color: var(--secondary-color);
    border-radius: 24px;
    padding: 30px;
    width: 90%;
    max-width: 360px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    animation: popUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-align: center;
}

@keyframes popUp {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.overlay-content h2 {
    margin-bottom: 20px;
    color: var(--primary-color);
}

.overlay-content ul {
    text-align: left;
    margin-bottom: 20px;
    padding-left: 20px;
}

.overlay-content li {
    margin-bottom: 8px;
}

.menu-btn-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
}

.menu-btn-list .btn {
    width: 100%;
}

.log {
    height: 30px;
    color: var(--accent-color);
    font-weight: 600;
    text-align: center;
    margin-top: 10px;
}

.hidden {
    display: none !important;
}

.round-result {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.6);
    /* Dim background */
    z-index: 50;
    backdrop-filter: blur(4px);
}

.result-box {
    background: linear-gradient(135deg, #ffffff 0%, #f0f2f5 100%);
    padding: 40px;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.5);
    text-align: center;
    min-width: 300px;
    transform: scale(0.9);
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes popIn {
    from {
        transform: scale(0.5);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.score-board {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.score-box {
    background: rgba(255, 255, 255, 0.95);
    padding: 10px 20px;
    border-radius: 16px;
    text-align: center;
    min-width: 100px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.5);
}

.score-label {
    font-size: 11px;
    color: #666;
    font-weight: 800;
    letter-spacing: 1px;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.score-value {
    font-size: 28px;
    color: var(--primary-color);
    font-weight: 900;
    line-height: 1;
}

.scores-display {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 30px;
}

.score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(0, 0, 0, 0.05);
    padding: 15px 25px;
    border-radius: 16px;
}

.score-item .label {
    font-size: 12px;
    text-transform: uppercase;
    color: #666;
    font-weight: 700;
    margin-bottom: 5px;
}

.score-item .value {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary-color);
}

.result-box h3 {
    color: var(--primary-color);
    font-size: 24px;
    margin-bottom: 20px;
}

/* Start Screen */
.start-screen {
    height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: 10;
}

.game-logo {
    position: relative;
    width: 300px;
    height: auto;
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
}

.main-logo-img {
    width: 100%;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.3));
}



.main-title {
    font-size: 48px;
    font-weight: 800;
    color: white;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    margin-bottom: 40px;
    letter-spacing: 2px;
}

.start-controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    max-width: 280px;
}

.big-btn {
    padding: 16px;
    font-size: 18px;
    width: 100%;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.lobby-code-box {
    background: rgba(0, 0, 0, 0.1);
    padding: 15px;
    border-radius: 8px;
    margin: 20px 0;
    font-family: monospace;
    font-size: 14px;
    word-break: break-all;
    border: 1px dashed #ccc;
    color: #333;
}