/* ==========================================================================
   PUKU – hra "Chyť pamlsky" (assets/css/game.css)
   Vzhľad, animácie a responzivita hernej scény. Grafika samotnej hry
   (miska, pamlsky, pozadie) je kreslená v canvase v assets/js/game-catch.js.
   ========================================================================== */

/* ── Sekcia / pozadie ─────────────────────────────────────────────────── */

.game-hero {
    position: relative;
    background:
        radial-gradient(1200px 500px at 50% -180px, rgba(18, 181, 160, 0.16), transparent 70%),
        radial-gradient(700px 380px at 100% 110%, rgba(255, 214, 165, 0.35), transparent 70%),
        linear-gradient(180deg, #fff9f4 0%, #fdf3ea 60%, #fff9f4 100%);
    overflow: hidden;
}

.game-eyebrow {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(18, 181, 160, 0.12);
    color: #0e9c8a;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

/* ── Scéna ────────────────────────────────────────────────────────────── */

.game-stage-wrap {
    max-width: 960px;
    margin-inline: auto;
}

.game-stage {
    position: relative;
    /* scéna sa prispôsobí výške okna, aby sa hra zmestila bez scrollovania */
    height: clamp(300px, calc(100vh - 330px), 620px);
    border-radius: 28px;
    overflow: hidden;
    background: #eafaf7;
    border: 1px solid rgba(18, 181, 160, 0.18);
    box-shadow:
        0 24px 60px -24px rgba(8, 42, 75, 0.35),
        0 2px 0 rgba(255, 255, 255, 0.7) inset;
    touch-action: none;             /* nech sa pri ťahaní nescrolluje stránka */
    -webkit-user-select: none;
    user-select: none;
}

/* Počas hry nechceme, aby do nej skákal chat */
.ai-chatbot-container { display: none !important; }
#mobile-ai-chat-toggle { display: none !important; }   /* chat je vypnutý, tlačidlo by bolo mrtvé */

@media (min-width: 640px) {
    .game-stage { border-radius: 32px; }
}

@media (min-width: 1024px) {
    .game-stage { height: clamp(360px, calc(100vh - 300px), 640px); }
}

/* ── Režim celej obrazovky ────────────────────────────────────────────── */

/* Natívny fullscreen (Android/Chrome, desktop) */
#game-stage:fullscreen,
#game-stage:-webkit-full-screen,
#game-stage:-moz-full-screen {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: #eafaf7;
}

/* Záložný režim pre iPhony a prehliadače bez Fullscreen API */
#game-stage.is-pseudo-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 900;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

/* Kým sme vo fullscreene, skryjeme okolie stránky (menu, pätu, chat, texty) */
body.game-fs-active,
html.game-fs-active { overflow: hidden !important; overscroll-behavior: none; }

body.game-fs-active header,
body.game-fs-active footer,
body.game-fs-active #floating-nav,
body.game-fs-active #sticky-footer-nav,
body.game-fs-active #mobile-search-panel,
body.game-fs-active #mobile-search-overlay,
body.game-fs-active #mobile-menu-panel,
body.game-fs-active #mobile-menu-overlay,
body.game-fs-active .game-intro,
body.game-fs-active .game-below,
body.game-fs-active .ai-chatbot-container,
body.game-fs-active #mobile-ai-chat-toggle {
    display: none !important;
}

/* HUD nič neprekryje (výrez, zahnuté hrany) */
#game-stage:fullscreen .game-hud,
#game-stage.is-pseudo-fullscreen .game-hud {
    inset: calc(12px + env(safe-area-inset-top)) calc(14px + env(safe-area-inset-right)) auto calc(14px + env(safe-area-inset-left));
}

/* V celoobrazovkovom režime nie je spodné menu, tak môže byť karta v strede */
body.game-fs-active .game-overlay {
    align-items: center;
    padding: calc(14px + env(safe-area-inset-top)) 14px calc(14px + env(safe-area-inset-bottom));
}

body.game-fs-active .game-overlay-card { max-height: calc(100% - 28px); }

.game-fs-start-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.game-fs-start-btn svg { width: 17px; height: 17px; }
.game-fs-start-btn.is-hidden { display: none; }

.game-fs-hint {
    position: absolute;
    left: 50%;
    bottom: 14px;
    z-index: 6;
    transform: translateX(-50%);
    padding: 9px 16px;
    border-radius: 999px;
    background: rgba(14, 59, 52, 0.88);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
    pointer-events: none;
}

.game-fs-hint.is-hidden { display: none; }

.game-stage.is-shaking { animation: game-shake 0.32s cubic-bezier(0.36, 0.07, 0.19, 0.97); }

@keyframes game-shake {
    0%, 100% { transform: translate3d(0, 0, 0); }
    20% { transform: translate3d(-6px, 2px, 0); }
    40% { transform: translate3d(5px, -2px, 0); }
    60% { transform: translate3d(-4px, 1px, 0); }
    80% { transform: translate3d(3px, -1px, 0); }
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ── HUD (nad canvasom) ───────────────────────────────────────────────── */

.game-hud {
    position: absolute;
    inset: 12px 12px auto 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: none;
    z-index: 5;
}

.game-hud-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: 0 6px 18px -8px rgba(8, 42, 75, 0.45);
    color: #0e3b34;
    font-weight: 900;
    font-size: 18px;
    line-height: 1;
    transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.game-hud-chip.is-pop { transform: scale(1.16); }

.game-hud-label {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(14, 59, 52, 0.55);
}

/* ── Level chip ───────────────────────────────────────────────────────── */

.game-hud-level strong { color: #0e9c8a; }
.game-hud-level-total { font-size: 12px; opacity: 0.6; margin-left: 1px; }

/* ── Levely v štartovej karte ─────────────────────────────────────────── */

.game-levels-strip {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-bottom: 16px;
}

.game-levels-item {
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(18, 181, 160, 0.1);
    color: #0e7a6c;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.game-levels-item-bad { background: rgba(220, 38, 38, 0.1); color: #b91c1c; }
.game-levels-item-prize { background: linear-gradient(135deg, rgba(255, 212, 81, 0.45), rgba(245, 158, 11, 0.3)); color: #7c4a03; }

/* ── Karta „level hotový“ (medzi levelmi) ─────────────────────────────── */

.game-level-card-next {
    margin-top: 10px;
    padding: 12px 14px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(255, 212, 81, 0.26), rgba(245, 158, 11, 0.18));
    border: 1px dashed rgba(245, 158, 11, 0.5);
    color: #7c4a03;
    font-size: 13px;
    line-height: 1.45;
    text-align: left;
}

.game-level-card-score {
    margin-top: 12px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(14, 59, 52, 0.6);
}

.game-level-card-score strong { color: #0e9c8a; font-size: 18px; }

.game-timer {
    flex: 1;
    height: 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.75);
    overflow: hidden;
    box-shadow: 0 6px 18px -10px rgba(8, 42, 75, 0.45) inset;
}

.game-timer-fill {
    height: 100%;
    width: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #12b5a0, #7ee0cf);
    transform-origin: left center;
    transition: background 0.3s ease;
}

.game-timer-fill.is-low { background: linear-gradient(90deg, #f97316, #fbbf24); }
.game-timer-fill.is-critical { background: linear-gradient(90deg, #dc2626, #f97316); }

.game-hud-actions {
    display: flex;
    gap: 6px;
    pointer-events: auto;
}

.game-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.7);
    color: #0e3b34;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.2s ease;
}

.game-icon-btn:hover { background: #fff; transform: translateY(-1px); }
.game-icon-btn:active { transform: scale(0.94); }
.game-icon-btn svg { width: 18px; height: 18px; }

/* ── Combo badge ──────────────────────────────────────────────────────── */

.game-combo {
    position: absolute;
    right: 14px;
    bottom: 14px;
    z-index: 5;
    padding: 8px 14px;
    border-radius: 999px;
    background: linear-gradient(135deg, #ffd451, #f59e0b);
    color: #4a2c00;
    font-weight: 900;
    font-size: 13px;
    letter-spacing: 0.08em;
    box-shadow: 0 12px 24px -12px rgba(245, 158, 11, 0.9);
    opacity: 0;
    transform: translateY(10px) scale(0.9);
    transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}

.game-combo.is-visible { opacity: 1; transform: translateY(0) scale(1); }
.game-combo.is-bump { transform: translateY(0) scale(1.12); }

/* ── Overlay (štart / pauza / výsledok) ───────────────────────────────── */

.game-overlay {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
    background: rgba(14, 59, 52, 0.22);
    backdrop-filter: blur(7px);
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.game-overlay.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }

/* Prvky, ktoré sa zobrazujú len v určitých situáciách (overlay sa schováva
   plynulo cez opacity/visibility, preto pre ne používame display:none). */
.game-duel-banner.is-hidden,
.game-duel-result.is-hidden,
.game-reward.is-hidden { display: none; }

.game-overlay-card {
    width: 100%;
    max-width: 420px;
    max-height: calc(100% - 12px);
    overflow-y: auto;
    padding: 18px;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 30px 70px -30px rgba(8, 42, 75, 0.7);
    text-align: center;
    animation: game-card-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.game-overlay-card-wide { max-width: 520px; }

@keyframes game-card-in {
    from { opacity: 0; transform: translateY(14px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.game-overlay-title {
    font-size: 22px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: #0e3b34;
}

/* Legenda predmetov */
.game-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 14px;
    margin-bottom: 18px;
}

.game-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    color: #0e3b34;
}

.game-legend-item svg { width: 28px; height: 28px; }
.game-legend-bad { color: #b91c1c; }
.game-legend-deadly { color: #166534; font-weight: 800; }
.game-legend-deadly svg { filter: drop-shadow(0 0 6px rgba(34, 197, 94, 0.55)); }

/* Výsledok po otrave (jed ukončí hru) */
.game-overlay-title.is-deadly { color: #15803d; }

/* Tlačidlá */
.game-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 26px;
    border: 1px solid #0e9c8a;
    border-radius: 16px;
    background: linear-gradient(135deg, #12b5a0, #0e9c8a);
    color: #fff;
    font-weight: 900;
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    cursor: pointer;
    box-shadow: 0 16px 30px -16px rgba(14, 156, 138, 0.95);
    transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.game-cta:hover { transform: translateY(-2px); filter: brightness(1.04); }
.game-cta:active { transform: scale(0.97); }

.game-cta-ghost {
    background: #fff;
    color: #0e3b34;
    border: 1px solid #d9e3e1;
    box-shadow: none;
}

.game-cta-ghost:hover { border-color: #12b5a0; color: #0e9c8a; }
.game-cta-small { padding: 11px 20px; font-size: 12px; }

.game-hint {
    margin-top: 12px;
    font-size: 11px;
    color: rgba(14, 59, 52, 0.6);
}

.game-hint kbd {
    padding: 1px 5px;
    border: 1px solid #d9e3e1;
    border-bottom-width: 2px;
    border-radius: 5px;
    background: #fff;
    font-size: 10px;
    font-weight: 700;
}

/* Výsledok */
.game-result-score {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 8px;
    margin: 2px 0 2px;
    color: #0e3b34;
}

.game-result-score span {
    font-size: 44px;
    font-weight: 900;
    line-height: 1;
    background: linear-gradient(135deg, #12b5a0, #0e9c8a);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: game-score-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes game-score-in {
    from { opacity: 0; transform: scale(0.6); }
    to { opacity: 1; transform: scale(1); }
}

.game-result-score small {
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: rgba(14, 59, 52, 0.55);
}

.game-result-line { margin-top: 2px; font-size: 13px; font-weight: 700; color: #0e3b34; }
.game-result-level {
    margin-top: 4px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: #0e9c8a;
}
.game-result-best { margin-top: 2px; font-size: 11px; color: rgba(14, 59, 52, 0.6); }

.game-duel-banner {
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: 14px;
    background: rgba(18, 181, 160, 0.12);
    color: #0e7a6c;
    font-size: 12px;
    font-weight: 800;
}

.game-duel-result {
    margin-top: 5px;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    font-weight: 900;
}

.game-duel-result.is-win { background: rgba(18, 181, 160, 0.14); color: #0e7a6c; }
.game-duel-result.is-lose { background: rgba(220, 38, 38, 0.1); color: #b91c1c; }
.game-duel-result.is-draw { background: rgba(100, 116, 139, 0.12); color: #475569; }

.game-reward {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(255, 212, 81, 0.28), rgba(245, 158, 11, 0.2));
    border: 1px dashed rgba(245, 158, 11, 0.55);
    color: #7c4a03;
    font-size: 13px;
    display: grid;
    gap: 2px;
}

.game-reward span { font-size: 11px; opacity: 0.8; }

/* Zdieľanie */
.game-share { margin-top: 12px; display: grid; gap: 6px; }

/* Tri akcie v jednom riadku (vyzvi kamaráta / hrať znova / uložiť a ukončiť) */
.game-result-actions {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    justify-content: center;
    gap: 6px;
    margin-top: 12px;
}

/* Tlačidlá sa rovnomerne rozdelia a vždy ostanú v jednom riadku */
.game-result-actions .game-cta {
    flex: 1 1 0;
    min-width: 0;
    flex-direction: column;
    gap: 4px;
    padding: 10px 6px;
    font-size: 11px;
    line-height: 1.15;
    letter-spacing: 0.03em;
    text-align: center;
    white-space: normal;
}

.game-result-actions .game-cta i { font-size: 14px; }

.game-share-hint {
    margin-top: 2px;
    font-size: 11px;
    line-height: 1.4;
    color: rgba(14, 59, 52, 0.55);
}

.game-share-label {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(14, 59, 52, 0.5);
}

.game-share-input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid #d9e3e1;
    border-radius: 14px;
    background: #fff;
    text-align: center;
    font-weight: 700;
    color: #0e3b34;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.game-share-input:focus { border-color: #12b5a0; box-shadow: 0 0 0 3px rgba(18, 181, 160, 0.15); }

.game-share-buttons {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.game-share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    border: 1px solid #d9e3e1;
    background: #fff;
    color: #0e3b34;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease;
}

.game-share-btn:hover { transform: translateY(-2px); border-color: #12b5a0; }
.game-share-btn svg { width: 20px; height: 20px; }
.game-share-wa { color: #25d366; }
.game-share-fb { color: #1877f2; }

.game-meta {
    margin-top: 10px;
    font-size: 11px;
    color: rgba(14, 59, 52, 0.55);
}

/* Toast */
.game-toast {
    position: absolute;
    left: 50%;
    bottom: 18px;
    z-index: 7;
    transform: translateX(-50%) translateY(10px);
    padding: 10px 18px;
    border-radius: 999px;
    background: rgba(14, 59, 52, 0.92);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.25s ease;
    pointer-events: none;
}

.game-toast.is-hidden { opacity: 0; }
.game-toast:not(.is-hidden) { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Sekcia pod hrou ──────────────────────────────────────────────────── */

.game-below {
    max-width: 960px;
    margin: 22px auto 0;
    display: grid;
    gap: 14px;
}

@media (min-width: 768px) {
    .game-below { grid-template-columns: 1fr 1fr; gap: 18px; }
}

.game-info-card {
    padding: 20px;
    border-radius: 22px;
    background: #fff;
    border: 1px solid #eee6de;
    box-shadow: 0 18px 40px -30px rgba(8, 42, 75, 0.5);
}

.game-info-card h2 {
    font-size: 16px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #0e3b34;
    margin-bottom: 10px;
}

.game-info-card ul { display: grid; gap: 8px; font-size: 13px; color: #475569; }
.game-info-card p { font-size: 13px; color: #475569; margin-bottom: 14px; }
.game-info-card .game-cta { margin-top: 16px; }
.game-info-accent { background: linear-gradient(150deg, #fff, #eafaf7); border-color: rgba(18, 181, 160, 0.25); }

/* ── Menšie obrazovky ─────────────────────────────────────────────────── */

@media (max-width: 899px) {
    /* Karta hore pod HUD, aby ju neprekrylo plávajúce menu dole */
    .game-overlay { align-items: flex-start; padding: 54px 12px 12px; }

    .game-legend {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px 10px;
        text-align: left;
        margin-bottom: 14px;
    }
}

@media (max-width: 480px) {
    .game-hud { inset: 8px 8px auto 8px; gap: 6px; }
    .game-hud-chip { padding: 5px 10px; font-size: 15px; }
    .game-hud-label { display: none; }
    .game-icon-btn { width: 38px; height: 38px; border-radius: 12px; }
    .game-icon-btn svg { width: 19px; height: 19px; }
    .game-timer { height: 6px; }
    .game-overlay-card { padding: 16px; border-radius: 20px; }
    .game-legend { gap: 6px 10px; }
    .game-legend-item { font-size: 11px; }
    .game-legend-item svg { width: 24px; height: 24px; }
    .game-result-score span { font-size: 42px; }
    .game-cta { padding: 12px 24px; font-size: 14px; }
}

/* ── Prístupnosť ──────────────────────────────────────────────────────── */

/* Dotykové zariadenia: väčšie terče (hra sa hrá prstom) */
@media (pointer: coarse) {
    .game-icon-btn { width: 42px; height: 42px; border-radius: 14px; }
    .game-icon-btn svg { width: 21px; height: 21px; }
    .game-fs-hint { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
    .game-stage.is-shaking { animation: none; }
    .game-overlay-card,
    .game-result-score span { animation: none; }
    .game-cta, .game-icon-btn, .game-share-btn { transition: none; }
}

.game-icon-btn:focus-visible,
.game-cta:focus-visible,
.game-share-btn:focus-visible,
.game-share-input:focus-visible {
    outline: 3px solid rgba(18, 181, 160, 0.45);
    outline-offset: 2px;
}
