*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100dvh;
    overflow: hidden;
}

body {
    background: #000;
    font-family: Arial, sans-serif;
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.container {
    width: 100%;
    max-width: clamp(360px, 55vw, 720px);
    height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: clamp(10px, 2vh, 24px) clamp(12px, 2vw, 32px);
}

#sound-toggle {
    position: fixed;
    top: clamp(8px, 1.2vh, 16px);
    right: clamp(10px, 1.5vw, 20px);
    background: none;
    border: 1px solid #444;
    color: #aaa;
    border-radius: 6px;
    padding: clamp(3px, 0.5vh, 6px) clamp(8px, 1vw, 14px);
    font-size: max(13px, clamp(0.7em, 1.2vw, 0.9em));
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
    z-index: 10;
}
#sound-toggle:hover { border-color: #aaa; color: #fff; }
#sound-toggle.sound-on { border-color: #0f0; color: #0f0; }

.video-row {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    flex: 1 1 0;
    min-height: 0;
    max-height: clamp(120px, 32vh, 340px);
    margin-bottom: clamp(10px, 1.8vh, 22px);
}

video {
    height: 100%;
    width: auto;
    max-width: 100%;
    max-height: clamp(120px, 32vh, 340px);
    display: block;
    object-fit: contain;
    cursor: pointer;
}

.form-row {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    margin-bottom: clamp(7px, 1.3vh, 18px);
}

label {
    width: clamp(110px, 14vw, 160px);
    text-align: right;
    margin-right: clamp(10px, 1.5vw, 20px);
    flex-shrink: 0;
    font-size: max(16px, clamp(0.82em, 1.3vw, 1em));
    color: #ccc;
}

.input-wrapper {
    flex: 1;
    position: relative;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    height: clamp(34px, 5vh, 48px);
    padding: 0 12px;
    background: #1a1a1a;
    border: 1px solid #444;
    color: #fff;
    border-radius: 6px;
    font-size: max(16px, clamp(0.82em, 1.3vw, 1em));
}
input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: #0f0;
}

#sec { padding-right: 64px; }

#result {
    padding-right: 116px;
    background: #0d0d0d;
    color: #0f0;
    font-weight: bold;
}

.checkbox-group {
    display: flex;
    align-items: center;
    height: clamp(34px, 5vh, 48px);
}
.checkbox-group input[type="checkbox"] {
    width: clamp(16px, 1.8vw, 20px);
    height: clamp(16px, 1.8vw, 20px);
    margin: 0;
    cursor: pointer;
    accent-color: #0f0;
}

select,
input[type="number"] {
    height: clamp(34px, 5vh, 48px);
    padding: 0 10px;
    background: #1a1a1a;
    border: 1px solid #444;
    color: #fff;
    border-radius: 6px;
    font-size: max(16px, clamp(0.82em, 1.3vw, 1em));
    cursor: pointer;
}
select:focus,
input[type="number"]:focus {
    outline: none;
    border-color: #0f0;
}
input[type="number"] {
    width: 5em;
    cursor: text;
}
input[type="number"]:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.result-wrapper { position: relative; }

.copy-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    padding: 0;
    background: none;
    border: none;
    font: inherit;
    color: #ff6666;
    cursor: pointer;
    user-select: none;
    font-size: 0.82em;
    opacity: 0.85;
    display: none;
}
.copy-icon:hover, .copy-icon:focus-visible { opacity: 1; }

.show-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    padding: 0;
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    font: inherit;
    font-size: 0.82em;
}
.show-btn:hover, .show-btn:focus-visible { color: #fff; }
#result-show { right: 62px; display: none; }

#copy-feedback {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #0f0;
    font-size: 0.78em;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    background: rgba(0,0,0,0.85);
    padding: 3px 8px;
    border-radius: 4px;
    display: none;
    white-space: nowrap;
}

.error {
    color: #f66;
    font-size: clamp(0.78em, 1.1vw, 0.88em);
    margin-bottom: clamp(4px, 0.8vh, 10px);
    padding-left: clamp(120px, 15.5vw, 180px);
    display: none;
    flex-shrink: 0;
}

.button-row {
    display: flex;
    justify-content: space-around;
    align-items: center;
    flex-shrink: 0;
    gap: clamp(12px, 2vw, 24px);
    margin-top: clamp(8px, 1.5vh, 20px);
    margin-bottom: clamp(4px, 0.6vh, 10px);
}

.txt-button {
    flex: 1;
    border: 2px solid #555;
    background: #111;
    color: #fff;
    border-radius: 10px;
    padding: clamp(10px, 1.6vh, 18px) 0;
    font-family: Courier, monospace;
    font-size: clamp(1em, 1.8vw, 1.4em);
    font-weight: bold;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: background 0.18s, border-color 0.18s, transform 0.15s;
}
.txt-button:hover {
    background: #1e1e1e;
    border-color: #aaa;
    transform: scale(1.04);
}
#reset-btn  { border-color: #c00; color: #f55; }
#reset-btn:hover  { border-color: #f55; background: #1a0000; }
#generate-btn { border-color: #0a0; color: #0f0; }
#generate-btn:hover { border-color: #0f0; background: #001a00; }
.txt-button:disabled { opacity: 0.5; cursor: default; transform: none; }

#countdown-row {
    display: none;
    align-items: center;
    gap: clamp(8px, 1vw, 12px);
    flex-shrink: 0;
    margin-top: clamp(6px, 1vh, 12px);
}

#countdown-bar-track {
    flex: 1;
    height: 5px;
    background: #333;
    border-radius: 3px;
    overflow: hidden;
}
#countdown-bar-fill {
    height: 100%;
    width: 100%;
    background: #0f0;
    border-radius: 3px;
    transition: background 0.5s;
}
#countdown-bar-fill.urgent { background: #f66; }

#countdown-label {
    font-size: max(13px, clamp(0.68em, 1vw, 0.8em));
    color: #aaa;
    white-space: nowrap;
    flex-shrink: 0;
}

#countdown-pause {
    background: none;
    border: 1px solid #555;
    color: #aaa;
    border-radius: 4px;
    padding: 2px clamp(6px, 0.8vw, 10px);
    font-size: max(13px, clamp(0.68em, 1vw, 0.8em));
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.2s, color 0.2s;
    flex-shrink: 0;
}
#countdown-pause:hover { border-color: #ccc; color: #fff; }
#countdown-pause.paused { border-color: #0f0; color: #0f0; }

#form {
    display: flex;
    flex-direction: column;
    height: 100%;
}
