:root {
    --toptica-black: #000000;
    --toptica-red: #e70038;
    --toptica-white: #ffffff;
}

html, body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    height: 100%;
    background-color: var(--toptica-black);
    color: var(--toptica-white);
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    text-align: center;
    justify-content: center;
    align-items: center;
}

.screen {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    margin: 2rem;
    margin-bottom: calc(10vh + 1rem);
}

h1, h2, h3, h4, h5, h6 {
    color: var(--toptica-white);
    margin-bottom: 1rem;
}

h1 {
    font-size: 3rem;
    margin-bottom: 2rem;
}

h1:focus {
    outline: none;
}

.layout-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: auto;
    min-height: 10vh;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 2rem 1rem 2rem;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 100;
    box-sizing: border-box;
}

    .layout-footer .footer-content {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
    }

    .layout-footer .footer-links {
        display: flex;
        gap: 1.5rem;
    }

    .layout-footer .footer-link {
        color: #aaa;
        font-size: 0.75rem;
        text-decoration: none;
        text-transform: uppercase;
        letter-spacing: 0.05rem;
        transition: color 0.2s;
    }

    .layout-footer .footer-link:hover {
        color: #fff;
    }

    .layout-footer .toptica-logo {
        width: 100%;
        height: 100%;
        max-width: 12rem;
        max-height: 4rem;
        cursor: pointer;
        transition: transform 0.2s ease-in-out;
    }

    .layout-footer .toptica-logo:hover {
        transform: scale(1.01);
    }

.global-close {
    position: fixed;
    top: 0;
    right: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    z-index: 100;
}

.global-close > a, .global-close > a:link, .global-close > a:visited {
    color: #aaa;
    background-color: transparent;
    text-decoration: none;
}

.global-close > a:hover, .global-close > a:active {
    color: var(--toptica-red);
}

.toptica-red {
    color: var(--toptica-red);
}

.toptica-white {
    color: var(--toptica-white);
}

.instruction {
    font-size: 2rem;
    margin: 2rem 0;
}

.target-time {
    font-size: 3rem;
    font-weight: bold;
    margin: 1rem 0;
}

.challenge-time {
    font-size: 2.5rem;
    font-weight: bold;
    margin: 1.5rem 0;
    text-align: center;
}

/* Result screen styles */
.container {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: min(50rem, 95vw);
    align-items: center;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Settings Screen Styles */
.settings-screen {
    padding: 2rem;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    background-color: rgba(255, 255, 255, 0.1);
    padding: 2rem;
    border-radius: 0.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 1.2rem;
    color: var(--toptica-white);
}

.form-group input {
    padding: 0.75rem;
    font-size: 1.1rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 0.25rem;
    background-color: rgba(0, 0, 0, 0.7);
    color: var(--toptica-white);
}

.settings-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
    gap: 1rem;
}

.settings-buttons button {
    padding: 0.75rem 1.5rem;
    font-size: 1.1rem;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}

.back-button {
    background-color: rgba(255, 255, 255, 0.2);
    color: var(--toptica-white);
}

.back-button:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

/* Button color variants */
.btn-green {
    background-color: #26b050 !important;
}

.btn-green:hover {
    background-color: #1e8f40 !important;
}

.btn-red {
    background-color: var(--toptica-red) !important;
}

.btn-red:hover {
    background-color: #c00030 !important;
}

/* Animation selection styling */
.animation-selection {
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    margin-top: 0.5rem;
}

.animation-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.5rem;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    width: 30%;
}

.animation-option:hover {
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
}

.animation-option.selected {
    border-color: var(--toptica-red);
    background-color: rgba(231, 0, 56, 0.1);
}

.animation-preview {
    width: 100%;
    height: 80px;
    border-radius: 0.25rem;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
    background-color: #333;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
}

    .animation-preview.video {
        background-color: #000;
        pointer-events: none;
    }

@keyframes preview-pulse {
    0% { opacity: 0.7; transform: scale(0.95); }
    100% { opacity: 1; transform: scale(1.05); }
}

.quit-button {
    background-color: #333;
    color: var(--toptica-white);
}

.quit-button:hover {
    background-color: #555;
}

/* Toggle switch styling */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.toggle-switch input[type="checkbox"] {
    appearance: none;
    width: 3rem;
    height: 1.5rem;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 1rem;
    position: relative;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.toggle-switch input[type="checkbox"]:checked {
    background-color: var(--toptica-red);
}

.toggle-switch input[type="checkbox"]::before {
    content: "";
    position: absolute;
    width: 1.2rem;
    height: 1.2rem;
    border-radius: 50%;
    background-color: white;
    top: 0.15rem;
    left: 0.15rem;
    transition: transform 0.3s ease;
}

.toggle-switch input[type="checkbox"]:checked::before {
    transform: translateX(1.5rem);
}

.toggle-label {
    font-size: 1rem;
    color: var(--toptica-white);
}

/* Start/Stop Button Styling */
.start-stop-button {
    width: 18rem;
    height: 18rem;
    border-radius: 50%;
    background-color: var(--toptica-red);
    color: var(--toptica-white);
    border: none;
    font-size: 2.66rem;
    font-weight: 550;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: auto auto 2rem auto;
    box-shadow: 0 0 20px rgba(231, 0, 56, 0.5);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    z-index: 100;
}

.start-stop-button:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(231, 0, 56, 0.7);
}

.start-stop-button:active {
    transform: scale(0.95);
    box-shadow: 0 0 10px rgba(231, 0, 56, 0.3);
}

.error-message {
    background-color: rgba(255, 0, 0, 0.2);
    color: var(--toptica-white);
    padding: 1rem;
    border-radius: 0.25rem;
    margin-bottom: 1.5rem;
    border-left: 4px solid var(--toptica-red);
}

.msg-box {
    font-size: 1.5rem;
    font-weight: 350;
    margin: .75rem;
    padding: 1rem;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
}

.red-box {
    font-size: 1.5rem;
    font-weight: bold;
    margin: .75rem;
    padding: 1.25rem 1rem;
    background-color: var(--toptica-red);
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
}

.buzzer-icon {
    width: 4rem;
    height: 4rem;
    margin-bottom: 0.5rem;
}

.animation-container {
    width: 100%;
    height: min(40vh, 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.animation-video {
    width: 100%;
    height: 100%;
    position: absolute;
    z-index: 1;
    pointer-events: none;
    background: transparent;
}

.photons-animation {
    width: 100%;
    height: 100%;
    position: absolute;
    z-index: 1;
    animation: photons-rotate 28.7s linear infinite, atom-fade 4.3s ease-in-out infinite;
}

.atom-animation {
    width: 45%;
    height: 45%;
    position: absolute;
    z-index: 2;
    /* Apply all animations */
    animation: atom-complex-transform 15.1s linear infinite, /* Consolidated transform */
               atom-fade 4.3s ease-in-out infinite,
               atom-glow 5.9s ease-in-out infinite;
}

/* Keyframes for the animations */
@keyframes photons-rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(-360deg); }
}

@keyframes atom-complex-transform { /* Consolidated rotate, scale, and wobble */
    0% { transform: rotate(0deg) scale(0.95) translate(0, 0); }
    15% { transform: rotate(54deg) scale(0.98) translate(3px, -2px); }
    30% { transform: rotate(108deg) scale(1.0) translate(-1px, 3px); }
    45% { transform: rotate(162deg) scale(1.03) translate(-4px, -1px); }
    60% { transform: rotate(216deg) scale(1.05) translate(2px, 2px); }
    75% { transform: rotate(270deg) scale(1.0) translate(5px, -3px); }
    90% { transform: rotate(324deg) scale(0.98) translate(-3px, 1px); }
    100% { transform: rotate(360deg) scale(0.95) translate(0, 0); }
}

@keyframes atom-fade {
    0% { opacity: 0.8; }
    33% { opacity: 1; }
    66% { opacity: 0.9; }
    100% { opacity: 0.8; }
}

/* Removed atom-wobble as it's now part of atom-complex-transform */

@keyframes atom-glow {
    0% { filter: drop-shadow(0 0 0 rgba(231, 0, 56, 0.6)); }
    50% { filter: drop-shadow(0 0 16px rgba(231, 0, 56, 1)); }
    100% { filter: drop-shadow(0 0 0 rgba(231, 0, 56, 0.6)); }
}
