/* Global Styles - Arknights Endfield Inspired */
:root {
    --bg-color: #0b0b0b;
    --text-color: #e0e0e0;
    --accent-color: #fffa00; /* Endfield Yellow */
    --error-color: #ff3333;
    --secondary-bg: #1a1a1a;
    --border-color: #555;
    --font-primary: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'Consolas', 'Courier New', monospace;
    --scanline-color: rgba(0, 0, 0, 0.5);
}

@keyframes scanline-move {
    0% { background-position: 0 0; }
    100% { background-position: 0 100%; }
}

@keyframes grid-scroll {
    0% { background-position: 0 0; }
    100% { background-position: 50px 50px; }
}

@keyframes text-glitch {
    0% { text-shadow: 4px 4px 0 var(--error-color), -4px -4px 0 var(--accent-color); transform: translate(2px, 2px); }
    2% { text-shadow: -4px -4px 0 var(--error-color), 4px 4px 0 var(--accent-color); transform: translate(-2px, -2px); }
    4% { text-shadow: 0 0 0 var(--error-color), 0 0 0 var(--accent-color); transform: translate(0, 0); }
    100% { text-shadow: 0 0 0 var(--error-color), 0 0 0 var(--accent-color); transform: translate(0, 0); }
}

@keyframes rgb-pulse {
    0% { box-shadow: 0 0 15px rgba(255, 250, 0, 0.2); }
    50% { box-shadow: 0 0 30px rgba(255, 250, 0, 0.6), 0 0 10px rgba(0, 255, 255, 0.4); }
    100% { box-shadow: 0 0 15px rgba(255, 250, 0, 0.2); }
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-primary);
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-image: 
        linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%),
        linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    background-size: 100% 4px, 6px 100%;
    animation: scanline-move 10s linear infinite;
}

/* Typography */
h1, h2, h3 {
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.1em;
    margin: 0.5em 0;
}

h1 { font-size: 3rem; text-shadow: 2px 2px 0px rgba(255, 250, 0, 0.2); }
h2 { font-size: 2rem; color: var(--accent-color); border-left: 5px solid var(--accent-color); padding-left: 1rem; }

/* Layout Utilities */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.full-screen {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    max-width: none;
}

/* UI Elements */
.btn {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 1rem 3rem;
    font-size: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
    margin: 1rem;
    position: relative;
    font-family: var(--font-primary);
    min-width: 220px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    top: -50%; left: -50%; width: 200%; height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.1), transparent);
    transform: rotate(45deg) translateY(-100%);
    transition: transform 0.5s;
}

.btn:hover::after {
    transform: rotate(45deg) translateY(0);
}

.btn::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 4px; height: 100%;
    background-color: var(--border-color);
    transition: background-color 0.2s;
}

.btn:hover {
    background-color: rgba(255, 250, 0, 0.15);
    border-color: var(--accent-color);
    color: var(--accent-color);
    text-shadow: 0 0 15px rgba(255, 250, 0, 0.8);
    transform: scale(1.05) translateX(5px);
    box-shadow: 0 0 20px rgba(255, 250, 0, 0.2);
}

.btn:hover::before {
    background-color: var(--accent-color);
}

.btn.primary {
    border-color: var(--accent-color);
    color: var(--bg-color);
    background-color: var(--accent-color);
    font-weight: bold;
    animation: rgb-pulse 3s infinite;
}

.btn.primary:hover {
    background-color: #fff;
    color: #000;
    box-shadow: 0 0 30px rgba(255, 250, 0, 0.6);
}

.input-field {
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--accent-color);
    color: white;
    padding: 1.2rem;
    font-size: 1.2rem;
    width: 100%;
    max-width: 400px;
    margin: 1rem 0;
    outline: none;
    text-align: center;
    font-family: var(--font-mono);
    transition: all 0.3s;
}

.input-field:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 25px rgba(255, 250, 0, 0.3);
}

/* Decorative Elements */
.deco-line {
    width: 100%;
    max-width: 600px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-color), transparent);
    margin: 2rem 0;
}

.corner-decor {
    position: fixed;
    width: 40px;
    height: 40px;
    border: 2px solid var(--border-color);
    pointer-events: none;
    z-index: 5;
    opacity: 0.5;
    transition: all 0.3s;
}
.corner-decor:hover { opacity: 1; border-color: var(--accent-color); box-shadow: 0 0 10px var(--accent-color); }
.top-left { top: 30px; left: 30px; border-right: none; border-bottom: none; }
.top-right { top: 30px; right: 30px; border-left: none; border-bottom: none; }
.bottom-left { bottom: 30px; left: 30px; border-right: none; border-top: none; }
.bottom-right { bottom: 30px; right: 30px; border-left: none; border-top: none; }

.corner-decor::after {
    content: '';
    position: absolute;
    width: 5px; height: 5px;
    background: var(--accent-color);
    box-shadow: 0 0 5px var(--accent-color);
}
.top-left::after { top: 0; left: 0; }
.top-right::after { top: 0; right: 0; }
.bottom-left::after { bottom: 0; left: 0; }
.bottom-right::after { bottom: 0; right: 0; }

/* TECH BACKGROUND DECOR */
.tech-grid {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: 1;
    animation: grid-scroll 20s linear infinite;
}

/* SYSTEM MODAL (Custom Alert/Prompt) */
.sys-modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sys-modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.sys-modal {
    background: #151515;
    border: 1px solid var(--border-color);
    min-width: 400px;
    max-width: 90vw;
    padding: 0;
    box-shadow: 0 0 50px rgba(255, 250, 0, 0.1);
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
}

.sys-modal-overlay.active .sys-modal {
    transform: scale(1);
}

.sys-modal::before {
    content: '';
    position: absolute;
    top: -1px; left: -1px; right: -1px; height: 4px;
    background: var(--accent-color);
    box-shadow: 0 0 15px var(--accent-color);
}

.sys-modal.error::before {
    background: var(--error-color);
    box-shadow: 0 0 15px var(--error-color);
}

.sys-header {
    background: rgba(255,255,255,0.05);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.sys-title {
    font-family: var(--font-mono);
    font-weight: bold;
    letter-spacing: 0.1em;
    color: var(--accent-color);
    text-shadow: 0 0 5px var(--accent-color);
}

.sys-modal.error .sys-title { color: var(--error-color); text-shadow: 0 0 5px var(--error-color); }

.sys-body {
    padding: 2rem;
    text-align: center;
}

.sys-footer {
    padding: 1rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
}

/* Game Specific */
#word-display {
    font-size: 10vw; /* Reduced further to ensure horizontal fit */
    font-weight: 800;
    text-align: center;
    line-height: 1;
    margin: 1rem 0;
    color: #fff;
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.4), 0 0 60px rgba(255, 255, 255, 0.2);
    animation: text-glitch 5s infinite;
    white-space: nowrap; /* Force horizontal */
    display: inline-block;
}

.full-screen {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    max-width: none; /* Allow full width for horizontal words */
    padding: 0;
}
#timer {
    font-family: var(--font-mono);
    font-size: 5rem; /* Increased size */
    color: var(--accent-color);
    position: absolute;
    top: 2rem;
    right: 3rem;
    text-shadow: 0 0 15px rgba(255, 250, 0, 0.8);
}

#score-board {
    font-family: var(--font-mono);
    font-size: 3rem; /* Increased size */
    position: absolute;
    top: 2rem;
    left: 3rem;
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    background: rgba(0,0,0,0.5);
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

.hidden { display: none !important; }

/* Game Result Modal (Mission Settlement) */
#game-modal {
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    z-index: 10000;
}

#modal-content.result-screen {
    background: transparent;
    border: none;
    box-shadow: none;
    width: 100%;
    max-width: 800px;
    text-align: center;
    position: relative;
}

.result-header {
    font-size: 4rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.3);
    margin-bottom: 2rem;
    letter-spacing: 0.1em;
    font-style: italic;
}

.result-grid {
    display: flex;
    justify-content: center;
    gap: 4rem;
    margin-bottom: 3rem;
}

.result-stat {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 2rem;
    min-width: 200px;
    position: relative;
    clip-path: polygon(20px 0, 100% 0, 100% 100%, 0 100%, 0 20px);
}

.result-stat::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 4px; height: 100%;
    background: var(--accent-color);
}

.result-stat .label {
    font-size: 1rem;
    color: #888;
    margin-bottom: 0.5rem;
    font-family: var(--font-mono);
}

.result-stat .value {
    font-size: 3.5rem;
    font-weight: bold;
    color: var(--accent-color);
    line-height: 1;
}

/* Enhanced Flash Effects (Vignette Glows) */
.flash-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: 900;
    opacity: 0;
    transition: opacity 0.3s ease-out;
}

.flash-correct {
    box-shadow: inset 0 0 100px 20px rgba(0, 255, 157, 0.6);
    background: radial-gradient(circle, transparent 60%, rgba(0, 255, 157, 0.2) 100%);
    border: 2px solid #00ff9d;
}

.flash-pass {
    box-shadow: inset 0 0 100px 20px rgba(255, 51, 51, 0.6);
    background: radial-gradient(circle, transparent 60%, rgba(255, 51, 51, 0.2) 100%);
    border: 2px solid #ff3333;
}

@keyframes hud-pulse {
    0% { opacity: 0; transform: scale(1.05); }
    10% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(1); }
}

.trigger-flash {
    animation: hud-pulse 0.4s ease-out forwards;
}

/* Floating Particles */
.particle {
    position: fixed;
    background: var(--accent-color);
    opacity: 0.3;
    pointer-events: none;
    z-index: 0;
    animation: float-up linear infinite;
}

@keyframes float-up {
    0% { transform: translateY(110vh) rotate(0deg); opacity: 0; }
    10% { opacity: 0.5; }
    90% { opacity: 0.5; }
    100% { transform: translateY(-10vh) rotate(360deg); opacity: 0; }
}

@media (max-width: 768px) {
    #timer { font-size: 2rem; top: 1rem; right: 1rem; }
    #score-board { font-size: 1.2rem; top: 1rem; left: 1rem; }
    h1 { font-size: 2rem; }
    .sys-modal { min-width: 90vw; }
    .result-grid { flex-direction: column; gap: 1rem; }
    #word-display { font-size: 18vw; } /* Adjust for mobile */
}

/* Background Floating Code */
.bg-code {
    position: fixed;
    color: var(--accent-color);
    font-family: var(--font-mono);
    font-size: 14px;
    opacity: 0.15;
    pointer-events: none;
    user-select: none;
    z-index: 0;
    white-space: nowrap;
}