@font-face {
  font-family: "PerfectDOS";
  src: url("./Perfect DOS VGA 437 Win.ttf") format("truetype");
  font-display: swap;
}

/* Local display font for header (from cabecera.txt) */
@font-face {
  font-family: 'Cal Sans';
  src: url('./CalSans-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* Header container with subtle noise texture and backdrop blur
   Updated so header spans full width with no outer gaps and sits flush to the top. */
header {
  position: relative;
  overflow: hidden;
  /* reduced top padding to bring text closer to the top edge, slightly tightened horizontal padding */
  padding: 0px 0px;
  text-align: center;
  background: rgba(255,255,255,0.03);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  /* increased bottom padding so there's a bit more space between the text and the animated/bordered area */
  border-radius: 0; /* remove rounded corners so header reaches edges */
  min-height: 20px;
  margin: 0; /* no gap above or below */
  width: 100vw; /* ensure it spans the full viewport width */
  left: 0;
  box-sizing: border-box;
  z-index: 1;
}

/* Noise texture pseudo-element (uses existing noise-texture.png) */
header::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background-image: url('./noise-texture.png');
  background-repeat: repeat;
  opacity: 0.15;
  pointer-events: none;
  animation: noise-animation 0.2s infinite steps(4);
  z-index: 0; /* ensure noise sits behind the title */
}

/* Noise animation keyframes */
@keyframes noise-animation {
  0%   { transform: translate(10px, 15px); }
  25%  { transform: translate(-10px, -10px); }
  50%  { transform: translate(5px, -15px); }
  75%  { transform: translate(-15px, 10px); }
  100% { transform: translate(10px, 15px); }
}

/* Glitch title styles */
.glitch {
  position: relative;
  color: #ffffff;
  font-family: 'Cal Sans', "PerfectDOS", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1.5rem; /* larger so text is clearly visible */
  line-height: 1.1;
  letter-spacing: 0.04em;
  z-index: 2; /* above the noise pseudo-element */
  display: inline-block;
  padding: 0px 16px; /* slightly more padding for visual balance */
  max-width: 100%;
  word-break: break-word;
  font-size: 1.5rem;
    font-weight: 600;
  margin-top: 20px;
}

/* Pseudo-elements that duplicate text for chromatic separation & slice animation */
.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}

.glitch::before {
  left: 2px;
  text-shadow: -1px 0 rgba(255,255,255,0.85); /* white tint to keep monochrome separation */
  color: rgba(255,255,255,0.95);
  animation: glitch-anim-1 2s infinite linear alternate-reverse;
}

.glitch::after {
  left: -2px;
  text-shadow: -1px 0 rgba(0,0,0,0.65); /* subtle dark shadow for separation */
  color: rgba(255,255,255,0.95);
  animation: glitch-anim-2 3s infinite linear alternate-reverse;
}

/* Clip-path slice keyframes for glitch fragmenting */
@keyframes glitch-anim-1 {
  0% { clip-path: polygon(0 0, 100% 0, 100% 5%, 0 5%); }
  10% { clip-path: polygon(0 25%, 100% 25%, 100% 30%, 0 30%); }
  20% { clip-path: polygon(0 50%, 100% 50%, 100% 55%, 0 55%); }
  30% { clip-path: polygon(0 70%, 100% 70%, 100% 75%, 0 75%); }
  40% { clip-path: polygon(0 40%, 100% 40%, 100% 45%, 0 45%); }
  50% { clip-path: polygon(0 60%, 100% 60%, 100% 65%, 0 65%); }
  60% { clip-path: polygon(0 10%, 100% 10%, 100% 15%, 0 15%); }
  70% { clip-path: polygon(0 80%, 100% 80%, 100% 85%, 0 85%); }
  80% { clip-path: polygon(0 55%, 100% 55%, 100% 60%, 0 60%); }
  90% { clip-path: polygon(0 15%, 100% 15%, 100% 20%, 0 20%); }
  100% { clip-path: polygon(0 90%, 100% 90%, 100% 95%, 0 95%); }
}

@keyframes glitch-anim-2 {
  0% { clip-path: polygon(0 5%, 100% 5%, 100% 10%, 0 10%); }
  10% { clip-path: polygon(0 30%, 100% 30%, 100% 35%, 0 35%); }
  20% { clip-path: polygon(0 55%, 100% 55%, 100% 60%, 0 60%); }
  30% { clip-path: polygon(0 75%, 100% 75%, 100% 80%, 0 80%); }
  40% { clip-path: polygon(0 45%, 100% 45%, 100% 50%, 0 50%); }
  50% { clip-path: polygon(0 65%, 100% 65%, 100% 70%, 0 70%); }
  60% { clip-path: polygon(0 15%, 100% 15%, 100% 20%, 0 20%); }
  70% { clip-path: polygon(0 85%, 100% 85%, 100% 90%, 0 90%); }
  80% { clip-path: polygon(0 60%, 100% 60%, 100% 65%, 0 65%); }
  90% { clip-path: polygon(0 20%, 100% 20%, 100% 25%, 0 25%); }
  100% { clip-path: polygon(0 95%, 100% 95%, 100% 100%, 0 100%); }
}

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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: #000000; /* changed to pure black background */
  color: #ffffff; /* primary text white for monochrome theme */
  font-family: "PerfectDOS", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Page-level flex column so footer can sit naturally at the bottom */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app {
  width: 100%;
  max-width: none;
  /* let the app flex within the page column so footer can remain after it */
  flex: 1 1 auto;
  padding: 0; /* remove outer padding so header sits flush with viewport */
  padding-bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 0; /* panels will sit edge-to-edge */
}

.panel {
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.4)); /* subtle monochrome panel */
  border-radius: 0; /* edge-to-edge panels */
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: none; /* remove outer border so panels align with edges */
  box-shadow: none;
  backdrop-filter: blur(0);
  width: 100%;
  box-sizing: border-box;
}

.panel-top {
  flex: 0 0 auto;
}

.panel-bottom {
  flex: 1 1 auto;
  display: flex;
  gap: 8px;
}

.file-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px; /* slightly wider for easier tapping */
  min-width: 220px; /* widen the picker button */
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255,255,255,0.03), rgba(0,0,0,0.6)); /* monochrome */
  font-size: 15px;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.8);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
  margin-bottom: 10px; /* added space below picker */
  color: #ffffff;
}

.file-label:hover {
  transform: translateY(-1px);
  border-color: rgba(255,255,255,0.18);
  background: linear-gradient(135deg, rgba(255,255,255,0.06), rgba(0,0,0,0.65));
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.85);
}

.file-label:active {
  transform: translateY(0);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.7);
}

.file-label input {
  display: none;
}

.controls-row {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-top: 12px; /* extra space between picker and quality selectors */
}

/* Separate FPS area from surrounding controls: add vertical breathing room and subtle internal padding */
.fps-row {
  margin: 16px 0; /* space above and below the FPS block */
  padding: 8px 0;  /* slight internal padding to visually isolate the slider */
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  align-items: center;
  text-align: center;
}

.control-title {
  opacity: 0.85;
  color: #e6e6e6;
}

.control-value {
  font-size: 11px;
  opacity: 0.75;
  text-align: right;
  color: #ddd;
}

/* FPS range styling: wider track, subtle monochrome track, pixel-art thumb */
#fps {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 14px;
  background: transparent;
  margin: 6px 0;
}

/* WebKit / Blink */
#fps::-webkit-slider-runnable-track {
  height: 8px;
  background: linear-gradient(90deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow: inset 0 -2px 6px rgba(0,0,0,0.6);
}

#fps::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -6px; /* vertically center the thumb */
  border-radius: 6px;
  background: linear-gradient(180deg, #ffffff, #bdbdbd);
  border: 2px solid rgba(0,0,0,0.8);
  box-shadow: 0 6px 14px rgba(0,0,0,0.75);
  cursor: pointer;
  image-rendering: crisp-edges;
}

/* Focus state */
#fps:focus::-webkit-slider-thumb {
  box-shadow: 0 8px 20px rgba(0,0,0,0.85), 0 0 8px rgba(255,255,255,0.06);
  transform: scale(1.06);
}

/* Firefox (Gecko) */
#fps::-moz-range-track {
  height: 8px;
  background: linear-gradient(90deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow: inset 0 -2px 6px rgba(0,0,0,0.6);
}

#fps::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: linear-gradient(180deg, #ffffff, #bdbdbd);
  border: 2px solid rgba(0,0,0,0.8);
  box-shadow: 0 6px 14px rgba(0,0,0,0.75);
  cursor: pointer;
}

/* IE/Edge (legacy) */
#fps::-ms-track {
  height: 8px;
  background: transparent;
  border-color: transparent;
  color: transparent;
}
#fps::-ms-fill-lower,
#fps::-ms-fill-upper {
  background: linear-gradient(90deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.06);
}

/* Subtle disabled look */
#fps:disabled::-webkit-slider-thumb,
#fps:disabled::-moz-range-thumb {
  opacity: 0.5;
  filter: grayscale(0.3);
  cursor: default;
}

/* Unified select styling for controls: quality, bitrate, audio mode, and volume */
#quality,
#bitrate-select,
#audio-mode,
#volume-mode {
  width: 100%;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  background: linear-gradient(180deg, rgba(0,0,0,0.6), rgba(0,0,0,0.4));
  color: #ffffff;
  font-size: 13px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  outline: none;
  box-shadow: inset 0 -1px 0 rgba(0,0,0,0.35);
  padding-right: 34px; /* room for custom arrow */
  position: relative;
}

/* Slightly bolder control titles for clarity and centered */
.control-title {
  opacity: 0.95;
  font-weight: 600;
  font-size: 12px;
  display: block;
  width: 100%;
  text-align: center;
  color: #f5f5f5;
}

/* Custom arrow using background image for selects (subtle) */
#quality,
#bitrate-select,
#audio-mode,
#volume-mode {
  background-image: linear-gradient(45deg, transparent 50%, rgba(255,255,255,0.06) 50%),
                    linear-gradient(135deg, rgba(255,255,255,0.06) 50%, transparent 50%),
                    linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.02));
  background-position: calc(100% - 18px) calc(1em + 2px), calc(100% - 13px) calc(1em + 2px), 0 0;
  background-size: 6px 6px, 6px 6px, 100% 100%;
  background-repeat: no-repeat;
}

/* add subtle focus state */
#quality:focus,
#bitrate-select:focus,
#audio-mode:focus,
#volume-mode:focus {
  box-shadow:
    0 8px 20px rgba(0,0,0,0.6),
    0 0 0 3px rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.16);
}



button#convert,
button#share,
button#download-btn {
  margin: 10px 0; /* more vertical breathing room above and below buttons */
  padding: 10px 16px;
  border-radius: 999px;
  border: none;
  color: #000000;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.9);
  transform: translateY(0);
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease, opacity 0.16s ease, background 0.16s ease;
  background: linear-gradient(180deg, #ffffff, #d6d6d6); /* bright monochrome buttons */
}

/* Make the save/download button span full width for prominence on mobile */
button#download-btn,
button#download-btn.full-width {
  width: 100%;
  padding-left: 16px;
  padding-right: 16px;
  text-align: center;
  display: inline-block;
}

button#convert:hover:not(:disabled),
button#share:hover:not(:disabled),
button#download-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.85);
  filter: brightness(0.98);
}

button#convert:active:not(:disabled),
button#share:active:not(:disabled),
button#download-btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 8px 16px rgba(0,0,0,0.9);
}

button#convert:disabled,
button#share:disabled,
button#download-btn:disabled {
  opacity: 0.45;
  cursor: default;
  box-shadow: none;
}

.status {
  min-height: 16px;
  font-size: 11px;
  opacity: 0.85;
  color: #ddd;
}

.instructions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
  padding: 8px 10px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.55));
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow:
    inset 0 0 0 1px rgba(0,0,0,0.6),
    0 6px 18px rgba(0,0,0,0.85);
}

.instructions-text {
  font-size: 11px;
  opacity: 0.95;
  line-height: 1.4;
  color: #f2f2f2;
}

.instructions-text div + div {
  margin-top: 1px;
}

.preview-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.actions-row {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.preview-title {
  font-size: 12px;
  opacity: 0.75;
  color: #dedede;
}

video {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  background: #000;
  object-fit: contain;
  max-height: 40vh; /* limit preview height to avoid huge vertical space on phones */
  border: 1px solid rgba(255,255,255,0.03);
}

/* On very narrow screens (compact mobiles) make previews even more compact */
@media (max-width: 420px) {
  video {
    max-height: 30vh;
  }
}

.download-link {
  margin-top: 4px;
  font-size: 12px;
  text-decoration: none;
  color: #ffffff;
  opacity: 0.9;
  word-break: break-all;
}

#work-canvas {
  display: none;
}

#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  opacity: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  transition: opacity 0.2s ease;
}

#loading-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(0,0,0,0.8));
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.9),
    0 0 0 1px rgba(0,0,0,0.9);
}

.loading-spinner {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.12);
  border-top-color: #ffffff;
  animation: spin 0.8s linear infinite;
}

.loading-text {
  font-size: 12px;
  color: #ffffff;
  text-shadow: none;
}



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

/* Prevent selection and contextual menu outside inputs */
:root {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

/* Allow text selection inside form controls */
input, textarea, select {
  -webkit-user-select: text;
  user-select: text;
}

/* Prevent overscroll navigation (pull-to-refresh) while allowing internal scrolling */
html, body {
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

/* Footer styling: placed in normal document flow under the app content */
.app-footer {
  position: static;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin-top: 8px;
  pointer-events: auto;
  font-size: 12px;
  opacity: 0.95;
  color: #ffffff;
  background: transparent;
  padding: 6px 12px;
}

/* Modal styles */
.app-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1200;
}
.app-modal.open {
  display: flex;
}
.app-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px);
}
.app-modal-sheet {
  position: relative;
  z-index: 2;
  min-width: 260px;
  max-width: 92%;
  border-radius: 12px;
  padding: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.95));
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow: 0 14px 36px rgba(0,0,0,0.9);
  color: #ffffff;
}
.app-modal-content {
  font-size: 14px;
  line-height: 1.3;
  margin-bottom: 8px;
}
.app-modal-actions {
  display: flex;
  justify-content: flex-end;
}
.app-modal-actions button {
  padding: 8px 12px;
  background: linear-gradient(180deg,#ffffff,#d6d6d6);
  border: none;
  color: #000;
  border-radius: 8px;
  cursor: pointer;
}

/* Ensure the app always fills the viewport and background remains visible
   when a <video> is toggled to fullscreen and when exiting fullscreen. */
html,
body,
.app {
  min-height: 100vh;
}

/* Keep page background visible under fullscreen elements */
:fullscreen,
:-webkit-full-screen,
:-moz-full-screen,
:-ms-fullscreen {
  background: inherit !important;
}

/* When video or preview goes fullscreen, don't force an opaque black background
   and let the app background show through; also ensure the app stays full height */
video:fullscreen,
video:-webkit-full-screen,
video:-moz-full-screen {
  background: transparent !important;
  object-fit: contain;
}

/* If the app container itself becomes fullscreen, make sure it inherits the page background */
.app:fullscreen,
.app:-webkit-full-screen,
.app:-moz-full-screen {
  background: inherit !important;
  height: 100vh !important;
  min-height: 100vh !important;
}

/* Prevent flashes or gaps on mobile when exiting fullscreen by forcing no scroll and full height */
html:fullscreen, body:fullscreen, .app:fullscreen {
  height: 100vh !important;
  min-height: 100vh !important;
  overflow: hidden;
}

.reusable-footer {
  text-align: center;
  margin: 0; /* reset default margins */
  margin-top: 0.5rem; /* slight breathing room above footer content */
  color: #fff;
  font-family: 'Cal Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 0.95rem;
  width: 100%;
  align-self: stretch;
  box-sizing: border-box;
  /* ensure footer stays at the bottom of the page flow */
  /* when body is a column flex, .app grows and footer appears after it */
}

.reusable-footer a {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.reusable-footer p {
  margin: 0;
  padding: 8px 12px;
  background: rgba(255,255,255,0.02);
  border-radius: 8px;
  display: inline-block;
}



