File size: 6,130 Bytes
1292ed1
74a6ec1
 
 
b922996
74a6ec1
 
 
 
 
b922996
74a6ec1
 
 
b922996
74a6ec1
 
 
 
 
 
 
b922996
74a6ec1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1292ed1
74a6ec1
 
 
 
 
 
 
 
1292ed1
74a6ec1
 
 
 
 
1292ed1
74a6ec1
 
 
 
 
1292ed1
74a6ec1
1292ed1
74a6ec1
1292ed1
74a6ec1
 
1292ed1
74a6ec1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1292ed1
74a6ec1
 
 
1292ed1
74a6ec1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1292ed1
74a6ec1
1292ed1
74a6ec1
 
 
1292ed1
74a6ec1
 
 
 
 
 
 
 
1292ed1
74a6ec1
 
 
 
 
 
 
 
 
 
1292ed1
74a6ec1
1292ed1
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
import streamlit as st
import time
import random
from streamlit.components.v1 import html

# Custom CSS for professional look
def inject_custom_css():
    st.markdown("""
    <style>
        @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap');
        
        * {
            font-family: 'Poppins', sans-serif;
        }
        
        .title {
            font-size: 3rem !important;
            font-weight: 700 !important;
            color: #6C63FF !important;
            text-align: center;
            margin-bottom: 0.5rem;
        }
        
        .subtitle {
            font-size: 1.2rem !important;
            text-align: center;
            color: #666 !important;
            margin-bottom: 2rem;
        }
        
        .question-box {
            background: #F8F9FA;
            border-radius: 15px;
            padding: 2rem;
            margin: 1.5rem 0;
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        }
        
        .answer-btn {
            border-radius: 12px !important;
            padding: 0.5rem 1.5rem !important;
            font-weight: 600 !important;
            margin: 0.5rem !important;
        }
        
        .yes-btn {
            background: #6C63FF !important;
            color: white !important;
        }
        
        .no-btn {
            background: #FF6B6B !important;
            color: white !important;
        }
        
        .final-reveal {
            animation: fadeIn 2s;
            font-size: 2.5rem;
            color: #6C63FF;
            text-align: center;
            margin: 2rem 0;
        }
        
        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }
        
        .confetti {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: 1000;
        }
    </style>
    """, unsafe_allow_html=True)

# Confetti animation (for final reveal)
def show_confetti():
    html("""
    <canvas id="confetti-canvas" class="confetti"></canvas>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/confetti.browser.min.js"></script>
    <script>
    const canvas = document.getElementById('confetti-canvas');
    const confetti = confetti.create(canvas, { resize: true });
    
    confetti({
        particleCount: 150,
        spread: 70,
        origin: { y: 0.6 }
    });
    
    setTimeout(() => {
        canvas.remove();
    }, 5000);
    </script>
    """)

# Game logic with fake data
def main():
    inject_custom_css()
    
    st.markdown('<div class="title">KASOTI</div>', unsafe_allow_html=True)
    st.markdown('<div class="subtitle">The Ultimate Guessing Game</div>', unsafe_allow_html=True)
    
    if 'game_state' not in st.session_state:
        st.session_state.game_state = "start"
        st.session_state.questions = [
            "Is it something you can hold in your hand?",
            "Is it commonly found in households?",
            "Can it be used as a tool?",
            "Is it primarily made of metal?",
            "Does it have moving parts?",
            "Is it electronic?",
            "Is it something you would gift to someone?",
            "Can it be found in an office?",
            "Does it require electricity to function?",
            "Is it typically under $100?"
        ]
        st.session_state.current_q = 0
        st.session_state.answers = []
        st.session_state.target = "smartphone"  # Fake target for testing
    
    # Start screen
    if st.session_state.game_state == "start":
        st.image("https://via.placeholder.com/600x300?text=Think+of+Something", use_column_width=True)
        
        with st.form("start_form"):
            category = st.radio("What are you thinking of?", 
                              ["A famous person", "An object", "A place"],
                              index=1)
            user_input = st.text_input("Type it here (we won't peek!):").strip().lower()
            
            if st.form_submit_button("Start Game"):
                if not user_input:
                    st.error("Please type something!")
                elif len(user_input) < 3:
                    st.error("Too short! Type properly.")
                else:
                    st.session_state.game_state = "gameplay"
                    st.session_state.user_input = user_input
                    st.rerun()
    
    # Gameplay screen
    elif st.session_state.game_state == "gameplay":
        col1, col2 = st.columns([1, 3])
        with col1:
            st.image("https://via.placeholder.com/200?text=Question", width=150)
        with col2:
            st.markdown(f'<div class="question-box">Question {st.session_state.current_q + 1}/10:<br><br>'
                       f'<strong>{st.session_state.questions[st.session_state.current_q]}</strong></div>', 
                       unsafe_allow_html=True)
        
        answer = st.radio("Your answer:", ["Yes", "No"], horizontal=True, label_visibility="collapsed")
        
        if st.button("Submit Answer", type="primary"):
            st.session_state.answers.append(answer == "Yes")
            st.session_state.current_q += 1
            
            if st.session_state.current_q >= len(st.session_state.questions):
                st.session_state.game_state = "result"
            st.rerun()
    
    # Result screen
    elif st.session_state.game_state == "result":
        show_confetti()
        st.markdown('<div class="final-reveal">🎉 I think it\'s a...</div>', unsafe_allow_html=True)
        time.sleep(1)
        st.markdown(f'<div class="final-reveal" style="font-size:3.5rem;color:#6C63FF;">{st.session_state.target.upper()}</div>', 
                   unsafe_allow_html=True)
        
        st.image("https://via.placeholder.com/400x200?text=Congratulations", use_column_width=True)
        
        if st.button("Play Again", key="play_again"):
            st.session_state.clear()
            st.rerun()

if __name__ == "__main__":
    main()