/* ========================================================
   OUR LITTLE STORY — Premium Pixel-Art Adventure Styling
   ======================================================== */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Quicksand:wght@500;600;700;800&family=Playfair+Display:ital,wght@0,600;0,700;1,600&display=swap');

:root {
    --gold: #f6c86a;
    --gold-glow: rgba(246, 200, 106, 0.6);
    --rose-pink: #f584aa;
    --sunset-orange: #f27244;
    --sunset-dark: #1e1124;
    --parchment: #fff9f0;
    --ink-dark: #2a1b18;
    --panel-bg: rgba(26, 14, 28, 0.88);
    --panel-border: #e3a857;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #0d0612;
    font-family: 'Quicksand', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #fff4e6;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #0d0612;
}

/* Canvas styling with strict pixel-art nearest-neighbor rendering */
#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-rendering: -moz-crisp-edges;
    image-rendering: -webkit-crisp-edges;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* Top UI Bar */
#top-hud {
    position: absolute;
    top: 14px;
    left: 18px;
    right: 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    z-index: 50;
    transition: opacity 0.4s ease;
}

#top-hud.hud-hidden,
#desktop-controls-hint.hud-hidden {
    opacity: 0 !important;
    pointer-events: none !important;
}

.hud-pill {
    pointer-events: auto;
    background: var(--panel-bg);
    border: 2px solid var(--panel-border);
    border-radius: 12px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5), 0 0 10px rgba(227, 168, 87, 0.3);
    backdrop-filter: blur(4px);
}

.hud-pill .flower-icon {
    font-size: 20px;
    animation: gentlePulse 2s infinite ease-in-out;
}

.hud-pill .counter-text {
    font-family: 'Press Start 2P', monospace;
    font-size: 11px;
    color: var(--gold);
    letter-spacing: 1px;
}

.hud-actions {
    pointer-events: auto;
    display: flex;
    gap: 10px;
}

.hud-btn {
    background: var(--panel-bg);
    border: 2px solid var(--panel-border);
    color: var(--gold);
    border-radius: 10px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    transition: transform 0.15s, background 0.2s, border-color 0.2s;
}

.hud-btn:hover {
    transform: scale(1.08);
    border-color: #ffd700;
}

.hud-btn:active {
    transform: scale(0.95);
}

/* Controls Hint (Desktop) */
#desktop-controls-hint {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(18, 10, 24, 0.85);
    border: 1px solid rgba(246, 200, 106, 0.5);
    border-radius: 20px;
    padding: 7px 18px;
    font-size: 12px;
    font-weight: 600;
    color: #eeddbb;
    pointer-events: none;
    z-index: 40;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    transition: opacity 0.4s ease;
}

#desktop-controls-hint kbd {
    background: #36203d;
    border: 1px solid var(--gold);
    border-radius: 4px;
    padding: 2px 6px;
    color: var(--gold);
    font-family: monospace;
    font-size: 11px;
    margin: 0 2px;
}

/* Virtual Joystick for Mobile */
#joystick-zone {
    position: absolute;
    bottom: 24px;
    left: 24px;
    width: 140px;
    height: 140px;
    z-index: 60;
    display: none; /* Shown on touch devices */
    touch-action: none;
}

#joystick-base {
    position: absolute;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(246, 200, 106, 0.15) 0%, rgba(20, 10, 25, 0.75) 80%);
    border: 2px solid rgba(246, 200, 106, 0.6);
    box-shadow: 0 0 15px rgba(246, 200, 106, 0.25), inset 0 0 10px rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

#joystick-knob {
    position: absolute;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: radial-gradient(circle, #fce599 0%, #d89635 100%);
    border: 2px solid #fff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6), 0 0 12px rgba(246, 200, 106, 0.8);
    transform: translate(0, 0);
    pointer-events: none;
}

/* Mobile Contextual Action Button */
#action-btn-zone {
    position: absolute;
    bottom: 28px;
    right: 28px;
    z-index: 60;
    display: none; /* Shown on touch devices */
}

#mobile-action-btn {
    min-width: 90px;
    height: 90px;
    padding: 0 16px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f8749c 0%, #d93d6b 100%);
    border: 3px solid #fff;
    color: #fff;
    font-family: 'Quicksand', sans-serif;
    font-size: 13px;
    font-weight: 800;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    box-shadow: 0 6px 20px rgba(217, 61, 107, 0.6), 0 0 15px rgba(248, 116, 156, 0.5);
    cursor: pointer;
    touch-action: none;
    transition: transform 0.15s, opacity 0.3s;
}

#mobile-action-btn:active {
    transform: scale(0.92);
}

#mobile-action-btn.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

#mobile-action-btn .btn-icon {
    font-size: 24px;
}

/* Interactive Floating World Prompt (Above Entities) */
.world-prompt {
    position: absolute;
    transform: translate(-50%, -100%);
    background: var(--panel-bg);
    border: 2px solid var(--gold);
    border-radius: 12px;
    padding: 6px 14px;
    color: var(--gold);
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    letter-spacing: 0.5px;
    pointer-events: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6), 0 0 12px var(--gold-glow);
    white-space: nowrap;
    animation: floatingBob 1.8s infinite ease-in-out;
    z-index: 45;
}

/* Modals & Overlays */
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 4, 14, 0.75);
    backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
    padding: 16px;
}

.modal-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

/* Memory Card (Shown when collecting flowers) */
.memory-card {
    background: linear-gradient(135deg, rgba(35, 18, 38, 0.95) 0%, rgba(20, 10, 24, 0.98) 100%);
    border: 3px solid var(--panel-border);
    border-radius: 16px;
    padding: 24px 28px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7), 0 0 20px rgba(227, 168, 87, 0.35);
    text-align: center;
    transform: translateY(20px) scale(0.95);
    transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    position: relative;
}

.modal-backdrop.active .memory-card {
    transform: translateY(0) scale(1);
}

.memory-badge {
    display: inline-block;
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    color: var(--gold);
    background: rgba(246, 200, 106, 0.12);
    border: 1px solid var(--gold);
    padding: 5px 12px;
    border-radius: 12px;
    margin-bottom: 14px;
    letter-spacing: 1px;
}

.memory-text {
    font-family: 'Playfair Display', serif;
    font-size: 21px;
    font-weight: 600;
    font-style: italic;
    color: #fff2df;
    line-height: 1.5;
    margin-bottom: 20px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

.memory-dismiss-btn {
    background: linear-gradient(135deg, #e3a857 0%, #c4822e 100%);
    border: 2px solid #fff;
    color: #2a1505;
    font-family: 'Quicksand', sans-serif;
    font-weight: 800;
    font-size: 13px;
    padding: 8px 24px;
    border-radius: 20px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    transition: transform 0.15s, box-shadow 0.2s;
}

.memory-dismiss-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 18px rgba(227, 168, 87, 0.5);
}

.memory-dismiss-btn:active {
    transform: scale(0.96);
}

/* Bouquet Assembly Mini-Game Screen */
.crafting-container {
    background: linear-gradient(135deg, rgba(32, 16, 36, 0.96) 0%, rgba(18, 9, 22, 0.98) 100%);
    border: 3px solid var(--panel-border);
    border-radius: 20px;
    padding: 24px 30px;
    max-width: 650px;
    width: 94%;
    max-height: 90vh;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.8), 0 0 25px rgba(227, 168, 87, 0.3);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow-y: auto;
}

.crafting-title {
    font-family: 'Playfair Display', serif;
    font-size: 24px;
    color: var(--gold);
    margin-bottom: 4px;
}

.crafting-subtitle {
    font-size: 13px;
    color: #e0d0c0;
    margin-bottom: 16px;
    font-weight: 500;
}

.crafting-workspace {
    position: relative;
    width: 260px;
    height: 230px;
    margin: 10px 0 16px;
    display: flex;
    justify-content: center;
    align-items: center;
}

#bouquet-target-zone {
    width: 220px;
    height: 220px;
    border: 2px dashed rgba(246, 200, 106, 0.4);
    border-radius: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    background: rgba(246, 200, 106, 0.04);
    transition: border-color 0.3s, background 0.3s;
}

#bouquet-target-zone.drag-over {
    border-color: var(--gold);
    background: rgba(246, 200, 106, 0.12);
}

#bouquet-preview-canvas {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
}

.flowers-tray {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 10px;
    max-width: 500px;
}

.flower-item {
    width: 60px;
    height: 70px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(246, 200, 106, 0.3);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: grab;
    transition: transform 0.15s, border-color 0.2s, background 0.2s;
    position: relative;
}

.flower-item:hover {
    transform: translateY(-4px) scale(1.05);
    border-color: var(--gold);
    background: rgba(246, 200, 106, 0.12);
}

.flower-item.placed {
    opacity: 0.25;
    pointer-events: none;
    transform: scale(0.9);
}

.flower-item canvas {
    width: 44px;
    height: 52px;
    image-rendering: pixelated;
}

.crafting-completed-msg {
    font-family: 'Playfair Display', serif;
    font-size: 21px;
    font-style: italic;
    color: var(--gold);
    margin: 14px 0 10px;
    text-shadow: 0 0 12px var(--gold-glow);
    display: none;
    animation: fadeInScale 0.6s ease forwards;
}

/* Birthday Wish Cinematic Banner */
#birthday-wish-banner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: linear-gradient(135deg, rgba(30, 12, 34, 0.95) 0%, rgba(18, 8, 20, 0.98) 100%);
    border: 3px solid var(--gold);
    border-radius: 20px;
    padding: 24px 36px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.8), 0 0 30px var(--gold-glow);
    text-align: center;
    z-index: 120;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

#birthday-wish-banner.active {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: auto;
}

#birthday-wish-banner h1 {
    font-family: 'Playfair Display', serif;
    font-size: 28px;
    color: #fff4e6;
    margin-bottom: 12px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}

/* Final Personal Message Parchment Card */
#final-letter-overlay {
    position: absolute;
    inset: 0;
    background: rgba(12, 5, 16, 0.78);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s ease;
    padding: 20px;
}

#final-letter-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.parchment-letter {
    background: #fffbf4;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(246, 200, 106, 0.12) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(245, 132, 170, 0.08) 0%, transparent 40%);
    border: 4px solid #b88636;
    border-radius: 14px;
    padding: 34px 38px;
    max-width: 580px;
    width: 95%;
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85), inset 0 0 30px rgba(227, 168, 87, 0.25);
    color: #2c1a14;
    position: relative;
    transform: translateY(25px);
    transition: transform 0.6s cubic-bezier(0.18, 0.89, 0.32, 1.2);
}

#final-letter-overlay.active .parchment-letter {
    transform: translateY(0);
}

.letter-header {
    font-family: 'Playfair Display', serif;
    font-size: 26px;
    font-weight: 700;
    color: #8c1d38;
    margin-bottom: 18px;
    text-align: center;
    letter-spacing: 0.5px;
}

.letter-body {
    font-family: 'Quicksand', sans-serif;
    font-size: 16px;
    line-height: 1.7;
    font-weight: 600;
    color: #3b251d;
    margin-bottom: 22px;
}

.letter-body p {
    margin-bottom: 16px;
}

.letter-body p:last-child {
    margin-bottom: 0;
}

.letter-footer-love {
    font-family: 'Playfair Display', serif;
    font-size: 19px;
    font-weight: 700;
    font-style: italic;
    color: #8c1d38;
    text-align: center;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px dashed rgba(184, 134, 54, 0.4);
}

/* Orientation Lock Reminder */
#orientation-lock {
    position: fixed;
    inset: 0;
    background: #0d0612;
    z-index: 999;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 30px;
}

#orientation-lock .phone-rotate-icon {
    font-size: 48px;
    margin-bottom: 18px;
    animation: rotatePhone 2s infinite ease-in-out;
}

#orientation-lock p {
    font-size: 16px;
    font-weight: 700;
    color: var(--gold);
    line-height: 1.5;
}

/* Animations */
@keyframes gentlePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

@keyframes floatingBob {
    0%, 100% { transform: translate(-50%, -100%) translateY(0); }
    50% { transform: translate(-50%, -100%) translateY(-6px); }
}

@keyframes fadeInScale {
    0% { opacity: 0; transform: scale(0.9); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes rotatePhone {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(90deg); }
}

/* Mobile & Portrait Media Queries */
@media (max-width: 900px) and (orientation: portrait) {
    #orientation-lock {
        display: flex;
    }
}

@media (max-width: 900px) {
    #desktop-controls-hint {
        display: none !important;
    }
    #joystick-zone {
        display: block;
    }
    #action-btn-zone {
        display: block;
    }
    .parchment-letter {
        padding: 24px 22px;
    }
    .letter-header {
        font-size: 22px;
    }
    .letter-body {
        font-size: 15px;
    }
}
