:root {
    --bg-color: #0a0a08;
    --text-primary: #e0ddd5;
    --text-secondary: rgba(200, 195, 180, 0.7);
    --accent-blood: #8a0303;
    --accent-blood-dim: rgba(138, 3, 3, 0.3);
    --accent-military: #3d5a1e;
    --accent-rust: #4a1a1a;
    --accent-terminal: #33ff33;
    --border-color: rgba(138, 3, 3, 0.25);
    --box-bg: rgba(10, 10, 8, 0.85);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Special Elite', monospace;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

/* ========================================
   BACKGROUND — Fog + Static + Scanlines
   ======================================== */
.background-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    z-index: 0;
}

/* Fog layers */
.fog {
    position: absolute;
    width: 200%;
    height: 100%;
    opacity: 0.12;
}

.fog-1 {
    background: radial-gradient(ellipse at 20% 50%, var(--accent-blood) 0%, transparent 50%),
                radial-gradient(ellipse at 80% 30%, var(--accent-military) 0%, transparent 50%);
    animation: fogDrift 30s infinite alternate ease-in-out;
}

.fog-2 {
    background: radial-gradient(ellipse at 60% 70%, var(--accent-rust) 0%, transparent 45%),
                radial-gradient(ellipse at 30% 20%, var(--accent-blood) 0%, transparent 40%);
    animation: fogDrift 25s infinite alternate-reverse ease-in-out;
    opacity: 0.08;
}

.fog-3 {
    background: radial-gradient(ellipse at 50% 50%, var(--accent-military) 0%, transparent 60%);
    animation: fogDrift 35s infinite alternate ease-in-out;
    opacity: 0.06;
}

@keyframes fogDrift {
    0% { transform: translateX(0) translateY(0); }
    50% { transform: translateX(-15%) translateY(3%); }
    100% { transform: translateX(-25%) translateY(-2%); }
}

/* Noise / Static overlay */
.noise-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    opacity: 0.06;
    pointer-events: none;
    mix-blend-mode: overlay;
}

/* Scanlines */
.scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 2px,
        rgba(0, 0, 0, 0.15) 2px,
        rgba(0, 0, 0, 0.15) 4px
    );
    pointer-events: none;
    animation: scanlineMove 8s linear infinite;
}

@keyframes scanlineMove {
    0% { transform: translateY(0); }
    100% { transform: translateY(4px); }
}

/* Vignette */
.vignette {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, 0.7) 100%);
    pointer-events: none;
}

/* ========================================
   LAYOUT
   ======================================== */
.content-wrapper {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 800px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

/* Badge */
.badge {
    background: var(--box-bg);
    border: 1px solid var(--accent-blood);
    padding: 0.5rem 1.4rem;
    border-radius: 2px;
    font-size: 0.8rem;
    font-weight: 400;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--accent-blood);
    margin-bottom: 2rem;
    box-shadow: 0 0 15px var(--accent-blood-dim), inset 0 0 10px rgba(138, 3, 3, 0.1);
    animation: flicker 4s infinite;
}

/* ========================================
   GLITCH TITLE
   ======================================== */
.main-title {
    font-family: 'Creepster', cursive;
    font-size: clamp(3rem, 9vw, 5.5rem);
    font-weight: 400;
    line-height: 1.1;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    position: relative;
    text-shadow: 0 0 10px rgba(138, 3, 3, 0.5);
    animation: glitch 5s infinite;
}

.main-title::before,
.main-title::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.main-title::before {
    color: #ff0040;
    animation: glitchLayer1 3s infinite linear alternate-reverse;
    clip-path: inset(0 0 80% 0);
    opacity: 0.7;
}

.main-title::after {
    color: #00ff88;
    animation: glitchLayer2 2.5s infinite linear alternate-reverse;
    clip-path: inset(80% 0 0 0);
    opacity: 0.7;
}

@keyframes glitch {
    0%, 92%, 100% { transform: translate(0); }
    93% { transform: translate(-3px, 1px); }
    94% { transform: translate(3px, -1px); }
    95% { transform: translate(-1px, 2px); }
    96% { transform: translate(2px, -2px); }
}

@keyframes glitchLayer1 {
    0%, 90%, 100% { clip-path: inset(0 0 80% 0); transform: translate(0); }
    92% { clip-path: inset(20% 0 40% 0); transform: translate(-4px, 0); }
    94% { clip-path: inset(60% 0 10% 0); transform: translate(4px, 0); }
    96% { clip-path: inset(10% 0 70% 0); transform: translate(-2px, 0); }
}

@keyframes glitchLayer2 {
    0%, 88%, 100% { clip-path: inset(80% 0 0 0); transform: translate(0); }
    90% { clip-path: inset(50% 0 20% 0); transform: translate(3px, 0); }
    93% { clip-path: inset(10% 0 60% 0); transform: translate(-3px, 0); }
    96% { clip-path: inset(70% 0 5% 0); transform: translate(2px, 0); }
}

/* Subtitle */
.subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin: 0 auto 3rem auto;
    max-width: 550px;
    line-height: 1.8;
    letter-spacing: 0.5px;
    text-align: center;
    animation: flicker 6s infinite;
}

@keyframes flicker {
    0%, 95%, 100% { opacity: 1; }
    96% { opacity: 0.6; }
    97% { opacity: 1; }
    98% { opacity: 0.4; }
    99% { opacity: 0.9; }
}

/* ========================================
   COUNTDOWN
   ======================================== */
.countdown {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-bottom: 3rem;
    flex-wrap: wrap;
}

.time-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--box-bg);
    border: 1px solid var(--border-color);
    border-radius: 2px;
    padding: 1.5rem;
    min-width: 100px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5), inset 0 0 15px rgba(138, 3, 3, 0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.time-box:hover {
    transform: translateY(-4px);
    border-color: var(--accent-blood);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 20px var(--accent-blood-dim);
}

.number {
    font-family: 'Creepster', cursive;
    font-size: 3rem;
    font-weight: 400;
    line-height: 1;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    text-shadow: 0 0 8px rgba(138, 3, 3, 0.4);
}

.label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-secondary);
    font-family: 'Special Elite', monospace;
}

.separator {
    font-size: 2rem;
    font-weight: 400;
    color: var(--accent-blood);
    margin-top: -1.5rem;
    text-shadow: 0 0 10px var(--accent-blood-dim);
    animation: flicker 3s infinite;
}

@media (max-width: 600px) {
    .content-wrapper { padding: 1rem; }
    .badge { margin-bottom: 1rem; font-size: 0.7rem; padding: 0.4rem 1rem; }
    .main-title { font-size: clamp(2.2rem, 8vw, 3.5rem); margin-bottom: 0.8rem; }
    .subtitle { margin: 0 auto 1.5rem auto; font-size: 0.95rem; line-height: 1.6; }
    .countdown { gap: 0.5rem; margin-bottom: 1.5rem; }
    .time-box {
        padding: 0.8rem;
        min-width: 68px;
    }
    .number { font-size: 1.8rem; }
    .label { font-size: 0.6rem; letter-spacing: 1px; }
    .separator { margin-top: -0.8rem; font-size: 1.2rem; }
    .hint-box { padding: 1rem 1.2rem; max-width: 100%; }
    #current-hint { font-size: 0.85rem; }
}

/* ========================================
   HINT BOX — Radio Transmission
   ======================================== */
.hint-box {
    background: var(--box-bg);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--accent-blood);
    border-radius: 2px;
    padding: 1.5rem 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    animation: pulseRed 4s infinite alternate;
    margin: 0 auto;
    max-width: 500px;
    text-align: left;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4);
}

.hint-icon {
    color: var(--accent-blood);
    display: flex;
    flex-shrink: 0;
    animation: flicker 3s infinite;
}

#current-hint {
    font-weight: 400;
    font-size: 1rem;
    letter-spacing: 0.5px;
    margin-bottom: 0;
    line-height: 1.6;
}

@keyframes pulseRed {
    0% { box-shadow: 0 0 15px rgba(138, 3, 3, 0.1); }
    100% { box-shadow: 0 0 25px rgba(138, 3, 3, 0.35), inset 0 0 10px rgba(138, 3, 3, 0.05); }
}

/* ========================================
   CIPHER SECTION — Pigpen
   ======================================== */
.cipher-section {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    background: var(--box-bg);
    border: 1px solid var(--border-color);
    border-top: 3px solid var(--accent-blood);
    border-radius: 2px;
    padding: 1.5rem 2rem;
    margin: 0 auto;
    max-width: 560px;
    width: 100%;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.5);
    animation: pulseRed 4s infinite alternate;
}

.cipher-section.active {
    display: flex;
}

.cipher-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.cipher-badge {
    font-size: 0.75rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--accent-blood);
    animation: flicker 3s infinite;
}

.cipher-type {
    font-family: 'Creepster', cursive;
    font-size: 1.4rem;
    color: var(--text-primary);
    text-shadow: 0 0 8px rgba(138, 3, 3, 0.4);
}

.cipher-symbols {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 5px;
    padding: 0.5rem 0;
    min-height: 50px;
    transition: opacity 0.3s ease;
}

/* Interference state */
.cipher-symbols.interference {
    animation: cipherGlitch 0.4s infinite steps(2);
}

.cipher-symbols.stable {
    animation: none;
}

@keyframes cipherGlitch {
    0% { transform: translateX(0); opacity: 0.85; }
    25% { transform: translateX(-2px); opacity: 0.7; }
    50% { transform: translateX(1px); opacity: 0.9; }
    75% { transform: translateX(-1px); opacity: 0.75; }
    100% { transform: translateX(2px); opacity: 0.85; }
}

.cipher-word {
    display: flex;
    gap: 3px;
}

.cipher-space {
    width: 14px;
}

.pigpen-char {
    width: 34px;
    height: 34px;
    color: var(--accent-blood);
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.cipher-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.cipher-status {
    font-size: 0.8rem;
    letter-spacing: 1px;
    transition: color 0.3s ease;
}

.cipher-status.searching {
    color: var(--accent-blood);
    animation: flicker 2s infinite;
}

.cipher-status.locked {
    color: var(--accent-terminal);
    text-shadow: 0 0 8px rgba(51, 255, 51, 0.4);
    animation: none;
}

.cipher-help {
    font-size: 0.75rem;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    text-align: center;
    opacity: 0.6;
    margin: 0;
}

/* Dictionary toggle button */
.dict-toggle {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 2px;
    color: var(--text-secondary);
    font-family: 'Special Elite', monospace;
    font-size: 0.8rem;
    padding: 0.5rem 1rem;
    cursor: pointer;
    letter-spacing: 1px;
    transition: all 0.3s ease;
    margin-top: 0.5rem;
}

.dict-toggle:hover {
    border-color: var(--accent-blood);
    color: var(--accent-blood);
    box-shadow: 0 0 10px var(--accent-blood-dim);
}

/* Dictionary overlay modal */
.dict-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    background: rgba(0, 0, 0, 0.85);
    justify-content: center;
    align-items: center;
    padding: 1.5rem;
}

.dict-overlay.open {
    display: flex;
}

.dict-modal {
    background: var(--bg-color);
    border: 1px solid var(--accent-blood);
    border-radius: 4px;
    padding: 1.5rem;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 0 40px rgba(138, 3, 3, 0.3);
    animation: fadeIn 0.3s ease-out;
}

.dict-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.dict-modal-title {
    font-family: 'Creepster', cursive;
    font-size: 1.2rem;
    color: var(--text-primary);
    text-shadow: 0 0 8px rgba(138, 3, 3, 0.4);
}

.dict-close {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 2px;
    color: var(--text-secondary);
    font-size: 1rem;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.dict-close:hover {
    border-color: var(--accent-blood);
    color: var(--accent-blood);
}

.dict-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    width: 100%;
}

.dict-cell {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.dict-cell .dict-letter {
    font-size: 0.75rem;
    color: var(--text-secondary);
    letter-spacing: 1px;
    font-family: 'Special Elite', monospace;
    min-width: 14px;
}

.dict-cell .pigpen-char {
    width: 22px;
    height: 22px;
}

.dict-separator {
    grid-column: 1 / -1;
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

@media (max-width: 600px) {
    .cipher-section { padding: 1rem 1.2rem; max-width: 100%; }
    .cipher-type { font-size: 1.2rem; }
    .pigpen-char { width: 28px; height: 28px; }
    .cipher-space { width: 10px; }
    .cipher-help { font-size: 0.65rem; }
    .cipher-badge { font-size: 0.65rem; }
    .dict-toggle { font-size: 0.7rem; }
    .dict-modal { padding: 1rem; }
    .dict-cell .pigpen-char { width: 20px; height: 20px; }
    .dict-cell .dict-letter { font-size: 0.65rem; }
    .dict-cell { padding: 4px 6px; }
}

/* Reduced motion: disable cipher glitch */
@media (prefers-reduced-motion: reduce) {
    .cipher-symbols.interference {
        animation: none;
        opacity: 1;
    }
    .cipher-status.searching {
        animation: none;
    }
    .main-title { animation: none; }
    .main-title::before, .main-title::after { animation: none; opacity: 0; }
    .badge { animation: none; }
    .subtitle { animation: none; }
    .scanlines { animation: none; }
    .fog { animation: none; }
    .separator { animation: none; }
}

/* ========================================
   VIEW STATES
   ======================================== */
.view-state {
    display: none;
    width: 100%;
    animation: fadeIn 1.5s ease-out forwards;
}

.view-state.active {
    display: block;
}

/* ========================================
   REVELATION STATE
   ======================================== */
.reveal-box {
    margin: 2rem auto 0;
    padding: 3rem 2rem;
    background: linear-gradient(135deg, rgba(138, 3, 3, 0.15), rgba(61, 90, 30, 0.1));
    border: 1px solid var(--accent-blood);
    border-radius: 2px;
    box-shadow: 0 0 40px rgba(138, 3, 3, 0.3), inset 0 0 30px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    animation: popIn 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.reveal-title {
    font-family: 'Creepster', cursive;
    font-size: clamp(1.8rem, 5vw, 3.5rem);
    font-weight: 400;
    color: var(--accent-terminal);
    text-shadow: 0 0 15px rgba(51, 255, 51, 0.4), 0 0 30px rgba(51, 255, 51, 0.2);
    margin-bottom: 0;
    animation: terminalPulse 2s infinite alternate;
}

@keyframes terminalPulse {
    0% { text-shadow: 0 0 15px rgba(51, 255, 51, 0.4), 0 0 30px rgba(51, 255, 51, 0.2); }
    100% { text-shadow: 0 0 20px rgba(51, 255, 51, 0.6), 0 0 40px rgba(51, 255, 51, 0.3); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes popIn {
    to { transform: scale(1); }
}

/* ========================================
   FOOTER
   ======================================== */
.footer {
    position: absolute;
    bottom: 2rem;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    opacity: 0.5;
    letter-spacing: 1px;
}
