:root {
    --bg: #050914;
    --panel: rgba(7, 18, 38, 0.88);
    --panel-border: rgba(66, 199, 255, 0.72);
    --text: #f5fbff;
    --muted: #a8c7da;
    --blue: #28c7ff;
    --blue-soft: rgba(40, 199, 255, 0.18);
    --danger: #ff6b9a;

    /* Mobil v režimu „verze pro počítač“ má široký CSS viewport.
       Těmito hodnotami se ladí velikost karty bez zásahu do logiky. */
    --phone-desktop-card-width: 94vw;
    --phone-desktop-card-max: 58rem;
    --phone-desktop-card-padding: 1.35rem;
    --phone-desktop-ui-scale: 1.45;
    --phone-desktop-card-scale: 1;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 50% 0%, rgba(39, 183, 255, 0.22), transparent 36rem),
        radial-gradient(circle at 0% 100%, rgba(45, 77, 255, 0.16), transparent 24rem),
        var(--bg);
}

.game-page::before {
    content: "TOP SECRET  •  MYSTERY  •  ACCESS  •  SECRET";
    position: fixed;
    inset: auto 0 3rem 0;
    z-index: 0;
    padding: 0 1.25rem;
    color: rgba(255, 255, 255, 0.06);
    font-size: clamp(2.2rem, 14vw, 7rem);
    font-weight: 800;
    letter-spacing: 0.08em;
    line-height: 1;
    text-align: center;
    pointer-events: none;
}

.game-shell {
    position: relative;
    z-index: 1;
    width: min(100%, 34rem);
    min-height: 100vh;
    margin: 0 auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1rem;
}

.access-card,
.story-card,
.hint-card {
    border: 1px solid var(--panel-border);
    border-radius: 1.35rem;
    background: var(--panel);
    box-shadow: 0 0 2rem rgba(40, 199, 255, 0.18), inset 0 0 1.5rem rgba(40, 199, 255, 0.06);
    backdrop-filter: blur(10px);
}

.access-card {
    padding: 1.4rem;
    text-align: center;
}

.eyebrow {
    margin: 0 0 0.45rem;
    color: var(--blue);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.28em;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0.8rem;
    font-size: clamp(1.7rem, 8vw, 2.6rem);
    line-height: 1.06;
}

.entry-lead {
    max-width: 92%;
    margin: 0 auto 1.15rem;
    color: var(--text);
    font-size: 1rem;
    line-height: 1.45;
    text-align: center;
}

h2 {
    margin-bottom: 0.75rem;
    font-size: 1.15rem;
}

.code-form {
    display: grid;
    gap: 0.75rem;
}

label {
    color: var(--muted);
    font-size: 0.95rem;
    text-align: center;
}

input {
    width: 100%;
    min-height: 3.4rem;
    border: 1px solid rgba(40, 199, 255, 0.7);
    border-radius: 0.95rem;
    padding: 0 1rem;
    color: var(--text);
    background: rgba(0, 0, 0, 0.34);
    box-shadow: inset 0 0 1rem rgba(40, 199, 255, 0.12);
    font-size: 1.4rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.08em;
    outline: none;
}

input:focus {
    border-color: #ffffff;
    box-shadow: 0 0 0 0.2rem rgba(40, 199, 255, 0.2), inset 0 0 1rem rgba(40, 199, 255, 0.16);
}

button {
    width: 100%;
    min-height: 3.35rem;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 0.95rem;
    color: #00101a;
    background: linear-gradient(180deg, #9becff, var(--blue));
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
}

.secondary-button {
    margin-top: 0.5rem;
    color: var(--text);
    background: var(--blue-soft);
    border-color: var(--panel-border);
}

.form-message {
    min-height: 1.25rem;
    margin: -0.25rem 0 0;
    color: var(--danger);
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.25rem;
}

.story-card,
.hint-card {
    padding: 1.15rem;
    color: var(--muted);
    line-height: 1.55;
}

.story-card p:last-child,
.hint-card p:last-child {
    margin-bottom: 0;
}

.hint-line {
    padding: 0.75rem;
    border: 1px solid rgba(40, 199, 255, 0.22);
    border-radius: 0.9rem;
    background: rgba(40, 199, 255, 0.08);
    color: var(--text);
}

.unlocked-card {
    padding-block: 2.2rem;
}

.final-text {
    margin-bottom: 0;
    color: var(--muted);
}

@media (min-width: 720px) {
    .game-shell {
        padding-block: 3rem;
    }
}

/* Varianty neonového nasvícení podle vybrané osoby/linie. */
.neon-blue {
    --panel-border: rgba(66, 199, 255, 0.72);
    --blue: #28c7ff;
    --blue-soft: rgba(40, 199, 255, 0.18);
}
.neon-pink {
    --panel-border: rgba(255, 70, 190, 0.72);
    --blue: #ff46be;
    --blue-soft: rgba(255, 70, 190, 0.18);
}
.neon-green {
    --panel-border: rgba(57, 255, 136, 0.72);
    --blue: #39ff88;
    --blue-soft: rgba(57, 255, 136, 0.18);
}
.neon-yellow {
    --panel-border: rgba(255, 234, 0, 0.72);
    --blue: #ffea00;
    --blue-soft: rgba(255, 234, 0, 0.18);
}
.neon-violet {
    --panel-border: rgba(168, 85, 247, 0.72);
    --blue: #a855f7;
    --blue-soft: rgba(168, 85, 247, 0.18);
}

.neon-pink button,
.neon-green button,
.neon-yellow button,
.neon-violet button {
    background: linear-gradient(180deg, #ffffff, var(--blue));
}

.service-link {
    color: var(--blue);
    font-weight: 800;
}

/* Mobilní zobrazení - vysoké rozlišení telefonů nesmí kartu zmenšovat. */
html {
    min-height: 100%;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

.game-page {
    min-height: 100svh;
}

@supports (min-height: 100dvh) {
    .game-page,
    .game-shell {
        min-height: 100dvh;
    }
}


/* Telefon v režimu „verze pro počítač“: prohlížeč nastaví široký desktop viewport,
   proto běžné max-width kartu zmenší. Na dotykových zařízeních ji roztáhneme podle viewportu. */
@media (pointer: coarse) {
    .game-shell {
        width: min(calc(var(--phone-desktop-card-width) * var(--phone-desktop-card-scale)), calc(var(--phone-desktop-card-max) * var(--phone-desktop-card-scale)));
        max-width: none;
        padding-left: max(calc(var(--phone-desktop-card-padding) * var(--phone-desktop-card-scale)), env(safe-area-inset-left));
        padding-right: max(calc(var(--phone-desktop-card-padding) * var(--phone-desktop-card-scale)), env(safe-area-inset-right));
    }

    .access-card,
    .story-card,
    .hint-card {
        width: 100%;
    }

    /* Telefon v režimu „verze pro počítač“: měřítko musí řídit celý obsah karty.
       Nepoužíváme zde pevné vw limity, protože ty zastavovaly hlavní nadpis i tlačítko. */
    .access-card {
        padding: calc(1.55rem * var(--phone-desktop-card-scale));
        border-radius: calc(1.35rem * var(--phone-desktop-card-scale));
    }

    .code-form {
        gap: calc(0.8rem * var(--phone-desktop-ui-scale));
    }

    .eyebrow {
        margin-bottom: calc(0.45rem * var(--phone-desktop-ui-scale));
        font-size: calc(0.72rem * var(--phone-desktop-ui-scale));
        line-height: 1.1;
    }

    h1 {
        margin-bottom: calc(0.8rem * var(--phone-desktop-ui-scale));
        font-size: calc(1.9rem * var(--phone-desktop-ui-scale));
        line-height: 1.02;
    }

    .entry-lead {
        max-width: 100%;
        margin-bottom: calc(1.05rem * var(--phone-desktop-ui-scale));
        font-size: calc(0.95rem * var(--phone-desktop-ui-scale));
        line-height: 1.35;
    }

    label {
        font-size: calc(0.9rem * var(--phone-desktop-ui-scale));
        line-height: 1.3;
    }

    input {
        min-height: calc(3.25rem * var(--phone-desktop-ui-scale));
        padding-inline: calc(0.9rem * var(--phone-desktop-ui-scale));
        font-size: calc(1.2rem * var(--phone-desktop-ui-scale));
        border-radius: calc(0.9rem * var(--phone-desktop-ui-scale));
    }

    button {
        min-height: calc(3.25rem * var(--phone-desktop-ui-scale));
        font-size: calc(0.92rem * var(--phone-desktop-ui-scale));
        border-radius: calc(0.9rem * var(--phone-desktop-ui-scale));
    }

    .form-message {
        font-size: calc(0.88rem * var(--phone-desktop-ui-scale));
        line-height: 1.35;
    }

    .story-card,
    .hint-card {
        padding: calc(1.15rem * var(--phone-desktop-card-scale));
        font-size: calc(0.95rem * var(--phone-desktop-ui-scale));
        border-radius: calc(1.35rem * var(--phone-desktop-card-scale));
    }
}

@media (max-width: 720px) {
    body {
        overflow-x: hidden;
    }

    .game-shell {
        width: 100%;
        max-width: none;
        min-height: 100svh;
        padding: max(0.85rem, env(safe-area-inset-top)) max(0.85rem, env(safe-area-inset-right)) max(0.85rem, env(safe-area-inset-bottom)) max(0.85rem, env(safe-area-inset-left));
        justify-content: center;
        gap: 0.9rem;
    }

    .access-card,
    .story-card,
    .hint-card {
        width: 100%;
        border-radius: 1.25rem;
    }

    .access-card {
        padding: clamp(1.2rem, 5vw, 1.75rem);
    }

    .eyebrow {
        font-size: clamp(0.8rem, 3.2vw, 1rem);
    }

    h1 {
        font-size: clamp(2.15rem, 11vw, 3.35rem);
        line-height: 1.02;
    }

    .entry-lead {
        max-width: 100%;
        margin-bottom: 1.05rem;
        font-size: clamp(1rem, 4.2vw, 1.22rem);
    }

    label {
        font-size: clamp(1rem, 4vw, 1.22rem);
    }

    input {
        min-height: clamp(4rem, 15vw, 4.8rem);
        font-size: clamp(1.55rem, 7vw, 2.1rem);
        border-radius: 1.05rem;
    }

    button {
        min-height: clamp(3.85rem, 14vw, 4.6rem);
        font-size: clamp(1.05rem, 4.5vw, 1.35rem);
        border-radius: 1.05rem;
    }

    .story-card,
    .hint-card {
        padding: clamp(1rem, 4.5vw, 1.35rem);
        font-size: clamp(1.02rem, 4.5vw, 1.22rem);
    }
}

.phone-split {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 8px;
}

.phone-prefix {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    padding: 0 12px;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 12px;
    background: rgba(255,255,255,.06);
    color: rgba(255,255,255,.9);
    font-weight: 700;
}

.status-message {
    color: #9fffd2;
    min-height: auto;
    margin-bottom: 12px;
}

/* Kouzelná úvodní scéna po prvním vstupním kódu. */
.magic-entry-shell {
    justify-content: center;
}

.magic-entry-shell .magic-message-card {
    order: 1;
    position: relative;
    overflow: hidden;
    min-height: calc(var(--magic-visible-lines, 3) * 1.55em + 2.4rem);
}

.magic-kicker {
    margin: 0 0 .8rem;
    color: rgba(203,213,225,.82);
    font-size: .78rem;
    font-weight: 900;
    letter-spacing: .22em;
    text-transform: uppercase;
}

.magic-message-window {
    max-height: calc(var(--magic-visible-lines, 3) * 1.55em);
    min-height: calc(var(--magic-visible-lines, 3) * 1.55em);
    overflow: hidden;
}

.magic-message-text {
    margin: 0;
    color: var(--text);
    line-height: 1.55;
    white-space: pre-wrap;
    font-size: 1.08rem;
    text-shadow: 0 0 1rem rgba(40, 199, 255, 0.16);
    text-align: left;
}

.magic-char {
    display: inline-block;
    transform-origin: center;
}

.magic-char.is-popping {
    animation: gameMagicBubble var(--magic-bubble-ms, 650ms) ease forwards;
}

.magic-entry-countdown {
    order: 2;
    min-height: 0;
    display: none;
    align-items: center;
    justify-content: center;
    color: #e0f2fe;
    font-size: clamp(4rem, 22vw, 8.5rem);
    font-weight: 950;
    text-shadow: 0 0 2rem rgba(40, 199, 255, 0.55);
    pointer-events: none;
}

.magic-entry-countdown.is-visible {
    display: flex;
    animation: gameMagicMist var(--magic-countdown-ms, 900ms) ease forwards;
}

.magic-gated-card {
    opacity: 0;
    transform: translateY(-2rem) scale(.06);
    filter: blur(1.2rem);
    pointer-events: none;
    max-height: 0;
    overflow: hidden;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    border-width: 0;
    margin: 0;
}

.magic-gated-card.is-visible {
    max-height: 60rem;
    border-width: 1px;
    margin: initial;
    animation: gameMagicPanelIn var(--magic-fade-ms, 900ms) cubic-bezier(.18,.9,.2,1) forwards;
    pointer-events: auto;
}

.access-card.magic-gated-card.is-visible {
    padding: 1.4rem !important;
}

.hint-card.magic-gated-card.is-visible {
    padding: 1.15rem !important;
}

.magic-code-reveal {
    opacity: 0;
    transform: scale(.84);
    filter: blur(.85rem);
    position: relative;
    overflow: hidden;
}

.magic-code-reveal.is-visible {
    animation: gameMagicBubbleReveal var(--magic-fade-ms, 900ms) ease forwards;
}

.magic-code-reveal::before {
    content: '';
    position: absolute;
    inset: -20%;
    opacity: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 16% 44%, rgba(224,242,254,.72) 0 .5rem, transparent .65rem),
        radial-gradient(circle at 72% 36%, rgba(40,199,255,.56) 0 .65rem, transparent .82rem),
        radial-gradient(circle at 44% 66%, rgba(255,255,255,.42) 0 .45rem, transparent .65rem);
}

.magic-code-reveal.is-visible::before {
    animation: gameMagicBubbles var(--magic-fade-ms, 900ms) ease forwards;
}

@keyframes gameMagicBubble {
    0% { opacity: 1; transform: translate(0, 0) scale(1); filter: blur(0); }
    55% { opacity: .6; transform: translate(var(--pop-x, 0), var(--pop-y, -1rem)) scale(1.65); filter: blur(.2rem); }
    100% { opacity: 0; transform: translate(calc(var(--pop-x, 0) * 1.3), calc(var(--pop-y, -1rem) * 1.3)) scale(2.25); filter: blur(.7rem); }
}

@keyframes gameMagicMist {
    0% { opacity: 0; transform: translateX(0) scale(.72); filter: blur(.9rem); }
    35% { opacity: 1; transform: translateX(0) scale(1); filter: blur(0); }
    100% { opacity: 0; transform: translateX(2.2rem) scale(1.18); filter: blur(1.3rem); }
}

@keyframes gameMagicPanelIn {
    0% { opacity: 0; transform: translateY(-2rem) scale(.06); filter: blur(1.2rem); }
    55% { opacity: .82; transform: translateY(-.35rem) scale(1.04); filter: blur(.32rem); }
    100% { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

@keyframes gameMagicBubbleReveal {
    0% { opacity: 0; transform: scale(.82); filter: blur(.9rem); clip-path: circle(0% at 50% 50%); }
    70% { opacity: .94; transform: scale(1.02); filter: blur(.12rem); clip-path: circle(72% at 50% 50%); }
    100% { opacity: 1; transform: scale(1); filter: blur(0); clip-path: circle(140% at 50% 50%); }
}

@keyframes gameMagicBubbles {
    0% { opacity: .95; transform: scale(.8) translateY(.9rem); filter: blur(.12rem); }
    70% { opacity: .55; transform: scale(1.08) translateY(-.25rem); filter: blur(.35rem); }
    100% { opacity: 0; transform: scale(1.25) translateY(-1.2rem); filter: blur(.75rem); }
}

.magic-message-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-top: .85rem;
}
.magic-message-action {
    width: auto;
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: rgba(125, 211, 252, .82);
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .02em;
    text-transform: none;
    box-shadow: none;
}
.magic-message-action:hover,
.magic-message-action:focus {
    color: #e0f2fe;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.magic-message-action.is-center {
    color: rgba(226, 232, 240, .86);
}

/* Veřejná úvodní scéna - zjednodušený stabilní režim. */
.magic-entry-shell {
    width: min(100%, 34rem);
    max-width: 34rem;
}

.magic-entry-shell .magic-message-card,
.magic-entry-shell .access-card {
    width: 100%;
}

.magic-char.is-clearing {
    animation: gameMagicLineClear 520ms ease forwards;
}

@keyframes gameMagicLineClear {
    0% { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
    100% { opacity: 0; transform: translateY(-0.35rem) scale(1.03); filter: blur(.45rem); }
}
