:root {
 --bg: #1a120b;
 --bg-secondary: #2a1e14;
 --accent: #d4a017;
 --accent-secondary: #8b4513;
 --text: #f5f5f5;
 --muted: #a0a0a0;
 --checkmark-color: #4CAF50;
 }

 /* --- Base & Resets --- */
 html {
 font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
 font-size: clamp(1rem, 0.8rem + 0.8vw, 1.5rem); /* Wider, more dynamic scaling */
 height: 100%;
 background: var(--bg);
 color: var(--text);
 }
 body {
 margin: 0;
 display: flex;
 flex-direction: column;
 align-items: center;
 padding: 0.5rem 1rem 9rem 1rem;
 overflow-x: visible;
 min-height: 100vh;
 box-sizing: border-box;
 }
 *, *::before, *::after {
 box-sizing: inherit;
 }

 /* --- Layout --- */
 .main-container {
 width: 100%;
 max-width: 95%; /* Wider on small screens */
 position: relative;
 margin: 0.1rem auto 15rem auto; /* Centered */
 z-index: 10;
 display: flex;
 flex-direction: column;
 min-height: calc(100vh - 2rem); /* Accommodate body padding */
 }

 /* --- Header --- */
 .header {
 display: flex;
 align-items: center;
 justify-content: space-between;
 padding: 1rem 0;
 }
 .header h1 {
 font-size: 1.875rem;
 font-weight: 700;
 color: var(--accent);
 margin: 0;
 }
 .header p {
 font-size: 0.875rem;
 color: var(--muted);
 margin: 0;
 }

 /* --- Generic Panel/Card --- */
 .panel {
 background-color: rgba(39, 39, 42, 0.4);
 backdrop-filter: blur(0.75rem);
 border-radius: 1rem;
 padding: 1.5rem;
 margin-bottom: 2rem;
 box-shadow: 0 0.625rem 0.9375rem -0.1875rem rgb(0 0 0 / 0.1), 0 0.25rem 0.375rem -0.25rem rgb(0 0 0 / 0.1);
 }

 /* --- Stage Info Panel --- */
 .stage-info-panel {
 display: flex;
 flex-direction: column;
 align-items: center;
 width: 100%;
 text-align: center;
 }
 #stageName {
 font-size: 1.25rem;
 font-weight: 600;
 color: var(--accent);
 }
 #stageSub {
 font-size: 0.875rem;
 color: var(--muted);
 margin-top: 0.25rem;
 }
 .progress-bar-container {
 width: 100%;
 height: 0.375rem;
 background-color: var(--bg-secondary);
 border-radius: 9999px;
 margin-top: 1rem;
 overflow: hidden;
 }
 #progressBar {
 height: 100%;
 width: 0;
 background-color: var(--accent);
 transition: width 500ms ease-in-out;
 }
 #renderProgressBar {
    height: 100%;
    width: 0;
    background-color: var(--accent);
    transition: width 250ms linear;
}

 /* --- Settings Panel --- */
 .settings-panel h2 {
 font-size: 1.25rem;
 font-weight: 600;
 margin-top: 0;
 margin-bottom: 1rem;
 }
 .settings-group {
 margin-bottom: 1.5rem;
 }
 .settings-group label {
 display: block;
 font-size: 1rem;
 font-weight: 500;
 margin-bottom: 0.5rem;
 }
 .preset-selector-button {
    width: 100%;
    background: linear-gradient(90deg,rgba(156, 148, 42, 0.2) 0%, rgba(44, 74, 17, 0.2) 50%, rgba(64, 57, 8, 0.2) 100%);
    color: var(--text);
    border: 1px solid var(--accent-secondary);
    border-bottom: 0.2rem solid orange;
    text-align: center;
    font-size: 1.3rem;
    position: relative;
    top: -2px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.4);
    transition: top 0.1s ease, box-shadow 0.1s ease;
 }

 .preset-selector-button:active {
    top: 0;
    box-shadow: 0 2px 3px rgba(0,0,0,0.4);
 }

 .slider-group {
 margin-bottom: 1rem;
 }
 .slider-label {
 display: flex;
 align-items: baseline;
 margin-bottom: 0.5rem;
 font-size: 1.5rem;
 gap: 0.75rem;
 }

/* Slider Value Indicator */
 .slider-label span:first-child {
 font-weight: 600;
 color: var(--accent);
 font-size: 1.25rem; /* Slightly smaller to prevent wrapping */
 min-width: 4.5rem; /* More flexible for small screens */
 text-align: center;
 }
 .toggle-group > * + * {
 margin-top: 0.5rem;
 }
 .toggle-button {
 width: 100%;
 text-align: left;
 display: flex;
 justify-content: flex-start;
 align-items: center;
 padding: 0.8rem;
 border-radius: 0.75rem;
 transition: background-color 150ms ease-in-out;
 background: none;
 border: none;
 color: var(--text);
 cursor: pointer;
 font-size: 1.2rem;
 font-weight: 600;
 letter-spacing: 0.15rem;
 gap: 0.8rem;
 }
 .toggle-button:hover {
 background-color: rgba(255, 255, 255, 0.1);
 }
 .toggle-button:focus-visible {
 outline: none;
 box-shadow: 0 0 0 0.125rem var(--bg-secondary), 0 0 0 0.25rem var(--accent);
 }
 .toggle-button[aria-checked="false"] .checkmark-container {
 border-width: 0.1875rem;
 }
 .checkmark-container {
 width: 2rem;
 height: 2rem;
 border-radius: 1rem;
 border: 0.25rem solid var(--checkmark-color);
 display: flex;
 align-items: center;
 justify-content: center;
 transition: all 200ms;
 }
 .checkmark {
 width: 1.5rem;
 height: 1.5rem;
 border-radius: 1rem;
 transition: all 200ms;
 }
 .bg-accent { background-color: var(--accent); }
 .bg-black { background-color: black; }

 /* --- Info Section --- */
 .info-cards {
 margin-bottom: 1rem; /* Adjusted margin */
 }
 .info-cards > .panel + .panel {
 margin-top: 1rem;
 }
 .info-panel h3 {
 font-size: 1.125rem;
 font-weight: 600;
 color: var(--accent);
 margin-top: 0;
 margin-bottom: 0.5rem;
 }
 .info-panel p, .info-panel ol, .info-panel ul, .info-panel dl {
 font-size: 0.875rem;
 line-height: 1.625;
 margin: 0;
 }
 .info-panel ol, .info-panel ul {
 padding-left: 1.25rem;
 margin-top: 0.5rem;
 }
 .info-panel ol > li + li, .info-panel ul > li + li {
 margin-top: 0.25rem;
 }

 /* --- About Section --- */
 .about-section hr {
 border-color: var(--bg-secondary);
 margin: 1rem 0;
 border-style: solid;
 border-top-width: 0.0625rem;
 }
 .about-section .content {
 margin-top: 2rem;
 }
 .about-section h2 {
 font-size: 1.5rem;
 font-weight: 700;
 color: var(--accent);
 margin-top: 0;
 margin-bottom: 1rem;
 }
 .about-section h3 {
 font-size: 1.25rem;
 font-weight: 600;
 margin-top: 0;
 margin-bottom: 0.5rem;
 }
 .about-section p, .about-section ul {
 font-size: 0.875rem;
 line-height: 1.625;
 color: var(--muted);
 margin-top: 0;
 margin-bottom: 1rem;
 }
 .about-section ul {
 padding-left: 1.25rem;
 }
 .about-section ul.no-bullets {
 list-style-type: none;
 padding-left: 0;
 }
 .about-section ul > li + li {
 margin-top: 0.25rem;
 }
 .about-section ul.no-bullets > li + li {
 margin-top: 1rem;
 }
 .about-section strong {
 color: var(--accent);
 font-weight: 600;
 }
 .github-link {
    text-align: center;
    margin-top: 2rem;
    margin-bottom: 0;
    font-size: 0.875rem;
}
.github-link a {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}
.github-link a:hover {
    text-decoration: underline;
}

 /* --- Sticky Footer Controls --- */
 .footer-controls {
 position: fixed;
 bottom: 0;
 left: 0;
 right: 0;
 background-color: rgba(26, 18, 11, 0.4);
 backdrop-filter: blur(0.5625rem);
 z-index: 50;
 padding: 0.1rem;
 box-shadow: 0 -0.625rem 1.5625rem -0.3125rem rgb(100 100 50 / 0.25);
 }
 .footer-controls-inner {
 display: flex;
 gap: 1rem;
 width: 100%;
 max-width: 90%;
 margin: 0 auto;
 }
 .control-button {
 flex: 1 1 0%;
 display: flex;
 align-items: center;
 justify-content: center;
 padding: 0.5rem 1rem;
 border-radius: 1rem;
 font-weight: 800;
 font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem); /* Fluid font size */
 box-shadow: 0 0.625rem 0.9375rem -0.1875rem rgb(0 0 0 / 0.1), 0 0.25rem 0.375rem -0.25rem rgb(0 0 0 / 0.1);
 transition: transform 150ms, background-color 150ms;
 border: none;
 cursor: pointer;
 }
 .control-button:active {
 transform: scale(0.95);
 }
 #playPauseBtn {
 flex-basis: 40%;
 gap: 1rem;
 background-color: var(--accent-secondary);
 color: white;
 }
 #playPauseBtn:hover {
 background-color: hsl(27, 69%, 35%);
 }
 #prevStageBtn, #nextStageBtn {
 background-color: transparent;
 border: 0.125rem solid var(--accent);
 color: var(--accent);
 }
 #prevStageBtn:hover, #nextStageBtn:hover {
 background-color: rgba(255, 255, 255, 0.1);
 }
 
 .button-row {
 display: flex;
 gap: 1rem;
 align-items: center;
 }
 .settings-button {
 padding: 0.8rem 1.2rem;
 border-radius: 0.75rem;
 font-weight: 600;
 font-size: 1.1rem;
 border: none;
 cursor: pointer;
 transition: background-color 150ms, transform 150ms, border-color 150ms;
 text-decoration: none;
 display: inline-block;
 text-align: center;
 }
 .settings-button:active {
 transform: scale(0.97);
 }
 .save-audio-button {
 background-color: var(--accent);
 color: var(--bg);
 }
 .save-audio-button:hover {
 background-color: hsl(44, 78%, 60%);
 }
 .save-audio-button:disabled {
 background-color: var(--bg-secondary);
 color: var(--muted);
 cursor: not-allowed;
 transform: none;
 }
 .install-app-button {
 background-color: transparent;
 border: 0.125rem solid var(--accent-secondary);
 color: var(--accent);
 padding: calc(0.8rem - 0.125rem) calc(1.2rem - 0.125rem);
 }
 .install-app-button:hover {
 background-color: var(--bg-secondary);
 border-color: var(--accent);
 }
 
 /* --- Media Queries --- */
 @media (min-width: 40rem) { /* 640px */
 body {
 padding: 1.5rem;
 }
 .main-container {
 min-height: calc(100vh - 3rem);
 max-width: 80%; /* Constrain width on tablets and desktops */
 }
 .footer-controls {
 padding: 1rem;
 }
 }
 
  @media (min-width: 64rem) { /* 1024px */
   .main-container {
     max-width: 60rem; /* Add a max-width for very large screens */
   }
 }
 
 .play-icon {
 width: 0;
 height: 0;
 border-top: 1.25rem solid transparent;
 border-bottom: 1.25rem solid transparent;
 border-left: 2.125rem solid white;
 }
 .pause-icon {
 width: 2.125rem;
 height: 2.5rem;
 border-left: 0.625rem solid white;
 border-right: 0.625rem solid white;
 }

 /* --- Slider Styles --- */
 input[type="range"] {
 -webkit-appearance: none; appearance: none;
 background: transparent; width: 100%; cursor: pointer;
 }
 /* Track */
 input[type="range"]::-webkit-slider-runnable-track {
 background: var(--bg-secondary);
 height: 0.7rem;
 border-radius: 0.5rem;
 background-image: radial-gradient(rgba(100, 100, 50, 0.33) 0.15rem, transparent 0);
 background-repeat: repeat;
 background-size: 0.7rem 0.7rem;
 background-position: left;
 }
 input[type="range"]::-moz-range-track {
 background: var(--bg-secondary);
 height: 0.7rem;
 border-radius: 0.5rem;
 background-image: radial-gradient(rgba(100, 100, 50, 0.33) 0.15rem, transparent 0);
 background-repeat: repeat;
 background-size: 0.7rem 0.7rem;
 background-position: left;
 }
 /* Thumb */
 input[type="range"]::-webkit-slider-thumb {
 -webkit-appearance: none;
 appearance: none;
 height: 2rem;
 width: 1rem;
 background-color: var(--accent);
 border-radius: 10%;
 border: 0;
 border-bottom: 0.15rem double green;
 margin-top: -0.65rem; /* Vertically center thumb on track */
 }
 input[type="range"]::-moz-range-thumb {
 height: 2rem;
 width: 1rem;
 background-color: var(--accent);
 border-radius: 10%;
 border: 0;
 border-bottom: 0.15rem double green;
 }
 
 /* --- CSS Gradient Blob Animation --- */
 #gradientBlobsContainer {
 position: fixed; top: 0; left: 0; width: 100%; height: 100%;
 z-index: 0; pointer-events: none; filter: blur(5rem); opacity: 0.8;
 }
 .blob {
 position: absolute;
 background-image: radial-gradient(circle at center, rgba(212, 160, 23, 0.7), rgba(42, 30, 20, 0.2));
 border-radius: 50%;
 animation: float-blob 40s linear infinite alternate;
 }
 .blob:nth-child(1) { width: 15.625rem; height: 15.625rem; top: 10%; left: 20%; animation-delay: 2s; }
 .blob:nth-child(2) { width: 18.75rem; height: 18.75rem; top: 40%; left: 70%; animation-delay: 10s; }
 .blob:nth-child(3) { width: 12.5rem; height: 12.5rem; top: 60%; left: 15%; animation-delay: 20s; }
 .blob:nth-child(4) { width: 21.875rem; height: 21.875rem; top: 80%; left: 50%; animation-delay: 35s; }
 .blob:nth-child(5) { width: 11.25rem; height: 11.25rem; top: 5%; left: 80%; animation-delay: 15s; }
 @keyframes float-blob {
 0% { transform: translate(0, 0) scale(1.0); }
 25% { transform: translate(-10vw, -15vh) scale(1.1); }
 50% { transform: translate(15vw, 5vh) scale(0.9); }
 75% { transform: translate(-5vw, 10vh) scale(1.2); }
 100% { transform: translate(0, 0) scale(1.0); }
 }

 #install-instructions ul svg {
     width: 1em;
     height: 1em;
 }

/* --- Modal Styles --- */
.hidden {
    display: none !important;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 100;
    backdrop-filter: blur(4px);
}

.modal-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: clamp(80vw, 600px, 90vw);
    max-height: 95vh;
    background-color: var(--bg);
    border: 1px solid var(--accent-secondary);
    border-radius: 1rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: 101;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--bg-secondary);
    background-color: var(--bg);
    height: 2.5rem;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--accent);
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 2.5rem;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close-btn:hover {
    color: var(--text);
}

.modal-content {
    padding: 1.5rem;
    overflow-y: auto;
}

.modal-footer {
    padding: 0 1.5rem;
    border-top: 1px solid var(--bg-secondary);
    background-color: var(--bg);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    height: 2.5rem;
}

.sticky-header {
    position: sticky;
    top: 0;
    z-index: 1;
}

.sticky-footer {
    position: sticky;
    bottom: 0;
    z-index: 1;
}

.modal-container.wide-modal {
    width: 80vw;
    height: 95vh;
}

#formatSelector {
    width: 100%;
    padding: 0.75rem;
    border-radius: 0.5rem;
    font-size: 1.1rem;
    font-weight: 500;
    background: var(--bg-secondary);
    color: var(--text);
    border: 1px solid var(--accent-secondary);
}
#formatSelector:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--accent);
}

.format-note {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.5rem;
}

.modal-actions {
    margin-top: 2rem;
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

#saveProgressView {
    text-align: center;
}

#progressStatusText {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

#progressTimeText {
    margin-top: 0.5rem;
    color: var(--muted);
}

/* --- Preset Dialog Cards --- */
.preset-cards {
    display: grid;
    grid-template-columns: 1fr; /* Display one card per row */
    gap: 0.5rem; /* Reduced spacing */
    padding-bottom: 1rem;
}

.preset-card {
    background-color: var(--bg-secondary);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem; /* Reduced padding */
    cursor: pointer;
    border-bottom: 0.2rem solid orange; /* Added orange bottom border */
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 0; /* Reduced internal gap */
}

.preset-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.25);
}

.preset-card h3 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent);
    margin: 0 0 0.2rem 0; /* Reduced bottom margin */
    display: flex;
    align-items: center;
}
.preset-card h3::before {
    content: '▶';
    margin-right: 0.6em;
    font-size: 0.8em;
    color: var(--accent);
}

.preset-card .details {
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.3; /* Tighter line-height */
    margin: 0; /* Removed margin */
}