/* リセット & ベース */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #111;
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-user-select: none;
    user-select: none;
}

#canvas {
    touch-action: none;
}

.hidden {
    display: none !important;
}

/* ドロップゾーン */
.drop-zone {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    transition: background 0.3s;
}

.drop-zone.dragover {
    background: linear-gradient(135deg, #0f3460 0%, #16213e 100%);
}

.drop-content {
    text-align: center;
    padding: 2rem;
}

.drop-content h1 {
    font-size: 2rem;
    margin-bottom: 1rem;
    font-weight: 300;
    letter-spacing: 2px;
}

.drop-content p {
    color: #aaa;
    margin-bottom: 1rem;
    font-size: 1rem;
}

.btn {
    display: inline-block;
    padding: 0.75rem 2rem;
    font-size: 1rem;
    color: #fff;
    background: #e94560;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.btn:hover {
    background: #c73e54;
}

.btn:active {
    transform: scale(0.98);
}

/* ビューワー */
.viewer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
}

#canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ローディング */
.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 30;
    pointer-events: none;
}

.spinner {
    width: 48px;
    height: 48px;
    margin: 0 auto 1rem;
    border: 3px solid rgba(255,255,255,0.2);
    border-top-color: #e94560;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* UIオーバーレイ */
.ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    pointer-events: none;
}

.ui-overlay > * {
    pointer-events: auto;
}

/* アイコンボタン */
.icon-btn {
    background: rgba(0,0,0,0.5);
    border: none;
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.icon-btn:hover {
    background: rgba(0,0,0,0.7);
}

.icon-btn svg {
    width: 24px;
    height: 24px;
}

/* 位置指定 */
.ui-top-left {
    position: absolute;
    top: 1rem;
    left: 1rem;
}

.ui-top-right {
    position: absolute;
    top: 1rem;
    right: 1rem;
}

/* 動画コントロール */
.video-controls {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(0,0,0,0.6);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    max-width: 90vw;
    flex-wrap: wrap;
}

.video-controls input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
}

.video-controls input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
}

.video-controls input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: #e94560;
    border-radius: 50%;
    margin-top: -5px;
}

#seek-bar {
    width: 200px;
    flex: 1;
    min-width: 120px;
}

#volume-bar {
    width: 80px;
}

#time-display {
    font-size: 0.8rem;
    color: #ccc;
    white-space: nowrap;
    min-width: 90px;
    text-align: center;
}

/* トースト通知 */
.toast {
    position: fixed;
    top: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(0,0,0,0.8);
    color: #fff;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.95rem;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
    max-width: 90vw;
    text-align: center;
    word-break: break-word;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* safe-area対応 */
.ui-top-left {
    top: max(1rem, env(safe-area-inset-top));
    left: max(1rem, env(safe-area-inset-left));
}

.ui-top-right {
    top: max(1rem, env(safe-area-inset-top));
    right: max(1rem, env(safe-area-inset-right));
}

.video-controls {
    bottom: max(1rem, env(safe-area-inset-bottom));
}

/* タッチターゲット拡大 */
.icon-btn {
    width: 48px;
    height: 48px;
}

/* Firefox range slider */
.video-controls input[type="range"]::-moz-range-track {
    height: 4px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
}

.video-controls input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #e94560;
    border-radius: 50%;
    border: none;
}

/* モバイル対応 */
@media (max-width: 640px) {
    .drop-content h1 {
        font-size: 1.5rem;
    }

    .video-controls {
        gap: 0.5rem;
        padding: 0.4rem 0.75rem;
    }

    #seek-bar {
        width: 140px;
    }

    #time-display {
        font-size: 0.7rem;
        min-width: 75px;
    }

    .icon-btn {
        width: 44px;
        height: 44px;
    }
}
