:root {
    --felt-color: #20a82b;
    --felt-dark-slot: #0f5a1a;
    --card-width: 72px;
    --card-height: 106px;
    --card-radius: 5px;
    --card-gap: 6px;
    --stack-offset: 18px;
    --ui-text-color: #083410;
}

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

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    overflow-x: hidden !important;
    overflow-y: hidden !important;
    position: fixed;
    background-color: #1a8f23;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Authentic Samsung GT-P1000 Green Felt Surface */
.felt-table {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background-color: #1ea326;
    background-image: 
        repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.015) 0px, rgba(0, 0, 0, 0.015) 1px, transparent 1px, transparent 4px),
        linear-gradient(180deg, #22b12a 0%, #1a9c22 100%);
    overflow: hidden;
    overflow-x: hidden !important;
    overflow-y: hidden !important;
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
    padding-top: max(6px, env(safe-area-inset-top, 0px));
    padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
}

/* Fullscreen Board Container (100% table space) */
.board-area {
    flex: 1;
    position: relative;
    padding: 8px 12px 10px 12px;
    display: flex;
    flex-direction: column;
    gap: var(--row-gap, 18px);
    overflow: hidden;
    overflow-x: hidden !important;
    overflow-y: hidden !important;
    width: 100%;
    max-width: 100%;
    align-items: center;
    box-sizing: border-box;
}

/* Rows */
.top-row {
    display: flex;
    justify-content: center;
    gap: var(--card-gap, 8px);
    align-items: center;
    width: auto;
    max-width: 100%;
    margin: 0 auto;
    flex-shrink: 0;
    box-sizing: border-box;
}

.tableau-row {
    display: flex;
    justify-content: center;
    gap: var(--card-gap, 8px);
    width: auto;
    max-width: 100%;
    margin: 0 auto;
    flex: 1;
    position: relative;
    box-sizing: border-box;
}

/* Authentic Sunken Dark Green Slots */
.card-slot {
    width: var(--card-width);
    height: var(--card-height);
    border: 1px solid rgba(0, 0, 0, 0.28);
    border-radius: var(--card-radius);
    position: relative;
    background-color: var(--felt-dark-slot);
    box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.55), 0 1px 1px rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.card-slot.stock-slot.can-redeal {
    cursor: pointer;
}

.redeal-indicator {
    font-size: calc(var(--card-width) * 0.38);
    line-height: 1;
    color: rgba(255, 255, 255, 0.45);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
    user-select: none;
    pointer-events: none;
    transition: transform 0.2s ease, color 0.2s ease;
}

.card-slot.stock-slot:hover .redeal-indicator,
.card-slot.stock-slot:active .redeal-indicator {
    color: rgba(255, 255, 255, 0.85);
    transform: rotate(-30deg) scale(1.1);
}

.card-slot.highlight {
    box-shadow: inset 0 0 8px rgba(255, 215, 0, 0.8), 0 0 10px rgba(255, 215, 0, 0.8);
}

/* Playing Cards */
.card {
    width: var(--card-width);
    height: var(--card-height);
    border-radius: var(--card-radius);
    position: absolute;
    top: 0;
    left: 0;
    background: #ffffff;
    border: 1px solid #1a1a1a;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    transform-origin: center center;
    touch-action: none;
}

.card * {
    pointer-events: none;
}

.card.dragging {
    opacity: 0.95;
    z-index: 2000 !important;
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.6);
    transform: scale(1.04);
}

.card.selected {
    outline: 2.5px solid #ffd700;
    box-shadow: 0 0 14px rgba(255, 215, 0, 0.9);
}

/* Eye-catching Golden Hint Animations */
.card.hint-highlight {
    outline: 3.5px solid #ffcc00 !important;
    outline-offset: -1px;
    box-shadow: 0 0 18px 5px rgba(255, 204, 0, 0.95), inset 0 0 10px rgba(255, 204, 0, 0.5) !important;
    z-index: 999 !important;
    animation: pulse-hint 0.65s infinite alternate ease-in-out !important;
}

.card-slot.hint-target-highlight {
    outline: 3.5px dashed #ffcc00 !important;
    outline-offset: -2px;
    box-shadow: 0 0 18px 4px rgba(255, 204, 0, 0.85), inset 0 0 14px rgba(255, 204, 0, 0.45) !important;
    animation: pulse-target 0.65s infinite alternate ease-in-out !important;
}

.card-slot.hint-draw-highlight {
    outline: 3.5px solid #00e5ff !important;
    box-shadow: 0 0 20px 5px rgba(0, 229, 255, 0.9) !important;
    animation: pulse-draw 0.65s infinite alternate ease-in-out !important;
}

@keyframes pulse-hint {
    0% { transform: scale(1); filter: brightness(1); }
    100% { transform: scale(1.08); filter: brightness(1.2); }
}

@keyframes pulse-target {
    0% { transform: scale(1); }
    100% { transform: scale(1.04); }
}

@keyframes pulse-draw {
    0% { transform: scale(1); }
    100% { transform: scale(1.05); }
}

/* Authentic Red Geometric Card Back (GT-P1000 Default) */
.card-back {
    width: 100%;
    height: 100%;
    border-radius: var(--card-radius);
    padding: 2.5px;
    background-color: #ffffff;
    box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.3);
}

.back-inner-pattern {
    width: 100%;
    height: 100%;
    border-radius: calc(var(--card-radius) - 1.5px);
}

/* Red GT-P1000 Ornament Back */
.card-back.classic-red .back-inner-pattern {
    background-color: #d32027;
    background-image: 
        radial-gradient(circle at center, #ffffff 1px, transparent 1.5px),
        repeating-linear-gradient(45deg, transparent, transparent 5px, rgba(255,255,255,0.22) 5px, rgba(255,255,255,0.22) 7px),
        repeating-linear-gradient(-45deg, transparent, transparent 5px, rgba(255,255,255,0.22) 5px, rgba(255,255,255,0.22) 7px);
    background-size: 14px 14px;
    border: 1.5px solid #b71c1c;
    box-shadow: inset 0 0 4px rgba(0,0,0,0.3);
}

/* Green Variant */
.card-back.classic-green .back-inner-pattern {
    background-color: #1b5e20;
    background-image: 
        repeating-linear-gradient(45deg, #1b5e20, #1b5e20 6px, #2e7d32 6px, #2e7d32 12px);
    border: 1.5px solid #0d3810;
}

/* Blue Variant */
.card-back.samsung-blue .back-inner-pattern {
    background-color: #0d47a1;
    background-image: 
        repeating-linear-gradient(135deg, #0d47a1, #0d47a1 6px, #1976d2 6px, #1976d2 12px);
    border: 1.5px solid #082a63;
}

/* Playing Card Face */
.card-face {
    width: 100%;
    height: 100%;
    border-radius: var(--card-radius);
    position: relative;
    background: #ffffff;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #c0c0c0;
    box-sizing: border-box;
}

.card-face-img {
    width: 100%;
    height: 100%;
    object-fit: fill;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

/* Authentic Corner Indices */
.corner-rank {
    position: absolute;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 0.9;
}

.corner-rank.top-left {
    top: 3px;
    left: 4px;
}

.corner-rank.bottom-right {
    bottom: 3px;
    right: 4px;
    transform: rotate(180deg);
}

.corner-rank .rank-txt {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: calc(var(--card-width) * 0.22);
    font-weight: 900;
    letter-spacing: -0.3px;
}

.corner-rank .suit-mini {
    width: calc(var(--card-width) * 0.16);
    height: calc(var(--card-width) * 0.16);
    margin-top: 1.5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.corner-rank .suit-mini .card-pip-svg {
    width: 100%;
    height: 100%;
}

/* Center Playing Field */
.card-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 84%;
    height: 86%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Center Pips Layout */
.poker-pip-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.poker-pip {
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.poker-pip .card-pip-svg {
    width: calc(var(--card-width) * 0.22);
    height: calc(var(--card-width) * 0.22);
}

/* Center Ace */
.poker-ace-center {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.poker-ace-center .card-pip-svg, .poker-ace-pip {
    width: calc(var(--card-width) * 0.44);
    height: calc(var(--card-width) * 0.44);
}

.poker-ace-spades {
    width: 82%;
    height: 82%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.poker-ace-svg {
    width: 100%;
    height: 100%;
}

/* Court Figures */
.poker-court-frame {
    width: 96%;
    height: 94%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.poker-court-svg {
    width: 100%;
    height: 100%;
}

.poker-ace-spades {
    width: 85%;
    height: 85%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.poker-ace-svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.3));
}

.poker-ace-center {
    font-size: calc(var(--card-width) * 0.52);
    display: flex;
    align-items: center;
    justify-content: center;
}

.poker-pip-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.poker-pip {
    position: absolute;
    font-size: calc(var(--card-width) * 0.24);
    line-height: 1;
    transform: translate(-50%, -50%);
}

.poker-court-frame {
    width: 96%;
    height: 94%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.poker-court-svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.25));
}

/* Drag Ghost */
.drag-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 3500;
    top: 0;
    left: 0;
}

/* Authentic Felt Stats Bottom Right */
.felt-corner-stats {
    position: absolute;
    bottom: max(10px, env(safe-area-inset-bottom, 0px));
    right: max(18px, env(safe-area-inset-right, 0px));
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none;
    z-index: 50;
}

.felt-cards-left {
    font-size: 1.15rem;
    font-weight: 800;
    color: #062e0d;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.25);
    letter-spacing: -0.2px;
}

.felt-timer {
    font-size: 1.1rem;
    font-weight: 800;
    color: #062e0d;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.25);
}

/* Floating Bottom Left Control Bar */
.felt-bottom-bar {
    position: absolute;
    bottom: max(10px, env(safe-area-inset-bottom, 0px));
    left: max(14px, env(safe-area-inset-left, 0px));
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 60;
}

.felt-action-btn {
    background: rgba(8, 45, 15, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: #ffffff;
    padding: 6px 9px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
}

.felt-action-btn:active {
    background: rgba(8, 45, 15, 0.7);
    transform: translateY(1px);
}

/* Victory Canvas */
.win-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2000;
}

/* Modal Dialogs */
.retro-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5000;
    opacity: 1;
    transition: opacity 0.2s ease;
    overflow: hidden;
    overflow-x: hidden !important;
}

.retro-modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.retro-modal {
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    max-height: 90dvh;
    background: #142817;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    overflow-x: hidden !important;
    color: #ffffff;
    box-sizing: border-box;
}

.modal-header {
    background: rgba(255, 255, 255, 0.06);
    padding: 12px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.modal-header h2 { font-size: 1.15rem; font-weight: 700; }
.modal-header.center { justify-content: center; text-align: center; }

.modal-close {
    background: transparent;
    border: none;
    color: #aaa;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.modal-body {
    padding: 14px 18px;
    overflow-y: auto;
    overflow-x: hidden !important;
    overscroll-behavior: contain;
    flex: 1;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
}

.modal-body::-webkit-scrollbar {
    width: 5px;
}
.modal-body::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}
.modal-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.sub-text { font-size: 0.9rem; color: #ccc; margin-bottom: 14px; }

.game-select-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.game-card-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 12px;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease;
}

.game-card-btn:hover, .game-card-btn:active {
    background: rgba(30, 144, 255, 0.3);
    border-color: #1e90ff;
}

.game-icon {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.game-info h3 { font-size: 1rem; margin-bottom: 2px; }
.game-info p { font-size: 0.78rem; color: #aaa; }

.option-buttons-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.retro-select {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    max-width: 180px;
    box-sizing: border-box;
    text-overflow: ellipsis;
}

/* Compact Landscape Screen Optimization (e.g. Pixel 10 & phones in landscape) */
@media (max-height: 520px) {
    .retro-modal {
        max-height: 94vh;
        max-height: 94dvh;
    }

    .retro-modal.settings-modal {
        max-width: 480px;
        width: 92%;
    }

    .settings-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .setting-row {
        padding: 5px 0;
        font-size: 0.86rem;
    }

    .retro-select {
        padding: 4px 8px;
        font-size: 0.84rem;
        max-width: 170px;
    }

    .modal-header {
        padding: 8px 16px;
    }

    .modal-header h2 {
        font-size: 1rem;
    }

    .modal-body {
        padding: 8px 16px;
        overflow-x: hidden !important;
    }

    .retro-modal.game-select-modal {
        max-width: 600px;
        width: 94%;
    }

    .game-select-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .game-card-btn {
        padding: 8px 10px;
        gap: 10px;
        min-width: 0;
    }

    .game-info {
        min-width: 0;
        overflow: hidden;
    }

    .game-info h3 {
        font-size: 0.88rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .game-info p {
        font-size: 0.72rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .game-icon {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }
}

.retro-btn {
    background: linear-gradient(180deg, #1e90ff 0%, #0c66db 100%);
    border: 1px solid #4ca3ff;
    color: #ffffff;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

/* Victory Modal Specifics */
.victory-modal { text-align: center; border-color: #ffd700; }
.victory-subtext { color: #ffd700; margin-bottom: 16px; font-weight: 600; }
.victory-stats { display: flex; flex-direction: column; gap: 8px; font-size: 0.95rem; }

/* Portrait prompt overlay for small mobile phones */
.rotate-device-prompt {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0f2712;
    color: #ffffff;
    z-index: 99999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 32px;
    box-sizing: border-box;
}

.rotate-device-prompt .rotate-icon {
    font-size: 3.5rem;
    margin-bottom: 20px;
    animation: rotate-phone-anim 2s infinite ease-in-out;
}

@keyframes rotate-phone-anim {
    0%, 20% { transform: rotate(0deg); }
    50%, 80% { transform: rotate(90deg); }
    100% { transform: rotate(90deg); }
}

@media screen and (orientation: portrait) and (max-width: 600px) {
    .rotate-device-prompt {
        display: flex;
    }
}

/* Animated Card to Foundation */
.flying-to-foundation {
    position: fixed !important;
    margin: 0 !important;
    z-index: 4000 !important;
    pointer-events: none !important;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.3) !important;
    transition: transform 0.22s cubic-bezier(0.25, 1, 0.5, 1) !important;
    will-change: transform;
}
