/* ============================================
   MOBILE CASINO LAYOUT - Teen Patti
   Professional mobile-first responsive design
   ============================================ */

/* iPhone SE, iPhone 8, and similar (up to 480px) */
@media screen and (max-width: 480px) {

    /* ========== BASE LAYOUT ========== */
    html, body {
        overflow: hidden;
        height: 100%;
        height: -webkit-fill-available;
    }

    #game-container {
        height: 100%;
        height: -webkit-fill-available;
        overflow: hidden;
    }

    .screen {
        height: 100%;
        overflow: hidden;
    }

    /* ========== START SCREEN - Full Cover ========== */
    #start-screen {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        z-index: 10000 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-start !important;
        padding: 20px !important;
        padding-top: 40px !important;
        box-sizing: border-box !important;
        background: linear-gradient(180deg, #1a0a20 0%, #0d0510 50%, #0a0308 100%) !important;
    }

    #start-screen:not(.active) {
        display: none !important;
    }

    /* Hide game screen when start screen active */
    #start-screen.active ~ #game-screen {
        visibility: hidden !important;
    }

    .landing-background {
        display: none !important;
    }

    .landing-content {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 15px !important;
        width: 100% !important;
        max-width: 300px !important;
    }

    .game-logo {
        width: 120px !important;
        height: auto !important;
        margin-bottom: 10px !important;
    }

    .game-title {
        font-size: 1.8rem !important;
        margin-bottom: 20px !important;
    }

    .player-setup {
        width: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
    }

    #player-name {
        width: 100% !important;
        padding: 12px 16px !important;
        font-size: 1rem !important;
        border-radius: 8px !important;
        box-sizing: border-box !important;
    }

    #start-game-btn {
        width: 100% !important;
        padding: 14px 20px !important;
        font-size: 1.1rem !important;
        font-weight: bold !important;
        border-radius: 8px !important;
    }

    /* ========== GAME SCREEN LAYOUT ========== */
    #game-screen {
        display: flex;
        flex-direction: column;
        height: 100%;
        padding: 4px;
        gap: 4px;
        overflow: hidden;
    }

    /* ========== TOP BAR - Compact ========== */
    #top-bar {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        gap: 6px;
        padding: 6px;
        flex-shrink: 0;
    }

    .top-bar-left,
    .top-bar-right {
        display: flex;
        gap: 4px;
    }

    #top-bar .btn-small {
        padding: 6px 10px;
        font-size: 0.65rem;
        min-width: auto;
    }

    .btn-small .settings-label,
    .btn-small .instructions-label,
    .btn-small .card-color-label {
        display: none;
    }

    .round-info,
    .stake-info {
        font-size: 0.65rem;
        padding: 3px 6px;
    }

    /* ========== POT DISPLAY - Compact ========== */
    .pot-display-wrapper {
        flex-shrink: 0;
    }

    .pot-display {
        padding: 4px 10px;
        gap: 6px;
        flex-direction: row;
    }

    .pot-label {
        font-size: 0.5rem;
    }

    .pot-value {
        font-size: 1rem;
    }

    /* ========== GAME TABLE - Round with padding ========== */
    #game-table {
        flex: 1 !important;
        width: 100% !important;
        max-width: 100% !important;
        min-height: 280px !important;
        max-height: 55vh !important;
        margin: 0 auto !important;
        padding: 0 15px !important;
        transform: none !important;
        box-sizing: border-box !important;
    }

    .table-felt {
        width: 45% !important;
        height: 45% !important;
        border-radius: 50% !important;
    }

    .table-center::before {
        width: 40px;
        height: 28px;
    }

    /* ========== PLAYER SEATS - Spread Out ========== */
    .player-seat {
        min-width: 70px !important;
        max-width: 100px !important;
        padding: 3px 5px !important;
        border-radius: 6px !important;
    }

    .player-seat[data-position="bottom"] {
        bottom: -100px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
    }

    .player-seat[data-position="top"] {
        top: -100px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
    }

    .player-seat[data-position="left"] {
        left: -80px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
    }

    .player-seat[data-position="right"] {
        right: -80px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
    }

    .player-info {
        gap: 3px;
    }

    .player-name {
        font-size: 1rem;
        font-weight: bold;
    }

    .player-chips {
        font-size: 0.9rem;
        gap: 4px;
    }

    .chip-icon {
        width: 14px;
        height: 14px;
    }

    .player-status {
        font-size: 0.7rem;
        padding: 3px 8px;
    }

    /* ========== CARDS - Slightly Smaller ========== */
    .card {
        width: 32px !important;
        height: 45px !important;
        min-width: 32px !important;
        min-height: 45px !important;
    }

    .player-cards {
        gap: 2px;
        min-height: 40px;
    }

    .card-back {
        border-width: 1px;
    }

    .card-face {
        border-radius: 3px !important;
    }

    .card-rank {
        font-size: 0.75rem !important;
        font-weight: bold !important;
    }

    .card-suit {
        font-size: 0.55rem !important;
    }

    .card-center {
        font-size: 1rem !important;
    }

    .card-bottom {
        display: none;
    }

    /* ========== DEALER BUTTON ========== */
    #dealer-button {
        width: 22px;
        height: 22px;
        font-size: 0.6rem;
    }

    /* ========== POT CHIPS - Visible ========== */
    #pot-chips {
        display: flex;
        justify-content: center;
        gap: 2px;
    }

    #pot-chips .chip {
        width: 28px;
        height: 28px;
    }

    .chip .chip-value {
        font-size: 0.5rem;
    }

    /* ========== CONTROLS PANEL - Always visible ========== */
    #controls-panel {
        flex-shrink: 0;
        width: 100%;
        padding: 6px 4px;
        padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
        margin-top: auto;
        gap: 6px;
    }

    /* ========== ACTION BUTTONS - 3x2 Grid ========== */
    #action-buttons {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px 6px;
        width: 100%;
    }

    .btn-action {
        flex: 1 1 calc(33.33% - 10px);
        max-width: calc(33.33% - 10px);
        min-width: 0;
        padding: 14px 8px;
        font-size: 0.8rem;
        letter-spacing: 0.5px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .btn-action.hidden {
        display: none;
    }

    /* ========== BET SLIDER - Compact ========== */
    #bet-slider-container {
        padding: 6px;
        gap: 6px;
    }

    .chip-presets {
        gap: 4px;
    }

    .chip-preset {
        min-width: 36px;
        height: 28px;
        padding: 2px 4px;
        font-size: 0.55rem;
    }

    .bet-display {
        padding: 4px 10px;
    }

    #bet-amount-display {
        font-size: 0.9rem;
    }

    /* ========== MODALS - Full screen on mobile ========== */
    .modal-content {
        width: 95%;
        max-width: 95%;
        max-height: 85vh;
        padding: 16px;
    }

    .modal-content h2 {
        font-size: 1.2rem;
    }

    /* ========== MESSAGE DISPLAY ========== */
    #message-display {
        bottom: 100px;
    }

    .message {
        font-size: 0.7rem;
        padding: 6px 12px;
    }

    /* ========== THINKING SPINNER ========== */
    .thinking-spinner {
        transform: scale(0.7);
    }
}

/* Very small phones (iPhone SE 1st gen, 320px) */
@media screen and (max-width: 360px) {
    #game-table {
        transform: scale(0.55);
        max-height: 45vh;
    }

    .card {
        width: 22px;
        height: 30px;
    }

    .player-seat {
        min-width: 50px;
        padding: 2px 4px;
    }

    .player-name {
        font-size: 0.5rem;
    }

    .player-chips {
        font-size: 0.45rem;
    }

    .btn-action {
        padding: 8px 3px;
        font-size: 0.55rem;
    }

    #top-bar .btn-small {
        padding: 3px 4px;
        font-size: 0.5rem;
    }
}

/* iPad and tablets */
@media screen and (min-width: 481px) and (max-width: 1024px) {
    #game-table {
        max-width: 90%;
        transform: scale(0.85);
    }

    .btn-action {
        padding: 12px 16px;
        font-size: 0.85rem;
    }
}

/* Landscape phones */
@media screen and (max-height: 450px) and (orientation: landscape) {
    #game-screen {
        flex-direction: row;
        flex-wrap: wrap;
    }

    #top-bar {
        width: 100%;
        padding: 2px 4px;
    }

    #game-table {
        flex: 1;
        max-width: 55%;
        max-height: 80vh;
        transform: scale(0.6);
    }

    #controls-panel {
        flex: 0 0 40%;
        max-width: 40%;
        padding: 4px;
    }

    .btn-action {
        padding: 6px 4px;
        font-size: 0.55rem;
    }

    .pot-display-wrapper {
        position: absolute;
        top: 40px;
        left: 50%;
        transform: translateX(-50%);
    }
}
