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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: black;
    font-family: 'Harry Potter', serif;
    cursor: crosshair;
    touch-action: manipulation;
}

img {
    user-select: none;
    -webkit-user-drag: none;
}

.hidden {
    display: none !important;
}

button {
    cursor: pointer;
    touch-action: manipulation;
}

/* ===================== NAČÍTAVANIE ===================== */

#loading {
    position: fixed;
    inset: 0;
    z-index: 900;
    background: #0b0820;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 28px;
    transition: opacity 0.6s ease;
}

#loading.fade {
    opacity: 0;
    pointer-events: none;
}

#loadingText {
    color: #ffd75e;
    font-size: clamp(26px, 6vw, 44px);
    letter-spacing: 3px;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
}

#loadingWand {
    width: 46px;
    height: 46px;
    border: 4px solid rgba(255, 215, 0, 0.25);
    border-top-color: #ffd75e;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ===================== MENU ===================== */

#menuScreen {
    position: fixed;
    inset: 0;
    background: black;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.5s ease;
}

#menuBg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#menuScreen.messages #menuBg,
#menuScreen.author #menuBg {
    display: none;
}

#menuScreen.messages {
    background: url(fireplace2.gif) center / cover no-repeat, black;
}

#menuScreen.author {
    background: url(obloha.gif) center / cover no-repeat, black;
}

#menuOverlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(0,0,0,0.15) 0%, rgba(0,0,0,0.65) 100%);
    pointer-events: none;
}

#menuContent {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(10px, 2.2vh, 26px);
    width: 100%;
    padding: clamp(10px, 3vh, 40px) 16px;
    max-height: 100dvh;
    overflow-y: auto;
}

#logo img {
    width: clamp(220px, 45vw, 480px);
    max-width: 90vw;
    filter: drop-shadow(0 0 18px rgba(255, 215, 0, 0.45));
    animation: logoGlow 3s ease-in-out infinite alternate;
}

@keyframes logoGlow {
    from { filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.3)); }
    to   { filter: drop-shadow(0 0 26px rgba(255, 215, 0, 0.7)); }
}

#bestScore {
    color: #ffd75e;
    font-family: Georgia, serif;
    font-size: clamp(15px, 4vw, 20px);
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 215, 0, 0.4);
    border-radius: 20px;
    padding: 6px 18px;
    text-shadow: 0 1px 3px black;
}

#buttons {
    display: flex;
    flex-direction: column;
    gap: clamp(10px, 1.8vh, 20px);
    width: min(86vw, 360px);
}

#buttons button {
    font-family: 'Harry Potter', serif;
    font-size: clamp(24px, 5.5vw, 38px);
    padding: clamp(10px, 1.6vh, 16px) 20px;
    color: #ffd75e;
    background: linear-gradient(180deg, rgba(20, 16, 46, 0.92), rgba(8, 6, 22, 0.92));
    border: 2px solid #b8860b;
    border-radius: 12px;
    letter-spacing: 2px;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 215, 0, 0.25);
    transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
}

#buttons button:hover {
    background: linear-gradient(180deg, rgba(60, 45, 10, 0.95), rgba(30, 22, 5, 0.95));
    box-shadow: 0 0 22px rgba(255, 215, 0, 0.55), inset 0 1px 0 rgba(255, 215, 0, 0.4);
    transform: translateY(-2px);
}

#buttons button:active {
    transform: translateY(2px) scale(0.98);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.35);
}

#hint {
    color: rgba(255, 255, 255, 0.85);
    font-family: Georgia, serif;
    font-size: clamp(13px, 3.4vw, 17px);
    text-align: center;
    max-width: min(90vw, 520px);
    text-shadow: 0 1px 4px black;
}

/* ===================== HRA ===================== */

#gameWindow {
    position: fixed;
    inset: 0;
    overflow: hidden;
    background: black;
}

#gameWindow.shake {
    animation: shake 0.35s ease;
}

@keyframes shake {
    0%, 100% { transform: translate(0, 0); }
    20% { transform: translate(-7px, 4px); }
    40% { transform: translate(6px, -5px); }
    60% { transform: translate(-5px, -3px); }
    80% { transform: translate(4px, 5px); }
}

#background {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

#background img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center bottom;
    animation: kenburns 70s ease-in-out infinite alternate;
}

@keyframes kenburns {
    from { transform: scale(1); }
    to   { transform: scale(1.1); }
}

#Voldemort {
    position: absolute;
    left: 2%;
    top: 2%;
    width: clamp(120px, 22vw, 280px);
    opacity: 0;
    filter: blur(4px) contrast(1.5);
    z-index: 5;
    pointer-events: none;
}

#Voldemort img { width: 100%; }

#Voldemort.show {
    animation: voldo 15s linear;
}

@keyframes voldo {
    0%   { opacity: 0; transform: translateX(0) scale(0.5); }
    30%  { opacity: 0.55; }
    100% { opacity: 0; transform: translateX(30vw) scale(1.4); }
}

/* ---------- HUD ---------- */

#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 300;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: max(8px, env(safe-area-inset-top)) 12px 8px;
    background: linear-gradient(180deg, rgba(0,0,0,0.75), rgba(0,0,0,0));
}

.hud-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.hud-item.center {
    flex: 0 0 auto;
    align-items: center;
    min-width: 90px;
}

.hud-item:last-child:not(.center) { align-items: flex-end; }

.hud-label {
    color: #ffd75e;
    font-size: clamp(15px, 4vw, 26px);
    letter-spacing: 1px;
    text-shadow: 0 2px 4px black;
    white-space: nowrap;
}

#scoreBox {
    color: white;
    font-family: Georgia, serif;
    font-weight: bold;
    font-size: clamp(18px, 5vw, 30px);
    text-shadow: 0 0 12px rgba(255, 215, 0, 0.8), 0 2px 4px black;
}

.bar {
    width: 100%;
    max-width: 340px;
    height: clamp(12px, 2.2vh, 18px);
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 215, 0, 0.5);
    border-radius: 10px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    width: 100%;
    border-radius: 10px;
    transition: width 0.4s ease, background-color 0.4s ease;
}

.bar-fill.castle { background: linear-gradient(90deg, #7ed957, #b3f06e); }
.bar-fill.castle.low { background: linear-gradient(90deg, #ff3b3b, #ff7b4f); }
.bar-fill.styx-hp { background: linear-gradient(90deg, #7a1fd1, #b451ff); }
.bar-fill.dem-hp  { background: linear-gradient(90deg, #1f7ad1, #51c4ff); }

/* ---------- Ohne ---------- */

#fireLayer {
    position: absolute;
    inset: 0;
    z-index: 150;
}

.fires {
    position: absolute;
    width: clamp(60px, 15vw, 110px);
    z-index: 150;
    cursor: pointer;
    animation: firePop 0.3s ease;
    filter: drop-shadow(0 0 12px rgba(255, 120, 0, 0.8));
}

@keyframes firePop {
    from { transform: scale(0); }
    to   { transform: scale(1); }
}

/* ---------- Efekty (splash, čísla, patronus) ---------- */

#fxLayer {
    position: absolute;
    inset: 0;
    z-index: 400;
    pointer-events: none;
    overflow: hidden;
}

.float {
    position: absolute;
    font-family: Georgia, serif;
    font-weight: bold;
    font-size: clamp(20px, 5vw, 32px);
    text-shadow: 0 2px 6px black;
    animation: floatUp 1s ease-out forwards;
    white-space: nowrap;
}

.float.gain  { color: #8dff6e; }
.float.dmg   { color: #ff5c4a; }
.float.combo {
    color: #ffd75e;
    font-family: 'Harry Potter', serif;
    font-size: clamp(26px, 7vw, 44px);
    text-shadow: 0 0 16px rgba(255, 215, 0, 0.9), 0 2px 6px black;
}

@keyframes floatUp {
    0%   { opacity: 0; transform: translateY(10px) scale(0.7); }
    15%  { opacity: 1; transform: translateY(0) scale(1.1); }
    100% { opacity: 0; transform: translateY(-70px) scale(1); }
}

.splash {
    position: absolute;
    font-size: clamp(40px, 10vw, 70px);
    animation: splashPop 0.6s ease-out forwards;
}

@keyframes splashPop {
    0%   { opacity: 0; transform: scale(0.3); }
    30%  { opacity: 1; transform: scale(1.3); }
    100% { opacity: 0; transform: scale(1.7) translateY(-20px); }
}

.patronus {
    position: absolute;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,1) 0%, rgba(150,220,255,0.9) 40%, rgba(150,220,255,0) 70%);
    animation: patronusBlast 0.7s ease-out forwards;
}

@keyframes patronusBlast {
    0%   { opacity: 0.2; transform: scale(0.5); }
    40%  { opacity: 1; transform: scale(5); }
    100% { opacity: 0; transform: scale(9); }
}

/* ---------- Styxon ---------- */

#styxon {
    position: absolute;
    left: 0;
    top: 0;
    width: clamp(52px, 13vw, 90px);
    display: none;
    z-index: 200;
    border-radius: 50%;
    box-shadow: 0 0 25px 6px rgba(0, 255, 60, 0.8);
    cursor: pointer;
    transition: transform 3.5s ease;
}

#styxon.rage {
    box-shadow: 0 0 30px 10px rgba(255, 30, 30, 0.9);
    transition: transform 1.8s ease;
    filter: contrast(1.3) saturate(1.4);
}

#styxon.hit {
    animation: hitFlash 0.35s ease;
}

@keyframes hitFlash {
    0%   { filter: brightness(2.5); }
    100% { filter: brightness(1); }
}

/* ---------- Čarodejnice (level 1) ---------- */

#dementor1, #dementor2 {
    position: absolute;
    width: clamp(80px, 20vw, 150px);
    display: none;
    z-index: 250;
    cursor: pointer;
}

#dementor1 {
    top: 28%;
    animation: witchLTR 4.5s linear infinite;
}

#dementor2 {
    top: 10%;
    transform: scaleX(-1);
    animation: witchRTL 3.5s linear infinite;
}

@keyframes witchLTR {
    from { left: -20%; }
    to   { left: 105%; }
}

@keyframes witchRTL {
    from { right: -20%; }
    to   { right: 105%; }
}

#dementor1.down, #dementor2.down {
    animation: witchDown 1.2s ease forwards;
    /* zostrelená striga nesmie požierať klepnutia na Styxona */
    pointer-events: none;
}

@keyframes witchDown {
    to { transform: translateY(80vh) rotate(120deg); opacity: 0; }
}

/* ---------- Dementori (level 2) ---------- */

.dementor {
    position: absolute;
    width: clamp(70px, 17vw, 140px);
    z-index: 250;
    cursor: pointer;
    filter: drop-shadow(0 0 14px rgba(120, 200, 255, 0.55)) brightness(0.9);
    animation: demBob 1.6s ease-in-out infinite alternate;
}

@keyframes demBob {
    from { margin-top: 0; }
    to   { margin-top: 18px; }
}

/* ---------- Oznamy ---------- */

#announce {
    position: absolute;
    top: 38%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 450;
    width: 94vw;
    text-align: center;
    font-size: clamp(30px, 8vw, 72px);
    color: #9edbff;
    letter-spacing: 2px;
    text-shadow: 0 0 24px rgba(120, 200, 255, 0.9), 0 4px 10px black;
    opacity: 0;
    pointer-events: none;
}

#announce.show {
    animation: announce 3s ease forwards;
}

@keyframes announce {
    0%   { opacity: 0; transform: translateX(-50%) scale(0.8); }
    15%  { opacity: 1; transform: translateX(-50%) scale(1.05); }
    80%  { opacity: 1; transform: translateX(-50%) scale(1); }
    100% { opacity: 0; transform: translateX(-50%) scale(1); }
}

/* ---------- Ovládanie v hre ---------- */

#controls {
    position: absolute;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    z-index: 350;
    display: flex;
    gap: 10px;
}

#controls button {
    width: 52px;
    height: 52px;
    font-size: 24px;
    color: white;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
}

#skipIntro {
    position: absolute;
    left: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    z-index: 350;
    font-family: Georgia, serif;
    font-size: clamp(14px, 3.5vw, 18px);
    padding: 10px 16px;
    color: white;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 10px;
}

/* ===================== PAUZA ===================== */

#pauseOverlay {
    position: fixed;
    inset: 0;
    z-index: 550;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5vh;
}

#pauseText {
    font-size: clamp(50px, 12vw, 100px);
    color: #ffd75e;
    letter-spacing: 4px;
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.7);
}

#resumeButton {
    font-family: 'Harry Potter', serif;
    font-size: clamp(24px, 6vw, 40px);
    padding: 14px 34px;
    color: #ffd75e;
    background: linear-gradient(180deg, rgba(20, 16, 46, 0.95), rgba(8, 6, 22, 0.95));
    border: 2px solid #b8860b;
    border-radius: 12px;
    letter-spacing: 2px;
    box-shadow: 0 0 18px rgba(255, 215, 0, 0.4);
}

/* ===================== VIDEO ===================== */

#videoContainer {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
}

#videoFrame {
    width: min(96vw, 1100px);
    aspect-ratio: 16 / 9;
    max-height: 88dvh;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 0 40px rgba(255, 150, 0, 0.35);
    animation: zoomIn 3s forwards;
}

#mainVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* priblíženie odstrihne vodoznak na hornom okraji videa */
    transform: scale(1.22);
}

@keyframes zoomIn {
    from { transform: scale(0.94); }
    to   { transform: scale(1); }
}

#closeVideo {
    position: absolute;
    top: max(12px, env(safe-area-inset-top));
    right: 14px;
    width: 46px;
    height: 46px;
    font-size: 22px;
    color: white;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
}

/* ===================== KONIEC HRY ===================== */

#endOverlay {
    position: fixed;
    inset: 0;
    z-index: 600;
    background: rgba(0, 0, 0, 0.78);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2.6vh;
    padding: 20px;
    animation: fadeIn 1s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

#endText {
    font-family: 'Harry Potter', serif;
    font-size: clamp(40px, 10vw, 100px);
    text-align: center;
    letter-spacing: 3px;
    line-height: 1.2;
}

#endOverlay.win #endText {
    color: #ffd75e;
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.8), 0 4px 10px black;
}

#endOverlay.lose #endText {
    color: #ff4b3b;
    text-shadow: 0 0 30px rgba(255, 60, 40, 0.8), 0 4px 10px black;
}

#stars {
    font-size: clamp(40px, 10vw, 80px);
    letter-spacing: 10px;
    filter: drop-shadow(0 0 14px rgba(255, 215, 0, 0.7));
    animation: starsPop 0.8s ease;
}

@keyframes starsPop {
    from { transform: scale(0); }
    to   { transform: scale(1); }
}

#scoreLine {
    color: white;
    font-family: Georgia, serif;
    font-size: clamp(20px, 5.5vw, 34px);
    text-shadow: 0 2px 6px black;
}

#recordLine {
    color: #ffd75e;
    font-family: Georgia, serif;
    font-size: clamp(16px, 4.5vw, 26px);
    text-shadow: 0 2px 6px black;
}

#recordLine.new {
    animation: recordPulse 1s ease infinite alternate;
}

@keyframes recordPulse {
    from { transform: scale(1); }
    to   { transform: scale(1.12); text-shadow: 0 0 20px rgba(255, 215, 0, 0.9); }
}

#restartButton {
    font-family: 'Harry Potter', serif;
    font-size: clamp(24px, 6vw, 40px);
    padding: 14px 34px;
    color: #ffd75e;
    background: linear-gradient(180deg, rgba(20, 16, 46, 0.95), rgba(8, 6, 22, 0.95));
    border: 2px solid #b8860b;
    border-radius: 12px;
    letter-spacing: 2px;
    box-shadow: 0 0 18px rgba(255, 215, 0, 0.4);
    transition: transform 0.15s ease, box-shadow 0.2s ease;
}

#restartButton:hover {
    box-shadow: 0 0 28px rgba(255, 215, 0, 0.7);
    transform: translateY(-2px);
}

/* ===================== MOBIL ===================== */

@media (max-width: 700px) {
    #hud { gap: 8px; }
    .hud-label { font-size: 14px; }
    .hud-item.center { min-width: 64px; }

    #buttons { width: min(90vw, 320px); }
}
