@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;600;700&family=JetBrains+Mono:wght@400;700&display=swap');

:root {
    --ink: #6b5876;
    --ink-soft: #9a88a6;
    --pink: #f59aa8;
    --mint: #8fd6be;
    --lilac: #c7a6ff;
    --butter: #ffd36e;
    --sky: #8fd3ff;
    --paper: #fffaf3;
    --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
    --round: "Fredoka", "Segoe UI", "Comic Sans MS", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

html {
    background: linear-gradient(180deg, #c9b8f0 0%, #f2c6dc 42%, #ffe6d6 66%, #e9f0ff 100%);
    background-attachment: fixed;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: var(--round);
    color: var(--ink);
    text-align: center;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

a { color: var(--ink); }

/* ---------- scéna ---------- */

#scene {
    position: fixed;
    inset: 0;
    z-index: 0;
}

#scene svg {
    width: 100%;
    height: 100%;
    display: block;
}

.ol {
    stroke: var(--ink);
    stroke-width: 2.4;
    stroke-linejoin: round;
    stroke-linecap: round;
}
.ol.thin { stroke-width: 1.5; }
.mono { font-family: var(--mono); }

.light { animation: twinkle 1.8s ease-in-out infinite; }
.led   { animation: blink 1.2s steps(2, start) infinite; }
.sparkle { animation: sparkle 3s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.tree-star { animation: starGlow 2.6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }

@keyframes twinkle  { 0%,100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes blink    { to { opacity: .25; } }
@keyframes sparkle  { 0%,100% { opacity: 0; transform: scale(.4); } 50% { opacity: .95; transform: scale(1); } }
@keyframes starGlow { 0%,100% { transform: scale(1) rotate(0); } 50% { transform: scale(1.12) rotate(8deg); } }

/* skřítci */
.elf .mover,
.hits .mover {
    transition: transform .28s cubic-bezier(.34, 1.56, .64, 1);
}
.elf .elf-anim { transform-box: fill-box; transform-origin: 50% 100%; }
.elf.out .elf-anim { animation: wiggle .9s ease-in-out infinite; }
.elf-alert { opacity: 0; }
.elf.out .elf-alert { animation: alert .5s ease-out forwards; }

.elf.giggle .elf-anim { animation: giggle .5s ease-in-out; }

.elf.caught .mover { transition: none; }
.elf.caught .elf-anim { animation: caught .8s cubic-bezier(.34, 1.56, .64, 1) forwards; }
.elf.caught .elf-alert { opacity: 0; }

@keyframes wiggle { 0%,100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
@keyframes alert  { 0% { opacity: 0; transform: translateY(4px); } 100% { opacity: 1; transform: none; } }
@keyframes giggle { 0%,100% { transform: none; } 25% { transform: translateY(-6px) rotate(-8deg); } 75% { transform: translateY(-3px) rotate(8deg); } }
@keyframes caught {
    0%   { transform: none; }
    35%  { transform: translateY(-30px) scale(1.25) rotate(-10deg); }
    65%  { transform: translateY(-18px) scale(1.3) rotate(8deg); }
    100% { transform: translateY(-60px) scale(0); opacity: 0; }
}

.hit { pointer-events: none; cursor: pointer; }
.hit.on { pointer-events: all; }

/* ---------- UI vrstva ---------- */

.top {
    position: relative;
    z-index: 2;
    margin-top: max(18px, env(safe-area-inset-top));
    padding: 0 16px;
    pointer-events: none;
}

h1, h2 {
    margin: 0;
    font-weight: 700;
    color: #fff;
    letter-spacing: .5px;
    text-shadow: 0 2px 0 var(--pink), 0 4px 0 var(--ink), 0 8px 16px rgba(107, 88, 118, .25);
}
h1 { font-size: clamp(30px, 8vw, 54px); }
h2 { font-size: clamp(26px, 7vw, 38px); margin-bottom: 14px; }

p {
    margin: 6px 0 16px;
    font-size: clamp(16px, 4.2vw, 21px);
    color: var(--ink);
}

.hint {
    display: inline-block;
    margin-top: 12px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, .78);
    border: 2px solid var(--ink);
    border-radius: 999px;
    box-shadow: 0 3px 0 var(--ink);
    font-weight: 600;
}

.cmt {
    display: block;
    margin-top: 4px;
    font: 12px var(--mono);
    color: var(--ink-soft);
}

.bottom {
    position: fixed;
    z-index: 2;
    left: 0;
    right: 0;
    bottom: max(10px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    pointer-events: none;
}

.bottom a, .pill {
    pointer-events: auto;
    padding: 6px 14px;
    background: rgba(255, 255, 255, .82);
    border: 2px solid var(--ink);
    border-radius: 999px;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
}

.version {
    font: 10.5px var(--mono);
    color: var(--ink-soft);
    background: rgba(255, 255, 255, .55);
    padding: 1px 8px;
    border-radius: 6px;
}

/* toast */
#toast {
    position: fixed;
    z-index: 5;
    left: 50%;
    top: 46%;
    transform: translate(-50%, 10px) scale(.9);
    max-width: 88vw;
    padding: 9px 15px;
    background: var(--ink);
    color: #fff;
    border-radius: 12px;
    font: 600 14px var(--mono);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    pointer-events: none;
    transition: .25s ease;
}
#toast.show { opacity: .95; transform: translate(-50%, 0) scale(1); }

.puff {
    position: fixed;
    z-index: 4;
    transform: translate(-50%, -50%);
    font-size: 26px;
    color: #fff;
    text-shadow: 0 0 2px var(--ink-soft);
    pointer-events: none;
    animation: puff .7s ease-out forwards;
}
@keyframes puff { to { transform: translate(-50%, -110%) scale(1.8); opacity: 0; } }

.burst {
    position: fixed;
    z-index: 4;
    font: 700 18px var(--mono);
    transform: translate(-50%, -50%);
    pointer-events: none;
    animation: burst .9s ease-out forwards;
}
@keyframes burst {
    to { transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(.5) rotate(180deg); opacity: 0; }
}

/* ---------- okno "terminálu" ---------- */

.window {
    background: var(--paper);
    border: 3px solid var(--ink);
    border-radius: 18px;
    box-shadow: 0 6px 0 var(--ink), 0 18px 40px rgba(107, 88, 118, .3);
    overflow: hidden;
    text-align: center;
}

.titlebar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: #f3e6ff;
    border-bottom: 3px solid var(--ink);
    font: 700 12px var(--mono);
    color: var(--ink);
}
.titlebar i {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--ink);
}
.titlebar i:nth-child(1) { background: var(--pink); }
.titlebar i:nth-child(2) { background: var(--butter); }
.titlebar i:nth-child(3) { background: var(--mint); }
.titlebar span { flex: 1; text-align: center; margin-right: 40px; }

.window .content { padding: 20px 22px 22px; }

.term {
    margin: 0 0 14px;
    font: 13px var(--mono);
    color: var(--ink-soft);
    text-align: left;
    min-height: 1.4em;
}
.term::after {
    content: "▋";
    animation: blink .8s steps(2, start) infinite;
}
.term.done::after { content: ""; }

.label { margin: 0; font-size: 17px; }

.name {
    margin: 8px 0 6px;
    font-size: clamp(28px, 8vw, 40px);
    font-weight: 700;
    line-height: 1.15;
    color: #e9798d;
    user-select: text;
    -webkit-user-select: text;
}

.meta {
    font: 11.5px var(--mono);
    color: var(--ink-soft);
    margin: 10px 0 0;
}

/* odhalení jména */
.reveal {
    position: fixed;
    z-index: 6;
    left: 50%;
    top: 50%;
    width: min(88vw, 420px);
    transform: translate(-50%, -50%) scale(.3) rotate(-8deg);
    opacity: 0;
    pointer-events: none;
    transition: transform .6s cubic-bezier(.34, 1.56, .64, 1), opacity .3s;
}
.reveal.show {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1) rotate(0);
}
.reveal .name, .reveal .label, .reveal .meta { opacity: 0; transition: opacity .5s; }
.reveal.named .name, .reveal.named .label, .reveal.named .meta { opacity: 1; }

.dim {
    position: fixed;
    inset: 0;
    z-index: 5;
    background: rgba(107, 88, 118, .25);
    opacity: 0;
    pointer-events: none;
    transition: opacity .4s;
}
.dim.show { opacity: 1; }

/* už vylosováno */
.drawn {
    position: relative;
    z-index: 2;
    width: min(88vw, 400px);
    margin-top: 18px;
    pointer-events: auto;
}

/* ---------- formuláře (login / forgot) ---------- */

.box {
    position: relative;
    z-index: 2;
    width: min(90vw, 340px);
    margin: auto;
    transform: translateY(-8vh);
}

form { margin: 0; }

input {
    display: block;
    width: 100%;
    margin: 0 0 12px;
    padding: 12px 14px;
    font: 15px var(--mono);
    color: var(--ink);
    background: #fff;
    border: 2px solid var(--ink);
    border-radius: 12px;
    outline: none;
    user-select: text;
    -webkit-user-select: text;
}
input::placeholder { color: #b9abc4; }
input:focus { box-shadow: 0 0 0 4px #e8d9ff; }

button {
    width: 100%;
    margin-top: 4px;
    padding: 12px;
    font: 700 17px var(--round);
    color: #fff;
    background: var(--pink);
    border: 2px solid var(--ink);
    border-radius: 12px;
    box-shadow: 0 4px 0 var(--ink);
    cursor: pointer;
    transition: transform .1s, box-shadow .1s;
}
button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }

.msg {
    margin: 0 0 14px;
    padding: 8px 10px;
    font: 13px var(--mono);
    color: #b4485e;
    background: #ffe3e8;
    border: 2px dashed #e9798d;
    border-radius: 10px;
}

.box .links { margin: 16px 0 0; font-size: 15px; }

/* landscape nízké displeje (mobil na šířku) */
@media (max-height: 480px) {
    .top { margin-top: 8px; }
    h1 { font-size: 28px; }
    .hint { margin-top: 6px; padding: 5px 12px; }
    .box { transform: none; margin: 8px auto; }
    .window .content { padding: 12px 16px 14px; }
}

@media (prefers-reduced-motion: reduce) {
    .light, .led, .sparkle, .tree-star, .elf.out .elf-anim { animation: none; }
}
