/* Letter Bloom - Mobile Portrait Styles */

/* Portrait Mode Detection and Layout */
@media screen and (max-width: 768px) and (orientation: portrait),
       screen and (max-aspect-ratio: 9/16) {
    
    /* Adjust body for mobile */
    body {
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    /* Mobile Game Wrapper - Full Screen */
    .game-wrapper {
        width: 100vw;
        height: 100vh;
        max-width: none;
        max-height: none;
        border-radius: 0;
        padding: 10px;
        display: flex;
        flex-direction: column;
    }
    
    /* Compact Header for Mobile */
    .game-header {
        padding: 5px 10px;
        margin-bottom: 10px;
        flex-direction: column;
        gap: 5px;
    }
    
    .game-header h1 {
        font-size: 1.8em;
        letter-spacing: 2px;
        margin-bottom: 5px;
    }
    
    .header-right {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .level-info {
        padding: 8px 15px;
        gap: 15px;
        font-size: 0.9em;
        flex: 1;
    }
    
    .help-button {
        width: 30px;
        height: 30px;
        font-size: 1em;
    }
    
    /* Mobile Game Area - Vertical Stack */
    .game-area {
        display: flex !important;
        flex-direction: column;
        gap: 10px;
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }
    
    /* Top Section - Crossword (1/3 of screen) */
    .left-panel {
        order: 1;
        flex: 0 0 35%;
        display: flex;
        flex-direction: column;
        gap: 10px;
        min-height: 0;
    }
    
    .crossword-container {
        flex: 1;
        padding: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 0;
        overflow: auto;
    }
    
    /* Smaller crossword cells on mobile */
    .crossword-cell {
        width: 22px !important;
        height: 22px !important;
        font-size: 0.8em !important;
        margin: 1px;
        border-radius: 4px;
    }
    
    /* Middle Section - Found Words (horizontal scroll) */
    .right-panel {
        order: 2;
        flex: 0 0 auto;
        display: flex;
        flex-direction: row;
        gap: 10px;
        padding: 10px;
        background: rgba(255, 255, 255, 0.08);
        border-radius: 15px;
        max-height: 120px;
        overflow: hidden;
    }
    
    .found-words, .bonus-words {
        flex: 1;
        min-width: 0;
    }
    
    .found-words h3, .bonus-words h3 {
        font-size: 0.85em;
        margin-bottom: 8px;
        padding-bottom: 5px;
    }
    
    .words-list {
        max-height: 60px;
        overflow-x: auto;
        overflow-y: hidden;
        display: flex;
        flex-wrap: nowrap;
        gap: 5px;
        padding-bottom: 5px;
    }
    
    .found-word, .bonus-word {
        font-size: 0.8em;
        padding: 4px 10px;
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    /* Bottom Section - Controls and Letter Wheel */
    .center-panel {
        order: 3;
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        gap: 10px;
        padding-bottom: 10px;
        min-width: unset;
    }
    
    /* Current word display - more compact */
    .current-word {
        font-size: 1.5em;
        min-height: 35px;
        letter-spacing: 4px;
        margin-bottom: 5px;
    }
    
    /* Horizontal button row */
    .controls {
        display: flex;
        flex-direction: row !important;
        gap: 8px;
        width: 100%;
        margin-top: 5px;
        margin-bottom: 10px;
        padding: 0 10px;
    }
    
    .controls button {
        flex: 1;
        padding: 10px 8px;
        font-size: 0.85em;
        border-radius: 20px;
        letter-spacing: 0;
    }
    
    /* Letter wheel container - at bottom */
    .letter-circle-container {
        height: 160px;
        margin-top: auto;
        background: radial-gradient(circle, rgba(255, 255, 255, 0.03) 0%, transparent 60%);
    }
    
    .letter-circle {
        width: 150px;
        height: 150px;
        margin: 0 auto;
    }
    
    /* Smaller letter buttons on mobile */
    .letter-button {
        width: 38px;
        height: 38px;
        font-size: 1em;
    }
    
    /* Adjust SVG for smaller circle */
    #connectionLine {
        width: 150px !important;
        height: 150px !important;
    }
    
    /* Hide or relocate media player on mobile */
    .media-player {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: 0;
        border-top: 1px solid rgba(255, 255, 255, 0.2);
        padding: 8px 15px;
        background: rgba(0, 0, 0, 0.9);
        backdrop-filter: blur(20px);
        z-index: 100;
        transform: translateY(100%);
        transition: transform 0.3s ease;
    }
    
    /* Show media player when music toggle is active */
    .media-player.active {
        transform: translateY(0);
    }
    
    /* Compact media player controls */
    .media-player-inner {
        gap: 5px;
    }
    
    .track-info {
        height: 20px;
        font-size: 0.8em;
    }
    
    .player-controls {
        gap: 5px;
    }
    
    .player-btn {
        width: 28px;
        height: 28px;
    }
    
    .player-btn.play-pause {
        width: 32px;
        height: 32px;
    }
    
    .volume-slider {
        max-width: 80px;
    }
    
    /* Music toggle button for mobile */
    .music-toggle-mobile {
        display: flex !important;
        position: fixed;
        bottom: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
        border-radius: 50%;
        background: linear-gradient(135deg, rgba(102, 126, 234, 0.9), rgba(240, 147, 251, 0.9));
        backdrop-filter: blur(10px);
        border: 2px solid rgba(255, 255, 255, 0.3);
        align-items: center;
        justify-content: center;
        font-size: 1.5em;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
        z-index: 101;
        cursor: pointer;
        transition: transform 0.3s ease;
    }
    
    .music-toggle-mobile:active {
        transform: scale(0.95);
    }
    
    /* Hide desktop music toggle on mobile */
    .music-toggle {
        display: none !important;
    }
    
    /* Adjust message popup for mobile */
    .message {
        top: 60px;
        font-size: 0.95em;
        padding: 10px 20px;
        border-radius: 25px;
        min-width: 150px;
    }
    
    /* Loading screen adjustments */
    .loading {
        font-size: 1.1em;
    }
    
    /* Help modal adjustments for mobile */
    .modal-content {
        max-width: 95%;
        max-height: 90vh;
        padding: 20px;
        margin: 10px;
    }
    
    .modal-content h2 {
        font-size: 1.5em;
    }
    
    .help-section h3 {
        font-size: 1.1em;
    }
    
    .example-cell {
        width: 28px;
        height: 28px;
        font-size: 0.9em;
    }
    
    /* Custom scrollbar for mobile */
    .words-list::-webkit-scrollbar {
        height: 4px;
    }
    
    .words-list::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.05);
        border-radius: 2px;
    }
    
    .words-list::-webkit-scrollbar-thumb {
        background: linear-gradient(90deg, rgba(102, 126, 234, 0.5), rgba(240, 147, 251, 0.5));
        border-radius: 2px;
    }
}

/* Landscape adjustments for mobile devices */
@media screen and (max-width: 768px) and (orientation: landscape) {
    .game-wrapper {
        padding: 5px;
    }
    
    .game-header {
        margin-bottom: 5px;
    }
    
    .game-header h1 {
        font-size: 1.5em;
    }
    
    .game-area {
        gap: 10px;
    }
    
    /* Use more horizontal space in landscape */
    .left-panel {
        flex: 0 0 45%;
    }
    
    .letter-circle-container {
        height: 140px;
    }
    
    .letter-circle {
        width: 130px;
        height: 130px;
    }
    
    .letter-button {
        width: 34px;
        height: 34px;
        font-size: 0.9em;
    }
}

/* Tablet Portrait (iPad) */
@media screen and (min-width: 769px) and (max-width: 1024px) and (orientation: portrait) {
    .game-wrapper {
        width: 95vw;
        max-width: 800px;
        padding: 20px;
    }
    
    .game-area {
        display: flex !important;
        flex-direction: column;
        gap: 15px;
    }
    
    .left-panel {
        order: 1;
        flex: 0 0 40%;
    }
    
    .right-panel {
        order: 2;
        flex: 0 0 auto;
        max-height: 150px;
    }
    
    .center-panel {
        order: 3;
        flex: 1;
    }
    
    .letter-circle-container {
        height: 180px;
    }
    
    .letter-circle {
        width: 160px;
        height: 160px;
    }
}

/* Touch-specific enhancements */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .letter-button {
        min-width: 44px;
        min-height: 44px;
    }
    
    .controls button {
        min-height: 44px;
    }
    
    .player-btn {
        min-width: 44px;
        min-height: 44px;
    }
    
    /* Disable hover effects on touch devices */
    .letter-button:hover {
        transform: none;
    }
    
    .controls button:hover {
        transform: none;
    }
}

/* Animations for mobile */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}