* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

main {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #000;
    color: #fff;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
    overflow-x: hidden;
}

h1 {
    font-size: 16px;
    font-weight: normal;
    text-align: center;
    margin-bottom: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.header-title {
    font-size: 24px;
    font-weight: bold;
}

.by-text {
    display: block;
}

h1 a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
}

h1 a:hover {
    opacity: 0.85;
}

h1 a:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.upload-area {
    border: 2px dashed #555;
    border-radius: 8px;
    padding: 60px 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 30px;
    max-width: 600px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.upload-area:hover {
    border-color: #888;
    background: #111;
}

.upload-text {
    font-size: 18px;
    margin-bottom: 20px;
}

.btn {
    background: #333;
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn:hover {
    background: #555;
}

#videoInput {
    display: none;
}

.video-container {
    display: none;
    text-align: center;
    margin: 20px 0;
    max-width: 900px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

video {
    width: 100%;
    max-width: 640px;
    max-height: 60vh;
    border-radius: 4px;
    border: 1px solid #444;
}

.controls {
    margin: 20px auto;
    display: none;
    max-width: 900px;
    width: 100%;
}

.controls-container {
    max-width: 600px;
    width: 100%;
    margin: 0 auto 20px;
}

.info {
    color: #aaa;
    font-size: 14px;
    margin-bottom: 15px;
    text-align: center;
}

.time-control {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 0 auto;
    width: 100%;
}

.time-control label {
    white-space: nowrap;
}

h2 {
    font-size: 1.2em;
    margin-bottom: 15px;
}

input[type="number"] {
    width: 80px;
    padding: 8px;
    font-size: 16px;
    background: #2a2a2a;
    color: #fff;
    border: 1px solid #444;
    border-radius: 4px;
}

input[type="range"] {
    flex: 1;
    height: 6px;
    background: #444;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: #007bff;
    border-radius: 50%;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #007bff;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.action-buttons button {
    background: #007bff;
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 16px;
    border-radius: 4px;
    cursor: pointer;
    margin: 5px;
}

.action-buttons button:hover {
    background: #0056b3;
}

.action-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 15px 0;
}

.reset-btn {
    background: #6c757d !important;
}

.reset-btn:hover {
    background: #5a6268 !important;
}

canvas {
    display: none;
}

.preview {
    margin-top: 20px;
    display: none;
    max-width: 900px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

.preview img {
    max-width: 100%;
    border: 1px solid #444;
    border-radius: 4px;
    margin: 10px 0;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.95);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px;
    max-width: 90%;
    max-height: 90vh;
}

.modal-content h2 {
    color: #fff;
    margin-bottom: 20px;
    font-size: 24px;
}

.modal-content img {
    max-width: 100%;
    max-height: 60vh;
    border: 2px solid #fff;
    border-radius: 4px;
    margin-bottom: 20px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.modal-download-btn {
    background: #007bff;
    color: #fff;
    padding: 12px 32px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
}

.modal-download-btn:hover {
    background: #0056b3;
}

.modal-close-btn {
    background: #6c757d;
    color: #fff;
    padding: 12px 32px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
}

.modal-close-btn:hover {
    background: #5a6268;
}

.modal-text {
    color: #fff;
    text-align: center;
    margin: 10px 0;
    font-size: 16px;
}

.mobile-only {
    display: none;
}

.desktop-only {
    display: block;
}

.action-buttons .desktop-only {
    display: inline-block;
}

.info {
    color: #aaa;
    font-size: 14px;
    margin: 10px 0;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (prefers-color-scheme: light) {
    body {
        background: #f5f5f5;
        color: #000;
    }
    
    h1 a:focus-visible {
        outline-color: #000;
    }
    
    .upload-area {
        border-color: #ccc;
    }
    
    .upload-area:hover {
        border-color: #999;
        background: #e8e8e8;
    }
    
    .btn {
        background: #e0e0e0;
        color: #000;
    }
    
    .btn:hover {
        background: #d0d0d0;
    }
    
    video {
        border-color: #ddd;
    }
    
    input[type="number"] {
        background: #fff;
        color: #000;
        border-color: #ccc;
    }
    
    input[type="range"] {
        background: #ddd;
    }
    
    .preview img {
        border-color: #ddd;
    }
    
    .info {
        color: #666;
    }
    
    .modal {
        background: rgba(255,255,255,0.95);
    }
    
    .modal-content h2 {
        color: #000;
    }
    
    .modal-content img {
        border-color: #000;
    }
    
    .modal-text {
        color: #000;
    }
}

@media (max-width: 768px) {
    body {
        padding: 20px 10px;
        justify-content: flex-start;
    }
    
    .header-title {
        font-size: 20px;
    }
    
    h1 {
        margin-bottom: 20px;
    }
    
    .upload-area {
        width: 90%;
        padding: 40px 20px;
    }
    
    .video-container {
        margin: 10px 0;
    }
    
    video {
        max-height: 40vh;
        width: auto;
        max-width: 100%;
    }
    
    .controls {
        margin: 10px auto;
    }
    
    .controls-container {
        max-width: 80%;
    }
    
    .info {
        font-size: 12px;
        margin-bottom: 10px;
    }
    
    .time-control {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .time-control label {
        width: 100%;
    }
    
    input[type="number"] {
        width: 100%;
    }
    
    input[type="range"] {
        width: 100%;
    }
    
    .action-buttons {
        flex-direction: column;
        gap: 5px;
        max-width: 80%;
        margin-left: auto;
        margin-right: auto;
    }
    
    .action-buttons button {
        width: 100%;
        padding: 14px;
    }
    
    .mobile-only {
        display: block;
    }
    
    .desktop-only {
        display: none;
    }
    
    .modal-content {
        max-width: 95%;
        padding: 5px;
    }
    
    .modal-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    .modal-close-btn,
    .modal-download-btn {
        width: 85%;
        margin: 0 auto;
    }
}
