/* =========================
   Global
========================= */
html, body {
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    width: 100%;
    max-width: 100vw;
    height: 100%;
    margin: 0;

    padding: 0;

    background: #121212;
    color: #ffffff;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto;

    text-align: center;
    touch-action: manipulation;
}

/*
    Wrapper
*/
#playlistSelectWrap {
    text-align: left;

    margin-top: 120px;
    margin-left: 0;
    padding-left: 10px;

    margin-bottom: 10px;
}
/* Remove default list styling */
#playlistListContainer ul,
#playlistListContainer li {
    list-style: none;
    padding-left: 0;
    margin-left: 0;
}

#playlistListContainer2 ul,
#playlistListContainer2 li {
    list-style: none;
    padding-left: 0;
    margin-left: 0;
}

/* =========================
   Main Container
========================= */
#mainContainer {
    width: 100%;
    max-width: 380px;
    margin: auto;
    background: #1b1b1b;
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.6);
    position: relative;
    z-index: 1;
}


/* =========================
   Heading
========================= */
h3 {
    margin-top: 0;
    font-weight: 500;
}

/* =========================
   YouTube Player
========================= */
#player {
    width: 90%;
    max-width: 800px; 
    height: 450px;            
    margin: 12px auto 18px auto;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.6);
}

#speedOverlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    
    font-size: 48px;
    font-weight: bold;
    color: #fff;
    
    background: rgba(0, 0, 0, 0.7);
    padding: 20px 40px;
    border-radius: 12px;

    z-index: 99999;

    opacity: 0;
    pointer-events: none;

    transition: opacity 0.3s;
}

/* =========================
   Inputs
========================= */
select,
input[type=text] {
    background: #2b2b2b;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px;
    margin: 6px;
    font-size: 16px;
    line-height: 1.4;
    appearance: none;
    box-sizing: border-box;
}

/* =========================
   Playlist Controls
========================= */
#playlistControls {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

/* =========================
   Round Buttons
========================= */
button {
    all: unset;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.circleBtn {
    background: linear-gradient(145deg, #777, #333);
    color: white;
    border: none;
    border-radius: 50%;
    width: 80px;
    height: 80px;
    font-size: 36px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    box-shadow:
        8px 8px 20px rgba(255,0,0,0.5),
        -6px -6px 15px rgba(255,255,255,0.25);
    transition: all 0.1s ease-in-out;
    touch-action: manipulation;
}

#btnPlay.circleBtn {
    width: 140px;
    height: 140px;
    font-size: 52px;
    background: linear-gradient(145deg, #ff6666, #cc0000);
    box-shadow:
        12px 12px 30px rgba(255,0,0,0.6),
        -12px -12px 20px rgba(255,255,255,0.3);
}

.circleBtn:active {
    transform: scale(0.95);
}
/* =========================
   Common Buttons
========================= */
.commonBtn {
    background: #555;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 16px;
    cursor: pointer;
}

.commonBtn:hover {
    background: #777;
}

.commonBtn:active {
    background: #999;
}

/* =========================
   Playlist
========================= */
#playlistView {
    list-style: none;
    padding: 0;
    margin: 8px 0;
    max-height: 300px;
    overflow-y: auto; /* PCは縦スクロール可能 */
}

#playlistView li {
    position: relative;
    background: #262626;
    margin-bottom: 6px;
    padding: 10px 10px 10px 28px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    text-align: center;
}

#playlistView li.nowPlaying {
    background: #7f1d1d;
    color: #ffffff;
    font-weight: bold;
}

#playlistView li.nowPlaying::before {
    content: "▶";
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: #ff4444;
    font-size: 18px;
}
/* =========================
   PlaylistContainer2（削除UI）
========================= */
#playlistWrapper2 {
    position: relative;
    width: 100%;
}

#playlistContainer2 {
    padding-top: 50px;
}

#deleteBtn2 {
    position: absolute;
    top: 8px;
    right: 12px;
    background: #7f1d1d;
    color: white;
    padding: 10px 15px;
    z-index: 10;
}

.playlistRow {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid black;
    margin: 5px;
    padding: 5px;
}

.playlistRow img {
    width: 120px;
    height: 90px;
    object-fit: cover;
    display: block;
    flex-shrink: 0;
}

.playlistRow > div:nth-child(2) {
    flex: 1;
    min-width: 0;
    text-align: left;
    word-break: break-word;
}

.checkBoxWrap {
    margin-left: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    flex-shrink: 0;
}

.delCheck {
    width: 18px;
    height: 18px;
    margin: 0;
    transform: translateY(0.5px);
}
/* =========================
   Dropdowns
========================= */
#libGenre,
#libArtist,
#libSong,
#plGenre,
#plArtist,
#plSong,
#playlistName {
    width: 100%;
    max-width: 300px;
    font-size: 16px;
    padding: 12px;
    margin: 6px;
    box-sizing: border-box;
}

/* =========================
   Divider
========================= */
hr {
    border: 0;
    border-top: 1px solid #333;
    margin: 14px 0;
}

/* =========================
   Login
========================= */
#loginArea,
#userArea {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 100;
}

#view-initial {
    padding: 12px;
    color: #fff;
    font-size: 14px;
    line-height: 1.6;
}

/* ラベル（ジャンル・歌手など） */
#view-initial b,
#view-initial label {
    display: block;
    margin-top: 10px;
    margin-bottom: 4px;
}

/* 入力系を統一 */
#view-initial select,
#view-initial input,
.commonBtn {
    width: auto;
    max-width: 300px;
    padding: 8px 12px;
    box-sizing: border-box;
}

/* 区切り（空div対策） */
#view-initial div {
    box-sizing: border-box;
}

/* ボタン統一 */
#view-initial .commonBtn {
    width: auto;
    max-width: 120px;
    padding: 6px 8px;
    font-size: 14px;
}

/* プレイリスト表示 */
#playlistView {
    margin-top: 10px;
    padding-left: 0;
}

/* 登録済みエリア */
#libGenre,
#libArtist,
#libSong {
    margin-bottom: 8px;
}

/* コントロールを縦並び */
#libControls {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
    justify-content: center;
}

#libControls .commonBtn {
    width: 200px;
    max-width: 120px;
    padding: 6px 8px;
    font-size: 14px;
}

/* 見出し強調 */
#view-initial b {
    margin-top: 12px;
    display: block;
}

/* =========================
   Playlist Extra Controls 
========================= */
#playlistExtraControls {
    display: flex !important;
    flex-direction: row !important;
    justify-content: center !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
}

#topMenuBar {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 9999;
}
/* =========================
  Section Title 
========================= */
.sectionTitle {
    display: block;
    width: 100%;
    font-size: 24px;
    font-weight: bold;
    color: #9a9a9a;

    text-align: left;
    letter-spacing: 2px;
    font-family: 'Segoe UI', 'Hiragino Kaku Gothic ProN', 'Meiryo', sans-serif;

    text-shadow: 3px 3px 0px rgba(255, 255, 255, 1);

    line-height: 1.8;
    padding-top: 15px;
    padding-bottom: 10px;
    margin-top: 15px;
    margin-bottom: 15px;

    border-bottom: none;
}

/* =========================
   Hamburger Menu Button 
========================= */
#hamburgerBtn {
    background: linear-gradient(145deg, #444444, #666666);
    color: #fff;
    border: none;
    border-radius: 50%; 
    width: 80px;
    height: 80px;
    font-size: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    box-shadow:
        8px 8px 20px rgba(255,0,0,0.5),  
        -6px -6px 15px rgba(255,255,255,0.25); 
    transition: all 0.1s ease-in-out;
}

#hamburgerBtn:hover {
    transform: scale(1.15);
    box-shadow:
        10px 10px 25px rgba(255,0,0,0.6),
        -8px -8px 20px rgba(255,255,255,0.3);
}

#hamburgerBtn:active {
    transform: scale(0.95);
    box-shadow:
        4px 4px 10px rgba(255,0,0,0.4),
        -2px -2px 5px rgba(255,255,255,0.15);
}

/* =========================
   Hamburger Menu Content
========================= */
#hamburgerContent {
    display: none;
    background: #1b1b1b;
    border-radius: 12px;
    position: absolute;
    top: 90px;
    right: 0;
    min-width: 250px;
    min-height: 300px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    overflow: hidden;
    z-index: 1000;
    padding: 20px;
    flex-direction: column;
    justify-content: flex-start;
    gap: 10px;
}

#hamburgerContent.show {
    display: flex;
}
/* messageBox */
#messageBox {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #111;
    border: 2px solid #ff3b3b;
    padding: 20px;
    min-width: 320px;
    z-index: 99999;
    text-align: center;
    color: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
    font-family: sans-serif;
}

#messageText {
    margin-bottom: 16px;
    font-size: 15px;
    line-height: 1.4;
}

#messageOkBtn {
    padding: 10px 24px;
    cursor: pointer;
    border: none;
    border-radius: 8px;

    background: linear-gradient(135deg, #ff3b3b, #ff7a18);
    color: white;
    font-weight: bold;
    font-size: 14px;

    box-shadow: 0 4px 12px rgba(255, 59, 59, 0.4);

    transition: all 0.2s ease;
}

#messageOkBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255, 59, 59, 0.6);
}

#messageOkBtn:active {
    transform: translateY(0px);
    box-shadow: 0 3px 8px rgba(255, 59, 59, 0.3);
}

/* =========================
   Header
========================= */
#currentTitle {
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    margin: 10px 0;
    color: #fff;
    letter-spacing: 1px;
}

#headerBar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 110px;
    background-color: rgba(27, 27, 27, 0.8);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-left: 20px;
    z-index: 9000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

#tubeAudio {
    font-size: 48px;
    font-weight: bold;
    font-family: 'Segoe UI', Roboto, system-ui;
    letter-spacing: 2px;
    color: #ff3300;
    text-shadow:
        1px 1px 0 #ff0000,
        2px 2px 2px #ff6600,
        0 0 6px #ff9900;
}

/* =========================
   フッターナビ
========================= */
#footerNav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 70px;
    background: rgba(15, 15, 15, 0.96);
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid rgba(255,255,255,0.08);
    z-index: 9999;
    backdrop-filter: blur(12px);
}

/* ボタン全体 */
#footerNav .navBtn {
    flex: 1;
    height: 100%;
    border: none;
    background: transparent;
    color: #aaa;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    transition: 0.2s;
    font-size: 11px;
}

/* アイコン部分 */
#footerNav .navBtn::before {
    font-size: 22px;
    line-height: 1;
}

/* テキスト */
#footerNav .navBtn {
    font-weight: 500;
}

/* ホバー */
#footerNav .navBtn:hover {
    color: #fff;
    transform: translateY(-2px);
}

/* 選択中 */
#footerNav .navBtn.active {
    color: #ff3b30;
}

/* アイコン割り当て */
#footerNav .navBtn.home::before {
    content: "🏠";
}

#footerNav .navBtn.search::before {
    content: "🔍";
}

#footerNav .navBtn.library::before {
    content: "📚";
}

#footerNav .navBtn.settings::before {
    content: "⚙";
}
/* =========================
   フッターリンク
========================= */
.settingsLink {
    color: #fff;              
    text-decoration: none;  
}

.settingsLink:hover {
    color: red; 
    text-decoration: underline;
    text-decoration-color: red;
}

.playlistRow2 {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
}

.playlistThumb {
    width: 120px;
    height: 90px;
    flex-shrink: 0;
}

.playlistText {
    flex: 1;
    text-align: left;
}

.playlistCheck {
    width: 60px; 
    display: flex;
    justify-content: center;
    align-items: center;
}

.delCheck {
    margin: 0;
}

button img {
    width: 70px;
    height: auto;
    display: block;
}

.playBtn img {
    width: 110px;
    height: auto;
}

td button {
    transition: transform 0.1s ease;
}

td button:active {
    transform: scale(0.92);
}

#libraryTable th:nth-child(1),
#libraryTable td:nth-child(1) { width: 8%; }

#libraryTable th:nth-child(2),
#libraryTable td:nth-child(2) { width: 7%; }

#libraryTable th:nth-child(3),
#libraryTable td:nth-child(3) { width: 10%; }

#libraryTable th:nth-child(4),
#libraryTable td:nth-child(4) { width: auto; }

#libraryTable {
    width: 100%;
    table-layout: fixed;
}

#searchBox {
    position: fixed;
    bottom: 60px;
    left: 0;
    width: 200px;
    display: none;
    padding: 8px;
    font-size: 14px;
    z-index: 999;
}
/*
　背景画像
*/
#view-initial::after,
#view-playlist-create::after,
#view-playlist-delete::after {
    content: "";
    position: fixed;

    top: 80px;
    right: 0;

    width: 320px;
    height: calc(100vh - 120px);

    background-image: url("img/bk.png");
    background-repeat: no-repeat;
    background-position: right calc(100% + 20px);
    background-size: auto 90%;

    pointer-events: none;
    z-index: 999;
    opacity: 1;
}

#view-initial > *,
#view-playlist-create > *,
#view-playlist-delete > * {
    position: relative;
    z-index: 1;
}

#view-service,
#view-function,
#view-copyright,
#view-help {
    background-color: #000;

    background-image: url("img/bk3.png"), url("img/bk2.png");
    background-repeat: no-repeat;

    background-position: 
        left calc(100% + 20px),
        right calc(100% + 20px);

    background-size: auto 90%;

    min-height: 100vh;
}
/* =========================
   MOBILE（統合済み）
========================= */
@media (max-width: 768px) {

    #libraryTable {
        width: 100% !important;
        table-layout: fixed;
    }

    #libraryTable th,
    #libraryTable td {
        font-size: 10px;
        padding: 3px;
    }

    #libraryTable th {
        text-align: center;
    }

    #libraryTable th:nth-child(1),
    #libraryTable td:nth-child(1) {
        width: 16%;
        white-space: nowrap;
    }

    #libraryTable th:nth-child(2),
    #libraryTable td:nth-child(2) { width: 10%; }

    #libraryTable th:nth-child(3),
    #libraryTable td:nth-child(3) { width: 14%; }

    #libraryTable th:nth-child(4) {
        width: 60%;
        text-align: center;
    }

    #libraryTable td:nth-child(4) {
        width: 60%;
        text-align: left;
    }
}

@media (max-width: 1024px) {
    /* =========================
       基本レイアウト
    ========================= */
    html,
    body {
        overflow-x: hidden;
        overflow-y: auto;
        max-width: 100vw;
        max-height: 100vh;
    }

    /* =========================
       ヘッダー
    ========================= */
    #headerBar {
        height: 70px !important;
    }

    #hamburgerBtn {
        width: 50px !important;
        height: 50px !important;
        font-size: 18px !important;
        box-shadow:
            4px 4px 10px rgba(255, 0, 0, 0.35),
            -2px -2px 6px rgba(255, 255, 255, 0.15);
    }

    #tubeAudio {
        font-size: 20px !important;
    }

    /* =========================
       プレイヤー
    ========================= */
    #player {
        width: 100vw !important;
        height: 260px !important;
        margin: 0 !important;
        padding: 0 !important;
        display: block;
    }

    #player iframe {
        width: 100% !important;
        height: 100% !important;
    }

    /* =========================
       コントロール系
    ========================= */
    #playlistControls {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 6px !important;
    }

    #playlistExtraControls {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 6px !important;
    }

    #playlistSelectWrap {
        display: block !important;
        align-self: flex-start !important;
        margin: 0 !important;
        padding: 0 !important;
        font-size: 0;
    }

    /* =========================
       ボタン類
    ========================= */
.circleBtn {
    width: 28px !important;
    height: 28px !important;
    font-size: 11px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;

    background: #444;
    color: #fff !important;
    border: none !important;

    flex: 0 0 auto !important;
}

#btnPlay.circleBtn {
    width: 48px !important;
    height: 48px !important;
    font-size: 16px !important;

    background: linear-gradient(145deg, #ff3b3b, #b80000) !important;

}

    /* =========================
       フォーム系
    ========================= */
    select,
    input[type=text] {
        font-size: 12px !important;
        padding: 4px !important;
    }

    #selectPlaylist {
        font-size: 14px !important;
    }

    /* =========================
       プレイリスト表示
    ========================= */
    #playlistView {
        margin-top: 6px !important;
        width: 100% !important;
    }

    #playlistView li {
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
        font-size: 11px !important;
    }

    #playlistView img {
        width: 60px !important;
        height: 45px !important;
    }

    #playlistView li > div {
        font-size: 11px !important;
        line-height: 1.2 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

}
@media (max-width: 768px) {

    .playlistRow2 {
        gap: 6px;
        padding: 3px;
    }

    .playlistThumb {
        width: 70px;
        height: 50px;
    }

    .playlistText {
        font-size: 11px !important;
        line-height: 1.2 !important;
    }

    .playlistText * {
        font-size: 11px !important;
    }

    .playlistCheck {
        width: 40px;
    }

    .delCheck {
        width: 14px;
        height: 14px;
    }
}
@media (max-width: 768px) {

    #playlistSelects {
        display: flex !important;
        flex-direction: row !important;
        gap: 4px !important;
        width: 100%;
    }

    #playlistSelects select {
        flex: 1 !important;
        min-width: 0 !important;
        font-size: 11px !important;
        padding: 3px !important;
    }

    #view-playlist-create {
        display: block;
    }

    #playlistName,
    #createPlaylistBtn {
        display: inline-block !important;
        vertical-align: middle !important;
    }

    #playlistName {
        width: 60% !important;
        font-size: 12px !important;
        margin-top: 5px;
    }

    #createPlaylistBtn {
        width: 35% !important;
        font-size: 12px !important;
        margin-left: 5px;
    }
}
@media (max-width: 1024px) {
    #libGenre,
    #libArtist,
    #libSong,
    #plGenre,
    #plArtist,
    #plSong,
    #playlistName {
        width: 90% !important;
        max-width: 140px;
        font-size: 12px !important;
        padding: 6px !important;
        box-sizing: border-box;
    }
}
@media (max-width: 1024px) {
    #createPlaylistBtn {
        width: 90px !important;
    }
}
@media (max-width: 1024px) {
    #libGenre {
        width: 25% !important;
    }

    #libArtist {
        width: 25% !important;
    }

    #libSong {
        width: 30% !important;
    }

    #libGenre,
    #libArtist,
    #libSong {
        max-width: none !important;
    }
}
@media (max-width: 768px) {

    td button img {
        width: 45px;
        height: auto;
        display: block;
    }

    .playBtn img {
        width: 70px;
        height: auto;
        display: block;
    }

    #btnRew,
    #btnFwd {
        font-size: 10px;
        padding: 3px 5px;
    }

    td button {
        padding: 0;
        margin: 0;
        border: none;
        background: transparent;
    }
}

@media screen and (max-width: 768px) {

    #view-initial,
    #view-playlist-create,
    #view-playlist-delete {
        background: none !important;
    }

    #view-initial::before,
    #view-playlist-create::before,
    #view-playlist-delete::before {

        content: "";
        position: absolute;
        inset: 0;

        background-image: url("img/bk3.png");
        background-repeat: no-repeat;
        background-position: right center;
        background-size: auto 80%;

        opacity: 0.8;
        pointer-events: none;
        z-index: 0;
    }

    #view-initial > *,
    #view-playlist-create > *,
    #view-playlist-delete > * {
        position: relative;
        z-index: 1;
    }

    #view-initial::after,
    #view-playlist-create::after,
    #view-playlist-delete::after {
        display: none;
    }
}

@media screen and (max-width: 768px) {

    #view-service,
    #view-function,
    #view-copyright,
    #view-help {
        background: none !important;
    }

    #view-service::before,
    #view-function::before,
    #view-copyright::before,
    #view-help::before {

        content: "";
        position: absolute;
        inset: 0;

        background-image: url("img/bk2.png");
        background-repeat: no-repeat;
        background-position: right center;
        background-size: auto 80%;

        opacity: 0.8;
        pointer-events: none;
        z-index: 0;
    }

    #view-service > *,
    #view-function > *,
    #view-copyright > *,
    #view-help > * {
        position: relative;
        z-index: 1;
    }

    #view-service::after,
    #view-function::after,
    #view-copyright::after,
    #view-help::after {
        display: none;
    }
}