:root {
    --bg: #07050d;
    --panel: rgba(14, 10, 26, 0.82);
    --line: rgba(140, 110, 255, 0.35);
    --text: #e6e2f3;
    --muted: #9a93b5;
    --cyan: #29f0ff;
    --pink: #ff2bd6;
    --orange: #ff8a1f;
    --red: #ff3355;
    --green: #4dffa6;
    --violet: #8a5cff;
    --display: 'Orbitron', sans-serif;
    --body: 'Rajdhani', sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: var(--body);
    font-size: 17px;
}

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.hidden { display: none !important; }
.static-build .online-only { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.accent { color: var(--cyan); font-weight: 600; }
.good { color: var(--green); }
.bad { color: var(--red); }

/* ---------- Buttons & inputs ---------- */
.btn {
    font-family: var(--display);
    font-size: 0.8rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--line);
    padding: 0.8rem 1.4rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}
.btn:hover:not(:disabled) { border-color: var(--cyan); box-shadow: 0 0 14px rgba(41, 240, 255, 0.35); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary { background: linear-gradient(90deg, #0fb8d6, #7b4dff); border-color: transparent; color: #fff; }
.btn.primary:hover:not(:disabled) { box-shadow: 0 0 22px rgba(123, 77, 255, 0.6); }
.btn.danger { background: linear-gradient(90deg, #ff3355, #ff8a1f); border-color: transparent; color: #fff; }
.btn.ghost { background: transparent; }

input {
    width: 100%;
    font-family: var(--body);
    font-size: 1rem;
    color: var(--text);
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 0.75rem 0.9rem;
    margin-bottom: 0.7rem;
    outline: none;
}
input:focus { border-color: var(--cyan); }

kbd {
    font-family: var(--display);
    font-size: 0.7rem;
    padding: 0.15rem 0.45rem;
    border: 1px solid var(--line);
    border-bottom-width: 2px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.06);
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 1.6rem;
    backdrop-filter: blur(10px);
    box-shadow: 0 0 40px rgba(80, 40, 160, 0.25);
}

/* ---------- Screens ---------- */
.screen {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10;
    background: radial-gradient(ellipse at center, rgba(7, 5, 13, 0.2), rgba(7, 5, 13, 0.85));
    padding: 1rem;
}
.screen.active { display: flex; }

.menu-inner {
    width: min(1100px, 100%);
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    grid-template-rows: auto auto;
    gap: 2rem;
    align-items: center;
}

.eyebrow { font-family: var(--display); letter-spacing: 0.4em; color: var(--pink); font-size: 0.8rem; margin: 0; }

.title {
    font-family: var(--display);
    font-weight: 900;
    font-size: clamp(2.6rem, 7vw, 5.4rem);
    line-height: 0.95;
    margin: 0.4rem 0;
    letter-spacing: 0.04em;
    text-shadow: 0 0 30px rgba(41, 240, 255, 0.5);
}
.title span {
    display: block;
    background: linear-gradient(90deg, var(--cyan), var(--pink));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.title.small { font-size: 2rem; }

.tagline { font-size: 1.3rem; color: var(--muted); margin: 0.8rem 0 0; }

#auth-box { display: flex; flex-direction: column; }
#auth-box h3 { font-family: var(--display); margin: 0 0 0.3rem; font-size: 1rem; letter-spacing: 0.08em; }
#auth-box .btn { width: 100%; margin-top: 0.5rem; }
#who { color: var(--cyan); }
.msg { min-height: 1.2rem; margin: 0.8rem 0 0; font-size: 0.95rem; color: var(--muted); }
.msg.error { color: var(--red); }

.menu-links { grid-column: 1 / -1; display: flex; gap: 1rem; flex-wrap: wrap; }
.menu-links button {
    font-family: var(--display);
    background: none;
    border: none;
    color: var(--muted);
    letter-spacing: 0.15em;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0.4rem 0;
    border-bottom: 1px solid transparent;
}
.menu-links button:hover { color: var(--cyan); border-color: var(--cyan); }

.page { width: min(820px, 100%); max-height: 90vh; overflow-y: auto; }
.page h2 { font-family: var(--display); letter-spacing: 0.1em; margin-top: 0; }
.page p { line-height: 1.55; }
.howto-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 1rem; }
.howto-grid h4 { font-family: var(--display); color: var(--cyan); letter-spacing: 0.1em; }
.howto-grid ul { padding-left: 1rem; line-height: 1.6; }
.keys td { padding: 0.25rem 0.6rem 0.25rem 0; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.dot.cyan { background: var(--cyan); }
.dot.orange { background: var(--orange); }
.dot.red { background: var(--red); }

.board { width: 100%; border-collapse: collapse; margin-bottom: 1.2rem; }
.board th { font-family: var(--display); font-size: 0.7rem; letter-spacing: 0.12em; color: var(--muted); text-align: left; }
.board th, .board td { padding: 0.55rem 0.5rem; border-bottom: 1px solid rgba(140, 110, 255, 0.15); }
.board .savior { color: var(--green); }
.board .overlord { color: var(--pink); }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }

#mission-panel {
    position: absolute;
    top: 18px;
    left: 18px;
    width: 360px;
    padding: 0.9rem 1.1rem;
    background: var(--panel);
    border-left: 3px solid var(--cyan);
    border-radius: 0 6px 6px 0;
}
.chapter { font-family: var(--display); font-size: 0.7rem; letter-spacing: 0.25em; color: var(--pink); }
.mtitle { font-family: var(--display); font-size: 1.15rem; margin: 0.2rem 0 0.4rem; }
.obj { line-height: 1.35; color: #cfc9e6; }
.obj .warn { color: var(--red); }
.mrow { display: flex; justify-content: space-between; margin-top: 0.5rem; font-family: var(--display); font-size: 0.85rem; }
#hud-dist { color: var(--cyan); }
#hud-timer.expired { color: var(--muted); }

#top-right { position: absolute; top: 18px; right: 18px; text-align: right; font-family: var(--display); }
#clock { font-size: 1.4rem; text-shadow: 0 0 12px rgba(138, 92, 255, 0.8); }
#clock small { font-size: 0.7rem; letter-spacing: 0.2em; margin-left: 0.4rem; color: var(--muted); }
#credits { color: var(--orange); font-size: 1.1rem; margin-top: 0.3rem; }

#bars { position: absolute; left: 18px; bottom: 18px; width: 280px; }
.bar { margin-top: 0.5rem; }
.bar label { font-family: var(--display); font-size: 0.62rem; letter-spacing: 0.18em; color: var(--muted); text-transform: uppercase; }
.track { height: 8px; background: rgba(255, 255, 255, 0.08); border-radius: 4px; overflow: hidden; margin-top: 0.2rem; }
.fill { height: 100%; width: 100%; transition: width 0.1s linear; }
.fill.health { background: linear-gradient(90deg, #ff3355, #ffb020); }
.fill.boost { background: linear-gradient(90deg, #0fb8d6, #29f0ff); }
.fill.energy { background: linear-gradient(90deg, #7b4dff, #ff2bd6); }
.fill.energy.ready { box-shadow: 0 0 10px var(--pink); }

#speedo {
    position: absolute;
    bottom: 230px;
    right: 28px;
    font-family: var(--display);
    font-size: 2.4rem;
    text-align: right;
    text-shadow: 0 0 14px rgba(41, 240, 255, 0.7);
}
#speedo small { display: block; font-size: 0.65rem; letter-spacing: 0.3em; color: var(--muted); }

#minimap {
    position: absolute;
    right: 18px;
    bottom: 18px;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    box-shadow: 0 0 20px rgba(138, 92, 255, 0.5);
}

#prompt {
    position: absolute;
    left: 50%;
    bottom: 22%;
    transform: translateX(-50%);
    font-family: var(--display);
    font-size: 0.9rem;
    letter-spacing: 0.08em;
    padding: 0.7rem 1.2rem;
    background: rgba(40, 0, 12, 0.8);
    border: 1px solid var(--red);
    border-radius: 4px;
    color: #ffd0d8;
}
#prompt:empty { display: none; }

#toasts {
    position: absolute;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    width: min(520px, 90vw);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.toast {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 0.55rem 0.9rem;
    animation: toastIn 0.3s ease;
    transition: opacity 0.6s;
}
.toast b { font-family: var(--display); font-size: 0.7rem; letter-spacing: 0.15em; color: var(--cyan); margin-right: 0.4rem; }
.toast.warn b { color: var(--red); }
.toast.out { opacity: 0; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } }

#vignette {
    position: absolute;
    inset: 0;
    opacity: 0;
    background: radial-gradient(ellipse at center, transparent 45%, rgba(160, 0, 40, 0.75));
}

/* ---------- Modal ---------- */
#modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(4, 2, 10, 0.6);
    padding: 1rem;
}
.modal-box {
    width: min(560px, 100%);
    max-height: 90vh;
    overflow-y: auto;
    background: linear-gradient(160deg, rgba(22, 14, 42, 0.96), rgba(10, 6, 20, 0.96));
    border: 1px solid var(--line);
    border-top: 3px solid var(--violet);
    border-radius: 8px;
    padding: 1.6rem;
    box-shadow: 0 0 60px rgba(123, 77, 255, 0.35);
    animation: modalIn 0.25s ease;
}
.modal-box.wide { width: min(720px, 100%); }
@keyframes modalIn { from { opacity: 0; transform: scale(0.96); } }
#modal-title { font-family: var(--display); letter-spacing: 0.08em; margin: 0 0 1rem; font-size: 1.3rem; }
#modal-body p { line-height: 1.6; }
#modal-body .item { font-family: var(--display); color: var(--orange); letter-spacing: 0.05em; }
.badge { display: inline-block; font-family: var(--display); font-size: 0.7rem; letter-spacing: 0.1em; padding: 0.15rem 0.5rem; margin-left: 0.4rem; border: 1px solid; border-radius: 3px; vertical-align: middle; }
#modal-body .quote { border-left: 3px solid var(--violet); padding-left: 1rem; font-style: italic; color: #d7cff5; }
#modal-actions { display: flex; gap: 0.8rem; justify-content: flex-end; flex-wrap: wrap; margin-top: 1.4rem; }

.reward-list { list-style: none; padding: 0; margin: 1rem 0 0; font-family: var(--display); font-size: 0.85rem; }
.reward-list li { display: flex; justify-content: space-between; padding: 0.35rem 0; border-bottom: 1px solid rgba(140, 110, 255, 0.15); }
.reward-list li.total { color: var(--orange); border: none; font-size: 1rem; }

.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; }
.choice-grid div { padding: 1rem; border-radius: 6px; border: 1px solid var(--line); }
.choice-grid .destroy { border-color: var(--orange); background: rgba(255, 138, 31, 0.08); }
.choice-grid .activate { border-color: var(--violet); background: rgba(138, 92, 255, 0.1); }
.choice-grid h4 { font-family: var(--display); margin: 0 0 0.5rem; }

.score-box { text-align: center; margin: 1.2rem 0; }
.score-box .score { font-family: var(--display); font-size: 2.6rem; color: var(--cyan); text-shadow: 0 0 20px rgba(41, 240, 255, 0.6); }

/* ---------- Garage ---------- */
.upgrades { display: grid; gap: 0.7rem; margin-top: 0.8rem; }
.upg {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.03);
}
.upg h4 { margin: 0; font-family: var(--display); font-size: 0.9rem; }
.upg p { margin: 0.2rem 0 0.4rem; color: var(--muted); }
.pips span { display: inline-block; width: 26px; height: 6px; margin-right: 4px; background: rgba(255, 255, 255, 0.12); border-radius: 3px; }
.pips span.on { background: var(--cyan); box-shadow: 0 0 6px var(--cyan); }
.upg .btn { min-width: 110px; }

/* ---------- Puzzles ---------- */
.puz-status { font-family: var(--display); text-align: center; letter-spacing: 0.1em; min-height: 1.4rem; color: var(--cyan); }
.puz-status.bad { color: var(--red); }
.puz-status.good { color: var(--green); }
.pads { display: grid; grid-template-columns: repeat(2, 110px); gap: 14px; justify-content: center; margin: 1.2rem 0; }
.pad { width: 110px; height: 110px; border-radius: 12px; border: 2px solid rgba(255, 255, 255, 0.15); cursor: pointer; opacity: 0.35; transition: opacity 0.1s, transform 0.1s; }
.pad.lit { opacity: 1; transform: scale(1.05); box-shadow: 0 0 30px currentColor; }
.shake { animation: shake 0.4s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

.grid-lights { display: grid; gap: 10px; justify-content: center; margin: 1.2rem 0; }
.cell { width: 70px; height: 70px; border-radius: 8px; border: 2px solid rgba(255, 255, 255, 0.12); background: #1a1428; cursor: pointer; transition: all 0.12s; }
.cell.on { background: radial-gradient(circle, #fff6b0, #ffb020); box-shadow: 0 0 18px rgba(255, 176, 32, 0.7); }
.cell.hint { outline: 3px solid var(--cyan); }
.puz-tools { display: flex; justify-content: center; gap: 0.6rem; }

/* ---------- Install page ---------- */
.install-page { display: flex; align-items: center; justify-content: center; overflow: auto; }
.install-panel { width: min(560px, 92vw); }
.install-panel code { color: var(--cyan); }

.noscript { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }

@media (max-width: 860px) {
    .menu-inner { grid-template-columns: 1fr; }
    .howto-grid, .choice-grid { grid-template-columns: 1fr; }
    #mission-panel { width: 260px; font-size: 0.9rem; }
    #speedo { bottom: 140px; }
    #minimap { width: 120px; height: 120px; }
}
