:root {
    --color-bg: #FFF8F0;
    --color-surface: #FFFFFF;
    --color-surface-2: #F5EDE0;
    --color-border: #E8DDD0;
    --color-text: #2C2218;
    --color-text-muted: #8A7A6A;
    --color-red: #E05252;
    --color-blue: #4A7DE8;
    --color-green: #3DAA72;
    --color-yellow: #F0A500;
    --color-wild: #1A1A1A;
    --color-accent: #E05252;
    --color-accent-bg: #FFF0F0;
    --card-shadow: 3px 3px 0 #E8DDD0;
    --card-radius: 8px;
    --ui-radius: 12px;
}

[data-theme="dark"] {
    --color-bg: #1A1512;
    --color-surface: #252018;
    --color-surface-2: #302820;
    --color-border: #4A3C2C;
    --color-text: #F0E8D8;
    --color-text-muted: #8A7A6A;
    --color-red: #FF7B7B;
    --color-blue: #7AABFF;
    --color-green: #5DD494;
    --color-yellow: #FFD166;
    --color-wild: #F0E8D8;
    --color-accent: #FF7B7B;
    --color-accent-bg: #3A1818;
    --card-shadow: 3px 3px 0 #0A0805;
    --card-radius: 8px;
    --ui-radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Nunito', sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    overflow-x: hidden;
}

#root {
    min-height: 100vh;
}

@keyframes wobble {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 0 0 var(--color-accent); }
    50% { box-shadow: 0 0 0 8px transparent; }
}

@keyframes slide-up {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes bounce-in {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.05); }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes confetti-fall {
    0% { transform: translateY(-100%) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

@keyframes card-flip {
    0% { transform: rotateY(0deg); }
    100% { transform: rotateY(180deg); }
}

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

.card-fan-item {
    animation: wobble 3s ease-in-out infinite;
}

.card-fan-item:nth-child(2) {
    animation-delay: 0.2s;
}

.card-fan-item:nth-child(3) {
    animation-delay: 0.4s;
}

.pulse-active {
    animation: pulse-glow 1.5s ease-in-out infinite;
}

.slide-up {
    animation: slide-up 0.3s ease-out;
}

.bounce-in {
    animation: bounce-in 0.5s ease-out;
}

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

.card-3d {
    transform-style: preserve-3d;
    transition: transform 0.3s ease-out;
}

.card-3d.flipped {
    transform: rotateY(180deg);
}

.card-3d .card-front,
.card-3d .card-back {
    backface-visibility: hidden;
    position: absolute;
    width: 100%;
    height: 100%;
}

.card-3d .card-back {
    transform: rotateY(180deg);
}

.hand-scroll {
    display: flex;
    overflow-x: auto;
    padding: 8px 0;
    gap: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.hand-scroll::-webkit-scrollbar {
    display: none;
}

.hand-card {
    flex-shrink: 0;
    margin-left: -12px;
    transition: transform 0.2s ease, margin 0.2s ease;
    cursor: pointer;
}

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

.hand-card.playable:hover,
.hand-card.playable:active {
    transform: translateY(-12px);
    z-index: 10;
}

.hand-card.selected {
    transform: translateY(-20px) !important;
    z-index: 20;
}

.hand-card.dimmed {
    opacity: 0.5;
    filter: grayscale(0.3);
}

/* Drag and Drop styles */
.player-item {
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    touch-action: none;
    user-select: none;
}

.player-item.dragging {
    opacity: 0.85;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.1);
    transform: scale(1.03);
    z-index: 100;
    background: var(--color-surface) !important;
}

.player-item.drag-over-above {
    border-top: 3px solid var(--color-accent) !important;
}

.player-item.drag-over-below {
    border-bottom: 3px solid var(--color-accent) !important;
}

.drag-handle {
    cursor: grab;
    padding: 8px;
    color: var(--color-text-muted);
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
}

.drag-handle:active {
    cursor: grabbing;
}

/* Card fly animation */
@keyframes card-fly-to-pile {
    0% {
        transform: translate(0, 0) scale(1) rotate(0deg);
        opacity: 1;
    }
    70% {
        transform: translate(var(--fly-x, 0px), var(--fly-y, -200px)) scale(0.6) rotate(15deg);
        opacity: 1;
    }
    100% {
        transform: translate(var(--fly-x, 0px), var(--fly-y, -200px)) scale(0.4) rotate(20deg);
        opacity: 0;
    }
}

.card-flying {
    animation: card-fly-to-pile 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    position: fixed;
    z-index: 1000;
    pointer-events: none;
}

/* Game mode cards responsive */
.game-modes-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

@media (min-width: 480px) {
    .game-modes-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Victory screen */
@keyframes trophy-bounce {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-12px) rotate(-5deg); }
    75% { transform: translateY(-6px) rotate(5deg); }
}

@keyframes victory-glow {
    0%, 100% { box-shadow: 0 0 20px rgba(240, 165, 0, 0.3); }
    50% { box-shadow: 0 0 40px rgba(240, 165, 0, 0.6), 0 0 60px rgba(240, 165, 0, 0.2); }
}

.trophy-bounce {
    animation: trophy-bounce 2s ease-in-out infinite;
}

.victory-card {
    animation: victory-glow 2s ease-in-out infinite;
}

/* Improved card pile appearance */
@keyframes pile-pop {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.pile-pop {
    animation: pile-pop 0.3s ease-out;
}

.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--ui-radius);
    padding: 10px 20px;
    box-shadow: var(--card-shadow);
    z-index: 1000;
    animation: slide-up 0.3s ease-out;
    font-size: 14px;
}

.confetti-piece {
    position: fixed;
    width: 10px;
    height: 10px;
    animation: confetti-fall 2s ease-out forwards;
}

/* Killer card flip */
.killer-card-inner {
    transform-style: preserve-3d;
}
.killer-card-flipped {
    transform: rotateY(180deg) !important;
}

/* Improved mobile scrolling for game area */
@media (max-height: 700px) {
    .game-area-center {
        gap: 6px !important;
    }
}

/* Better touch targets on small screens */
@media (max-width: 380px) {
    .hand-card {
        margin-left: -16px;
    }
}