/* =========================================
   1. GLOBAL RESET & BASICS
   ========================================= */
* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Poppins', sans-serif; -webkit-tap-highlight-color: transparent; user-select: none; }
html, body { height: 100%; width: 100%; overflow: hidden; background: #00F7F7; overscroll-behavior: none; }
button { cursor: pointer; }

/* UTILITY */
.screen-view { width: 100%; height: 100dvh; display: flex; flex-direction: column; align-items: center; overflow-y: auto; }
.hidden { display: none !important; }

/* RESULT SCREEN CENTER */
#view-result {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 50;
    background: #00F7F7; display: flex; justify-content: center; align-items: center; padding: 10px;
}

/* THANK YOU SCREEN */
#view-thankyou {
    justify-content: center; align-items: center; z-index: 60;
    background: transparent; width: 100%; height: 100%; position: fixed; top: 0; left: 0;
    display: flex; flex-direction: column;
}

#flower-container { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 100; }

/* --- RESULT CARD --- */
.result-card { 
    width: 100%; max-width: 550px; 
    max-height: 95vh; overflow-y: auto; 
    display: flex; flex-direction: column; align-items: center; 
    gap: 15px; padding-bottom: 20px;
    scrollbar-width: none; 
}
.result-card::-webkit-scrollbar { display: none; }

.image-container { width: 100%; border-radius: 12px 12px 0 0; overflow: hidden; margin-bottom: -5px; box-shadow: 0 5px 15px rgba(0,0,0,0.2); flex-shrink: 0; }
.image-container img { width: 100%; height: auto; display: block; max-height: 35vh; object-fit: cover; }

.info-box { width: 98%; padding: 15px 15px; text-align: center; box-shadow: 0 4px 8px rgba(0,0,0,0.15); border-radius: 8px; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.hindi-box { background-color: #C0E474; border: 2px solid #a9c963; color: #000; margin-top: 5px; }
.english-box { background-color: #FFCCFF; border: 2px solid #e6b3e6; color: #000; }

.main-word { font-weight: 900; font-size: 2.2rem; margin: 0 0 5px 0; text-transform: uppercase; line-height: 1.1; width: 100%; }

/* BRACKET ISSUE RESOLVED */
.meaning-text { 
    font-weight: 700; font-size: 1.25rem; 
    margin: 0; line-height: 1.4; color: #1a1a1a; 
    width: 100%; 
    white-space: pre-wrap; 
    word-break: normal; 
    overflow-wrap: break-word; 
}

.author-text { font-size: 0.9rem; font-weight: 600; color: #444; margin-top: 5px; font-style: italic; }
.source-section { text-align: center; font-size: 0.85rem; font-weight: 700; color: #333; margin-top: 10px; background: rgba(255,255,255,0.4); padding: 5px 15px; border-radius: 20px; }

/* THANK YOU TEXT */
.text-div { 
    width: 90%; max-width: 500px; 
    height: auto; min-height: 80px;
    padding: 20px; 
    display: flex; align-items: center; justify-content: center; 
    border-radius: 18px; margin: 10px 0; 
    font-weight: 800; font-size: 1.6rem; color: white; 
    text-align: center; box-shadow: 0 5px 15px rgba(0,0,0,0.2); 
    white-space: normal; line-height: 1.3;
}
.text1 { background-color: #00B050; } .text2 { background-color: #FFCCFF; color: #0070C0; } .text3 { background-color: #C00000; }

/* HOME & GAME */
#view-home { justify-content: center; background: url('../../imgs/bg.jpg') no-repeat center center/cover; }
.main-logo { width: 200px; height: 200px; object-fit: cover; border-radius: 50%; margin-bottom: 40px; box-shadow: 0 10px 20px rgba(0,0,0,0.3); border: 4px solid white; }
.btn-play { background: #61CD40; color: white; border: none; padding: 15px 70px; font-size: 1.8rem; border-radius: 50px; font-weight: 800; box-shadow: 0 5px 15px rgba(0,0,0,0.3); transition: transform 0.2s; }
.btn-play:active { transform: scale(0.95); }

.navbar { width: 100%; height: 60px; padding: 0 15px; display: flex; justify-content: space-between; align-items: center; background: rgba(0,0,0,0.1); padding-top: env(safe-area-inset-top); height: calc(60px + env(safe-area-inset-top)); flex-shrink: 0; }
.nav-logo { width: 45px; height: 45px; object-fit: cover; border-radius: 50%; border: 2px solid white; }
.nav-buttons { display: flex; gap: 5px; }
.nav-buttons button { background: #E6BBEA; border: 2px solid white; height: 38px; border-radius: 20px; font-size: 0.85rem; font-weight: 600; color: #333; display: flex; align-items: center; justify-content: center; padding: 0 12px; }

.screen2-content { display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 60vh; transition: all 0.8s; margin-top: 20px; }
.game-flower { height: 50vh; width: auto; transition: all 0.8s ease; }
.screen2-content.flower-moved { min-height: 20vh; margin-top: 5px; }
.screen2-content.flower-moved .game-flower { height: 15vh; }
.btn-start { background: #61CD40; color: white; border: none; padding: 15px 50px; font-size: 1.5rem; border-radius: 50px; font-weight: 800; margin-top: 20px; box-shadow: 0 5px 15px rgba(0,0,0,0.3); }

.game-container { flex-grow: 1; display: flex; flex-direction: column; justify-content: center; width: 100%; max-width: 450px; }
.game-info { display: flex; flex-direction: column; align-items: center; width: 100%; margin-bottom: 15px; }
.timer-display { color: white; font-weight: 800; font-size: 1.5rem; text-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.grid-wrapper { display: flex; flex-direction: column; gap: 10px; align-items: center; margin-bottom: 2vh; width: 100%; }
.word-row { display: flex; gap: 8px; justify-content: center; width: 100%; }
.box { width: 14vw; max-width: 55px; height: 14vw; max-height: 55px; background-color: #FFFFFF; border: 3px solid #E0E0E0; border-radius: 50%; display: flex; justify-content: center; align-items: center; font-size: 1.6rem; font-weight: 800; transition: transform 0.6s ease, background-color 0.4s ease; }
.box:not(:empty) { border-color: #888; background-color: #F9F9F9; }
.box.green { background-color: #00D84A !important; border-color: #00D84A !important; color: white !important; }
.box.yellow { background-color: #FFCE00 !important; border-color: #FFCE00 !important; color: #333 !important; }
.box.grey { background-color: #90A4AE !important; border-color: #90A4AE !important; color: white !important; }

/* ANIMATIONS */
.shake { animation: shakeAnim 0.5s cubic-bezier(.36,.07,.19,.97) both; transform: translate3d(0, 0, 0); backface-visibility: hidden; }
@keyframes shakeAnim { 10%, 90% { transform: translate3d(-1px, 0, 0); } 20%, 80% { transform: translate3d(2px, 0, 0); } 30%, 50%, 70% { transform: translate3d(-4px, 0, 0); } 40%, 60% { transform: translate3d(4px, 0, 0); } }
.pop-anim { animation: pop 0.1s ease-in-out; }
@keyframes pop { 50% { transform: scale(1.1); } }

/* MOBILE KEYBOARD (Default) */
.keyboard { width: 100%; padding: 10px 5px; display: flex; flex-direction: column; gap: 6px; padding-bottom: calc(env(safe-area-inset-bottom) + 10px); }
.kb-row { display: flex; justify-content: center; gap: 4px; }
.kb-btn { flex: 1; height: 50px; background: #E6BBEA; border: none; border-radius: 6px; font-weight: 600; font-size: 1.1rem; max-width: 45px; }
.kb-btn-wide { flex: 1.5; max-width: 70px; background: #D4A5D9; font-size: 0.9rem; }

/* MODALS */
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100dvh; background: rgba(0,0,0,0.6); align-items: center; justify-content: center; }
.modal.active { display: flex !important; }
.modal-content { background: #fefefe; padding: 25px; border-radius: 15px; text-align: center; width: 92%; max-width: 500px; position: relative; max-height: 85dvh; overflow-y: auto; box-shadow: 0 10px 30px rgba(0,0,0,0.3); animation: slideIn 0.3s ease-out; }
@keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-close { position: absolute; right: 15px; top: 10px; font-size: 28px; cursor: pointer; background: #f0f0f0; width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.btn-modal { background: #4472C4; color: white; border: none; padding: 12px 35px; border-radius: 25px; margin-top: 15px; font-size: 1rem; font-weight: 600; }
.btn-replay { position: absolute; top: 10px; left: 15px; background: transparent; border: none; width: 35px; height: 35px; font-size: 1.5rem; font-weight: bold; color: #4472C4; display: flex; justify-content: center; align-items: center; transition: all 0.3s ease; }
.btn-replay:hover { transform: rotate(180deg) scale(1.1); background: #f0f0f0; border-radius: 50%; }

/* FEEDBACK & HOW TO PLAY */
#feedbackModal { z-index: 2000 !important; background-color: rgba(0,0,0,0.8); }
#feedbackModal .modal-content { z-index: 2001 !important; border: 2px solid #4472C4; max-width: 550px; }
.how-to-content { text-align: left; padding: 15px; width: 100%; }
.ht-title { font-size: 1.8rem; font-weight: 800; margin-top: 5px; margin-bottom: 10px; text-transform: uppercase; letter-spacing: 1px; text-align: center; }
.ht-intro { font-size: 0.95rem; color: #333; margin-bottom: 5px; line-height: 1.4; font-weight: 600; text-align: center; }
.ht-list { padding-left: 20px; font-size: 0.95rem; margin-bottom: 15px; color: #444; list-style-type: disc; }
.ht-list li { margin-bottom: 8px; } 
.ht-divider { border-bottom: 1px solid #d3d6da; margin: 15px 0; }
#demo-stage { background: #e0f7fa; border-radius: 12px; padding: 20px 20px 0px; min-height: fit-content; width: fit-content; max-width: 100%; margin: 10px auto; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; overflow: visible; border: 2px dashed #4472C4; }
#demo-intro { display: flex; flex-direction: column; align-items: center; transition: all 0.6s ease; gap: 8px; }
.demo-flower { height: 60px; transition: transform 0.6s ease; }
.btn-start-mini { background: #61CD40; color: white; border: none; padding: 6px 16px; border-radius: 20px; font-weight: bold; font-size: 0.85rem; cursor: default; }
#demo-grid { margin-top: -20px; padding: 0; transition: opacity 0.5s ease; display: flex; flex-direction: column; gap: 5px; opacity: 0; }
.ht-source-text { font-size: 0.85rem; color: #555; margin-top: 15px; font-style: italic; background-color: #f9f9f9; padding: 10px; border-radius: 8px; border-left: 4px solid #4472C4; }
.example-row { display: flex; gap: 6px; margin: 0; justify-content: center; }
.box-help { width: 35px; height: 35px; background: #FFF; border: 2px solid #E0E0E0; color: #333; display: flex; justify-content: center; align-items: center; font-size: 1.1rem; font-weight: bold; text-transform: uppercase; border-radius: 50%; }
.box-help.green { background-color: #00D84A !important; border-color: #00D84A !important; color: #FFF !important; }
.box-help.yellow { background-color: #FFCE00 !important; border-color: #FFCE00 !important; color: #333 !important; }
.box-help.grey { background-color: #90A4AE !important; border-color: #90A4AE !important; color: #FFF !important; }
.ht-text { font-size: 0.9rem; margin: 8px 0 0px 0; line-height: 1.3; text-align: center; min-height: 30px; }

/* Flower Animation */
.flower { position: absolute; background-size: contain; background-repeat: no-repeat; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(360deg); } }
#toast { visibility: hidden; background-color: #333; color: #fff; text-align: center; border-radius: 50px; padding: 12px 20px; position: fixed; z-index: 1100; left: 50%; top: 15%; transform: translateX(-50%); opacity: 0; transition: 0.5s; }
#toast.show { visibility: visible; opacity: 1; }

/* =========================================
   LARGE SCREENS / PC / DESKTOP (UPDATED)
   ========================================= */
@media (min-width: 768px) {
    /* 1. WELCOME LOGO */
    .main-logo { width: 350px; height: 350px; margin-bottom: 50px; border: 6px solid white; }

    /* 2. PLAY BUTTON (Wide) */
    .btn-play { padding: 20px 140px; font-size: 2.5rem; }

    /* 3. GRID BOXES (Smaller) */
    .game-container { max-width: 800px; }
    .box { width: 65px; height: 65px; font-size: 2rem; border-width: 3px; }
    .grid-wrapper { gap: 15px; margin-bottom: 4vh; }
    .word-row { gap: 12px; }

    /* 4. KEYBOARD (Wide & Landscape) */
    .keyboard { 
        max-width: 1000px; /* Wide Container */
        margin: 0 auto; 
        gap: 8px; /* Tighter gap */
        padding-bottom: 40px; 
    }
    .kb-btn { 
        height: 60px; /* Reduced Height = Landscape Feel */
        font-size: 1.5rem; 
        border-radius: 8px; 
        flex: 1; /* Stretch evenly */
        max-width: none; /* Remove constraint */
    }
    /* Enter Key adjustment */
    .kb-btn-wide { flex: 1.5; font-size: 1.3rem; max-width: none; }

    /* 5. RESULT CARD */
    .result-card { max-width: 750px; }
    .main-word { font-size: 3.5rem; }
    .meaning-text { font-size: 1.8rem; }
    .info-box { padding: 30px; }
    .image-container img { max-height: 55vh; }

    /* 6. THANK YOU BOXES */
    .text-div { width: 750px; min-height: 140px; font-size: 2.8rem; border-radius: 25px; margin: 20px 0; padding: 30px; }

    /* Navbar */
    .navbar { height: 90px; padding: 0 50px; }
    .nav-logo { width: 70px; height: 70px; }
    .nav-buttons button { height: 50px; font-size: 1.3rem; padding: 0 30px; }
    
    /* 7. MODALS */
    .modal-content { width: 700px; max-width: 80%; padding: 40px; }
    .ht-title { font-size: 2.5rem; }
    .ht-intro, .ht-list { font-size: 1.4rem; }
}

@media (min-width: 1200px) {
    /* Extra Large Screens */
    .keyboard { max-width: 1200px; }
    .kb-btn { height: 65px; font-size: 1.7rem; }
    .modal-content { width: 800px; }
}

/* =========================================
   MOBILE ADJUSTMENTS (SMALL SCREENS)
   ========================================= */
@media (max-width: 480px) {
  .how-to-content { padding: 10px 10px !important; width: 95% !important; max-height: 98vh !important; overflow-y: hidden; }
  .ht-title { font-size: 1.2rem !important; margin-top: 15px !important; margin-bottom: 5px !important; }
  .ht-intro { font-size: 0.8rem !important; line-height: 1.2 !important; margin-bottom: 8px !important; }
  .ht-list { font-size: 0.75rem !important; margin-bottom: 5px !important; padding-left: 15px !important; }
  .ht-list li { margin-bottom: 2px !important; }
  .ht-list span { padding: 1px 5px !important; font-size: 0.7rem !important; }
  #demo-stage { min-height: 150px !important; width: 100% !important; margin: 5px auto !important; padding: 0 !important; display: flex !important; flex-direction: column !important; justify-content: flex-start !important; align-items: center !important; padding-top: 15px !important; }
  #demo-intro { margin-top: 10px !important; min-height: 110px; }
  .demo-flower { height: 50px !important; margin-bottom: 5px !important; }
  .btn-start-mini { padding: 4px 12px !important; font-size: 0.8rem !important; }
  #demo-grid { margin-top: 0 !important; padding-top: 5px !important; gap: 4px !important; }
  .example-row { gap: 4px !important; margin-bottom: 0 !important; }
  .box-help { width: 28px !important; height: 28px !important; font-size: 0.9rem !important; border-width: 2px !important; }
  .ht-text { font-size: 0.7rem !important; margin-top: auto !important; margin-bottom: 5px !important; }
  .ht-source-text { font-size: 0.65rem !important; padding: 5px !important; margin-top: 5px !important; line-height: 1.2; }
  .btn-modal { margin-top: 5px !important; padding: 8px 30px !important; font-size: 0.9rem !important; }
  .modal-close { top: 5px !important; right: 10px !important; width: 30px; }
  .btn-replay { top: 5px !important; left: 10px !important; width: 30px; }
}/* =========================================
   MOBILE RESULT IMAGE FIX (CLARITY FOCUS)
   ========================================= */
@media (max-width: 480px) {
    /* 1. Card Layout */
    .result-card {
        max-height: 85vh;
        width: 92%; /* Thoda aur genrous width */
    }

    /* 2. Image Container - Flexible Height */
    .image-container {
        width: 100%;
        height: auto; /* Height content ke hisab se */
        /* Mobile screen ka max 40% height hi le, usse zyada nahi */
        max-height: 40vh; 
        background: #f8f8f8; /* Halka grey background agar image choti ho */
        display: flex;
        justify-content: center; /* Center horizontally */
        align-items: center; /* Center vertically */
        padding: 5px 0; /* Thoda sa breathing room */
    }

    /* 3. Image Fitting - NO STRETCHING */
    .image-container img {
        /* Zabardasti 100% nahi karenge agar image choti hai */
        width: auto; 
        height: auto;
        
        /* Container se bahar na jaye */
        max-width: 100%; 
        max-height: 40vh; /* Container ki max height match kare */
        
        /* IMPORTANT: Poori image dikhao, kaato mat */
        object-fit: contain; 
        
        /* Thoda sa shadow taaki uthi hui lage */
        box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        border-radius: 8px; /* Soft corners */
    }

    /* 4. Text Adjustment */
    .main-word { font-size: 1.8rem; margin-top: 10px; }
    .meaning-text { font-size: 1rem; padding: 0 10px; line-height: 1.3; }
}
