/* Все мобильные стили (до 768px) */
@media (max-width: 768px) {
    /* Общие для портрета и ландшафта */
    body {
        overflow: hidden;
        background: var(--tg-theme-bg-color, #111);
    }

    /* ===== ПОРТРЕТНАЯ ОРИЕНТАЦИЯ ===== */
    @media (orientation: portrait) {
        body {
            display: flex;
            flex-direction: column;
            height: 100vh;
        }

        .lyrics {
            flex: 1;
            overflow-y: auto;
            padding: 1rem;
            color: var(--tg-theme-text-color, #ddd);
            text-shadow: 2px 2px 4px #000;
            background: var(--tg-theme-bg-color, #111);
        }

        .lyrics-bg {
            opacity: 0.15;
        }

        .lyrics-content {
            font-size: 1.2rem;
            line-height: 1.6;
            padding: 0;
            max-height: none;
        }

        .karaoke-mode .lyrics-content {
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            text-align: center;
            overflow-y: hidden;
        }

        .prev-line {
            font-size: 1.5rem;
            margin-bottom: 1rem;
        }

        .current-line {
            font-size: 2.5rem;
            margin-bottom: 1rem;
            text-shadow: 0 0 15px var(--tg-theme-button-color, cyan);
        }

        .next-line {
            font-size: 1.5rem;
        }

        .container {
            background: var(--tg-theme-bg-color, #111);
            border-radius: 24px 24px 0 0;
            padding: 1rem;
            padding-bottom: calc(2rem + env(safe-area-inset-bottom, 30px));
            box-shadow: 0 -5px 20px rgba(0,0,0,0.5);
            z-index: 2;
            height: auto;
            transform: none !important;
        }

        .container.shifted {
            transform: none;
        }

        header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            color: var(--tg-theme-text-color, #ccc);
            font-size: 1.4rem;
            margin-bottom: 0.5rem;
        }

        main {
            display: flex;
            flex-direction: row;
            flex-wrap: wrap;
            align-items: center;
            justify-content: center;
            gap: 10px;
            margin-bottom: 0.5rem;
        }

        .album-title {
            width: 100%;
            order: 1;
            text-align: center;
            margin: 0 0 5px 0;
            font-size: 1.2rem;
            color: var(--tg-theme-text-color, #fff);
        }

        .album-art {
            order: 2;
            padding: 0;
            background: transparent;
            border-radius: 0;
            margin-bottom: 0;
            flex: 0 0 auto;
        }

        .album-art img {
            width: 150px;
            height: 150px;
            border-radius: 12px;
        }

        .player {
            order: 3;
            position: relative;
            width: 150px;
            height: 150px;
            background: linear-gradient(0deg, #222, #111);
            border-radius: 50%;
            border: solid 2px #000;
            box-shadow: inset 0 2px 4px rgba(255,255,255,0.2), 0 6px 4px rgba(0,0,0,0.3);
            margin: 0;
            flex: 0 0 auto;
        }

        .player .fa {
            font-size: 1.2rem;
            position: absolute;
            cursor: pointer;
            color: #fff;
            -webkit-tap-highlight-color: transparent;
        }

        .player .fa-play,
        .player .fa-pause {
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 70px;
            height: 70px;
            border: solid 2px #000;
            box-shadow: inset 0 2px 4px rgba(255,255,255,0.2), 0 0 8px rgba(0,0,0,0.8);
            border-radius: 50%;
            line-height: 70px;
            text-align: center;
            background: linear-gradient(0deg, #111, #222);
            font-size: 2rem;
        }

        .fa-repeat {
            top: 5%;
            left: 50%;
            transform: translateX(-50%);
        }

        .fa-fast-backward {
            top: 50%;
            left: 5%;
            transform: translateY(-50%);
        }

        .fa-fast-forward {
            top: 50%;
            left: auto;
            right: 5%;
            transform: translateY(-50%);
        }

        .fa-random {
            top: auto;
            bottom: 5%;
            left: 50%;
            transform: translateX(-50%);
        }

        .nav-indicator {
            font-size: 0.9rem;
        }

        .playlist-wrapper, .albums-wrapper {
            gap: 0.3rem;
        }

        time-tracker {
            order: 4;
            width: 100%;
            margin: 0.5rem 0;
        }

        .text-control {
            order: 5; /* чтобы шёл после таймлайна */
            margin: 0.5rem 0;
            justify-content: center;
        }

        .slider-container {
            flex: 1;
        }

        .time-labels {
            font-size: 0.7rem;
        }

        .slider-bar-bg {
            height: 5px; /* чуть тоньше на мобильных */
        }

        .text-toggle {
            font-size: 1.2rem;
        }

        .text-label {
            display: inline-block;
            font-size: 0.9rem;
        }

        .time {
            font-size: 0.8rem;
            min-width: 70px;
            color: var(--tg-theme-hint-color, #aaa);
        }

        .text-toggle {
            font-size: 1.2rem;
            color: var(--tg-theme-text-color, #ccc);
            -webkit-tap-highlight-color: transparent;
        }

        .text-toggle:hover,
        .text-toggle.active {
            color: var(--tg-theme-button-color, cyan);
        }

        /* Стиль для лейбла текста в портрете */
        .text-label {
            display: inline-block; /* Показываем всегда */
            font-size: 0.9rem;
        }

        footer {
            margin-top: 0;
            border-top: 1px solid var(--tg-theme-hint-color, #333);
            padding: 0.5rem 0 0 0;
            min-height: auto;
        }

        .track-info {
            gap: 0.5rem;
        }

        #album-cover {
            width: 50px;
            height: 50px;
            cursor: pointer;
        }

        .track-details {
            font-size: 0.9rem;
        }

        .track-title {
            font-size: 0.9rem;
            color: var(--tg-theme-text-color, #fff);
        }

        .author {
            font-size: 0.8rem;
            color: var(--tg-theme-hint-color, #aaa);
        }

        .contacts {
            font-size: 0.7rem;
            color: var(--tg-theme-hint-color, #888);
        }

        .panel-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.6);
            backdrop-filter: blur(3px);
            z-index: 99;
            opacity: 0;
            visibility: hidden;
            transition: opacity 0.3s ease, visibility 0.3s ease;
            pointer-events: none;
        }

        .panel-overlay.active {
            opacity: 1;
            visibility: visible;
            pointer-events: auto;
        }

        .panel {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 60vh;
            background: var(--tg-theme-bg-color, rgba(20, 20, 20, 0.98));
            backdrop-filter: blur(5px);
            box-shadow: 0 5px 15px rgba(0,0,0,0.5);
            transition: transform 0.3s ease;
            z-index: 100;
            padding: 1.5rem;
            border-radius: 0 0 24px 24px;
            transform: translateY(-100%);
            overflow-y: auto;
        }

        .panel.open {
            transform: translateY(0);
        }

        .panel-header {
            margin-bottom: 1.5rem;
        }

        #playlist li, #albumsList li {
            padding: 12px;
            background: rgba(128, 128, 128, 0.15);
            -webkit-tap-highlight-color: transparent;
        }

        #playlist li:hover, #albumsList li:hover {
            background: rgba(128, 128, 128, 0.25);
        }

        #playlist img, #albumsList img {
            width: 40px;
            height: 40px;
        }

        .bottom-spacer {
            display: block;
            height: 1rem;
        }
    }

    /* ===== ЛАНДШАФТНАЯ ОРИЕНТАЦИЯ ===== */
    @media (orientation: landscape) {
        body {
            display: grid;
            grid-template-columns: 1fr 400px;
            background: var(--tg-theme-bg-color, linear-gradient(180deg, #333, #111));
            height: 100vh;
            overflow: hidden;
        }

        .lyrics {
            height: 100vh;
            padding: 1rem;
            overflow-y: auto;
        }

        .lyrics-bg {
            opacity: 0.2;
        }

        .lyrics-content {
            font-size: 1.2rem;
            line-height: 1.5;
        }

        .prev-line {
            font-size: 1.5rem;
        }

        .current-line {
            font-size: 2.5rem;
            text-shadow: 0 0 15px var(--tg-theme-button-color, cyan);
        }

        .next-line {
            font-size: 1.5rem;
        }

        .container {
            background: var(--tg-theme-bg-color, #111);
            border-radius: 24px 0 0 24px;
            padding: 1rem;
            box-shadow: -5px 0 15px rgba(0,0,0,0.5);
            height: 100vh;
            display: flex;
            flex-direction: column;
            transform: none !important;
        }

        .container.shifted {
            transform: translateX(-320px);
        }

        header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            color: var(--tg-theme-text-color, #ccc);
            font-size: 1.4rem;
            margin-bottom: 0.5rem;
        }

        main {
            display: flex;
            flex-direction: column;
            align-items: center;
            flex: 1;
            justify-content: center;
        }

        .album-title {
            width: 100%;
            text-align: center;
            margin: 0.5rem 0;
            font-size: 1.2rem;
            color: var(--tg-theme-text-color, #fff);
        }

        .album-art {
            padding: 0.5rem;
            background: transparent;
            border-radius: 12px;
            margin-bottom: 0.5rem;
        }

        .album-art img {
            width: 180px;
            height: 180px;
            border-radius: 12px;
        }

        .player {
            position: relative;
            width: 180px;
            height: 180px;
            background: linear-gradient(0deg, #222, #111);
            border-radius: 50%;
            border: solid 2px #000;
            box-shadow: inset 0 2px 4px rgba(255,255,255,0.2), 0 6px 4px rgba(0,0,0,0.3);
            margin: 0.5rem 0;
        }

        .player .fa {
            font-size: 1.2rem;
            color: #fff;
            -webkit-tap-highlight-color: transparent;
        }

        .player .fa-play,
        .player .fa-pause {
            width: 80px;
            height: 80px;
            line-height: 80px;
            font-size: 2.2rem;
        }

        .time-tracker {
            width: 100%;
            max-width: 350px;
            margin: 0.5rem auto;
        }
        
        .text-control {
            justify-content: center;
            margin: 0.5rem auto;
            max-width: 350px;
        }

        .slider-bar-bg {
            height: 6px;
        }

        .text-label {
            display: inline-block;
        }

        .text-toggle {
            color: var(--tg-theme-text-color, #ccc);
            -webkit-tap-highlight-color: transparent;
        }

        .text-toggle:hover,
        .text-toggle.active {
            color: var(--tg-theme-button-color, cyan);
        }

        /* Лейбл текста в ландшафте */
        .text-label {
            display: inline-block;
        }

        footer {
            margin-top: auto;
            border-top: 1px solid var(--tg-theme-hint-color, #333);
            padding: 0.5rem 0;
            min-height: auto;
        }

        .track-info {
            gap: 0.5rem;
        }

        #album-cover {
            width: 60px;
            height: 60px;
            cursor: pointer;
        }

        .track-title {
            color: var(--tg-theme-text-color, #fff);
        }

        .panel-overlay {
            display: none;
        }

        .panel {
            position: absolute;
            top: 0;
            right: -320px;
            width: 300px;
            height: 100vh;
            background: var(--tg-theme-bg-color, rgba(20, 20, 20, 0.98));
            backdrop-filter: blur(5px);
            box-shadow: -5px 0 15px rgba(0,0,0,0.5);
            transition: right 0.3s ease;
            z-index: 10;
            padding: 1.5rem;
            overflow-y: auto;
            border-radius: 0;
        }

        .panel.open {
            right: 0;
        }

        .panel-header {
            margin-bottom: 1.5rem;
        }

        #playlist li, #albumsList li {
            padding: 12px;
            background: rgba(128, 128, 128, 0.15);
            -webkit-tap-highlight-color: transparent;
        }

        #playlist li:hover, #albumsList li:hover {
            background: rgba(128, 128, 128, 0.25);
        }

        #playlist img, #albumsList img {
            width: 40px;
            height: 40px;
        }

        .bottom-spacer {
            display: none;
        }
    }
}