/**
 * Mobile Landscape Layout - Optimized for Horizontal Play
 * Everything fits on screen or in modals
 */

/* =========================
   MOBILE BASE FIXES
   ========================= */
@media (max-width: 900px) {
  html {
    height: 100%;
    height: 100vh;
    height: -webkit-fill-available;
  }
  
  body {
    min-height: 100%;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    overflow: hidden;
    position: relative;
  }
  
  /* Fix for rotation issues */
  * {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
  }
}

/* =========================
   FORCE LANDSCAPE ORIENTATION
   ========================= */
@media (max-width: 900px) and (orientation: portrait) {
  /* Hide game container in portrait */
  #game-container {
    display: none !important;
  }
  
  /* Rotation prompt overlay */
  body::before {
    content: '📱 Please rotate your device';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    color: #fff;
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    z-index: 999999;
    text-align: center;
    padding: 20px;
    animation: rotatePromptPulse 2s ease-in-out infinite;
  }
  
  body::after {
    content: '↻';
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) translateY(60px);
    font-size: 5rem;
    color: #ffd700;
    z-index: 999999;
    animation: rotateIcon 3s ease-in-out infinite;
  }
  
  @keyframes rotatePromptPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
  }
  
  @keyframes rotateIcon {
    0%, 100% { transform: translate(-50%, -50%) translateY(60px) rotate(0deg); }
    50% { transform: translate(-50%, -50%) translateY(60px) rotate(90deg); }
  }
}

/* =========================
   LANDSCAPE LAYOUT (< 900px width in landscape)
   ========================= */
@media (max-width: 900px) and (orientation: landscape) {
  /* Full screen app-like experience */
  html {
    width: 100%;
    height: 100vh;
    height: -webkit-fill-available;
    overflow: hidden;
  }
  
  body {
    width: 100%;
    height: 100vh;
    height: -webkit-fill-available;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    margin: 0;
    padding: 0;
  }
  
  /* Remove pseudo-elements in landscape */
  body::before,
  body::after {
    display: none !important;
  }
  
  #game-container {
    display: grid !important;
    grid-template-columns: 140px 1fr 140px;
    grid-template-rows: 45px 1fr 70px;
    gap: 0;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    width: 100vw;
    padding: 0;
    margin: 0;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    transition: opacity 0.2s ease;
    font-size: 0.9rem;
  }
  
  /* =========================
     TOP BAR (spans all columns)
     ========================= */
  .game-hud,
  .desktop-nav {
    display: none !important;
  }
  
  .mobile-nav {
    grid-column: 1 / -1;
    grid-row: 1;
    display: flex !important;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(10, 10, 10, 0.95);
    border-bottom: 1px solid rgba(255, 215, 0, 0.2);
    align-items: center;
    justify-content: space-between;
    z-index: 100;
  }
  
  .mobile-nav-left,
  .mobile-nav-center,
  .mobile-nav-right {
    display: flex;
    gap: 8px;
    align-items: center;
  }
  
  .mobile-nav-center {
    flex: 1;
    justify-content: center;
  }
  
  .mobile-nav button {
    min-height: 36px;
    font-size: 0.85rem;
    padding: 8px 12px;
  }
  
  /* Chips/Keys display in nav */
  .mobile-chips-display {
    display: flex;
    gap: 12px;
    font-size: 0.9rem;
    font-weight: bold;
  }
  
  .mobile-chips-display .chips {
    color: #ffd700;
  }
  
  .mobile-chips-display .keys {
    color: #9C27B0;
  }
  
  /* =========================
     LEFT SIDEBAR - Waiting List
     ========================= */
  .waiting-list {
    grid-column: 1;
    grid-row: 2;
    position: static;
    width: 100%;
    max-width: none;
    height: 100%;
    margin: 0;
    padding: 8px;
    background: rgba(0, 0, 0, 0.7);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .waiting-list h2 {
    font-size: 0.85rem;
    margin-bottom: 8px;
    color: #ffd700;
  }
  
  #waiting-list-list {
    list-style: none;
    padding: 0;
  }
  
  #waiting-list-list li {
    font-size: 0.75rem;
    padding: 6px;
    margin: 3px 0;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  /* =========================
     CENTER - Game Table
     ========================= */
  .game-table {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    padding: 12px;
    gap: 12px;
    min-height: 0;
    overflow: hidden;
  }
  
  /* Dealer area - compact */
  .dealer-area {
    flex: 0 0 auto;
    padding: 8px;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }
  
  .dealer-area-left {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  
  .deck {
    width: 40px;
    height: 60px;
    flex-shrink: 0;
  }
  
  #dealer-hand {
    display: flex;
    gap: 3px;
    flex-wrap: nowrap;
  }
  
  #dealer-hand .card {
    width: 40px;
    height: 60px;
    min-width: 40px;
    font-size: 0.75rem;
  }
  
  #dealer-value {
    padding: 4px 8px;
    font-size: 0.85rem;
    margin: 0;
  }
  
  /* Players area - horizontal scroll */
  .players-area {
    flex: 1;
    display: flex;
    flex-direction: row;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 6px 4px;
    align-items: stretch;
    min-height: 0;
  }
  
  .player-spot {
    flex: 0 0 auto;
    min-width: 140px;
    max-width: 160px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    height: auto;
  }
  
  .player-name {
    font-size: 0.8rem;
    margin: 0;
  }
  
  .player-chips {
    font-size: 0.75rem;
    padding: 3px 6px;
  }
  
  .hand {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
    justify-content: center;
    min-height: 65px;
    margin: 4px 0;
  }
  
  .player-spot .card {
    width: 40px;
    height: 60px;
    min-width: 40px;
    font-size: 0.75rem;
  }
  
  /* Card suit size handled by mobile-comprehensive-fix.css */
  
  .hand-value {
    font-size: 0.8rem;
    padding: 3px;
    margin: 3px 0;
  }
  
  .player-result {
    font-size: 0.75rem;
    padding: 4px;
    margin: 3px 0;
  }
  
  /* Messages */
  #message,
  #round-result {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 12px 20px;
    font-size: 1rem;
    max-width: 300px;
    z-index: 50;
  }
  
  /* =========================
     RIGHT SIDEBAR - Leaderboard
     ========================= */
  .leaderboard {
    grid-column: 3;
    grid-row: 2;
    position: static;
    width: 100%;
    max-width: none;
    height: 100%;
    top: auto;
    right: auto;
    margin: 0;
    padding: 8px;
    background: rgba(0, 0, 0, 0.7);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .leaderboard h2 {
    font-size: 0.85rem;
    margin-bottom: 8px;
    color: #ffd700;
  }
  
  #leaderboard-list {
    list-style: none;
    padding: 0;
  }
  
  #leaderboard-list li {
    font-size: 0.75rem;
    padding: 6px;
    margin: 3px 0;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
  }
  
  #refresh-leaderboard-btn {
    width: 100%;
    margin-bottom: 6px;
    padding: 4px;
    font-size: 0.75rem;
  }
  
  /* =========================
     BOTTOM BAR - Actions
     ========================= */
  .action-bar {
    grid-column: 1 / -1;
    grid-row: 3;
    position: static;
    display: flex;
    gap: 8px;
    padding: 12px;
    background: rgba(10, 10, 10, 0.98);
    border-top: 1px solid rgba(255, 215, 0, 0.2);
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
    bottom: auto;
    left: auto;
    right: auto;
  }
  
  .action-bar button {
    flex: 1;
    max-width: 140px;
    min-height: 44px;
    font-size: 0.95rem;
    padding: 10px 12px;
  }
  
  /* Betting controls - bottom bar */
  #betting-controls,
  .betting-controls {
    grid-column: 1 / -1;
    grid-row: 3;
    position: static;
    display: flex !important;
    gap: 12px;
    padding: 12px;
    background: rgba(10, 10, 10, 0.98);
    border-top: 1px solid rgba(255, 215, 0, 0.2);
    justify-content: center;
    align-items: center;
    bottom: auto;
    left: auto;
    right: auto;
  }
  
  .betting-controls.hidden {
    display: none !important;
  }
  
  .bet-label {
    font-size: 0.9rem;
    margin: 0;
  }
  
  .bet-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
  }
  
  #bet-amount {
    width: 120px;
    min-height: 44px;
    font-size: 1rem;
    padding: 10px;
  }
  
  #place-bet {
    min-height: 44px;
    min-width: 100px;
    padding: 10px 20px;
    font-size: 1rem;
  }
  
  /* =========================
     CHAT - Modal Overlay (Bottom Right Position)
     ========================= */
  .bj-chat-toggle {
    position: fixed !important;
    bottom: 90px !important;
    right: 12px !important;
    top: auto !important;
    width: 52px !important;
    height: 52px !important;
    z-index: 10002 !important;
    font-size: 1.5rem !important;
    background: #ffd700 !important;
    color: #000 !important;
    border: none !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.7) !important;
  }
  
  .bj-chat-badge {
    top: -6px !important;
    right: -6px !important;
    width: 22px !important;
    height: 22px !important;
    font-size: 0.75rem !important;
    background: #ff4444 !important;
    border: 2px solid #ffd700 !important;
    border-radius: 50% !important;
  }
  
  /* Chat panel - starts hidden off-screen */
  #chat-panel {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: calc(var(--vh, 1vh) * 100) !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    z-index: 10000 !important;
    transform: translateX(100%) !important;
    transition: transform 0.3s ease !important;
    display: flex !important;
    flex-direction: column !important;
  }
  
  /* When chat is open */
  #chat-panel.bj-open {
    transform: translateX(0) !important;
  }
  
  .chat-header {
    padding: 12px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    background: rgba(0, 0, 0, 0.95) !important;
    border-bottom: 1px solid rgba(255, 215, 0, 0.2) !important;
    flex-shrink: 0 !important;
  }
  
  .chat-header h2 {
    font-size: 1rem !important;
  }
  
  .bj-chat-close {
    min-width: 40px !important;
    min-height: 40px !important;
    font-size: 1.5rem !important;
  }
  
  #chat-messages {
    flex: 1 !important;
    overflow-y: auto !important;
    padding: 10px !important;
    background: rgba(10, 10, 10, 0.98) !important;
  }
  
  #chat-form {
    padding: 10px !important;
    background: rgba(0, 0, 0, 0.95) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
    flex-shrink: 0 !important;
  }
  
  .bj-chat-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: rgba(0, 0, 0, 0.7) !important;
    z-index: 9999 !important;
    display: none !important;
  }
  
  .bj-chat-overlay.bj-show {
    display: block !important;
  }
  
  /* =========================
     MODALS - Full Screen
     ========================= */
  .modal-content {
    width: 90vw;
    max-width: 500px;
    max-height: 80vh;
    padding: 20px;
  }
  
  .modal-content h2 {
    font-size: 1.3rem;
  }
  
  .modal-content input {
    min-height: 44px;
    font-size: 1rem;
  }
  
  .modal-content button {
    min-height: 48px;
    font-size: 1.1rem;
  }
  
  /* =========================
     HIDE SEASON BADGE (space saving)
     ========================= */
  #season-badge {
    display: none;
  }
  
  /* =========================
     COMPACT CARD STYLES
     ========================= */
  .card::before,
  .card::after {
    font-size: 0.9rem !important;
  }
  
  .card::before {
    top: 2px;
    left: 3px;
  }
  
  .card::after {
    bottom: 2px;
    right: 3px;
  }
}

/* =========================
   SMALL PHONES (320-568px landscape)
   ========================= */
@media (max-width: 568px) and (orientation: landscape) {
  #game-container {
    grid-template-columns: 110px 1fr 110px;
    grid-template-rows: 38px 1fr 62px;
    font-size: 0.8rem;
  }
  
  .waiting-list,
  .leaderboard {
    padding: 5px;
  }
  
  .waiting-list h2,
  .leaderboard h2 {
    font-size: 0.7rem;
    margin-bottom: 6px;
  }
  
  #waiting-list-list li,
  #leaderboard-list li {
    font-size: 0.65rem;
    padding: 4px;
    margin: 2px 0;
  }
  
  .player-spot {
    min-width: 115px;
    padding: 5px;
  }
  
  .player-name {
    font-size: 0.7rem;
  }
  
  .player-chips {
    font-size: 0.65rem;
  }
  
  .player-spot .card,
  #dealer-hand .card,
  .deck {
    width: 36px;
    height: 54px;
    min-width: 36px;
    font-size: 0.7rem;
  }
  
  /* Card suit size handled by mobile-comprehensive-fix.css */
  
  .action-bar button {
    font-size: 0.7rem;
    padding: 6px 8px;
    min-height: 38px;
  }
  
  .mobile-nav button {
    font-size: 0.7rem;
    padding: 5px 8px;
    min-height: 32px;
  }
  
  .mobile-chips-display {
    font-size: 0.75rem;
  }
  
  #dealer-value {
    font-size: 0.75rem;
    padding: 3px 6px;
  }
}

/* =========================
   MEDIUM PHONES (569-768px landscape)
   ========================= */
@media (min-width: 569px) and (max-width: 768px) and (orientation: landscape) {
  #game-container {
    grid-template-columns: 145px 1fr 145px;
    grid-template-rows: 44px 1fr 68px;
    font-size: 0.85rem;
  }
  
  .waiting-list,
  .leaderboard {
    padding: 7px;
  }
  
  .waiting-list h2,
  .leaderboard h2 {
    font-size: 0.8rem;
  }
  
  #waiting-list-list li,
  #leaderboard-list li {
    font-size: 0.72rem;
    padding: 5px;
  }
  
  .player-spot {
    min-width: 145px;
    padding: 7px;
  }
  
  .player-name {
    font-size: 0.78rem;
  }
  
  .player-chips {
    font-size: 0.72rem;
  }
  
  .player-spot .card,
  #dealer-hand .card,
  .deck {
    width: 42px;
    height: 63px;
    min-width: 42px;
    font-size: 0.78rem;
  }
  
  /* Card suit size handled by mobile-comprehensive-fix.css */
  
  .action-bar button {
    font-size: 0.8rem;
    padding: 8px 10px;
    min-height: 42px;
  }
  
  .mobile-nav button {
    font-size: 0.78rem;
    padding: 6px 10px;
    min-height: 36px;
  }
  
  #dealer-value {
    font-size: 0.82rem;
  }
}

/* =========================
   LARGER PHONES/SMALL TABLETS (769-900px landscape)
   ========================= */
@media (min-width: 769px) and (max-width: 900px) and (orientation: landscape) {
  #game-container {
    grid-template-columns: 160px 1fr 160px;
    grid-template-rows: 46px 1fr 72px;
    font-size: 0.9rem;
  }
  
  .waiting-list,
  .leaderboard {
    padding: 8px;
  }
  
  .waiting-list h2,
  .leaderboard h2 {
    font-size: 0.85rem;
  }
  
  #waiting-list-list li,
  #leaderboard-list li {
    font-size: 0.75rem;
    padding: 6px;
  }
  
  .player-spot {
    min-width: 155px;
    padding: 8px;
  }
  
  .player-name {
    font-size: 0.82rem;
  }
  
  .player-chips {
    font-size: 0.76rem;
  }
  
  .player-spot .card,
  #dealer-hand .card,
  .deck {
    width: 45px;
    height: 67px;
    min-width: 45px;
    font-size: 0.82rem;
  }
  
  /* Card suit size handled by mobile-comprehensive-fix.css */
  
  .action-bar button {
    font-size: 0.85rem;
    padding: 8px 12px;
    min-height: 44px;
  }
  
  .mobile-nav button {
    font-size: 0.82rem;
    padding: 7px 11px;
    min-height: 38px;
  }
  
  #dealer-value {
    font-size: 0.88rem;
  }
}

