/* Glassmorphism panels */
.glass {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.glass-darker {
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.glass-light {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Playing cards */
.card {
    width: 60px;
    height: 84px;
    background: linear-gradient(145deg, #ffffff 0%, #f0f0f0 100%);
    border-radius: 6px;
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.1),
        0 4px 8px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 4px 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.card:hover {
    transform: translateY(-8px);
    box-shadow:
        0 8px 16px rgba(0, 0, 0, 0.2),
        0 12px 24px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.card.selected {
    transform: translateY(-12px);
    box-shadow:
        0 12px 24px rgba(139, 92, 246, 0.4),
        0 16px 32px rgba(139, 92, 246, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    outline: 3px solid rgb(139, 92, 246);
}

.card.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.card.disabled:hover {
    transform: none;
}

.card.not-your-turn {
    filter: grayscale(40%) brightness(0.85);
    cursor: default;
}

.card.not-your-turn:hover {
    transform: none;
}

.card-small {
    width: 45px;
    height: 63px;
    padding: 2px 4px;
    font-size: 0.75rem;
}

.card-tiny {
    width: 32px;
    height: 45px;
    padding: 2px 3px;
    font-size: 0.6rem;
}

.card .rank {
    font-weight: 700;
    font-size: 1rem;
    line-height: 1;
}

.card .suit {
    font-size: 1.5rem;
    line-height: 1;
    text-align: center;
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card .rank-bottom {
    font-weight: 700;
    font-size: 1rem;
    line-height: 1;
    align-self: flex-end;
    transform: rotate(180deg);
}

.card.red {
    color: #dc2626;
}

.card.black {
    color: #1f2937;
}

.card-small .rank,
.card-small .rank-bottom {
    font-size: 0.75rem;
}

.card-small .suit {
    font-size: 1rem;
}

.card-tiny .rank,
.card-tiny .rank-bottom {
    font-size: 0.55rem;
}

.card-tiny .suit {
    font-size: 0.75rem;
}

/* Run display */
.run-container {
    display: flex;
    align-items: center;
    gap: -15px;
}

.run-container .card {
    margin-left: -20px;
}

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

.run-container .card:hover {
    transform: translateY(-4px);
    z-index: 10;
}

/* Card deck */
.deck {
    width: 60px;
    height: 84px;
    background: linear-gradient(145deg, #6366f1 0%, #4f46e5 100%);
    border-radius: 6px;
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.2),
        2px 2px 0 rgba(255, 255, 255, 0.1),
        4px 4px 0 rgba(99, 102, 241, 0.8),
        6px 6px 0 rgba(79, 70, 229, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, rgb(139, 92, 246) 0%, rgb(109, 40, 217) 100%);
    color: white;
    box-shadow: 0 4px 6px rgba(139, 92, 246, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(139, 92, 246, 0.4);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

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

.btn-danger {
    background: linear-gradient(135deg, rgb(239, 68, 68) 0%, rgb(185, 28, 28) 100%);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, rgb(34, 197, 94) 0%, rgb(21, 128, 61) 100%);
    color: white;
}

/* Player indicator */
.player-active {
    border-left: 3px solid rgb(139, 92, 246);
    background: rgba(139, 92, 246, 0.1);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease forwards;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 20px rgba(139, 92, 246, 0.3); }
    50% { box-shadow: 0 0 30px rgba(139, 92, 246, 0.6); }
}

.pulse-glow {
    animation: pulse-glow 2s infinite;
}

/* Score animation */
@keyframes score-celebration {
    0% { transform: scale(1); }
    20% { transform: scale(1.15); }
    40% { transform: scale(1); }
    60% { transform: scale(1.1); }
    80% { transform: scale(1); }
    100% { transform: scale(1); }
}

@keyframes score-glow {
    0% { box-shadow: 0 0 0 rgba(34, 197, 94, 0); }
    30% { box-shadow: 0 0 40px rgba(34, 197, 94, 0.8); }
    100% { box-shadow: 0 0 0 rgba(34, 197, 94, 0); }
}

.just-scored {
    animation: score-celebration 0.8s ease-out, score-glow 1.2s ease-out;
}

.score-flash {
    position: relative;
}

.score-flash::after {
    content: '+1';
    position: absolute;
    top: -20px;
    right: 0;
    font-size: 1.5rem;
    font-weight: bold;
    color: #22c55e;
    animation: score-float 1.5s ease-out forwards;
}

@keyframes score-float {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-30px); }
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    z-index: 100;
    animation: fadeIn 0.3s ease;
}

.toast-success {
    background: rgba(34, 197, 94, 0.9);
    color: white;
}

.toast-error {
    background: rgba(239, 68, 68, 0.9);
    color: white;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* HTMX loading indicator */
.htmx-request .htmx-indicator {
    opacity: 1;
}

.htmx-indicator {
    opacity: 0;
    transition: opacity 0.2s ease;
}

/* Card back (for opponents' hands) */
.card-back {
    width: 60px;
    height: 84px;
    border-radius: 6px;
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Black trim border */
    border: 3px solid #1a1a1a;
    /* Diamond pattern background - white and red alternating */
    background-color: #ffffff;
    background-image:
        linear-gradient(45deg, #dc2626 25%, transparent 25%),
        linear-gradient(-45deg, #dc2626 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #dc2626 75%),
        linear-gradient(-45deg, transparent 75%, #dc2626 75%);
    background-size: 12px 12px;
    background-position: 0 0, 6px 6px, 6px 0, 0 6px;
    overflow: hidden;
}

.card-back::before {
    content: '';
    z-index: 1;
}

/* Only show snake on the last (top) card in a stack */
.hand-cards-stacked .card-back:last-child::before {
    content: '';
    width: 34px;
    height: 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 122.88 118.93'%3E%3Cpath fill='%231a1a1a' d='M113.72,7.59l0.18,0.18c-1.32-0.78-3.16-1.05-5.46-1.05c-9.82,0-20.43,6.64-22.68,16.59 c-1.34,1.67-2.87,2.73-4.6,3.17c-4.99,1.28-7.72-2.09-11.51-4.37c-2.1-1.26-4.2-2.15-6.64-2.52c-1.77-0.27-3.63-0.28-5.6,0.04 c-21.9,3.52-21.23,24.5-10.27,38.58c3.2,4.11,6.97,8.13,10.29,11.96c3.41,3.94,6.81,7.58,7.54,11.24c1.01,5.06-2.95,8.86-7.64,7.83 c-4.2-0.92-9.77-4.16-15.75-7.9L20.02,68.89c-4-2.47-7.76-3.47-11.27-2.88c-6.52,1.1-9.87,6.76-8.41,13.13 c2.36,10.28,14.79,15.74,13.89,27.66c-0.34,4.57-3.06,8.61-8.08,12.12c1.37,0.06,2.92-0.5,4.65-1.68c1.81-1.23,3.25-2.48,4.35-3.83 c6.15-7.5,2.21-16.4-1.87-23.55c-0.88-1.55-1.67-3.2-2.14-5.26c-1.11-4.86,0.95-7.54,5.86-5.45c10.97,4.67,34.26,27.62,46.94,26.25 c8.83-0.96,15.76-8.59,17.75-16.94c2.51-10.55-4.68-17.7-10.56-25.98c-3.83-5.39-7.83-10.62-11.51-16.12 c-1.17-1.85-0.86-3.82,0.21-5.17c3.1-3.91,6.62,0.05,9.66,1.65c3.15,1.66,6.36,2.5,9.41,2.82c7.88,0.84,16.44-2.92,21.72-8.76 c9.82-2.94,15.36-13.03,15.73-23.09c0.07-1.93-0.21-3.37-0.83-4.43l0.03,0.03c1.9-1.82,4.71-3.03,7.33-3.77 c-1.68-0.52-3.35-0.81-4.99-0.65c0.32-1.65,0.22-3.31-0.22-4.99C116.59,2.69,115.09,5.61,113.72,7.59L113.72,7.59z M111.53,20.13 c-0.88-0.88-2.32-0.88-3.2,0c-0.89,0.88-0.89,2.32,0,3.2c0.88,0.88,2.32,0.88,3.2,0C112.41,22.45,112.41,21.01,111.53,20.13 L111.53,20.13z M102.97,11.57c-0.89-0.89-2.32-0.89-3.2,0c-0.88,0.88-0.88,2.32,0,3.2c0.88,0.89,2.32,0.89,3.2,0 C103.86,13.89,103.86,12.46,102.97,11.57L102.97,11.57z'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transform: rotate(-45deg);
}

.hand-cards-stacked .card-back-small:last-child::before {
    width: 26px;
    height: 26px;
}

/* Inner border effect - removed */
.card-back::after {
    display: none;
}

.card-back-small {
    width: 45px;
    height: 63px;
    border-width: 2px;
    background-size: 10px 10px;
    background-position: 0 0, 0 5px, 5px -5px, -5px 0px;
}

.card-back-small::before {
    font-size: 1rem;
}


/* Drag and drop states */
.dragging {
    opacity: 0.5;
    cursor: grabbing !important;
}

.drag-ghost {
    opacity: 0.3;
}

[draggable="true"] {
    cursor: grab;
}

[draggable="true"]:active {
    cursor: grabbing;
}

/* Drop zone states */
.drop-zone {
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    transition: all 0.2s ease;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.drop-zone-empty {
    background: rgba(255, 255, 255, 0.02);
}

.drop-zone-empty::after {
    content: 'Drop card here';
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.75rem;
}

/* Opponent empty slots - no drop text */
.drop-zone-empty.opponent-slot::after {
    content: none;
}

.drop-zone.drag-over {
    border-color: rgba(139, 92, 246, 0.6);
    background: rgba(139, 92, 246, 0.1);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.3);
}

.drop-zone.valid-target {
    border-color: rgba(34, 197, 94, 0.6);
    background: rgba(34, 197, 94, 0.1);
}

.drop-zone.invalid-target {
    border-color: rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.05);
}

/* Run slot styling */
.run-slot {
    min-width: 120px;
    min-height: 100px;
    padding: 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
}

.run-slot.has-run {
    background: rgba(255, 255, 255, 0.05);
}

.run-slot.can-drop {
    border-color: rgba(34, 197, 94, 0.5);
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.2);
}

/* Player areas - milky glass effect */
.player-area {
    padding: 12px;
    border-radius: 12px;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.06) 0%,
        rgba(255, 255, 255, 0.12) 50%,
        rgba(255, 255, 255, 0.06) 100%
    );
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow:
        inset 0 1px 1px rgba(255, 255, 255, 0.1),
        0 4px 12px rgba(0, 0, 0, 0.1);
}

.player-area.is-current-turn {
    border-color: rgba(139, 92, 246, 0.5);
    box-shadow:
        inset 0 1px 1px rgba(255, 255, 255, 0.1),
        0 0 20px rgba(139, 92, 246, 0.2),
        0 4px 12px rgba(0, 0, 0, 0.1);
}

.player-area.is-you {
    /* Same milky glass effect as opponents */
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.06) 0%,
        rgba(255, 255, 255, 0.12) 50%,
        rgba(255, 255, 255, 0.06) 100%
    );
    border-color: rgba(255, 255, 255, 0.15);
}

/* Table layout - compact with overlap */
.game-table {
    position: relative;
    height: calc(100vh - 60px);
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.table-top {
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 8px;
}

.table-left {
    position: absolute;
    left: 60px;
    top: 40%;
    transform: translateY(-50%);
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.table-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 0;
    margin-top: 40px;
}

.table-right {
    position: absolute;
    right: 60px;
    top: 40%;
    transform: translateY(-50%);
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.table-bottom {
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 8px;
}

/* Opponent name labels - always right-side up, above player area */
.opponent-label {
    text-align: center;
    padding: 4px 12px;
    margin-bottom: 8px;
}

/* No rotations - each position is styled independently in the template */

/* Rotate left player's hand 270 degrees (cards face toward center) */
.table-left .hand-cards-stacked {
    transform: rotate(270deg);
}

/* Rotate right player's hand 90 degrees (cards face toward center) */
.table-right .hand-cards-stacked {
    transform: rotate(90deg);
}

/* 2 player layout - hide left/right */
.game-table.players-2 .table-left,
.game-table.players-2 .table-right {
    display: none;
}

/* 3 player layout - hide top, use left and right */
.game-table.players-3 .table-top {
    display: none;
}

/* Hand display - overlapping cards with hover fan-out */
.hand-cards {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    padding: 10px 40px; /* Extra padding for hover expansion */
}

.hand-cards .card {
    margin-left: -25px;
    transition: transform 0.2s ease;
    z-index: 1;
}

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

/* Hovered card moves straight up */
.hand-cards .card:hover {
    transform: translateY(-20px);
    z-index: 10;
}

/* Cards to the RIGHT of hovered card shift right */
.hand-cards .card:hover ~ .card {
    transform: translateX(20px);
}

/* Cards to the LEFT of hovered card shift left - use has() to detect hover then exclude hovered and cards after it */
.hand-cards:has(.card:hover) .card:not(:hover):not(.card:hover ~ .card) {
    transform: translateX(-20px);
}

.hand-cards-stacked {
    display: flex;
    margin-left: 0;
}

.hand-cards-stacked .card-back {
    margin-left: -40px;
}

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

/* Run cards fanned display */
.run-cards {
    display: flex;
    position: relative;
    pointer-events: none; /* Let parent handle drag events */
}

.run-cards .card {
    margin-left: -35px;
    transition: all 0.15s ease;
    pointer-events: none; /* Let parent handle drag events */
}

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

/* Opponent run (draggable for steal/eat) */
.opponent-run {
    cursor: grab;
    transition: all 0.2s ease;
}

.opponent-run:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.opponent-run.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

/* Number input styling - custom plus/minus buttons */
input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Wrapper for number input with custom buttons */
.number-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.number-input-wrapper input[type="number"] {
    text-align: center;
    padding-left: 40px;
    padding-right: 40px;
}

.number-input-wrapper .number-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 1.25rem;
    font-weight: 300;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.number-input-wrapper .number-btn:hover {
    background: rgba(139, 92, 246, 0.4);
}

.number-input-wrapper .number-btn:active {
    background: rgba(139, 92, 246, 0.6);
    transform: translateY(-50%) scale(0.95);
}

.number-input-wrapper .number-btn-minus {
    left: 6px;
}

.number-input-wrapper .number-btn-plus {
    right: 6px;
}

/* Card draw animation container */
.card-draw-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    overflow: hidden;
}

.card-draw-animation {
    position: absolute;
    width: 45px;
    height: 63px;
    border-radius: 6px;
    border: 2px solid #1a1a1a;
    background-color: #ffffff;
    background-image:
        linear-gradient(45deg, #dc2626 25%, transparent 25%),
        linear-gradient(-45deg, #dc2626 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #dc2626 75%),
        linear-gradient(-45deg, transparent 75%, #dc2626 75%);
    background-size: 10px 10px;
    background-position: 0 0, 5px 5px, 5px 0, 0 5px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transform-origin: center center;
}

/* Animation keyframes - cards fly from deck to player */
@keyframes card-fly {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(var(--dx), var(--dy)) scale(1);
    }
}

.card-draw-animation.animating {
    animation: card-fly 0.4s ease-out forwards;
}

/* ========================================
   MOBILE RESPONSIVE STYLES
   ======================================== */

/* CSS Custom Properties for responsive sizing */
:root {
    --card-width: 60px;
    --card-height: 84px;
    --card-small-width: 45px;
    --card-small-height: 63px;
    --card-tiny-width: 32px;
    --card-tiny-height: 45px;
    --table-padding: 8px;
    --player-area-padding: 12px;
}

/* Mobile breakpoints */
@media (max-width: 768px) {
    :root {
        --card-width: 48px;
        --card-height: 67px;
        --card-small-width: 38px;
        --card-small-height: 53px;
        --card-tiny-width: 28px;
        --card-tiny-height: 39px;
        --table-padding: 4px;
        --player-area-padding: 8px;
    }
}

@media (max-width: 480px) {
    :root {
        --card-width: 42px;
        --card-height: 59px;
        --card-small-width: 34px;
        --card-small-height: 48px;
        --card-tiny-width: 24px;
        --card-tiny-height: 34px;
        --table-padding: 2px;
        --player-area-padding: 6px;
    }
}

/* Use CSS variables for card sizing */
.card {
    width: var(--card-width);
    height: var(--card-height);
}

.card-small {
    width: var(--card-small-width);
    height: var(--card-small-height);
}

.card-tiny {
    width: var(--card-tiny-width);
    height: var(--card-tiny-height);
}

.card-back {
    width: var(--card-width);
    height: var(--card-height);
}

.card-back-small {
    width: var(--card-small-width);
    height: var(--card-small-height);
}

.deck {
    width: var(--card-width);
    height: var(--card-height);
}

/* Mobile game table layout */
@media (max-width: 768px) {
    .game-table {
        height: auto;
        min-height: calc(100vh - 50px);
        min-height: calc(100dvh - 50px); /* Dynamic viewport for mobile browsers */
        padding: var(--table-padding);
        padding-bottom: 0;
        display: flex;
        flex-direction: column;
        gap: 8px;
        overflow: visible;
    }

    /* Stack all players vertically on mobile */
    .table-top,
    .table-left,
    .table-right,
    .table-bottom {
        position: relative;
        left: auto;
        right: auto;
        top: auto;
        transform: none;
        width: 100%;
    }

    /* Show all player positions on mobile regardless of player count */
    .game-table.players-2 .table-left,
    .game-table.players-2 .table-right,
    .game-table.players-3 .table-top {
        display: flex;
    }

    /* Center deck area on mobile */
    .table-center {
        order: 0;
        flex: 0 0 auto;
        margin: 8px 0;
    }

    /* Opponent areas on mobile - compact horizontal layout */
    .table-top,
    .table-left,
    .table-right {
        order: 1;
    }

    /* Your area always at bottom */
    .table-bottom {
        order: 2;
        margin-top: auto;
    }

    /* Remove card rotations on mobile */
    .table-left .hand-cards-stacked,
    .table-right .hand-cards-stacked {
        transform: none;
    }

    /* Mobile player area styling */
    .player-area {
        padding: var(--player-area-padding);
        border-radius: 8px;
        flex-direction: row !important;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }

    /* Opponent label mobile */
    .opponent-label {
        width: 100%;
        text-align: center;
        margin-bottom: 4px;
        padding: 2px 8px;
        font-size: 0.875rem;
    }

    /* Run slots mobile */
    .run-slot {
        min-width: 80px;
        min-height: 70px;
        padding: 4px;
    }

    /* Hand cards mobile - tighter overlap */
    .hand-cards {
        padding: 8px 20px;
    }

    .hand-cards .card {
        margin-left: -20px;
    }

    .hand-cards-stacked .card-back {
        margin-left: -35px;
    }

    /* Run cards mobile - much tighter overlap */
    .run-cards .card {
        margin-left: -38px;
    }

    /* Card font sizes mobile */
    .card .rank,
    .card .rank-bottom {
        font-size: 0.85rem;
    }

    .card .suit {
        font-size: 1.2rem;
    }

    .card-small .rank,
    .card-small .rank-bottom {
        font-size: 0.65rem;
    }

    .card-small .suit {
        font-size: 0.85rem;
    }

    /* Button sizing mobile */
    .btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.9375rem;
        min-height: 44px; /* Touch-friendly minimum */
    }

    /* Toast positioning mobile */
    .toast {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
        max-width: none;
    }
}

/* Small mobile (phones) */
@media (max-width: 480px) {
    .game-table {
        padding: 2px;
        gap: 6px;
    }

    /* Even tighter card overlap on small screens */
    .hand-cards .card {
        margin-left: -18px;
    }

    .hand-cards-stacked .card-back {
        margin-left: -30px;
    }

    .run-cards .card {
        margin-left: -32px;
    }

    /* Smaller font sizes */
    .card .rank,
    .card .rank-bottom {
        font-size: 0.75rem;
    }

    .card .suit {
        font-size: 1rem;
    }

    .card-small .rank,
    .card-small .rank-bottom {
        font-size: 0.55rem;
    }

    .card-small .suit {
        font-size: 0.7rem;
    }

    /* Smaller run slots */
    .run-slot {
        min-width: 60px;
        min-height: 55px;
        padding: 3px;
    }

    .run-slot .text-xs {
        font-size: 0.625rem;
    }

    /* Player area even more compact */
    .player-area {
        padding: 4px;
        gap: 4px;
    }

    .opponent-label {
        font-size: 0.75rem;
        padding: 2px 6px;
    }

    /* Deck sizing */
    .deck {
        font-size: 0.875rem;
    }

    /* Reduce hover effects on small screens */
    .hand-cards .card:hover {
        transform: translateY(-12px);
    }

    .hand-cards .card:hover ~ .card {
        transform: translateX(12px);
    }

    .hand-cards:has(.card:hover) .card:not(:hover):not(.card:hover ~ .card) {
        transform: translateX(-12px);
    }
}

/* Mobile header adjustments */
@media (max-width: 768px) {
    .game-header {
        padding: 8px;
    }

    .game-header h1 {
        font-size: 1.25rem;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Disable hover effects on touch devices */
    .card:hover {
        transform: none;
    }

    .hand-cards .card:hover {
        transform: none;
    }

    .hand-cards .card:hover ~ .card {
        transform: none;
    }

    .hand-cards:has(.card:hover) .card:not(:hover):not(.card:hover ~ .card) {
        transform: none;
    }

    .opponent-run:hover {
        transform: none;
    }

    /* Add active states for touch */
    .card:active {
        transform: scale(1.05);
        z-index: 10;
    }

    .hand-cards .card:active {
        transform: translateY(-15px) scale(1.05);
        z-index: 20;
    }

    /* Larger tap targets */
    .card {
        min-width: 44px;
        min-height: 44px;
    }

    /* Touch-friendly drag handle */
    [draggable="true"] {
        touch-action: none;
    }

    /* Selected state for touch */
    .card.touch-selected {
        transform: translateY(-15px);
        box-shadow:
            0 12px 24px rgba(139, 92, 246, 0.4),
            0 16px 32px rgba(139, 92, 246, 0.2),
            inset 0 1px 0 rgba(255, 255, 255, 0.8);
        outline: 3px solid rgb(139, 92, 246);
        z-index: 20;
    }
}

/* Mobile opponent area - horizontal scrollable */
@media (max-width: 768px) {
    .table-top .player-area,
    .table-left .player-area,
    .table-right .player-area {
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .table-top .player-area::-webkit-scrollbar,
    .table-left .player-area::-webkit-scrollbar,
    .table-right .player-area::-webkit-scrollbar {
        display: none;
    }

    /* Opponent runs in a row */
    .table-top .flex-col,
    .table-left .flex-col,
    .table-right .flex-col {
        flex-direction: row;
        gap: 4px;
    }
}

/* Mobile-specific your area layout */
@media (max-width: 768px) {
    .table-bottom .player-area.is-you {
        display: flex;
        flex-direction: column;
        gap: 8px;
        overflow: visible;
    }

    .table-bottom .your-runs .flex-wrap {
        flex-wrap: wrap;
        justify-content: center;
    }

    .table-bottom .your-hand .hand-cards {
        -webkit-overflow-scrolling: touch;
        justify-content: center;
        flex-direction: row;
        flex-wrap: wrap;
        padding: 8px 16px;
        overflow: visible;
        row-gap: 8px;
    }

    .table-bottom {
        overflow: visible;
    }
}

/* Landscape mobile optimization */
@media (max-width: 896px) and (orientation: landscape) {
    .game-table {
        flex-direction: row;
        flex-wrap: wrap;
        height: auto;
        min-height: calc(100vh - 40px);
        min-height: calc(100dvh - 40px);
    }

    .table-center {
        order: 0;
        flex: 0 0 100%;
        margin: 4px 0;
    }

    .table-top,
    .table-left,
    .table-right {
        flex: 1 1 30%;
        min-width: 0;
    }

    .table-bottom {
        flex: 0 0 100%;
        order: 3;
    }

    /* Smaller cards in landscape */
    :root {
        --card-width: 44px;
        --card-height: 62px;
        --card-small-width: 36px;
        --card-small-height: 50px;
    }
}

/* ========================================
   DASHBOARD MOBILE STYLES
   ======================================== */

@media (max-width: 768px) {
    /* Dashboard header */
    .dashboard-header {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }

    .dashboard-header h1 {
        font-size: 1.75rem;
    }

    /* Create game form */
    .create-game-form .grid {
        grid-template-columns: 1fr;
    }

    /* Game options grid */
    .game-options-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Games list */
    .games-list-item {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }

    .games-list-item .flex {
        flex-wrap: wrap;
        justify-content: center;
    }

    /* Modal full width on mobile */
    .modal-content {
        width: calc(100% - 2rem);
        max-width: none;
        margin: 1rem;
    }

    /* Glass panels more compact */
    .glass {
        padding: 1rem;
    }

    /* Form inputs larger touch targets */
    input[type="text"],
    input[type="password"],
    input[type="number"],
    select {
        min-height: 44px;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    /* Select dropdowns */
    select {
        appearance: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ffffff' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 12px center;
        padding-right: 36px;
    }
}

@media (max-width: 480px) {
    /* Even smaller dashboard */
    .game-options-grid {
        grid-template-columns: 1fr;
    }

    /* Lobby waiting slots wrap */
    .waiting-players {
        gap: 6px;
    }

    .waiting-players span {
        font-size: 0.875rem;
        padding: 6px 12px;
    }
}

/* ========================================
   TOUCH TAP-TO-SELECT MODE
   ======================================== */

/* Selection indicator bar for touch mode */
.touch-selection-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.7));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    z-index: 100;
    transform: translateY(100%);
    transition: transform 0.2s ease;
}

.touch-selection-bar.visible {
    transform: translateY(0);
}

.touch-selection-bar .selection-info {
    flex: 1;
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.9);
}

.touch-selection-bar .selection-actions {
    display: flex;
    gap: 8px;
}

.touch-selection-bar .btn {
    padding: 8px 16px;
    font-size: 0.875rem;
    min-height: 40px;
}

/* Drop zone highlighting for touch mode */
.drop-zone.touch-highlight {
    border-color: rgba(139, 92, 246, 0.8);
    background: rgba(139, 92, 246, 0.15);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.4);
    animation: pulse-highlight 1s ease-in-out infinite;
}

@keyframes pulse-highlight {
    0%, 100% { box-shadow: 0 0 20px rgba(139, 92, 246, 0.4); }
    50% { box-shadow: 0 0 30px rgba(139, 92, 246, 0.6); }
}

/* Touch mode card styles */
.card.touch-selectable {
    cursor: pointer;
}

.card.touch-selected {
    transform: translateY(-15px);
    box-shadow:
        0 12px 24px rgba(139, 92, 246, 0.4),
        0 16px 32px rgba(139, 92, 246, 0.2);
    outline: 3px solid rgb(139, 92, 246);
    z-index: 20;
}

/* Run slot when tappable target */
.run-slot.touch-target {
    border: 2px solid rgba(139, 92, 246, 0.6);
    background: rgba(139, 92, 246, 0.1);
    cursor: pointer;
}

.run-slot.touch-target:active {
    background: rgba(139, 92, 246, 0.2);
}

/* Opponent run when tappable for steal/eat */
.opponent-run.touch-target {
    cursor: pointer;
    outline: 2px dashed rgba(239, 68, 68, 0.6);
}

.opponent-run.touch-target:active {
    outline-color: rgba(239, 68, 68, 0.9);
    background: rgba(239, 68, 68, 0.1);
}

/* Mobile action buttons in player area */
@media (max-width: 768px) {
    .mobile-actions {
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
        justify-content: center;
        margin-top: 8px;
    }

    .mobile-actions .btn {
        flex: 1;
        min-width: 100px;
        max-width: 150px;
    }
}

/* Hide elements on specific platforms */
@media (hover: none) and (pointer: coarse) {
    .desktop-only {
        display: none !important;
    }
}

@media (hover: hover) and (pointer: fine) {
    .touch-only {
        display: none !important;
    }
}

/* ========================================
   MOBILE WAITING LOBBY
   ======================================== */

@media (max-width: 768px) {
    .waiting-lobby {
        padding: 1.5rem;
        margin-top: 2rem;
    }

    .waiting-lobby h2 {
        font-size: 1.5rem;
    }

    .waiting-lobby .flex-wrap {
        gap: 8px;
    }

    .waiting-lobby .px-4 {
        padding-left: 12px;
        padding-right: 12px;
    }
}

/* ========================================
   GAME OVER MOBILE
   ======================================== */

@media (max-width: 768px) {
    .game-over-screen {
        padding: 1.5rem;
        margin-top: 2rem;
    }

    .game-over-screen h2 {
        font-size: 2rem;
    }

    .game-over-screen .space-y-2 > div {
        padding: 8px 12px;
    }
}

/* ========================================
   iOS SAFE AREA SUPPORT
   ======================================== */

/* Support for iOS safe areas (notch, home indicator) */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }

    .touch-selection-bar {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .game-table {
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }

    .table-bottom {
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }
}

/* ========================================
   PREVENT TEXT SIZE ADJUST ON IOS
   ======================================== */

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* ========================================
   SMOOTH SCROLLING FOR MOBILE
   ======================================== */

@media (max-width: 768px) {
    html {
        scroll-behavior: smooth;
    }

    /* Momentum scrolling for iOS */
    .game-table,
    .hand-cards,
    .player-area {
        -webkit-overflow-scrolling: touch;
    }
}

/* ========================================
   PREVENT PULL-TO-REFRESH DURING GAME
   ======================================== */

.game-table {
    overscroll-behavior-y: contain;
}

/* ========================================
   ACCESSIBILITY IMPROVEMENTS
   ======================================== */

/* Focus visible for keyboard navigation */
.btn:focus-visible,
.card:focus-visible,
.run-slot:focus-visible {
    outline: 2px solid rgb(139, 92, 246);
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .card:hover {
        transform: none;
    }

    .hand-cards .card:hover {
        transform: none;
    }

    .hand-cards .card:hover ~ .card {
        transform: none;
    }

    .hand-cards:has(.card:hover) .card:not(:hover):not(.card:hover ~ .card) {
        transform: none;
    }
}

