/* Game Grid Styles - Poker Table Felt */

.grid-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Grid wrapper inside poker table */
.grid-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: clamp(4px, 0.8vh, 12px);
}

/* The main game grid - Poker table grid */
.game-grid {
    display: grid;
    grid-template-columns: repeat(10, var(--cell-size));
    grid-template-rows: repeat(10, var(--cell-size));
    gap: var(--grid-gap);
    background: transparent;
    padding: 0;
    position: relative;
    z-index: 1; /* Above highlight layer */
    /* Grid lines like poker table betting areas */
    border-radius: 4px;
}

/* Grid cell - Poker table betting spot look */
.grid-cell {
    width: var(--cell-size);
    height: var(--cell-size);
    /* Darker felt for grid cells */
    background: rgba(10, 50, 30, 0.4);
    border: 1px solid rgba(30, 80, 50, 0.5);
    border-radius: 2px;
    transition: all var(--transition-fast);
    position: relative;
    cursor: crosshair;
}

/* All children should pass pointer events to cell */
.grid-cell * {
    pointer-events: none;
}

/* Subtle depth on empty cells */
.grid-cell::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        /* Subtle inner shadow for sunken look */
        linear-gradient(180deg, rgba(0,0,0,0.1) 0%, transparent 30%, transparent 70%, rgba(0,0,0,0.05) 100%);
    border-radius: 2px;
    pointer-events: none;
}

/* Filled Cell - Poker Chip Look with 2.5D depth */
.grid-cell.filled {
    background: var(--blue-medium);
    border-color: var(--blue-light);
    border-radius: 3px;
    /* 2.5D chip stack effect */
    box-shadow:
        /* Highlight on top edge */
        inset 0 2px 0 0 rgba(255, 255, 255, 0.3),
        /* Shadow on bottom edge */
        inset 0 -2px 0 0 rgba(0, 0, 0, 0.25),
        /* Chip edge/stack */
        0 3px 0 0 rgba(0, 0, 0, 0.5),
        0 4px 0 0 rgba(0, 0, 0, 0.3),
        /* Drop shadow */
        0 5px 8px rgba(0, 0, 0, 0.4);
    transform: translateY(-2px);
    position: relative;
}

/* Glossy reflection on filled cells */
.grid-cell.filled::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 15%;
    width: 70%;
    height: 35%;
    background: linear-gradient(180deg, rgba(255,255,255,0.3) 0%, transparent 100%);
    border-radius: 50% 50% 50% 50% / 80% 80% 20% 20%;
    pointer-events: none;
}

/* Suit-colored filled cells - Poker chip colors */
.grid-cell.filled.hearts {
    background: linear-gradient(150deg, #ff6b6b 0%, #ef4444 40%, #dc2626 100%);
    border-color: #f87171;
    box-shadow:
        inset 0 2px 0 0 rgba(255, 180, 180, 0.4),
        inset 0 -2px 0 0 rgba(139, 0, 0, 0.3),
        0 3px 0 0 #991b1b,
        0 4px 0 0 #7f1d1d,
        0 5px 8px rgba(0, 0, 0, 0.4);
}

.grid-cell.filled.diamonds {
    background: linear-gradient(150deg, #60a5fa 0%, #3b82f6 40%, #2563eb 100%);
    border-color: #93c5fd;
    box-shadow:
        inset 0 2px 0 0 rgba(147, 197, 253, 0.4),
        inset 0 -2px 0 0 rgba(30, 58, 138, 0.3),
        0 3px 0 0 #1e40af,
        0 4px 0 0 #1e3a8a,
        0 5px 8px rgba(0, 0, 0, 0.4);
}

.grid-cell.filled.clubs {
    background: linear-gradient(150deg, #4ade80 0%, #22c55e 40%, #16a34a 100%);
    border-color: #86efac;
    box-shadow:
        inset 0 2px 0 0 rgba(134, 239, 172, 0.4),
        inset 0 -2px 0 0 rgba(20, 83, 45, 0.3),
        0 3px 0 0 #15803d,
        0 4px 0 0 #14532d,
        0 5px 8px rgba(0, 0, 0, 0.4);
}

.grid-cell.filled.spades {
    background: linear-gradient(150deg, #a78bfa 0%, #8b5cf6 40%, #7c3aed 100%);
    border-color: #c4b5fd;
    box-shadow:
        inset 0 2px 0 0 rgba(196, 181, 253, 0.4),
        inset 0 -2px 0 0 rgba(76, 29, 149, 0.3),
        0 3px 0 0 #6d28d9,
        0 4px 0 0 #5b21b6,
        0 5px 8px rgba(0, 0, 0, 0.4);
}

/* Rank display on filled cells */
.grid-cell.filled .cell-rank {
    position: absolute;
    top: 1px;
    left: 2px;
    font-family: var(--font-pixel);
    font-size: calc(var(--cell-size) * 0.35);
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.6);
    z-index: 5;
    line-height: 1;
    font-weight: bold;
}

/* Suit display on filled cells */
.grid-cell.filled .cell-suit {
    position: absolute;
    bottom: 1px;
    right: 2px;
    font-size: calc(var(--cell-size) * 0.35);
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5);
    z-index: 5;
    line-height: 1;
}

/* Fallback suit symbol on filled cells (for cells without explicit display) */
.grid-cell.filled:not(:has(.cell-suit))::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: calc(var(--cell-size) * 0.5);
    opacity: 0.4;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
}

.grid-cell.filled.hearts:not(:has(.cell-suit))::after { content: '♥'; color: #fff; }
.grid-cell.filled.diamonds:not(:has(.cell-suit))::after { content: '♦'; color: #fff; }
.grid-cell.filled.clubs:not(:has(.cell-suit))::after { content: '♣'; color: #fff; }
.grid-cell.filled.spades:not(:has(.cell-suit))::after { content: '♠'; color: #fff; }

/* Special block states */
.grid-cell.filled.gold {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 50%, #d97706 100%);
    border-color: #fcd34d;
    animation: gold-shimmer 2s infinite;
    box-shadow: 
        inset -3px -3px 0 0 #92400e,
        inset 3px 3px 0 0 #fde68a,
        0 4px 0 0 #78350f,
        0 0 20px rgba(251, 191, 36, 0.5);
}

@keyframes gold-shimmer {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.3); }
}

.grid-cell.filled.glass {
    background: rgba(59, 130, 246, 0.3);
    border-color: var(--blue-light);
    backdrop-filter: blur(4px);
    box-shadow: 
        inset 0 0 20px rgba(96, 165, 250, 0.3),
        0 4px 0 0 rgba(0, 0, 0, 0.2);
}

.grid-cell.filled.steel {
    background: linear-gradient(135deg, #64748b 0%, #475569 50%, #334155 100%);
    border-color: #94a3b8;
    box-shadow: 
        inset -3px -3px 0 0 #1e293b,
        inset 3px 3px 0 0 #cbd5e1,
        0 4px 0 0 #1e293b;
}

.grid-cell.filled.wild {
    background: linear-gradient(135deg, var(--purple) 0%, var(--cyan) 50%, var(--pink) 100%);
    border-color: var(--blue-pale);
    animation: rainbow-glow 3s infinite linear;
}

/* Preview/Ghost piece - Fluid visual snapping */
.grid-cell.preview {
    background: rgba(80, 160, 255, 0.55);
    border: 2px solid rgba(120, 180, 255, 0.8);
    border-radius: 3px;
    transform: scale(0.92);
    transition: transform 0.08s ease-out, background 0.08s ease-out, border-color 0.08s ease-out;
    box-shadow:
        inset 0 0 10px rgba(59, 130, 246, 0.4),
        0 0 8px rgba(59, 130, 246, 0.3),
        0 2px 4px rgba(0, 0, 0, 0.2);
    /* Smooth snapping feel */
    animation: preview-appear 0.1s ease-out forwards;
}

@keyframes preview-appear {
    0% { transform: scale(0.8); opacity: 0.4; }
    100% { transform: scale(0.92); opacity: 1; }
}

/* Valid placement pulse */
.grid-cell.preview:not(.invalid) {
    animation: preview-appear 0.1s ease-out forwards, preview-pulse 1.5s ease-in-out infinite 0.1s;
}

@keyframes preview-pulse {
    0%, 100% {
        box-shadow: inset 0 0 10px rgba(59, 130, 246, 0.4), 0 0 8px rgba(59, 130, 246, 0.3), 0 2px 4px rgba(0, 0, 0, 0.2);
    }
    50% {
        box-shadow: inset 0 0 15px rgba(59, 130, 246, 0.5), 0 0 12px rgba(59, 130, 246, 0.4), 0 2px 4px rgba(0, 0, 0, 0.2);
    }
}

/* Invalid placement - can't place here */
.grid-cell.preview.invalid {
    background: rgba(239, 68, 68, 0.35);
    border: 2px dashed rgba(255, 100, 100, 0.7);
    animation: preview-invalid 0.15s ease-out forwards;
    box-shadow:
        inset 0 0 8px rgba(239, 68, 68, 0.3),
        0 0 6px rgba(239, 68, 68, 0.2);
}

@keyframes preview-invalid {
    0% { transform: scale(0.8); opacity: 0.4; }
    100% { transform: scale(0.9); opacity: 0.8; }
}

/* Filled cell under cursor - subtle indicator */
.grid-cell.filled.preview-blocked {
    filter: brightness(0.8);
}

/* Clearing animation - Dramatic (for scoring cells) */
.grid-cell.clearing {
    animation: clearCell 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes clearCell {
    0% {
        transform: translateZ(4px) scale(1);
        opacity: 1;
    }
    30% {
        transform: translateZ(20px) scale(1.3);
        opacity: 1;
        filter: brightness(2);
    }
    100% {
        transform: translateZ(50px) scale(0) rotateZ(180deg);
        opacity: 0;
    }
}

/* ===== SCORING CASCADE SYSTEM ===== */

/* Highlight layer for cleared lines - sits behind cells */
.highlight-layer {
    transition: opacity 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.highlight-layer.fade-out {
    opacity: 0;
}

/* Scoring block actively being scored */
.grid-cell.scoring-active {
    animation: scoring-pulse 0.4s ease-out;
    background: linear-gradient(145deg, #ffd700, #ffb800) !important;
    border-color: #ffdf00 !important;
    filter: brightness(1.3);
    transform: translateZ(15px) scale(1.15);
    z-index: 100;
    box-shadow:
        0 0 25px rgba(255, 215, 0, 0.8),
        0 0 50px rgba(255, 180, 0, 0.5),
        inset 0 2px 0 rgba(255, 255, 255, 0.5),
        inset 0 -2px 0 rgba(0, 0, 0, 0.2);
}

@keyframes scoring-pulse {
    0% {
        transform: translateZ(0) scale(1);
        filter: brightness(1);
    }
    30% {
        transform: translateZ(25px) scale(1.3);
        filter: brightness(2.5);
    }
    100% {
        transform: translateZ(15px) scale(1.15);
        filter: brightness(1.8);
    }
}

/* Scoring block after being scored - glowing */
.grid-cell.scoring-scored {
    background: linear-gradient(145deg, #ffc800, #e6a800) !important;
    border-color: #ffd000 !important;
    filter: brightness(1.1);
    transform: translateZ(10px) scale(1.08);
    box-shadow:
        0 0 15px rgba(255, 200, 0, 0.6),
        0 0 30px rgba(255, 180, 0, 0.3),
        inset 0 2px 0 rgba(255, 255, 255, 0.4),
        inset 0 -2px 0 rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
}

/* Chip value popup on each block */
.chip-popup {
    position: absolute;
    font-family: var(--font-pixel);
    font-size: 14px;
    font-weight: bold;
    color: #4ade80;
    text-shadow:
        0 0 8px rgba(74, 222, 128, 0.8),
        1px 1px 0 rgba(0, 0, 0, 0.8);
    pointer-events: none;
    z-index: 200;
    animation: chip-float 0.8s ease-out forwards;
    white-space: nowrap;
}

.chip-popup.mult {
    color: #f87171;
    text-shadow:
        0 0 8px rgba(248, 113, 113, 0.8),
        1px 1px 0 rgba(0, 0, 0, 0.8);
}

@keyframes chip-float {
    0% {
        opacity: 0;
        transform: translateY(0) scale(0.5);
    }
    20% {
        opacity: 1;
        transform: translateY(-10px) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translateY(-40px) scale(0.8);
    }
}

/* ===== FLOATING TALLY (randomly positioned) ===== */
.floating-tally {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 18px;
    background: linear-gradient(135deg, rgba(15, 25, 45, 0.92), rgba(8, 12, 25, 0.95));
    border: 2px solid rgba(74, 222, 128, 0.5);
    border-radius: 10px;
    font-family: var(--font-pixel);
    pointer-events: none;
    z-index: 500;
    animation: tally-pop-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    box-shadow:
        0 0 25px rgba(74, 222, 128, 0.25),
        0 8px 20px rgba(0, 0, 0, 0.4);
}

@keyframes tally-pop-in {
    0% {
        opacity: 0;
        scale: 0.5;
    }
    100% {
        opacity: 1;
        scale: 1;
    }
}

.floating-tally .tally-hand {
    font-size: 16px;
    color: #22d3ee;
    text-shadow: 0 0 12px rgba(34, 211, 238, 0.7);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.floating-tally .tally-equation {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 20px;
}

.floating-tally .tally-chips {
    color: #4ade80;
    min-width: 40px;
    text-align: right;
    text-shadow: 0 0 10px rgba(74, 222, 128, 0.7);
}

.floating-tally .tally-mult {
    color: #f87171;
    min-width: 30px;
    text-shadow: 0 0 10px rgba(248, 113, 113, 0.7);
}

.floating-tally .tally-op {
    color: #64748b;
    font-size: 16px;
}

.floating-tally .tally-result {
    color: #fbbf24;
    min-width: 50px;
    font-size: 24px;
    text-shadow: 0 0 15px rgba(251, 191, 36, 0.7);
}

.floating-tally .tally-result.final-score {
    font-size: 30px;
    color: #ffd700;
    text-shadow:
        0 0 25px rgba(255, 215, 0, 0.9),
        0 0 50px rgba(255, 215, 0, 0.5);
    animation: final-pop 0.25s ease-out;
}

@keyframes final-pop {
    0% { scale: 1; }
    50% { scale: 1.5; }
    100% { scale: 1.15; }
}

.floating-tally.final {
    border-color: rgba(255, 215, 0, 0.7);
    box-shadow:
        0 0 35px rgba(255, 215, 0, 0.4),
        0 8px 25px rgba(0, 0, 0, 0.5);
}

.floating-tally.fade-out {
    animation: tally-pop-out 0.4s ease-out forwards;
}

@keyframes tally-pop-out {
    0% { opacity: 1; scale: 1; }
    100% { opacity: 0; scale: 1.3; }
}

.floating-tally .bump {
    animation: value-bump 0.12s ease-out;
}

@keyframes value-bump {
    0% { scale: 1; }
    50% { scale: 1.35; }
    100% { scale: 1; }
}

/* ===== FLOATING CHIP VALUES ===== */
.floating-chip {
    position: absolute;
    font-family: var(--font-pixel);
    font-size: 15px;
    font-weight: bold;
    color: #4ade80;
    text-shadow:
        0 0 12px rgba(74, 222, 128, 0.9),
        2px 2px 0 rgba(0, 0, 0, 0.8);
    pointer-events: none;
    z-index: 400;
    animation: chip-burst 0.7s ease-out forwards;
    --offset-x: 0px;
    --rotation: 0deg;
}

@keyframes chip-burst {
    0% {
        opacity: 0;
        transform: translateY(0) translateX(var(--offset-x)) rotate(0deg) scale(0.5);
    }
    20% {
        opacity: 1;
        transform: translateY(-15px) translateX(var(--offset-x)) rotate(var(--rotation)) scale(1.3);
    }
    100% {
        opacity: 0;
        transform: translateY(-45px) translateX(var(--offset-x)) rotate(var(--rotation)) scale(0.7);
    }
}

/* ===== FLOATING JOKER TRIGGER ===== */
.floating-joker {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 14px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.4), rgba(88, 28, 135, 0.4));
    border: 2px solid rgba(167, 139, 250, 0.6);
    border-radius: 8px;
    font-family: var(--font-pixel);
    pointer-events: none;
    z-index: 450;
    animation: joker-burst 1s ease-out forwards;
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.4);
}

@keyframes joker-burst {
    0% {
        opacity: 0;
        scale: 0.5;
    }
    15% {
        opacity: 1;
        scale: 1.1;
    }
    80% {
        opacity: 1;
        scale: 1;
    }
    100% {
        opacity: 0;
        scale: 0.9;
    }
}

.floating-joker .joker-name {
    font-size: 11px;
    color: #c4b5fd;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.floating-joker .joker-effect {
    font-size: 14px;
    color: #fbbf24;
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.6);
}

/* Row/Column highlight */
.grid-cell.row-highlight,
.grid-cell.col-highlight {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.4);
}

/* Full row/col ready to clear */
.grid-cell.ready-clear {
    animation: ready-pulse 0.5s infinite;
}

@keyframes ready-pulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.5); }
}

/* Grid Overlay for effects */
.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

/* Piece Selection Area - Card Hand Display */
.piece-selection {
    display: flex;
    gap: clamp(16px, 2.5vw, 40px);
    justify-content: center;
    align-items: flex-end;
    padding: clamp(8px, 1.2vh, 16px);
    perspective: var(--perspective);
}

/* Piece Slot - Living 2.5D Playing Card */
.piece-slot {
    width: var(--piece-card-width);
    height: var(--piece-card-height);
    background: linear-gradient(165deg, #ffffff 0%, #f8f6f0 30%, #e8e4dc 70%, #d8d4cc 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition:
        transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow 0.2s ease-out,
        filter 0.15s ease;
    position: relative;
    transform-style: preserve-3d;
    /* 2.5D card appearance - thicker, more depth */
    border-radius: 10px;
    border: none;
    box-shadow:
        /* Thick card edge - layered effect */
        0 1px 0 0 #f0ece4,
        0 2px 0 0 #e8e4dc,
        0 3px 0 0 #e0dcd4,
        0 4px 0 0 #d8d4cc,
        0 5px 0 0 #d0ccc4,
        0 6px 0 0 #c8c4bc,
        /* Main shadow */
        0 8px 12px rgba(0, 0, 0, 0.15),
        0 16px 24px rgba(0, 0, 0, 0.12),
        /* Ambient occlusion */
        0 2px 4px rgba(0, 0, 0, 0.08);
    overflow: visible;
    /* Subtle idle animation - card breathes */
    animation: card-idle 3s ease-in-out infinite;
}

@keyframes card-idle {
    0%, 100% {
        transform: translateY(0) rotateX(0deg) rotateY(0deg);
    }
    50% {
        transform: translateY(-2px) rotateX(0.5deg) rotateY(0.3deg);
    }
}

/* Stop idle animation on hover/selected */
.piece-slot:hover,
.piece-slot.selected {
    animation: none;
}

/* Card face highlight - glossy effect */
.piece-slot::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(
        180deg,
        rgba(255,255,255,0.4) 0%,
        rgba(255,255,255,0.15) 30%,
        transparent 100%
    );
    border-radius: 10px 10px 0 0;
    pointer-events: none;
    z-index: 1;
    transition: opacity 0.2s ease;
}

/* Card inner border - embossed look */
.piece-slot::before {
    content: '';
    position: absolute;
    top: 5px;
    left: 5px;
    right: 5px;
    bottom: 5px;
    border: 2px solid rgba(0, 0, 0, 0.04);
    border-radius: 6px;
    pointer-events: none;
    z-index: 1;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.03);
}

/* Hotkey indicator - 3D keyboard key */
.piece-slot .slot-hotkey {
    position: absolute;
    top: 8px;
    left: 8px;
    min-width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-pixel);
    font-size: 11px;
    font-weight: bold;
    color: #444;
    background: linear-gradient(180deg, #f0f0f0 0%, #d8d8d8 50%, #c8c8c8 100%);
    border-radius: 4px;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.9),
        inset 0 -1px 0 rgba(0,0,0,0.1),
        0 2px 0 #a0a0a0,
        0 3px 0 #888,
        0 4px 6px rgba(0,0,0,0.3);
    z-index: 5;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

/* Disabled hotkey for face-down cards */
.piece-slot .slot-hotkey.disabled {
    color: #888;
    background: linear-gradient(180deg, #a0a0a0 0%, #888 50%, #777 100%);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.3),
        inset 0 -1px 0 rgba(0,0,0,0.1),
        0 1px 0 #666,
        0 2px 3px rgba(0,0,0,0.2);
    opacity: 0.6;
}

/* Hover - Card lifts and tilts towards viewer */
.piece-slot:hover {
    transform: translateY(-10px) rotateX(5deg) scale(1.02);
    box-shadow:
        0 1px 0 0 #f0ece4,
        0 2px 0 0 #e8e4dc,
        0 3px 0 0 #e0dcd4,
        0 4px 0 0 #d8d4cc,
        0 5px 0 0 #d0ccc4,
        0 6px 0 0 #c8c4bc,
        /* Elevated shadow */
        0 15px 20px rgba(0, 0, 0, 0.2),
        0 25px 40px rgba(0, 0, 0, 0.15),
        0 5px 10px rgba(0, 0, 0, 0.1);
    filter: brightness(1.03);
}

.piece-slot:hover::after {
    opacity: 0.8;
}

.piece-slot:hover .slot-hotkey {
    transform: translateY(-1px);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.9),
        inset 0 -1px 0 rgba(0,0,0,0.1),
        0 3px 0 #a0a0a0,
        0 4px 0 #888,
        0 5px 8px rgba(0,0,0,0.35);
}

/* Selected - Card lifted with glow and gentle sway */
.piece-slot.selected {
    animation: card-selected-float 2.5s ease-in-out infinite;
    box-shadow:
        /* Tinted card edge */
        0 1px 0 0 #d4e4f8,
        0 2px 0 0 #c4d8f0,
        0 3px 0 0 #b4cce8,
        0 4px 0 0 #a4c0e0,
        0 5px 0 0 #94b4d8,
        0 6px 0 0 #84a8d0,
        /* Big elevated shadow */
        0 20px 30px rgba(0, 0, 0, 0.25),
        0 35px 50px rgba(0, 0, 0, 0.18),
        /* Selection glow */
        0 0 0 3px rgba(59, 130, 246, 0.5),
        0 0 30px rgba(59, 130, 246, 0.3),
        0 0 60px rgba(59, 130, 246, 0.15);
    filter: brightness(1.08);
    /* Smooth transition into selected state */
    transition: box-shadow 0.25s ease, filter 0.25s ease;
}

/* Gentle floating sway while selected */
@keyframes card-selected-float {
    0%, 100% {
        transform: translateY(-16px) rotateX(7deg) rotateZ(-0.8deg) scale(1.08);
    }
    50% {
        transform: translateY(-20px) rotateX(9deg) rotateZ(0.8deg) scale(1.08);
    }
}

.piece-slot.selected::after {
    background: linear-gradient(
        180deg,
        rgba(180, 210, 255, 0.5) 0%,
        rgba(150, 190, 255, 0.2) 30%,
        transparent 100%
    );
}

.piece-slot.selected .slot-hotkey {
    background: linear-gradient(180deg, #b8d4f8 0%, #90b8e8 50%, #78a8d8 100%);
    color: #1a365d;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.9),
        0 2px 0 #5a8ac0,
        0 3px 0 #4a7ab0,
        0 4px 8px rgba(0,0,0,0.3);
    animation: hotkey-pulse 2s ease-in-out infinite;
}

@keyframes hotkey-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow:
            inset 0 1px 0 rgba(255,255,255,0.9),
            0 2px 0 #5a8ac0,
            0 3px 0 #4a7ab0,
            0 4px 8px rgba(0,0,0,0.3);
    }
    50% {
        transform: scale(1.05);
        box-shadow:
            inset 0 1px 0 rgba(255,255,255,0.9),
            0 2px 0 #5a8ac0,
            0 3px 0 #4a7ab0,
            0 4px 8px rgba(0,0,0,0.3),
            0 0 10px rgba(59, 130, 246, 0.4);
    }
}

/* Active/Pressing - Card pushes down slightly */
.piece-slot:active:not(.empty) {
    transform: translateY(-4px) rotateX(2deg) scale(0.98);
    transition: transform 0.05s ease;
    box-shadow:
        0 1px 0 0 #e8e4dc,
        0 2px 0 0 #e0dcd4,
        0 3px 0 0 #d8d4cc,
        0 6px 10px rgba(0, 0, 0, 0.2),
        0 10px 20px rgba(0, 0, 0, 0.15);
}

.piece-slot:active .slot-hotkey {
    transform: translateY(2px);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.5),
        0 1px 0 #a0a0a0,
        0 2px 4px rgba(0,0,0,0.2);
}

/* Empty slot - ghostly placeholder */
.piece-slot.empty {
    background: linear-gradient(165deg, #3a3a4a 0%, #2a2a3a 50%, #1a1a25 100%);
    opacity: 0.5;
    cursor: not-allowed;
    animation: slot-empty-appear 0.3s ease-out;
    transform: translateY(0) scale(0.95);
    box-shadow:
        0 1px 0 0 #333,
        0 2px 0 0 #2a2a2a,
        0 3px 0 0 #222,
        0 4px 8px rgba(0, 0, 0, 0.3);
    filter: saturate(0.3);
}

@keyframes slot-empty-appear {
    0% {
        opacity: 0.8;
        transform: scale(1);
    }
    100% {
        opacity: 0.5;
        transform: scale(0.95);
    }
}

.piece-slot.empty::before {
    border-color: rgba(255, 255, 255, 0.03);
    box-shadow: none;
}

.piece-slot.empty::after {
    background: linear-gradient(180deg, rgba(255,255,255,0.05) 0%, transparent 50%);
    opacity: 0.5;
}

.piece-slot.empty:hover {
    transform: translateY(0) scale(0.95);
    opacity: 0.6;
    filter: saturate(0.3) brightness(1.1);
}

/* Card deal animation - when new cards appear */
.piece-slot.dealing {
    animation: card-deal 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.piece-slot[data-slot="0"].dealing { animation-delay: 0ms; }
.piece-slot[data-slot="1"].dealing { animation-delay: 80ms; }
.piece-slot[data-slot="2"].dealing { animation-delay: 160ms; }

@keyframes card-deal {
    0% {
        transform: translateY(100px) translateX(-30px) rotateZ(-15deg) scale(0.5);
        opacity: 0;
    }
    60% {
        transform: translateY(-8px) translateX(0) rotateZ(2deg) scale(1.03);
        opacity: 1;
    }
    100% {
        transform: translateY(0) translateX(0) rotateZ(0) scale(1);
        opacity: 1;
    }
}

/* Error shake for empty slot click */
.piece-slot.error-shake {
    animation: slot-error-shake 0.4s ease;
}

@keyframes slot-error-shake {
    0%, 100% { transform: translateX(0); }
    10% { transform: translateX(-8px); }
    20% { transform: translateX(8px); }
    30% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    50% { transform: translateX(-4px); }
    60% { transform: translateX(4px); }
    70% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
}

.piece-slot.error-shake.empty {
    box-shadow:
        inset 0 0 30px rgba(239, 68, 68, 0.2),
        0 2px 0 0 #7f1d1d,
        0 4px 0 0 #450a0a,
        0 8px 15px rgba(0, 0, 0, 0.3),
        0 0 20px rgba(239, 68, 68, 0.4);
}

/* ===== DECK OF CARDS UNDERNEATH (using box-shadow) ===== */
.piece-slot.has-pile {
    box-shadow:
        /* Original card edge shadows */
        0 1px 0 0 #f0ece4,
        0 2px 0 0 #e8e4dc,
        0 3px 0 0 #e0dcd4,
        0 4px 0 0 #d8d4cc,
        0 5px 0 0 #d0ccc4,
        0 6px 0 0 #c8c4bc,
        /* First stacked card behind - blue */
        3px 10px 0 0 #1a2a4a,
        4px 11px 0 0 #0a1a30,
        /* Second stacked card behind - darker blue */
        6px 14px 0 0 #0a1a30,
        7px 15px 0 0 #050a18,
        /* Shadows */
        0 8px 12px rgba(0, 0, 0, 0.15),
        8px 20px 20px rgba(0, 0, 0, 0.2);
}

/* When card is selected - lifted off the deck, face-down card visible below */
.piece-slot.has-pile.selected {
    box-shadow:
        /* Card edge */
        0 1px 0 0 #d4e4f8,
        0 2px 0 0 #c4d8f0,
        0 3px 0 0 #b4cce8,
        0 4px 0 0 #a4c0e0,
        0 5px 0 0 #94b4d8,
        0 6px 0 0 #84a8d0,
        /* Face-down card revealed underneath - more visible */
        4px 20px 0 0 #2a3a5a,
        5px 21px 0 0 #1a2a4a,
        6px 22px 0 0 #1a2a4a,
        7px 23px 0 0 #0a1a30,
        /* Second stacked card */
        9px 27px 0 0 #0a1a30,
        10px 28px 0 0 #050a18,
        /* Lifted shadow */
        0 25px 35px rgba(0, 0, 0, 0.3),
        10px 35px 40px rgba(0, 0, 0, 0.25),
        /* Selection glow */
        0 0 0 3px rgba(59, 130, 246, 0.5),
        0 0 30px rgba(59, 130, 246, 0.3);
}

/* When hovering - slight lift, peek at deck */
.piece-slot.has-pile:hover:not(.selected) {
    box-shadow:
        /* Card edge */
        0 1px 0 0 #f0ece4,
        0 2px 0 0 #e8e4dc,
        0 3px 0 0 #e0dcd4,
        0 4px 0 0 #d8d4cc,
        0 5px 0 0 #d0ccc4,
        0 6px 0 0 #c8c4bc,
        /* Face-down card more visible on hover */
        3px 14px 0 0 #2a3a5a,
        4px 15px 0 0 #1a2a4a,
        5px 16px 0 0 #0a1a30,
        /* Second stacked card */
        7px 19px 0 0 #0a1a30,
        8px 20px 0 0 #050a18,
        /* Hover shadow */
        0 15px 25px rgba(0, 0, 0, 0.2),
        8px 25px 30px rgba(0, 0, 0, 0.18);
}

/* ===== FACE-DOWN CARD STYLING ===== */
.piece-slot.face-down {
    background: linear-gradient(165deg, #2a3a5a 0%, #1a2a4a 50%, #0a1a30 100%);
    cursor: not-allowed;
    animation: none;
}

.piece-slot.face-down::after {
    background: linear-gradient(180deg, rgba(100, 150, 255, 0.1) 0%, transparent 50%);
}

.card-back-pattern {
    position: absolute;
    top: 10%;
    left: 10%;
    width: 80%;
    height: 80%;
    background:
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 5px,
            rgba(100, 150, 255, 0.1) 5px,
            rgba(100, 150, 255, 0.1) 10px
        ),
        repeating-linear-gradient(
            -45deg,
            transparent,
            transparent 5px,
            rgba(100, 150, 255, 0.1) 5px,
            rgba(100, 150, 255, 0.1) 10px
        );
    border: 2px solid rgba(100, 150, 255, 0.2);
    border-radius: 4px;
    box-shadow: inset 0 0 20px rgba(100, 150, 255, 0.1);
}

/* Question mark or back design */
.card-back-pattern::after {
    content: '?';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: clamp(24px, 4vh, 40px);
    color: rgba(100, 150, 255, 0.3);
    font-family: var(--font-pixel);
    font-weight: bold;
}

/* ===== FLIP REVEAL ANIMATION ===== */
.piece-slot.flipping {
    animation: card-flip 0.28s ease-in-out;
    transform-style: preserve-3d;
    /* Disable box-shadow transition during flip to prevent flash */
    transition: none !important;
}

@keyframes card-flip {
    0% {
        transform: rotateY(0deg);
    }
    50% {
        transform: rotateY(90deg) scale(0.95);
    }
    100% {
        transform: rotateY(0deg);
    }
}

/* ===== HOTKEY TRANSITION ===== */
.slot-hotkey.hotkey-transition {
    animation: hotkey-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes hotkey-pop {
    0% {
        transform: scale(1.5);
        opacity: 0.5;
        background: var(--gold);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Card corners for piece slots */
.piece-slot .card-corner {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: var(--font-pixel);
    line-height: 1;
    z-index: 3;
}

.piece-slot .card-corner.top-right {
    top: 10px;
    right: 10px;
}

.piece-slot .card-corner.bottom-left {
    bottom: 10px;
    left: 10px;
    transform: rotate(180deg);
}

.piece-slot .corner-rank {
    font-size: clamp(12px, 1.6vh, 18px);
    font-weight: bold;
}

.piece-slot .corner-suit {
    font-size: clamp(10px, 1.3vh, 14px);
}

/* Center suit symbol */
.piece-slot .center-suit {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: clamp(28px, 4vh, 48px);
    opacity: 0.15;
    z-index: 1;
    pointer-events: none;
}

/* Piece Preview inside slot - Card face */
.piece-preview {
    display: grid;
    gap: 2px;
    position: relative;
    z-index: 2;
}

.piece-preview .piece-cell {
    width: 14px;
    height: 14px;
    border-radius: 2px;
    box-shadow:
        inset -1px -1px 0 0 rgba(0,0,0,0.3),
        inset 1px 1px 0 0 rgba(255,255,255,0.3);
}

.piece-preview .piece-cell.hearts {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}
.piece-preview .piece-cell.diamonds {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}
.piece-preview .piece-cell.clubs {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}
.piece-preview .piece-cell.spades {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

/* Dragging Piece - Floating Card */
.dragging-piece {
    position: fixed;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 2000;
    opacity: 0.95;
    display: grid;
    gap: 3px;
    /* GPU acceleration for smooth movement */
    will-change: transform;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.5));
}

/* Touch-specific dragging styles */
.dragging-piece.touch-drag {
    /* Larger drop shadow for better visibility above finger */
    filter: drop-shadow(0 15px 30px rgba(0, 0, 0, 0.6));
    opacity: 0.92;
}

.dragging-piece .piece-cell {
    width: clamp(30px, 4vh, 45px);
    height: clamp(30px, 4vh, 45px);
    background: var(--blue-medium);
    box-shadow:
        inset -3px -3px 0 0 rgba(0,0,0,0.3),
        inset 3px 3px 0 0 rgba(255,255,255,0.2),
        0 4px 0 0 rgba(0, 0, 0, 0.3);
}

/* Touch drag cells - simpler shadows for performance */
.dragging-piece.touch-drag .piece-cell {
    box-shadow:
        inset -2px -2px 0 0 rgba(0,0,0,0.3),
        inset 2px 2px 0 0 rgba(255,255,255,0.15);
}

/* Hotkey Bar - Shows available keyboard controls */
.hotkey-bar {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--gap-lg);
    margin-top: var(--gap-lg);
    padding: var(--gap-md) var(--gap-lg);
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.hotkey-item {
    display: flex;
    align-items: center;
    gap: var(--gap-sm);
    font-family: var(--font-retro);
    font-size: clamp(12px, 1.4vh, 16px);
    color: var(--text-dim);
}

.hotkey-item .hotkey-action {
    color: var(--text-medium);
}

/* Combo Display */
.combo-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    font-family: var(--font-pixel);
    font-size: clamp(24px, 5vh, 48px);
    color: var(--gold);
    text-shadow: 
        0 0 20px var(--gold),
        0 0 40px var(--orange),
        4px 4px 0 #8B4513;
    z-index: 100;
    pointer-events: none;
    animation: combo-pop 1s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes combo-pop {
    0% { transform: translate(-50%, -50%) scale(0) rotate(-10deg); opacity: 0; }
    30% { transform: translate(-50%, -50%) scale(1.5) rotate(5deg); opacity: 1; }
    60% { transform: translate(-50%, -50%) scale(1.2) rotate(-2deg); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(0.8) translateY(-50px); opacity: 0; }
}

/* Score Popup */
.score-popup {
    position: fixed;
    font-family: var(--font-pixel);
    font-size: clamp(16px, 2.5vh, 28px);
    color: var(--blue-light);
    text-shadow: 
        2px 2px 0 #000,
        0 0 10px var(--blue-glow);
    pointer-events: none;
    z-index: 1000;
    animation: score-pop 1s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.score-popup.big {
    font-size: clamp(24px, 4vh, 40px);
    color: var(--gold);
    text-shadow: 
        3px 3px 0 #8B4513,
        0 0 20px var(--gold);
}

.score-popup.jackpot {
    font-size: clamp(32px, 6vh, 56px);
    color: var(--gold);
    animation: jackpot-pop 1.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes jackpot-pop {
    0% { transform: scale(0) rotate(-20deg); opacity: 0; }
    20% { transform: scale(2) rotate(10deg); opacity: 1; filter: brightness(2); }
    40% { transform: scale(1.5) rotate(-5deg); opacity: 1; }
    60% { transform: scale(1.8) rotate(5deg); opacity: 1; }
    100% { transform: scale(0.5) translateY(-100px); opacity: 0; }
}

/* Piece placed animation - card flies to grid and shrinks */
.piece-placed-animation {
    --move-x: 0px;
    --move-y: 0px;
    transition: none;
}

.piece-placed-animation.animating {
    animation: piece-fly-to-grid 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes piece-fly-to-grid {
    0% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform:
            translate(calc(var(--move-x) * 0.6), calc(var(--move-y) * 0.6))
            scale(0.8)
            rotate(-5deg);
        opacity: 1;
        filter: brightness(1.3);
    }
    100% {
        transform:
            translate(var(--move-x), var(--move-y))
            scale(0)
            rotate(10deg);
        opacity: 0;
        filter: brightness(2);
    }
}
