:root {
    --primary-blue: #16adf8;
    --primary-hover: #0294e0;
    --active-cyan: #00e5ff;

    --dark-bg: #0f172a;
    --panel-black: #111827;
    --panel-surface: #1e293b;
    --panel-deep: #0f172a;
    --border-gray: #334155;
    --text-gray: #94a3b8;
    --panel-divider: #1e293b;

    --range-thumb-size: 56px;
    --control-btn-size: 52px;
    --control-gap: 12px;
    --volume-width: 125px;
    --time-width: 108px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Courier New', Courier, monospace;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    min-height: 100vh;
    background-color: var(--dark-bg);
    background-image: url('./image/background.jpg');
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    -ms-overflow-style: none;
    scrollbar-width: none;
    -webkit-user-select: none;
    user-select: none;
}

html::-webkit-scrollbar, body::-webkit-scrollbar { display: none; }
a { text-decoration: none; }

body {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.viewport-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.cassette-player {
    background: linear-gradient(145deg, var(--panel-surface), var(--panel-deep));
    border: 5px solid var(--border-gray);
    border-radius: 20px;
    width: auto;
    height: 600px;
    min-width: 840px;
    max-width: 96vw;
    padding: 28px 34px;
    opacity: 0.75;
    transition: opacity 0.2s ease, transform 0.2s ease;
    margin-top: 100px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.85), inset 0 1px 3px rgba(255, 255, 255, 0.12);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.cassette-player:hover {
    opacity: 0.75;
}

.player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    font-size: 14px;
    font-weight: bold;
    color: var(--text-gray);
    border-bottom: 2px solid var(--panel-divider);
    padding-bottom: 8px;
    min-height: 44px;
}

.now-playing {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    max-width: 420px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 14px;
    color: #fff;
}

.embed-code-label {
    margin-left: auto;
    color: var(--primary-blue);
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.now-playing.marquee {
    display: inline-block;
    padding-left: 100%;
    animation: marquee-scroll 12s linear infinite;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--primary-blue);
    letter-spacing: 1.5px;
}

.brand.playing-glow .brand-text {
    background: linear-gradient(90deg, #16adf8, #00e5ff, #3b82f6, #8b5cf6, #16adf8);
    background-size: 200% auto;
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    animation: rainbow-glow 4s linear infinite;
}

@keyframes rainbow-glow {
    0% { background-position: 0% center; }
    100% { background-position: 200% center; }
}

.player-body { display: flex; flex-direction: column; gap: 18px; }

.marquee {
    padding-left: 100%;
    animation: marquee-scroll 12s linear infinite;
}
@keyframes marquee-scroll { 100% { transform: translate(-100%, 0); } }

.progress-section {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
    height: 74px;
    padding: 0 6px;
}

.progress-section::before {
    content: '';
    position: absolute;
    inset: 14px 0 14px 0;
    background-image: radial-gradient(circle at 20% 50%, rgba(0, 229, 255, 0.22) 0%, transparent 22%),
                      radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.18) 0%, transparent 18%),
                      radial-gradient(circle at 80% 50%, rgba(0, 229, 255, 0.22) 0%, transparent 22%);
    background-size: 18% 100%, 22% 100%, 18% 100%;
    background-repeat: no-repeat;
    filter: blur(1px);
    opacity: 0.75;
    transform-origin: center;
    transform: scaleY(var(--wave-scale, 1));
    transition: transform 0.1s ease;
    z-index: 0;
}

.progress-section.playing::before {
    animation: waveform-vibe 0.35s ease-in-out infinite;
}

@keyframes waveform-vibe {
    0%, 100% { transform: scaleY(var(--wave-scale, 1)); }
    50% { transform: scaleY(calc(var(--wave-scale, 1) + 0.08)); }
}

.progress-section input[type="range"] {
    position: relative;
    z-index: 1;
    flex: 1 1 auto;
    min-width: 0;
    height: 10px;
    border-radius: 999px;
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background: linear-gradient(90deg, rgba(22, 173, 248, 0.24), rgba(255,255,255,0.07));
    margin: 0;
}

.progress-section input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: var(--range-thumb-size);
    height: var(--range-thumb-size);
    border-radius: 16px;
    border: none;
    background: url('./image/logo.png') center/contain no-repeat;
    box-shadow: none;
    cursor: pointer;
}

.progress-section input[type="range"]::-moz-range-thumb {
    width: var(--range-thumb-size);
    height: var(--range-thumb-size);
    border-radius: 16px;
    border: none;
    background: url('./image/logo.png') center/contain no-repeat;
    box-shadow: none;
    cursor: pointer;
}

.progress-section input[type="range"]::-ms-thumb {
    width: var(--range-thumb-size);
    height: var(--range-thumb-size);
    border-radius: 16px;
    border: none;
    background: url('./image/logo.png') center/contain no-repeat;
    box-shadow: none;
    cursor: pointer;
}

.time-display {
    font-size: 13px;
    font-weight: bold;
    color: var(--active-cyan);
    white-space: nowrap;
    min-width: var(--time-width);
    text-align: right;
    letter-spacing: 0.4px;
}

.controls-panel {
    display: flex;
    align-items: center;
    gap: var(--control-gap);
    flex-wrap: nowrap;
    width: 100%;
    padding: 0 4px;
    box-sizing: border-box;
    overflow: hidden;
}
.controls { display: flex; gap: var(--control-gap); flex: 0 0 auto; }

.btn.icon-btn {
    background: linear-gradient(to bottom, #334155, #1e293b);
    border: 1px solid #0f172a;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 3px 0 var(--panel-black);
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 0 0 var(--control-btn-size);
    width: var(--control-btn-size);
    height: var(--control-btn-size);
    transition: background 0.15s ease, transform 0.1s ease;
}

.btn.icon-btn svg { width: 22px; height: 22px; fill: #fff; pointer-events: none; }

.btn.icon-btn:active, .btn.icon-btn.active {
    box-shadow: 0 1px 0 var(--panel-black);
    transform: translateY(2px);
    background: linear-gradient(to bottom, var(--primary-blue), var(--primary-hover));
}

.volume-container { display: flex; align-items: center; gap: 10px; flex: 0 0 var(--volume-width); width: var(--volume-width); max-width: var(--volume-width); box-sizing: border-box; overflow: hidden; }
    .vol-btn { background: none; border: none; cursor: pointer; display: flex; padding: 2px; }
    .vol-btn svg { width: 20px; height: 20px; fill: var(--text-gray); transition: fill 0.2s; pointer-events: none; }
    .vol-btn:hover svg { fill: var(--primary-blue); }

    .volume-container input { flex: 1 1 auto; width: auto; height: 7px; accent-color: var(--primary-blue); cursor: pointer; max-width: calc(var(--volume-width) - 36px); }

.playlist-section {
    border-top: 1px dashed var(--border-gray);
    padding-top: 15px;
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 10px;
}

.playlist-header { 
    display: flex; 
    align-items: center; 
    gap: 12px; 
    margin-bottom: 10px;
}

.playlist-columns-title {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 5px;
    padding-right: 34px;
    font-size: 13px;
    font-weight: bold;
    color: var(--text-gray);
}

.col-title-name {
    flex: 1;
    text-align: left;
    padding-left: 10px;
    min-width: 0;
}

.col-title-link {
    flex: 2;
    text-align: left;
    padding-left: 10px;
    min-width: 0;
}

.add-row-btn {
    background-color: #0369a1;
    border: 1px solid var(--primary-blue);
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    width: 30px;
    height: 30px;
    margin-left: 5px;
    font-size: 18px;
    transition: all 0.2s ease;
}
.add-row-btn:hover { background-color: var(--primary-blue); box-shadow: 0 0 8px rgba(22, 173, 248, 0.4); }

.delete-row-btn {
    background-color: #1e293b;
    border: 1px solid var(--border-gray);
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-gray);
    width: 30px;
    height: 30px;
    font-size: 18px;
    transition: all 0.2s ease;
}

.delete-row-btn:hover {
    background-color: #334155;
    color: var(--primary-blue);
    border-color: var(--primary-blue);
    box-shadow: 0 0 6px rgba(22, 173, 248, 0.3);
}

.track-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: 299px;
    overflow-y: auto;
    padding-right: 6px;
    -webkit-overflow-scrolling: touch;
}

.track-list::-webkit-scrollbar { width: 6px; }
.track-list::-webkit-scrollbar-track { background: #0f172a; border-radius: 4px; }
.track-list::-webkit-scrollbar-thumb { background: var(--border-gray); border-radius: 4px; }

.track-row { 
    display: flex; 
    gap: 10px;
    margin: 5px; 
    align-items: center; 
    cursor: grab; 
}

.track-row.dragging {
    opacity: 0.6;
    cursor: grabbing;
}

.track-row.drag-over {
    outline: 2px dashed var(--primary-blue);
    outline-offset: 2px;
    border-radius: 4px;
}

.track-row.fade-in { animation: fadeInRow 0.15s ease-out forwards; }

@keyframes fadeInRow {
    from { opacity: 0; }
    to { opacity: 1; }
}

.track-index {
    width: 30px;
    height: 30px;
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    color: var(--primary-blue);
    flex-shrink: 0;
    margin-top: 10px;
    margin-right: 8px;
}

.track-row input {
    background-color: var(--panel-black);
    border: 1px solid var(--border-gray);
    color: #fff;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 15px;
    text-align: left;
    user-select: text !important;
}

.track-row input:focus { outline: none; border-color: var(--primary-blue); }
.input-title { flex: 1; }
.input-url { flex: 2; }

.track-row .input-title,
.track-row .input-url {
    padding-left: 10px;
}

.track-row.active-track input {
    border-color: var(--primary-blue);
    background-color: #0c4a6e;
}


@media screen and (max-width: 768px) and (orientation: portrait) {
    body {
        align-items: center;
        overflow: hidden;
    }

    .viewport-wrapper {
        width: 100vh;
        height: 100vw;
        transform: rotate(90deg);
        transform-origin: center center;
        display: flex;
        justify-content: center;
        align-items: flex-start;
    }

    .cassette-player {
        margin-top: 15px;
        width: 92vh;
        max-width: 100vh;
        padding: 12px 16px;
        gap: 8px;
        border-width: 3px;
    }

    .controls-panel {
        gap: 8px;
        padding: 0 2px;
    }

    .track-list { max-height: 120px; }
    .btn.icon-btn {
        width: 44px;
        height: 44px;
        flex-basis: 44px;
    }
    .btn.icon-btn svg { width: 20px; height: 20px; }
    .time-display { min-width: 96px; font-size: 12px; }
    .volume-container { flex-basis: 108px; width: 108px; max-width: 108px; gap: 8px; }
}

@media screen and (max-width: 900px) and (orientation: landscape) {
    .cassette-player {
        margin-top: 10px;
        width: 96vw;
        padding: 10px 16px;
        gap: 8px;
    }

    .track-list { max-height: 100px; }
}