:root {
    --eva-orange: #ffaa00;
    --eva-red: #cc0000;
    --eva-green: #39ff14;
    --eva-yellow: #f1c40f;
    --eva-frame-bg: #1a1a1a;
    --bg-dark: #000;
}

@font-face {
    font-family: 'DSEG7';
    src: url('https://cdn.jsdelivr.net/npm/dseg@0.46.0/fonts/DSEG7-Classic/DSEG7Classic-Bold.woff2') format('woff2');
}

body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    color: var(--eva-orange);
    font-family: 'Teko', sans-serif;
    overflow: hidden;
    user-select: none;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: none;
}

/* Emergency & Flash - STROBE EFFECT */
body.emergency {
    --eva-orange: #ff0000 !important;
    --eva-green: #ff0000 !important;
    --eva-yellow: #ff0000 !important;
    background-color: #000;
}

body.beat-flash {
    background-color: #aa0000 !important;
}

.screen-wrapper {
    width: 100vw;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

/* --- LAYER 1: Background Gradient --- */
.bg-gradient {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200vmax;
    height: 200vmax;
    transform: translate(-50%, -50%);
    z-index: 0;
    background: linear-gradient(135deg, var(--eva-green), var(--eva-yellow), var(--eva-red), var(--eva-yellow));
    background-size: 400% 400%;
    animation: flowGradient 10s linear infinite;
    filter: blur(80px);
    opacity: 0.5;
    pointer-events: none;
}

body.emergency .bg-gradient {
    background: linear-gradient(135deg, #ff0000, #800000, #ff0000);
    animation: flowGradient 0.2s linear infinite;
    opacity: 0.1;
}

body.beat-flash .bg-gradient {
    opacity: 1;
}

@keyframes flowGradient {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* --- LAYER 2: Grid Pattern --- */
.grid-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(circle, #000 2px, transparent 2.5px);
    background-size: 20px 20px;
    z-index: 1;
    pointer-events: none;
    opacity: 1.0;
}

/* --- Content Layers --- */
/* Elements outside frame (PC Global placement) matches standard absolute positioning */

/* Right Panel Info (Header in Mobile) */
.right-panel {
    position: absolute;
    top: 5%;
    right: 2%;
    width: 25%;
    display: flex;
    flex-direction: column;
    gap: 5px;
    transform: skewX(-10deg);
    z-index: 100;
    /* Above everything */
}

.panel-box {
    border: 2px solid var(--eva-orange);
    padding: 10px;
    background: rgba(20, 10, 0, 0.5);
}

.panel-box.internal {
    border-color: var(--eva-red);
    position: relative;
}

.panel-box.internal .hazard-stripe {
    position: absolute;
    top: 0;
    right: 0;
    width: 50px;
    height: 100%;
    opacity: 0.5;
}

.en-large {
    font-size: 3rem;
    font-weight: 700;
    line-height: 0.9;
    color: var(--eva-orange);
}
.en-large a {
    font-size: 3rem;
    font-weight: 700;
    line-height: 0.9;
    color: var(--eva-orange);
}
.en-small {
    font-size: 1.2rem;
    letter-spacing: 2px;
    color: var(--eva-orange);
    opacity: 0.8;
}

.hazard-stripe {
    background: repeating-linear-gradient(45deg, var(--eva-red), var(--eva-red) 10px, #000 10px, #000 20px);
}

/* Bottom Panel */
.bottom-panel {
    position: absolute;
    /* Needed now that it's in wrapper */
    bottom: 0;
    right: 0;
    left: auto;
    width: 45%;
    height: 15%;
    background: #111;
    border-top: 2px solid var(--eva-green);
    clip-path: polygon(10% 0, 100% 0, 100% 100%, 0 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.status-group {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    width: 90%;
    margin-right: 20px;
}

.status-label {
    text-align: center;
    color: var(--eva-orange);
    font-size: 1.2rem;
    border: 1px solid var(--eva-orange);
    background: #000;
    padding: 2px;
}

.status-lights {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    height: 20px;
}

.light {
    background: #333;
    border: 1px solid #555;
}

.light.active {
    box-shadow: 0 0 15px currentColor;
    background: currentColor;
}

.light.time {
    color: var(--eva-orange);
}

.light.ready {
    color: var(--eva-green);
}

.light.urgent {
    color: var(--eva-red);
}

.light.complete {
    color: #fff;
}

.status-label.active {
    background: var(--eva-orange);
    color: #000;
}

/* Decor (Top Left) */
.frame-deco {
    position: absolute;
    z-index: 100;
}

/* Shared class might need check */
.frame-deco.top-left-panel {
    background-color: #1a2a1a;
    border: 1px solid var(--eva-green);
}

.top-left-panel {
    top: 0;
    left: 0;
    width: 25%;
    height: 10%;
    background: #4a5c4a;
    clip-path: polygon(0 0, 100% 0, 85% 100%, 0 100%);
}

.top-left-panel::after {
    content: "";
    display: block;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(45deg, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5) 5px, transparent 5px, transparent 10px);
}

/* --- LAYER 3: Frame --- */
.glow-anchor {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 98%;
    left: 0;
    height: 70%;
    z-index: 2;
}

/* Inner Frame */
.mech-frame {
    position: relative;
    width: 100%;
    height: 100%;
    background: #151515;
    border: 1px solid rgba(255, 170, 0, 0.5);
    clip-path: polygon(0 0, 95% 0, 100% 10%, 100% 90%, 95% 100%, 0 100%);
    z-index: 10;
}

/* Mode Indicator */
.mode-indicator {
    position: absolute;
    top: 5%;
    left: 2%;
    transform: skewX(-15deg);
    border: 2px solid var(--eva-orange);
    background: rgba(0, 0, 0, 0.8);
    padding: 0 40px;
    box-shadow: 0 0 15px rgba(255, 170, 0, 0.2);
    z-index: 20;
}

.mode-indicator span {
    font-size: 5rem;
    line-height: 1.2;
    font-weight: 700;
    color: var(--eva-orange);
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.5);
}

/* Main Timer */
.main-timer {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) skewX(-10deg) scaleY(1.3);
    font-family: 'DSEG7', monospace;
    font-weight: 700;
    z-index: 100;
}

.timer-fg {
    font-size: 14vw;
    line-height: 1;
    color: var(--eva-orange);
    text-shadow: 0 0 10px var(--eva-orange);
    position: relative;
    z-index: 2;
}

.timer-bg {
    font-size: 14vw;
    line-height: 1;
    color: rgba(255, 170, 0, 0.05);
    position: absolute;
    top: 0;
    left: 0;
    z-index: -1;
}

.ms {
    font-size: 0.6em;
}

.blink-colon {
    animation: colonBlink 1s step-end infinite;
}

@keyframes colonBlink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* Sub Clock */
.sub-clock {
    position: absolute;
    bottom: 5%;
    left: 450px;
    transform: skewX(-10deg);
    font-family: 'DSEG7', monospace;
    font-size: 1.5rem;
    color: var(--eva-green);
    opacity: 0;
    transition: opacity 0.5s;
    background: rgba(0, 0, 0, 0.8);
    padding: 10px;
    border: 1px solid var(--eva-green);
    z-index: 100;
}

.sub-clock span {
    font-size: 2.5rem;
    display: block;
}

/* Controls */
.timer-controls {
    position: absolute;
    bottom: 5%;
    left: 2%;
    transform: skewX(-10deg);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 100;
    background: rgba(0, 0, 0, 0.8);
    padding: 15px;
    border: 1px solid var(--eva-orange);
}

.control-label {
    font-size: 1.2rem;
    color: var(--eva-orange);
    background: #111;
    padding: 2px 10px;
}

.input-group {
    display: flex;
    gap: 10px;
}

#timer-input {
    background: #000;
    border: 2px solid var(--eva-orange);
    color: var(--eva-orange);
    font-family: 'DSEG7', monospace;
    font-size: 2.5rem;
    width: 140px;
    text-align: center;
}

button {
    background: rgba(255, 170, 0, 0.2);
    border: 2px solid var(--eva-orange);
    color: var(--eva-orange);
    font-family: 'Teko', sans-serif;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 20px;
    transition: all 0.2s;
}

button:hover {
    background: var(--eva-orange);
    color: #000;
}


/* --- Mobile / Portrait Responsive --- */
@media screen and (max-width: 768px) {

    /* Main Layout - Frame Centered, Smaller */
    .glow-anchor {
        width: 100%;
        height: 100%;
        top: 0;
        transform: none;
        z-index: 5;
        /* Lower than header/footer */
        pointer-events: none;
        /* Let clicks pass to header/footer if needed, but controls are inside */
    }

    .mech-frame {
        pointer-events: auto;
        clip-path: polygon(0 0, 90% 0, 100% 5%, 100% 95%, 90% 100%, 0 100%);
        border: 1px solid var(--eva-orange);
        background: #151515;
        ;
        /* Center in screen, occupy middle 60% approx */
        width: 90%;
        height: 60%;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        margin: 0;
    }

    .screen-wrapper {
        overflow: hidden;
    }

    /* Decors Hide */
    .top-left-panel,
    .hazard-stripe,
    .panel-box.system {
        display: none;
    }

    /* 2. Header (Right Panel as Header) */
    .right-panel {
        display: flex !important;
        /* Force show */
        position: absolute;
        top: 2%;
        left: 50%;
        width: 90%;
        /* Width 90% for box look */
        transform: translateX(-50%) skewX(-10deg);
        /* Skew added back */
        align-items: center;
        justify-content: center;
        gap: 0;
        z-index: 200;
    }

    .panel-box.internal {
        background: rgba(20, 10, 0, 0.5);
        /* Background restored */
        border: 2px solid var(--eva-orange);
        /* Border restored */
        padding: 5px 20px;
        text-align: center;
        width: 100%;
    }

    .box-header {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .hazard-stripe {
        display: block;
        width: 30px;
    }

    /* Optional: Restore stripe if wanted, or keep hidden */
    /* ANGEL CLOCK Text */
    .en-large {
        font-size: 2.0rem;
        letter-spacing: 2px;
    }

    /* Slightly smaller for box fit */
    .panel-box.system {
        display: none;
    }

    /* Bigger Header */

    /* Mode Indicator (System State) - Just below Header inside frame?? 
       Or overlay? Let's put inside frame top */
    .mode-indicator {
        top: 2%;
        left: 50%;
        transform: translateX(-50%);
        width: 100%;
        text-align: center;
        border: none;
        background: transparent;
        box-shadow: none;
    }

    .mode-indicator span {
        font-size: 8vw;
    }

    /* 2. Footer (Bottom Panel) */
    .bottom-panel {
        bottom: 0;
        left: 0;
        width: 100%;
        height: 10%;
        clip-path: none;
        transform: none;
        border: none;
        border-top: 2px solid var(--eva-green);
        background: #111;
        z-index: 200;
    }

    .status-group {
        width: 95%;
        margin: auto;
    }

    /* 3. Main Timer */
    .main-timer {
        top: 40%;
        transform: translate(-50%, -50%) scaleY(1.3);
    }

    .timer-upper {
        font-size: 25vw;
        display: block;
        margin-bottom: 2vh;
        /* Increased gap */
    }

    .timer-lower {
        font-size: 18vw;
        display: block;
    }

    .timer-fg,
    .timer-bg {
        font-size: 0;
    }

    /* Reset parent */

    /* 4. Sub Clock */
    .sub-clock {
        left: 50%;
        bottom: 20%;
        /* Lowered from 25% */
        transform: translateX(-50%);
        width: 100%;
        text-align: center;
        background: transparent;
        border: none;
    }

    /* 5. Controls - Minimized */
    .timer-controls {
        left: 50%;
        bottom: 5%;
        transform: translateX(-50%) skewX(0);
        width: 70%;
        background: rgba(0, 0, 0, 0.8);
        border: 1px solid var(--eva-orange);
        padding: 5px;
        /* Minimal padding */
        gap: 2px;
    }

    .control-label {
        font-size: 0.7rem;
        padding: 2px;
    }

    /* Half Height Input */
    #timer-input {
        height: 30px;
        line-height: 30px;
        font-size: 1.5rem;
        margin-bottom: 2px;
    }

    .btn-group {
        gap: 5px;
    }

    button {
        padding: 0;
        height: 30px;
        font-size: 1rem;
        line-height: 30px;
    }

    .grid-bg {
        background-size: 15px 15px;
    }
}