@import url('https://fonts.googleapis.com/css2?family=Black+Ops+One&family=Oswald:wght@400;500;600;700&display=swap');

:root {
    --bg: #0b0d08;
    --panel: rgba(38, 43, 31, 0.72);
    --panel-border: rgba(120, 130, 96, 0.85);
    --slot-bg: rgba(8, 9, 5, 0.92);
    --text: #ecead7;
    --muted: #9aa183;
    --ink: #14160d;
    --accent: #c43c2a;
    --accent-strong: #8c281a;
    --amber: #e2a32b;
    --warning: #e23b2b;
    --steel: #3c4231;
    --steel-dark: #20241a;
    --shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
    --radius: 6px;
    --hazard: repeating-linear-gradient(45deg, #e2a32b 0 14px, #14160d 14px 28px);

    /* Type scale */
    --font-xs: 4px;
    --font-sm: 8px;
    --font-md: 16px;
    --font-lg: 32px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Oswald', 'Trebuchet MS', sans-serif;
    color: var(--text);
    background: var(--bg);
}

button,
input {
    font: inherit;
}

/* ---------- Battlefield backdrop ---------- */
.app-background {
    position: fixed;
    inset: 0;
    z-index: -2;
    background:
        radial-gradient(ellipse at 50% 40%, rgba(70, 78, 52, 0.42), rgba(13, 16, 9, 0.85) 55%, rgba(4, 5, 3, 1) 100%),
        linear-gradient(160deg, rgba(28, 33, 22, 0.95), rgba(10, 12, 7, 0.98));
    overflow: hidden;
}

/* hex-grid recon overlay */
.app-background::before {
    content: '';
    position: absolute;
    inset: -10%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='100' viewBox='0 0 56 100'%3E%3Cg fill='none' stroke='%237c8a52' stroke-width='1.4' stroke-opacity='0.5'%3E%3Cpath d='M28 0 L56 16 L56 50 L28 66 L0 50 L0 16 Z'/%3E%3Cpath d='M28 66 L56 82 L56 116 L28 132 L0 116 L0 82 Z'/%3E%3C/g%3E%3C/svg%3E");
    background-size: 112px 200px;
    opacity: 0.16;
    filter: drop-shadow(0 0 1px rgba(124, 138, 82, 0.4));
    mask-image: radial-gradient(ellipse at 50% 45%, #000 35%, transparent 80%);
    -webkit-mask-image: radial-gradient(ellipse at 50% 45%, #000 35%, transparent 80%);
}

/* scanlines + grime + vignette */
.app-background::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(0deg, transparent 0 3px, rgba(0, 0, 0, 0.16) 3px 4px),
        radial-gradient(ellipse at 18% 12%, rgba(0, 0, 0, 0.5), transparent 30%),
        radial-gradient(ellipse at 88% 88%, rgba(0, 0, 0, 0.55), transparent 32%),
        radial-gradient(ellipse at 50% 120%, rgba(0, 0, 0, 0.6), transparent 50%);
    opacity: 0.9;
    pointer-events: none;
}

.lock-page,
.projects-page {
    display: grid;
    place-items: center;
    padding: 40px clamp(32px, 6vw, 120px);
}

.lock-shell,
.projects-shell {
    width: min(100%, 914px);
}

/* ---------- Armor panel ---------- */
.pin-panel,
.projects-panel {
    position: relative;
    overflow: hidden;
    width: 100%;
    padding: 58px 88px 62px;
    border: 2px solid var(--panel-border);
    border-radius: 8px;
    background:
        linear-gradient(160deg, rgba(70, 78, 54, 0.45), rgba(24, 28, 18, 0.7) 45%, rgba(10, 12, 7, 0.6)),
        repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.018) 0 2px, transparent 2px 4px),
        var(--panel);
    box-shadow:
        var(--shadow),
        inset 0 0 0 1px rgba(0, 0, 0, 0.5),
        inset 0 0 0 4px rgba(124, 138, 82, 0.12),
        inset 0 0 120px rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px) saturate(1.05);
    -webkit-backdrop-filter: blur(8px) saturate(1.05);
}

/* hazard tape stripe along the top edge */
.pin-panel::before,
.projects-panel::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 10px;
    background: var(--hazard);
    opacity: 0.92;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.6), 0 6px 14px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

/* corner rivets */
.pin-panel::after,
.projects-panel::after {
    content: '';
    position: absolute;
    inset: 22px;
    border-radius: 4px;
    pointer-events: none;
    background:
        radial-gradient(circle at 0 0, rgba(220, 226, 200, 0.55) 0 2px, rgba(0, 0, 0, 0.6) 2.5px 4px, transparent 5px) no-repeat top left,
        radial-gradient(circle at 100% 0, rgba(220, 226, 200, 0.55) 0 2px, rgba(0, 0, 0, 0.6) 2.5px 4px, transparent 5px) no-repeat top right,
        radial-gradient(circle at 0 100%, rgba(220, 226, 200, 0.55) 0 2px, rgba(0, 0, 0, 0.6) 2.5px 4px, transparent 5px) no-repeat bottom left,
        radial-gradient(circle at 100% 100%, rgba(220, 226, 200, 0.55) 0 2px, rgba(0, 0, 0, 0.6) 2.5px 4px, transparent 5px) no-repeat bottom right;
    background-size: 12px 12px;
}

.pin-panel > *,
.projects-panel > * {
    position: relative;
    z-index: 1;
}

.system-label {
    display: block;
    margin: 0 0 6px;
    color: var(--amber);
    font-family: 'Oswald', sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.42em;
    text-align: center;
    text-transform: uppercase;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.system-label::before { content: '// '; color: var(--accent); }
.system-label::after { content: ' //'; color: var(--accent); }

/* ---------- Stenciled headline ---------- */
h1 {
    margin: 6px 0 34px;
    color: #d7d8c2;
    font-family: 'Black Ops One', 'Oswald', sans-serif;
    font-weight: 400;
    font-size: clamp(3.6rem, 7.5vw, 5.4rem);
    line-height: 0.92;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    text-shadow:
        0 2px 0 rgba(0, 0, 0, 0.65),
        0 4px 0 rgba(0, 0, 0, 0.5),
        0 0 28px rgba(196, 60, 42, 0.35),
        0 10px 26px rgba(0, 0, 0, 0.7);
}

.lock-page h1 {
    color: #d8412f;
    text-shadow:
        0 2px 0 rgba(0, 0, 0, 0.7),
        0 0 22px rgba(216, 65, 47, 0.55),
        0 10px 26px rgba(0, 0, 0, 0.75);
}

/* ---------- Engage / unlock bar ---------- */
.unlock-button {
    display: block;
    width: min(100%, 540px);
    min-height: 74px;
    margin: 0 auto 32px;
    border: 2px solid rgba(124, 138, 82, 0.6);
    border-radius: 5px;
    color: rgba(236, 234, 215, 0.55);
    background:
        linear-gradient(180deg, rgba(70, 78, 54, 0.85), rgba(32, 36, 26, 0.92)),
        repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.03) 0 1px, transparent 1px 4px);
    box-shadow:
        inset 0 1px rgba(255, 255, 255, 0.18),
        inset 0 -2px rgba(0, 0, 0, 0.6),
        0 4px 0 rgba(0, 0, 0, 0.55),
        0 12px 24px rgba(0, 0, 0, 0.4);
    cursor: default;
    font-family: 'Oswald', sans-serif;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    text-shadow: 0 2px 3px rgba(0, 0, 0, 0.8);
    transition: color 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.unlock-button:focus { outline: none; }

.unlock-button:focus-visible {
    box-shadow:
        0 0 0 3px rgba(226, 163, 43, 0.3),
        inset 0 1px rgba(255, 255, 255, 0.18),
        inset 0 -2px rgba(0, 0, 0, 0.6),
        0 4px 0 rgba(0, 0, 0, 0.55);
}

.unlock-icon {
    position: relative;
    display: inline-block;
    width: 24px;
    height: 19px;
    margin-right: 16px;
    border: 3px solid currentColor;
    border-radius: 3px;
    vertical-align: -2px;
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.4);
    opacity: 0.7;
}

.unlock-icon::before {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 13px;
    width: 14px;
    height: 16px;
    border: 3px solid currentColor;
    border-bottom: 0;
    border-radius: 10px 10px 0 0;
    transform: translateX(-50%);
}

.unlock-icon::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 5px;
    width: 4px;
    height: 7px;
    border-radius: 2px;
    background: currentColor;
    transform: translateX(-50%);
}

/* armed state — ready to engage */
.unlock-button.can-submit {
    color: #fff3e6;
    border-color: var(--accent);
    background:
        linear-gradient(180deg, rgba(196, 60, 42, 0.92), rgba(140, 40, 26, 0.95)),
        repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 4px);
    box-shadow:
        inset 0 1px rgba(255, 255, 255, 0.28),
        inset 0 -2px rgba(0, 0, 0, 0.5),
        0 4px 0 rgba(70, 16, 10, 0.9),
        0 0 26px rgba(216, 65, 47, 0.45);
    cursor: pointer;
    animation: armed-pulse 1.6s ease-in-out infinite;
}

@keyframes armed-pulse {
    0%, 100% { box-shadow: inset 0 1px rgba(255, 255, 255, 0.28), inset 0 -2px rgba(0, 0, 0, 0.5), 0 4px 0 rgba(70, 16, 10, 0.9), 0 0 18px rgba(216, 65, 47, 0.35); }
    50% { box-shadow: inset 0 1px rgba(255, 255, 255, 0.28), inset 0 -2px rgba(0, 0, 0, 0.5), 0 4px 0 rgba(70, 16, 10, 0.9), 0 0 34px rgba(216, 65, 47, 0.7); }
}

.unlock-button.can-submit .unlock-icon { opacity: 1; }

.unlock-button.is-loading,
.unlock-button.is-loading:disabled {
    color: #fff7e8;
    border-color: var(--amber);
    background:
        linear-gradient(180deg, rgba(226, 163, 43, 0.92), rgba(140, 90, 20, 0.96)),
        repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.06) 0 1px, transparent 1px 4px);
    box-shadow:
        inset 0 2px rgba(255, 255, 255, 0.3),
        inset 0 -2px rgba(0, 0, 0, 0.45),
        0 2px 0 rgba(70, 46, 10, 0.9),
        0 0 36px rgba(226, 163, 43, 0.7);
    cursor: wait;
    transform: translateY(2px);
    animation: unlock-loading-pulse 0.8s ease-in-out infinite;
}

@keyframes unlock-loading-pulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.18); }
}

body.is-unlocking .pin-panel {
    pointer-events: none;
}

.access-loading {
    position: fixed;
    inset: 0;
    display: none;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(ellipse at 50% 45%, rgba(226, 163, 43, 0.18), transparent 42%),
        rgba(5, 6, 4, 0.74);
    backdrop-filter: blur(9px) saturate(1.1);
    -webkit-backdrop-filter: blur(9px) saturate(1.1);
    z-index: 30;
}

.access-loading.is-visible {
    display: grid;
}

.access-loading-card {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 8px;
    width: 420px;
    max-width: calc(100vw - 48px);
    padding: 36px 30px 32px;
    border: 2px solid rgba(226, 163, 43, 0.78);
    border-radius: 7px;
    background:
        linear-gradient(160deg, rgba(70, 78, 54, 0.78), rgba(14, 16, 10, 0.96)),
        rgba(20, 24, 15, 0.96);
    box-shadow:
        0 30px 70px rgba(0, 0, 0, 0.7),
        inset 0 0 0 1px rgba(226, 163, 43, 0.22),
        0 0 42px rgba(226, 163, 43, 0.26);
    text-align: center;
    text-transform: uppercase;
}

.access-loading-card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 8px;
    border-radius: 5px 5px 0 0;
    background: var(--hazard);
}

.access-loading-icon {
    width: 42px;
    height: 42px;
    border: 3px solid var(--amber);
    border-radius: 50%;
    box-shadow: 0 0 24px rgba(226, 163, 43, 0.55);
    animation: access-loading-spin 0.9s linear infinite;
}

.access-loading-icon::before {
    content: '';
    display: block;
    width: 12px;
    height: 12px;
    margin: -5px auto 0;
    border-radius: 50%;
    background: #fff7e8;
    box-shadow: 0 0 14px rgba(255, 247, 232, 0.8);
}

.access-loading-card p {
    margin: 8px 0 0;
    color: #fff7e8;
    font-family: 'Black Ops One', sans-serif;
    font-size: 1.6rem;
    line-height: 1.2;
    letter-spacing: 0.08em;
    text-shadow: 0 0 18px rgba(226, 163, 43, 0.55);
}

.access-loading-card span:not(.access-loading-icon) {
    color: var(--amber);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.18em;
}

@keyframes access-loading-spin {
    to { transform: rotate(360deg); }
}

/* ---------- Code slots (ammo cells) ---------- */
.pin-slots {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 16px;
    width: min(100%, 735px);
    margin: 0 auto 28px;
}

.pin-slot {
    width: 100%;
    aspect-ratio: 1 / 1;
    border: 2px solid rgba(124, 138, 82, 0.55);
    border-radius: 5px;
    outline: none;
    color: var(--text);
    background:
        radial-gradient(ellipse at 50% 40%, rgba(60, 66, 49, 0.5), transparent 60%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 24%, rgba(0, 0, 0, 0.5) 100%),
        var(--slot-bg);
    box-shadow:
        inset 0 0 0 3px rgba(0, 0, 0, 0.7),
        inset 0 12px 22px rgba(0, 0, 0, 0.75),
        inset 0 -2px rgba(124, 138, 82, 0.25),
        0 2px 0 rgba(0, 0, 0, 0.6);
    text-align: center;
    font-family: 'Black Ops One', sans-serif;
    font-size: clamp(1.8rem, 4.5vw, 3rem);
    font-weight: 400;
    caret-color: transparent;
    cursor: pointer;
}

.pin-slot:focus {
    border-color: var(--amber);
    box-shadow:
        0 0 0 3px rgba(226, 163, 43, 0.25),
        inset 0 0 0 3px rgba(0, 0, 0, 0.7),
        inset 0 12px 20px rgba(0, 0, 0, 0.7);
}

.pin-slot.is-filled {
    color: var(--amber);
    border-color: rgba(226, 163, 43, 0.7);
    text-shadow: 0 0 10px rgba(226, 163, 43, 0.6);
}

/* ---------- Keypad (ammo crate keys) ---------- */
.numpad {
    display: block;
    width: min(100%, 690px);
    margin: 0 auto;
    border: 0;
    padding: 0;
    background: transparent;
}

.numpad.is-open { display: block; }

.numpad-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px 12px;
}

.numpad-key {
    min-height: 80px;
    border: 2px solid rgba(124, 138, 82, 0.45);
    border-radius: 5px;
    color: rgba(236, 234, 215, 0.92);
    background:
        linear-gradient(180deg, rgba(74, 82, 56, 0.92), rgba(40, 46, 30, 0.95) 50%, rgba(24, 28, 18, 0.96)),
        repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.03) 0 1px, transparent 1px 4px);
    box-shadow:
        inset 0 1px rgba(255, 255, 255, 0.16),
        inset 0 -2px rgba(0, 0, 0, 0.55),
        0 3px 0 rgba(0, 0, 0, 0.7),
        0 9px 16px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    font-family: 'Black Ops One', sans-serif;
    font-size: 2.3rem;
    font-weight: 400;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.85);
    transition: border-color 0.12s, color 0.12s, transform 0.05s;
}

.numpad-key:hover,
.numpad-key:focus-visible {
    border-color: var(--amber);
    color: #fff7e8;
    outline: none;
}

.numpad-key:active {
    transform: translateY(3px);
    box-shadow:
        inset 0 1px rgba(255, 255, 255, 0.16),
        inset 0 -2px rgba(0, 0, 0, 0.55),
        0 0 0 rgba(0, 0, 0, 0.7);
}

.numpad-key-icon {
    color: var(--accent);
    font-size: 1.9rem;
}

/* ---------- Alert modal (breach warning) ---------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(20, 6, 4, 0.5);
    backdrop-filter: blur(8px) saturate(0.8);
    -webkit-backdrop-filter: blur(8px) saturate(0.8);
    z-index: 20;
}

.modal-backdrop.is-visible { display: grid; }

.modal-card {
    position: relative;
    display: grid;
    justify-items: center;
    width: 400px;
    max-width: calc(100vw - 48px);
    padding: 36px 34px 30px;
    border: 2px solid var(--warning);
    border-radius: 7px;
    background:
        linear-gradient(160deg, rgba(60, 28, 22, 0.7), rgba(12, 8, 6, 0.96)),
        rgba(20, 14, 10, 0.96);
    box-shadow:
        0 24px 50px rgba(0, 0, 0, 0.6),
        inset 0 0 0 1px rgba(226, 59, 43, 0.3),
        0 0 40px rgba(226, 59, 43, 0.25);
    text-align: center;
}

.modal-card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 8px;
    background: var(--hazard);
    border-radius: 5px 5px 0 0;
}

.modal-card h2 {
    margin: 14px 0 22px;
    color: var(--text);
    font-family: 'Black Ops One', sans-serif;
    font-weight: 400;
    font-size: 1.5rem;
    line-height: 1.3;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-shadow: 0 0 14px rgba(226, 59, 43, 0.4);
}

.warning-icon {
    position: relative;
    display: grid;
    place-items: center;
    width: 48px;
    height: 44px;
    margin: 0 auto;
    color: #fff;
    font-family: 'Black Ops One', sans-serif;
    font-size: 1.3rem;
    line-height: 1;
    z-index: 1;
    animation: alert-blink 1s steps(2, start) infinite;
}

@keyframes alert-blink {
    0%, 100% { filter: drop-shadow(0 0 6px rgba(226, 59, 43, 0.9)); }
    50% { filter: drop-shadow(0 0 14px rgba(226, 59, 43, 1)); }
}

.warning-icon::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    clip-path: polygon(50% 0, 100% 100%, 0 100%);
    background: rgba(226, 59, 43, 0.28);
    border: 2px solid var(--warning);
}

.warning-icon::after {
    content: '';
    position: absolute;
    inset: 6px;
    z-index: -1;
    clip-path: polygon(50% 0, 100% 100%, 0 100%);
    border: 1px solid rgba(226, 59, 43, 0.7);
}

.retry-button {
    width: 270px;
    max-width: 100%;
    min-height: 56px;
    border: 2px solid rgba(226, 163, 43, 0.7);
    border-radius: 5px;
    color: #fff3e6;
    background: linear-gradient(180deg, rgba(74, 82, 56, 0.85), rgba(32, 36, 26, 0.92));
    cursor: pointer;
    font-family: 'Oswald', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.18), 0 3px 0 rgba(0, 0, 0, 0.6);
}

.retry-button:disabled {
    color: rgba(236, 234, 215, 0.8);
    cursor: wait;
    border-color: rgba(124, 138, 82, 0.5);
}

/* ---------- Projects (mission select) ---------- */
.project-links {
    display: grid;
    gap: 14px;
}

.project-button,
.lock-link {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 76px;
    padding: 18px 22px;
    border: 2px solid rgba(124, 138, 82, 0.5);
    border-radius: var(--radius);
    color: var(--text);
    background:
        linear-gradient(180deg, rgba(70, 78, 54, 0.6), rgba(24, 28, 18, 0.75));
    text-align: center;
    text-decoration: none;
    font-family: 'Oswald', sans-serif;
    font-size: var(--font-lg);
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
    transition: border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.project-button:hover,
.lock-link:hover {
    border-color: var(--amber);
    color: #fff7e8;
    box-shadow: 0 0 22px rgba(226, 163, 43, 0.4), inset 0 0 0 1px rgba(226, 163, 43, 0.35);
}

.omr-button {
    border-color: rgba(226, 163, 43, 0.45);
    background: linear-gradient(180deg, rgba(226, 163, 43, 0.28), rgba(140, 90, 20, 0.16));
}

.lock-link {
    width: 100%;
    min-height: 56px;
    margin-top: 18px;
    color: var(--muted);
    font-size: var(--font-md);
    border-color: rgba(124, 138, 82, 0.3);
    background: rgba(10, 12, 7, 0.4);
}

@media (max-width: 520px) {
    .lock-page,
    .projects-page {
        padding: 18px;
    }

    .pin-panel,
    .projects-panel {
        padding: 34px 18px 30px;
    }

    h1 {
        font-size: clamp(2.4rem, 14vw, 3.6rem);
        letter-spacing: 0.08em;
    }

    .unlock-button {
        min-height: 56px;
        font-size: 1.05rem;
    }

    .unlock-icon {
        margin-right: 8px;
        transform: scale(0.78);
        transform-origin: right center;
    }

    .pin-slots {
        gap: 6px;
    }

    .numpad-grid {
        gap: 8px;
    }

    .numpad-key {
        min-height: 60px;
        font-size: 1.6rem;
    }

    .modal-card {
        width: 340px;
        max-width: calc(100vw - 36px);
        padding: 26px 20px;
    }
}
