/* Mobile and Responsive Styles for Trenta-u */

/* Mobile Detection and Base Classes */
.mobile-device {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

.tablet-device {
    /* Tablet-specific adjustments */
}

/* Touch Feedback */
.touch-active {
    transform: scale(0.95);
    opacity: 0.8;
    transition: all 0.1s ease;
}

/* Orientation-specific styles */
.landscape-mode .players-section {
    flex-direction: row;
    flex-wrap: wrap;
}

.portrait-mode .players-section {
    flex-direction: column;
}


/* Mobile Menu */
.mobile-menu {
    position: fixed;
    top: 0;
    left: -100%;
    width: 80%;
    max-width: 300px;
    height: 100vh;
    background: linear-gradient(180deg, var(--primary-color), var(--secondary-color));
    z-index: 1001;
    transition: left 0.3s ease;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
}

.mobile-menu.show {
    left: 0;
}

.mobile-menu-header {
    padding: 20px;
    background: var(--accent-color);
    color: var(--primary-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mobile-menu-header h3 {
    margin: 0;
    font-size: 1.5rem;
}

.close-menu-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-menu-content {
    padding: 20px;
}

.menu-item {
    display: block;
    width: 100%;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    border: none;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 8px;
    text-align: left;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.menu-item:active {
    background: rgba(255, 255, 255, 0.2);
    transform: translateX(5px);
}

.mobile-menu-trigger {
    position: fixed;
    top: 10px;
    left: 10px;
    background: var(--accent-color);
    color: var(--primary-color);
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    font-size: 1.2rem;
    z-index: 1000;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
}

.mobile-menu-trigger:active {
    transform: scale(0.9);
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-container {
        padding: 10px;
        min-height: 100vh;
        overflow-y: auto;
    }

    .game-header {
        margin-top: 10px;
        padding-top: 15px;
        position: relative;
        z-index: 1;
    }

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

    .game-info {
        flex-direction: column;
        gap: 10px;
    }

    .players-section {
        gap: 15px;
    }

    .player-slot {
        min-width: 100%;
        margin-bottom: 15px;
    }

    .dealer-section {
        margin-bottom: 20px;
    }

    /* Hide complex elements on mobile */
    .side-bets-panel,
    .insurance-area {
        display: none;
    }

    /* Simplify betting controls */
    .betting-controls {
        flex-direction: column;
        gap: 10px;
    }

    .bet-slider {
        width: 100%;
        margin-bottom: 10px;
    }

    /* Larger touch targets */
    .action-btn {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 16px;
        font-size: 16px;
        margin: 4px;
    }

    /* Compact layout for all buttons including player 1 */
    #player-1 .action-btn {
        font-size: 11px;
        padding: 6px 8px;
        min-height: 32px;
    }

    /* Single-row layout for player actions - Override grid layout */
    #player-1 .player-actions {
        display: flex !important;
        flex-wrap: nowrap !important;
        gap: 4px !important;
        justify-content: space-between !important;
        grid-template-columns: none !important;
        grid-template-rows: none !important;
        opacity: 1 !important;
        transform: none !important;
        visibility: visible !important;
    }

    #player-1 .player-actions .action-btn {
        flex: 1 !important;
        text-align: center !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    /* Card sizing for mobile */
    .card {
        width: 100px;
        height: 140px;
        margin: 2px;
    }

    /* Ensure all table containers can accommodate full card height */
    .poker-table,
    .table-surface,
    .table-cards,
    #table-cards {
        min-height: auto !important;
        height: auto !important;
        overflow: visible !important;
    }

    .table-cards,
    #table-cards {
        min-height: 150px !important;
    }

    /* Ensure table cards have same height as player cards */
    .table-cards .card,
    .table-cards .table-card,
    #table-cards .card,
    #table-cards .table-card {
        width: 100px !important;
        height: 140px !important;
    }

    /* Panel adjustments */
    .multiplayer-panel,
    .chat-panel {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 1001;
        background: var(--primary-color);
        overflow-y: auto;
    }

    .multiplayer-panel.hidden,
    .chat-panel.hidden {
        transform: translateY(100%);
    }

    /* Theme panel mobile override */
    .theme-panel {
        position: fixed;
        top: 0;
        right: -100%; /* Start off-screen to the right */
        width: 100%;
        height: 100%;
        z-index: 1001;
        background: var(--primary-color);
        overflow-y: auto;
        transition: right 0.3s ease-in-out;
    }

    .theme-panel.active {
        right: 0; /* Slide in from right */
    }

    /* Achievements panel mobile override */
    .achievements-panel {
        position: fixed;
        top: 0;
        left: -100%; /* Start off-screen to the left */
        width: 100%;
        height: 100%;
        z-index: 1001;
        background: var(--primary-color);
        overflow-y: auto;
        transition: left 0.3s ease-in-out;
    }

    .achievements-panel.active {
        left: 0; /* Slide in from left */
    }

    /* Modal mobile adjustments */
    .modal-content {
        width: 95%;
        max-width: none;
        margin: 10px;
    }

    .modal-body {
        padding: 20px;
        font-size: 1rem;
    }

    .modal-footer .action-btn {
        font-size: 1.1em;
        padding: 14px 25px;
        min-width: 150px;
    }




    /* Achievements close button for mobile */
    .achievements-close-btn {
        position: absolute;
        top: 15px;
        right: 15px;
        background: rgba(255, 255, 255, 0.2);
        border: none;
        color: var(--text-color);
        width: 40px;
        height: 40px;
        border-radius: 50%;
        font-size: 1.5rem;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;
        z-index: 10;
    }

    .achievements-close-btn:hover,
    .achievements-close-btn:active {
        background: rgba(255, 255, 255, 0.3);
        transform: scale(1.1);
    }

    .achievements-header {
        position: relative;
        padding-right: 60px;
    }

    /* Theme close button for mobile */
    .theme-close-btn {
        position: absolute;
        top: 15px;
        right: 15px;
        background: rgba(255, 255, 255, 0.2);
        border: none;
        color: var(--text-color);
        width: 40px;
        height: 40px;
        border-radius: 50%;
        font-size: 1.5rem;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;
        z-index: 10;
    }

    .theme-close-btn:hover,
    .theme-close-btn:active {
        background: rgba(255, 255, 255, 0.3);
        transform: scale(1.1);
    }

    .theme-header {
        position: relative;
        padding-right: 60px;
    }

    /* Game Over Modal mobile adjustments */
    .game-over-modal-content {
        width: 95%;
        max-width: none;
        margin: 10px;
    }

    .winner-announcement h3 {
        font-size: 1.8em;
    }

    .winner-subtitle {
        font-size: 1rem;
    }

    .player-summary {
        padding: 10px 12px;
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    .player-summary .player-name,
    .player-summary .rounds-won {
        font-size: 1rem;
    }

    .rounds-won {
        align-self: flex-end;
        min-width: 40px;
    }

    /* Prevent message text wrapping on mobile */
    .message-display {
        font-size: 13px;
        line-height: 1.2;
    }
}

@media (max-width: 480px) {
    .game-header h1 {
        font-size: 1.5rem;
    }

    .player-info h3 {
        font-size: 1rem;
    }

    .card {
        width: 90px;
        height: 126px;
    }

    /* Ensure all table containers can accommodate full card height */
    .poker-table,
    .table-surface,
    .table-cards,
    #table-cards {
        min-height: auto !important;
        height: auto !important;
        overflow: visible !important;
    }

    .table-cards,
    #table-cards {
        min-height: 135px !important;
    }

    /* Ensure table cards have same height as player cards */
    .table-cards .card,
    .table-cards .table-card,
    #table-cards .card,
    #table-cards .table-card {
        width: 90px !important;
        height: 126px !important;
    }

    .action-btn {
        font-size: 11px;
        padding: 6px 8px;
        min-height: 32px;
        min-width: auto;
    }

    /* Compact single-row layout for player actions - Apply to all players */
    .player-actions {
        display: flex !important;
        flex-wrap: nowrap !important;
        gap: 4px !important;
        justify-content: space-between !important;
        grid-template-columns: none !important;
        grid-template-rows: none !important;
        opacity: 1 !important;
        transform: none !important;
        visibility: visible !important;
    }

    .player-actions .action-btn {
        flex: 1 !important;
        text-align: center !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    /* Compact message display */
    .game-messages {
        font-size: 14px;
        padding: 10px;
        margin-top: 0;
    }

    .message-display {
        font-size: 12px;
        line-height: 1.2;
    }
}

/* Landscape mode optimizations */
@media (orientation: landscape) and (max-height: 500px) {
    .game-header {
        padding: 5px 0;
        margin-bottom: 10px;
        margin-top: 10px;
    }

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

    .players-section {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-around;
    }

    .player-slot {
        width: 48%;
        margin-bottom: 10px;
    }

}

/* Touch-specific animations */
@keyframes touchRipple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

.touch-ripple {
    position: relative;
    overflow: hidden;
}

.touch-ripple::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: scale(0);
    animation: touchRipple 0.6s linear;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin-left: -10px;
    margin-top: -10px;
}

/* Mobile tooltip */
.mobile-tooltip {
    position: fixed;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    z-index: 1002;
    pointer-events: none;
    white-space: nowrap;
}

/* Info modal styles */
.info-modal {
    z-index: 1003;
}

.info-modal-content {
    max-width: 90%;
    max-height: 85vh;
    overflow-y: auto;
}

.info-modal .modal-header {
    position: sticky;
    top: 0;
    background: var(--primary-color);
    padding-right: 60px;
    z-index: 20;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.info-body {
    padding: 20px;
    line-height: 1.6;
}

.info-section {
    margin-bottom: 25px;
}

.info-section h3 {
    color: var(--accent-color);
    margin-bottom: 10px;
    font-size: 1.2rem;
}

.info-section p {
    margin-bottom: 8px;
}

.info-section a {
    color: var(--accent-color);
    text-decoration: none;
}

.info-section a:hover {
    text-decoration: underline;
}

.info-section ul {
    list-style-type: disc;
    padding-left: 20px;
}

.info-section li {
    margin-bottom: 5px;
}

.close-info-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
    z-index: 10;
}

.close-info-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Help modal styles */
.help-modal {
    z-index: 1003;
}

.help-modal-content {
    max-width: 90%;
    max-height: 85vh;
    overflow-y: auto;
}

.help-modal .modal-header {
    position: sticky;
    top: 0;
    background: var(--primary-color);
    padding-right: 60px;
    z-index: 20;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.help-body {
    padding: 20px;
    line-height: 1.6;
}

.help-section {
    margin-bottom: 25px;
}

.help-section h3 {
    color: var(--accent-color);
    margin-bottom: 10px;
    font-size: 1.2rem;
}

.help-section p {
    margin-bottom: 8px;
}

.help-section ul {
    list-style-type: disc;
    padding-left: 20px;
}

.help-section li {
    margin-bottom: 8px;
}

.help-section strong {
    color: var(--accent-color);
}

.close-help-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
    z-index: 10;
}

.close-help-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Welcome modal close button */
.close-welcome-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
    z-index: 10;
}

.close-welcome-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Welcome modal header positioning */
.welcome-modal-content .modal-header {
    position: sticky;
    top: 0;
    background: var(--primary-color);
    padding-right: 60px;
    z-index: 20;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* General sticky header rule for all modals on mobile */
@media (max-width: 768px) {
    .modal-header {
        position: sticky !important;
        top: 0;
        background: var(--primary-color) !important;
        z-index: 20;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    }

    /* Ensure modal content can scroll properly */
    .modal-content {
        display: flex;
        flex-direction: column;
        max-height: 85vh;
    }

    .modal-body {
        flex: 1;
        overflow-y: auto;
    }
}

/* Accessibility improvements for mobile */
@media (prefers-reduced-motion: reduce) {
    .touch-active,
    .mobile-menu,
    * {
        transition: none !important;
        animation: none !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .action-btn {
        border: 2px solid var(--text-color);
    }

    .mobile-menu {
        border: 1px solid var(--text-color);
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .mobile-tooltip {
        background: rgba(255, 255, 255, 0.9);
        color: black;
    }
}

/* Prevent text selection during touch */
.no-select {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Prevent scrolling bounce on iOS */
.no-bounce {
    -webkit-overflow-scrolling: touch;
}

/* Safe area support for newer devices */
@supports (padding: max(0px)) {

    .mobile-menu-trigger {
        top: max(10px, env(safe-area-inset-top));
        left: max(10px, env(safe-area-inset-left));
    }

    .mobile-menu {
        padding-top: env(safe-area-inset-top);
        padding-left: env(safe-area-inset-left);
    }
}

/* Player Actions Visibility - Disabled for mobile to prevent disappearing */
/*
.player-actions.visible {
    opacity: 1;
    transform: scale(1.05);
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 100;
}

.player-actions {
    opacity: 0.7;
    transform: scale(1);
    transition: opacity 0.3s ease, transform 0.3s ease;
}
*/

/* Force player actions to always be visible and in single row on mobile */
@media (max-width: 768px) {
    .player-actions,
    #player-1 .player-actions {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
        grid-template-columns: none !important;
        grid-template-rows: none !important;
        gap: 4px !important;
        justify-content: space-between !important;
        align-items: center !important;
    }

    .player-actions .action-btn,
    #player-1 .player-actions .action-btn {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        flex: 1 !important;
        margin: 0 !important;
        min-width: 0 !important;
        text-align: center !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
}

/* Betting Area Minimized State */
.betting-area.minimized {
    opacity: 0.5;
    transform: scale(0.9);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Mobile Stats Panel */
.mobile-stats-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1002;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-stats-panel.show {
    opacity: 1;
}

.mobile-stats-panel .stats-content {
    background: var(--card-bg, white);
    padding: 20px;
    border-radius: 10px;
    max-width: 90%;
    text-align: center;
    position: relative;
    transform: scale(0.8);
    transition: transform 0.3s ease;
}

.mobile-stats-panel.show .stats-content {
    transform: scale(1);
}

.mobile-stats-panel .close-stats-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-color, black);
}