body {
    margin: 0;
    padding: 20px;
    background: #000000;
    color: #fff;
    font-family: Arial, sans-serif;
    overflow: hidden;
}

/* Controls */
#controls {
    position: fixed;
    left: 20px;
    top: 81px;
    background: rgba(0, 0, 0, 0.8);
    padding: clamp(10px, 2vw, 20px);
    border-radius: 10px;
    color: white;
    z-index: 10001;
    transform: translateX(0);
    transition: transform 0.3s ease-in-out;
    width: clamp(200px, 25vw, 300px);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

#controls.controls-hidden {
    transform: translateX(-400px);
}

.toggle-controls {
    position: fixed;
    left: 20px;
    top: 20px;
    z-index: 10002;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border: none;
    padding: clamp(6px, 1vw, 12px) clamp(8px, 1.5vw, 16px);
    border-radius: 5px;
    cursor: pointer;
    font-size: clamp(16px, 2vw, 20px);
    transition: transform 0.3s ease-in-out;
    outline: none;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.toggle-controls.active {
    transform: rotate(180deg);
}

.toggle-controls:hover {
    background: rgba(40, 40, 40, 0.8);
}

.slider-group, .toggle-group, .button-group {
    margin: clamp(10px, 2vw, 20px) 0;
}

label {
    display: block;
    margin: clamp(8px, 1.5vw, 15px) 0;
    font-size: clamp(12px, 1.5vw, 14px);
}

input[type="range"] {
    width: 100%;
    height: clamp(15px, 2vw, 25px);
}

select {
    width: 100%;
    padding: clamp(4px, 1vw, 8px);
    font-size: clamp(12px, 1.5vw, 14px);
    background: #333;
    color: white;
    border: 1px solid #444;
    border-radius: 4px;
}

button {
    margin: clamp(3px, 0.8vw, 5px);
    padding: clamp(6px, 1vw, 12px) clamp(10px, 1.5vw, 20px);
    font-size: clamp(12px, 1.5vw, 14px);
    background: #444;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

button:hover {
    background: #555;
}

/* Matrix Rain Effect */
#matrixCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background: #000000;
}

/* Overlay Canvas */
#overlayCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000000;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.5s ease-out;
}

.loading-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.loading-screen img {
    position: relative;
    z-index: 2;
    width: 600px;
    height: 600px;
    animation: initialBounce 2.5s ease-out forwards;
    opacity: 0;
    transform-origin: center;
}

@keyframes initialBounce {
    0% {
        opacity: 0;
        transform: scale(0.7);
    }
    30% {
        opacity: 0.8;
        transform: scale(1.1);
    }
    60% {
        opacity: 1;
        transform: scale(0.95);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Main content */
.content-wrapper {
    position: relative;
    width: 100%;
    height: 100vh;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease-out;
}

.content-wrapper.visible {
    opacity: 1;
    visibility: visible;
}

#canvas-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

/* Desktop copyright */
#copyright {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    text-align: center;
    z-index: 1000;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    width: auto;
    padding: 0 15px;
}

/* Mobile copyright */
@media screen and (max-width: 768px) {
    #copyright {
        bottom: 80px;
        font-size: 12px;
        width: 90%;
        margin: 0 auto;
        padding: 0 10px;
    }
}

/* Portrait phone screens (9:16 aspect ratio) */
@media screen and (max-aspect-ratio: 9/16) {
    #copyright {
        bottom: 100px;
        font-size: 11px;
        width: 85%;
        padding: 0 8px;
    }
}

/* Recording button styles */
#recordButton.recording {
    background-color: #ff3333;
    color: white;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 51, 51, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(255, 51, 51, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 51, 51, 0);
    }
}

/* Recording indicator */
#recording-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 30px;  
    height: 30px; 
    border-radius: 50%;
    background-color: #ff3333;
    opacity: 0;
    pointer-events: none;
    z-index: 1000;
}

#recording-indicator::after {
    content: 'REC';
    position: absolute;
    top: 35px;  
    left: 50%;
    transform: translateX(-50%);
    color: #ff3333;
    font-weight: bold;
    font-size: 18px;  
    white-space: nowrap;
}

#recording-indicator.active {
    animation: fadeInOut 2s infinite;
}

#recording-indicator.active::after {
    opacity: 1;
}

@keyframes fadeInOut {
    0% {
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

/* Media queries for responsive design */
/* Portrait phone screens (9:16 aspect ratio) */
@media screen and (max-aspect-ratio: 9/16) {
    #controls {
        width: 90%;
        max-width: 300px;
        left: 50%;
        transform: translateX(-50%);
        top: auto;
        bottom: 66px;
        padding: 8px;
        background: rgba(0, 0, 0, 0.7);
    }

    #controls label {
        margin: 4px 0 12px 0;  
        font-size: 12px;
        display: flex;
        align-items: center;
        white-space: nowrap;
        line-height: 1;
    }

    #controls label:last-of-type {
        margin-bottom: 4px;
    }

    #controls label > span {
        min-width: 85px;
        margin-right: 4px;
    }

    #controls input[type="range"] {
        flex: 1;
        margin: 1px 0;
        height: 15px;
    }

    #controls input[type="color"] {
        flex: 1;
        height: 24px;
        padding: 0;
        margin: 1px 0;
    }

    #controls input[type="checkbox"] {
        margin: 1px 0;
        transform: scale(1.2);
        width: 20px;
        height: 20px;
    }

    #controls select {
        width: 100%;
        margin: 4px 0 8px 0;
        padding: 3px;
        font-size: 12px;
        height: 24px;
    }

    .button-group {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 4px;
        margin-top: 8px;
    }

    .button-group button {
        width: 100%;
        margin: 0;
        padding: 5px 3px;
        font-size: 12px;
        height: 28px;
        line-height: 1;
    }

    #controls.controls-hidden {
        transform: translate(-50%, 150%);
    }

    .toggle-controls {
        left: 50%;
        transform: translateX(-50%);
        bottom: 20px;
        top: auto;
        z-index: 10003;
        padding: 6px 12px;
        border-radius: 20px;
        font-size: 13px;
        width: 90px;
        text-align: center;
        height: 28px;
        line-height: 1;
        transition: transform 0.3s ease;
    }

    .toggle-controls.active {
        transform: translateX(-50%) rotate(180deg);
    }
}

/* Mobile devices */
@media screen and (max-width: 768px) {
    #controls {
        width: 90%;
        max-width: 300px;
        left: 50%;
        transform: translateX(-50%);
        top: auto;
        bottom: 66px;
        padding: 8px;
        background: rgba(0, 0, 0, 0.7);
    }

    #controls label {
        margin: 4px 0 12px 0;  
        font-size: 12px;
        display: flex;
        align-items: center;
        white-space: nowrap;
        line-height: 1;
    }

    #controls label:last-of-type {
        margin-bottom: 4px;
    }

    #controls label > span {
        min-width: 85px;
        margin-right: 4px;
    }

    #controls input[type="range"] {
        flex: 1;
        margin: 1px 0;
        height: 15px;
    }

    #controls input[type="color"] {
        flex: 1;
        height: 24px;
        padding: 0;
        margin: 1px 0;
    }

    #controls input[type="checkbox"] {
        margin: 1px 0;
        transform: scale(1.2);
        width: 20px;
        height: 20px;
    }

    #controls select {
        width: 100%;
        margin: 4px 0 8px 0;
        padding: 3px;
        font-size: 12px;
        height: 24px;
    }

    .button-group {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 4px;
        margin-top: 8px;
    }

    .button-group button {
        width: 100%;
        margin: 0;
        padding: 5px 3px;
        font-size: 12px;
        height: 28px;
        line-height: 1;
    }

    #controls.controls-hidden {
        transform: translate(-50%, 150%);
    }

    .toggle-controls {
        left: 50%;
        transform: translateX(-50%);
        bottom: 20px;
        top: auto;
        z-index: 10003;
        padding: 6px 12px;
        border-radius: 20px;
        font-size: 13px;
        width: 90px;
        text-align: center;
        height: 28px;
        line-height: 1;
        transition: transform 0.3s ease;
    }

    .toggle-controls.active {
        transform: translateX(-50%) rotate(180deg);
    }
}

/* Additional tweaks for very small screens */
@media screen and (max-width: 380px) {
    #controls {
        width: 90%;
        padding: 10px;
    }

    .button-group {
        grid-template-columns: 1fr;  
    }

    label {
        font-size: 12px;
    }

    input[type="range"] {
        height: 20px;
    }
}

/* Handle landscape orientation on mobile */
@media screen and (max-height: 500px) and (orientation: landscape) {
    #controls {
        max-height: 80vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 60px;  
    }

    .toggle-controls {
        bottom: 10px;
    }

    #copyright {
        bottom: 60px;
    }
}

.button-group {
    display: flex;
    gap: 10px;
    flex-direction: row;
}

.button-group button {
    flex: 1;
}

@media (max-width: 768px), (max-aspect-ratio: 9/16) {    
    .button-group {
        flex-direction: column;
    }
    
    .button-group button {
        width: 100%;
    }
}

.camera-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    display: block;
    cursor: pointer;
    z-index: 1001;
    user-select: none;
    font-size: 24px;
    transition: transform 0.2s ease;
    text-align: center;
    line-height: 50px;
}

.camera-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.2s ease;
    background-color: var(--flash-color, white);
    filter: blur(8px);
}

.camera-button.flash::before {
    opacity: 0.6;
}

.camera-button:hover {
    transform: scale(1.2);
}

.camera-button:active {
    transform: scale(1.4);
}
