/* Base */
/* Load Minecraft-styled fonts provided in project root */
@font-face {
    font-family: 'MinecraftSeven_2';
    src: url('Minecraft Seven_2 (3).ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'MinecraftSeven_2';
    src: url('Minecraft Seven_2 (4).ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    font-family: 'Courier New', Courier, monospace;
    user-select: none;
}

/* Use MinecraftSeven_2 for in-game/dialogue UI elements */
#dialogue-box,
#character-name,
#dialogue-text,
.choice-btn,
#qte-prompt {
    font-family: 'MinecraftSeven_2', 'Courier New', monospace;
}

/* Intro / Title Screen */
#intro-screen {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 30;
    overflow: hidden;
}

/* animated layered background sitting under intro overlay and above video (keeps video visible) */
.intro-bg {
    position: absolute;
    inset: 0;
    z-index: 1; /* below overlay (overlay uses z-index:2) */
    pointer-events: none;
    overflow: hidden;
}

/* sky layer (top portion) — subtle vertical drift */
.intro-bg .sky {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 60%;
    background: #87CEEB;
    z-index: 1;
    transform-origin: center;
    animation: move-sky 18s linear infinite;
}

/* ground layer uses the provided grass texture and scrolls horizontally */
.intro-bg .ground {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 200%; /* double width so it can scroll smoothly */
    height: 40%;
    background-image: url('IMG_7384.webp');
    background-size: cover;
    background-repeat: repeat-x;
    background-position: center bottom;
    z-index: 1;
    transform: translateZ(0);
    animation: scroll-grass 28s linear infinite;
}

/* keep the video darker but above background layers */
#intro-video { z-index: 0; }

/* small vertical drift for sky */
@keyframes move-sky {
    0% { transform: translateY(0px) scaleY(1); }
    50% { transform: translateY(-6px) scaleY(1.01); }
    100% { transform: translateY(0px) scaleY(1); }
}

/* horizontal scroll for the grass texture */
@keyframes scroll-grass {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); } /* shifts left so 200% width gives seamless loop */
}

#intro-video {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: cover;
    top: 0;
    left: 0;
    z-index: 1;
    filter: brightness(0.45) contrast(1.05);
}

#intro-overlay {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px; /* tighter spacing to keep content compact */
    padding: 16px;
    box-sizing: border-box;
    max-width: 100%;
}

#intro-title {
    color: #fff;
    text-align: center;
    font-size: 2.2rem;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.7);
    pointer-events: none;
}

#intro-sub { font-size: 1rem; opacity: 0.9; }

/* season 3 logo + decorative sun sizing for intro */
#intro-sun {
    display: block;
    width: min(180px, 28vw);
    height: auto;
    pointer-events: none;
    margin: 0 auto 8px;
    filter: drop-shadow(0 6px 12px rgba(0,0,0,0.55));
    transform-origin: center;
    /* gentle float + continuous spin for the sun (slower spin) */
    animation: float-sun 2200ms ease-in-out infinite, spin 18s linear infinite;
    opacity: 0.98;
}

/* season 3 logo sizing for intro */
#season3-logo {
    max-width: 60vw; /* constrain logo width to viewport for better mobile fit */
    width: auto;
    height: auto;
    pointer-events: none;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.6));
    max-height: 24vh; /* slightly reduced to accommodate the sun above */
    object-fit: contain;
    transform-origin: center;
    /* subtle pulsing scale animation to make the title breathe */
    animation: pulse 1600ms ease-in-out infinite;
}

/* subtle continuous spin for the decorative sun */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* float animation for the decorative sun (kept to preserve vertical movement) */
@keyframes float-sun {
    0% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-6px) scale(1.03); }
    100% { transform: translateY(0) scale(1); }
}

#intro-buttons {
    pointer-events: auto;
    display: flex;
    gap: 14px;
    flex-direction: column;
    align-items: center;
}

/* Intro button images (Continue / Start New Game) */
.intro-btn {
    /* These are img elements; visually scaled modestly for better fit on mobile */
    display: block;
    width: auto;
    height: auto;
    max-width: 86vw;       /* slightly tighter cap so images fit comfortably */
    max-height: 14vh;      /* reduced height for a more compact look */
    /* outline removed — use subtle background instead of a border */
    border: none;
    outline: none;
    border-radius: 6px;
    box-sizing: border-box;
    padding: 8px 14px;     /* smaller padding for reduced visual scale */
    background: rgba(255,255,255,0.04);
    cursor: pointer;
    object-fit: contain;

    /* modest scale for a natural size */
    transform: scale(1.15);
    transform-origin: center;
    /* remove aggressive enforced minimums so layout can be responsive */
    min-width: auto;
    min-height: auto;
    transition: transform 120ms ease, box-shadow 120ms ease;
}

/* Remove focus outline for accessibility keyboard focus but keep a subtle inner focus hint */
.intro-btn:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(255,255,255,0.06) inset;
}

/* Shake animation on hover (and pointerdown for tactile feedback) */
@keyframes shake {
    0% { transform: translateX(0) rotate(0deg); }
    15% { transform: translateX(-6px) rotate(-2deg); }
    30% { transform: translateX(6px) rotate(2deg); }
    45% { transform: translateX(-4px) rotate(-1.5deg); }
    60% { transform: translateX(4px) rotate(1.5deg); }
    75% { transform: translateX(-2px) rotate(-0.8deg); }
    100% { transform: translateX(0) rotate(0deg); }
}

/* Pulse animation used for the Season 3 logo: gently scales up and down */
@keyframes pulse {
    0% { transform: scale(1) translateZ(0); }
    50% { transform: scale(1.06) translateZ(0); }
    100% { transform: scale(1) translateZ(0); }
}

/* Apply a short shake on hover for pointer devices and on focus for keyboard users */
@media (hover: hover) and (pointer: fine) {
    .intro-btn:hover {
        animation: shake 420ms ease;
    }
}

/* Also provide quick feedback for touch/pointerdown */
.intro-btn:active {
    transform: scale(0.98);
    animation: shake 360ms ease;
}

/* Make sure buttons don't get too small on large screens and maintain touch-friendly hit area */
#intro-buttons .intro-btn {
    min-width: 140px;
    min-height: 42px;
}

/* Slight active feedback */
.intro-btn:active { transform: scale(0.985); }

.intro-btn:active { transform: scale(0.98); }

/* Visual disabled state for intro buttons (used for Continue when no save) */
.intro-btn.disabled {
    opacity: 0.45;
    filter: grayscale(60%);
    pointer-events: none;
    cursor: default;
}

#intro-logos {
    position: absolute;
    left: 14px;
    bottom: 10px;
    display: flex;
    gap: 10px;
    pointer-events: none;
    align-items: flex-end;
    z-index: 5;
}

#intro-logos img {
    height: 64px; /* increased size so Mojang logo is more prominent */
    width: auto;
    opacity: 0.95;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.7));
}

/* Game container hidden when intro is visible */
#game-container.hidden { display: none; }

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#bg-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* UI overlay */
#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding-bottom: 40px;
    z-index: 10;
}

/* Objective display (top-left, visible during gameplay) */
#objective {
    position: absolute;
    top: 14px;
    left: 14px;
    pointer-events: none;
    background: rgba(0,0,0,0.65);
    color: #fff;
    border: 3px solid rgba(255,255,255,0.06);
    padding: 8px 12px;
    font-family: 'MinecraftSeven', monospace;
    font-size: 1rem;
    letter-spacing: 0.6px;
    border-radius: 6px;
    z-index: 22;
    display: inline-block;
    text-transform: uppercase;
    box-shadow: 0 6px 14px rgba(0,0,0,0.5);
    min-width: 140px;
    text-align: left;
}

.hidden {
    display: none !important;
}

#dialogue-box {
    width: 90%;
    background: rgba(0, 0, 0, 0.8);
    border: 4px solid #fff;
    padding: 14px 18px;
    color: white;
    pointer-events: auto;
    position: relative;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    box-sizing: border-box;
}

/* Dialogue portrait icon */
#dialogue-icon {
    width: 72px;
    height: 72px;
    object-fit: cover;
    image-rendering: pixelated;
    border: 3px solid rgba(255,255,255,0.06);
    background: rgba(0,0,0,0.15);
    border-radius: 6px;
    flex: 0 0 72px;
    display: none; /* shown/hidden by JS */
}

/* keep text column responsive */
#dialogue-box > #character-name,
#dialogue-box > #dialogue-text {
    flex: 1 1 auto;
}

#character-name {
    font-weight: bold;
    color: #ffff00;
    margin-bottom: 10px;
    font-size: 1.2rem;
}

#dialogue-text {
    font-size: 1rem;
    line-height: 1.4;
}

#dialogue-next {
    position: absolute;
    bottom: 5px;
    right: 10px;
    font-size: 0.8rem;
    color: #888;
}

#choices-container {
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.choice-btn {
    background: #4a4a4a;
    color: white;
    border: 4px solid #fff;
    padding: 15px 30px;
    font-size: 1.2rem;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s;
}

.choice-btn:active {
    background: #7a7a7a;
}

#qte-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: white;
    text-shadow: 2px 2px #000;
}

#qte-prompt {
    font-size: 2.5rem;
    font-weight: bold;
    margin-bottom: 20px;
    white-space: pre-wrap;
    line-height: 1.2;
}

#qte-timer-bar {
    width: 200px;
    height: 10px;
    background: #333;
    border: 2px solid white;
}

#qte-timer-fill {
    width: 100%;
    height: 100%;
    background: #f00;
}

#joystick-zone {
    position: absolute;
    bottom: 40px;
    left: 40px;
    width: 120px;
    height: 120px;
    z-index: 20;
}

#sprint-btn {
    position: absolute;
    bottom: 60px;
    right: 40px;
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.2);
    border: 4px solid white;
    border-radius: 50%;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 0.8rem;
    pointer-events: auto;
    z-index: 20;
    user-select: none;
    cursor: pointer;
}

#jump-btn {
    position: absolute;
    bottom: 160px;
    right: 40px;
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.18);
    border: 4px solid #fff;
    border-radius: 50%;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 0.8rem;
    pointer-events: auto;
    z-index: 20;
    user-select: none;
    cursor: pointer;
}

#jump-btn:active {
    background: rgba(255,255,255,0.45);
    transform: scale(0.95);
}

/* Mobile-friendly POV toggle button (touch target, visible on small viewports) */
#change-pov {
    position: absolute;
    bottom: 260px; /* stacked above sprint/jump on mobile */
    right: 40px;
    width: 92px;
    height: 44px;
    background: rgba(255,255,255,0.12);
    border: 3px solid #fff;
    border-radius: 10px;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 0.8rem;
    pointer-events: auto;
    z-index: 21;
    user-select: none;
    cursor: pointer;
    box-shadow: 0 6px 14px rgba(0,0,0,0.45);
}

/* active/tap feedback */
#change-pov:active {
    background: rgba(255,255,255,0.28);
    transform: translateY(1px);
}

/* Keep the desktop label concise and place differently on larger screens */
@media (min-width: 880px) {
    #change-pov {
        right: 40px;
        bottom: 24px;
        width: auto;
        height: auto;
        padding: 8px 12px;
        border-radius: 6px;
        background: rgba(255,255,255,0.06);
        font-size: 0.75rem;
        z-index: 20;
    }
}

#sprint-btn:active {
    background: rgba(255, 255, 255, 0.5);
    transform: scale(0.95);
}

#game-over {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(139, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
}

#game-over-title {
    font-size: 3rem;
    color: white;
    margin-bottom: 30px;
}

#retry-btn {
    background: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.5rem;
    cursor: pointer;
}