Spaces:
Sleeping

byte-vortex commited on
Commit
7232542
·
verified ·
1 Parent(s): 9f33618

Deploy Myco from CI

Browse files
Files changed (1) hide show
  1. ui/scene_renderers.py +153 -222
ui/scene_renderers.py CHANGED
@@ -1,286 +1,217 @@
1
- """Markdown renderers for the Myco Gradio interface — animated game scene."""
2
 
3
  from html import escape
4
- import random
5
  from models.mushroom import Mushroom
6
 
7
  POISONOUS_MUSHROOM_NAMES = {
8
  "Ghost Gill", "Pepper Pixie", "Ruby Knuckle", "Clockwork Chanterelle",
9
  }
10
 
11
- # Different mushroom visuals by rarity + poison
12
  MUSHROOM_SPRITES = {
13
- "poison": ["🔴", "💀", "🟥"],
14
- "legendary": ["⭐", "🌟", "✨"],
15
- "rare": ["💜", "🔵", "💎"],
16
- "common": ["🍄", "🍄‍🟫", "🟫"],
 
 
17
  }
18
 
19
  SCENE_STYLES = """
20
  <style>
21
- /* ── Base scene ── */
22
  .forest-scene {
23
- position:relative; isolation:isolate; overflow:hidden;
24
- min-height:22rem; padding:.75rem; border-radius:28px;
25
- background:
26
- radial-gradient(circle at 50% 72%,rgba(255,239,173,.26),transparent 8rem),
27
- radial-gradient(circle at 18% 24%,rgba(134,225,153,.22),transparent 10rem),
28
- linear-gradient(180deg,#123626 0%,#245c3c 54%,#523b20 100%);
29
- border:1px solid rgba(225,255,209,.25);
30
- box-shadow:0 18px 48px rgba(8,30,20,.26);
31
- color:#f9ffe9;
32
- /* Anti-flicker optimization */
33
  contain: layout style;
 
34
  }
35
 
36
- /* ── HUD ── */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  .scene-hud {
38
- position:relative; z-index:3;
39
- display:flex; flex-wrap:wrap; gap:.4rem;
40
- padding:.5rem .75rem; border-radius:999px;
41
- background:rgba(13,38,28,.72); backdrop-filter:blur(6px);
42
- font-size:.78rem; font-weight:800;
43
  }
44
-
45
- /* ── Stage ── */
46
  .scene-stage {
47
- position:relative; height:14rem; margin:.6rem 0;
48
- background:
49
- linear-gradient(transparent 58%,rgba(44,28,8,.7) 59%,rgba(30,60,30,.4) 60%),
50
- radial-gradient(ellipse at bottom,rgba(190,255,180,.18),transparent 60%);
51
- border-radius:22px; overflow:hidden;
52
  }
53
- .scene-stage > * { position:absolute; line-height:1; }
54
-
55
- /* ── Ground strip ── */
56
  .ground-strip {
57
- bottom:0; left:0; right:0; height:38%;
58
- background:linear-gradient(180deg,rgba(80,50,15,.0) 0%,rgba(40,25,5,.65) 100%);
59
- border-radius:0 0 22px 22px;
60
  }
61
 
62
- /* ── Trees / grass ── */
63
- .tree-left { left:4%; bottom:30%; font-size:5rem; filter:drop-shadow(0 8px 14px rgba(0,0,0,.35)); z-index:1; }
64
- .tree-right { right:5%; bottom:32%; font-size:4.6rem; filter:drop-shadow(0 8px 14px rgba(0,0,0,.35)); z-index:1; }
65
- .grass-a { left:20%; bottom:28%; font-size:2.2rem; z-index:2; }
66
- .grass-b { right:22%; bottom:29%; font-size:2rem; z-index:2; }
67
- .grass-c { left:48%; bottom:27%; font-size:1.8rem; z-index:2; }
68
-
69
- /* ── Sparkles ── */
70
- .sparkle-one { left:32%; top:14%; font-size:1.6rem; animation:twinkle 1.8s ease-in-out infinite; z-index:1; }
71
- .sparkle-two { right:31%; top:20%; font-size:1.4rem; animation:twinkle 2.3s ease-in-out infinite reverse; z-index:1; }
72
- @keyframes twinkle {
73
- 0%,100%{opacity:.25;transform:scale(.8);}
74
- 50%{opacity:1;transform:scale(1.2);}
75
- }
76
-
77
- /* ── Myco player ── */
78
  .myco-player {
79
- font-size:4.2rem; z-index:5; bottom:28%;
80
- transition:left .38s cubic-bezier(.34,1.56,.64,1), bottom .38s cubic-bezier(.34,1.56,.64,1);
81
- filter:drop-shadow(0 6px 14px rgba(255,92,92,.3));
82
- }
83
-
84
- /* Grid positions */
85
- .pos-0-0 .myco-player{left:12%;bottom:60%;}
86
- .pos-1-0 .myco-player{left:40%;bottom:60%;}
87
- .pos-2-0 .myco-player{left:66%;bottom:60%;}
88
- .pos-0-1 .myco-player{left:12%;bottom:40%;}
89
- .pos-1-1 .myco-player{left:40%;bottom:40%;}
90
- .pos-2-1 .myco-player{left:66%;bottom:40%;}
91
- .pos-0-2 .myco-player{left:12%;bottom:26%;}
92
- .pos-1-2 .myco-player{left:40%;bottom:26%;}
93
- .pos-2-2 .myco-player{left:66%;bottom:26%;}
94
-
95
- /* Idle bob */
96
- .myco-player { animation:myco-bob 2.4s ease-in-out infinite; }
97
- @keyframes myco-bob {
98
- 0%,100%{transform:translateY(0) scaleX(1);}
99
- 50%{transform:translateY(-.4rem) scaleX(1);}
100
  }
101
 
102
- /* ── THE MUSHROOM ── */
103
- .mushroom-spot {
104
- z-index:4;
105
- display:flex; flex-direction:column; align-items:center;
106
- gap:0;
107
- }
108
- /* Stem */
109
- .shroom-stem {
110
- width:.7rem; border-radius:2px;
111
- background:linear-gradient(180deg,#d4a96a,#8b5e2a);
112
- transform-origin:bottom center;
113
- }
114
- /* Cap */
115
- .shroom-cap {
116
- font-size:2.8rem; line-height:1;
117
- filter:drop-shadow(0 4px 10px rgba(0,0,0,.4));
118
- transform-origin:bottom center;
119
- }
120
- /* ── Mushroom positions (right side of clearing, away from Myco) ── */
121
- .shroom-pos-0 { right:38%; bottom:28%; }
122
- .shroom-pos-1 { right:28%; bottom:30%; }
123
- .shroom-pos-2 { right:48%; bottom:26%; }
124
- .shroom-pos-3 { right:33%; bottom:32%; }
125
-
126
- /* ── STATE: waiting — no mushroom ── */
127
- .state-waiting .mushroom-spot { display:none; }
128
- .state-waiting .myco-player { animation:myco-bob 2.4s ease-in-out infinite; }
129
-
130
- /* ── STATE: discovered — mushroom erupts from ground ── */
131
- .state-discovered .shroom-cap { animation: cap-popup .65s cubic-bezier(.34,1.56,.64,1) both; }
132
- .state-discovered .shroom-stem { animation: stem-grow .5s ease-out both; }
133
- .state-discovered .myco-player { animation: myco-bob 2.4s ease-in-out infinite, myco-spot .5s ease both; }
134
- @keyframes cap-popup {
135
- 0% {opacity:0; transform:scale(.1) translateY(2rem);}
136
- 60% {opacity:1; transform:scale(1.25) translateY(-.3rem);}
137
- 100%{opacity:1; transform:scale(1) translateY(0);}
138
- }
139
- @keyframes stem-grow {
140
- 0% {height:0; opacity:0;}
141
- 100%{height:1.2rem; opacity:1;}
142
- }
143
- @keyframes myco-spot {
144
- 0% {transform:scaleX(1) translateY(0);}
145
- 30% {transform:scaleX(-1) translateY(-.2rem);}
146
- 60% {transform:scaleX(1) translateY(-.1rem);}
147
- 100%{transform:scaleX(1) translateY(0);}
148
- }
149
 
150
- /* ── STATE: picking — Myco runs, mushroom waits ── */
151
- .state-picking .myco-player { animation: myco-run-pick .55s cubic-bezier(.34,1.56,.64,1) both !important; }
152
- .state-picking .shroom-cap { animation: shroom-tremble .55s ease both; }
153
- @keyframes myco-run-pick {
154
- 0% {transform:scaleX(1) translateX(0);}
155
- 40% {transform:scaleX(-1) translateX(3.5rem);}
156
- 100%{transform:scaleX(-1) translateX(5rem);}
157
- }
158
- @keyframes shroom-tremble {
159
- 0%,100%{transform:rotate(0);}
160
- 25%{transform:rotate(-8deg);}
161
- 75%{transform:rotate(8deg);}
162
- }
163
 
164
- /* ── STATE: picked — mushroom flies up, Myco celebrates ── */
165
- .state-picked .shroom-cap { animation: shroom-fly .6s cubic-bezier(.34,1.56,.64,1) both; }
166
- .state-picked .shroom-stem { animation: stem-shrink .4s ease both; }
167
- .state-picked .myco-player { animation: myco-celebrate .6s ease both !important; }
168
- @keyframes shroom-fly {
169
- 0% {opacity:1; transform:scale(1) translateY(0) rotate(0);}
170
- 40% {opacity:1; transform:scale(1.4) translateY(-3rem) rotate(20deg);}
171
- 100%{opacity:0; transform:scale(.1) translateY(-7rem) rotate(60deg);}
172
- }
173
- @keyframes stem-shrink {
174
- 0% {height:1.2rem; opacity:1;}
175
- 100%{height:0; opacity:0;}
176
- }
177
- @keyframes myco-celebrate {
178
- 0% {transform:translateY(0) scale(1);}
179
- 30% {transform:translateY(-1.8rem) scale(1.15);}
180
- 60% {transform:translateY(-.4rem) scale(1.05);}
181
- 100%{transform:translateY(0) scale(1);}
182
- }
183
 
184
- /* ── STATE: danger (poison discovered) ── */
185
- .state-danger .shroom-cap {
186
- animation: cap-popup .65s cubic-bezier(.34,1.56,.64,1) both, poison-pulse 1s ease-in-out infinite .65s;
187
- filter:drop-shadow(0 0 18px rgba(255,50,80,1)) !important;
188
- }
189
- .state-danger .shroom-stem {
190
- animation:stem-grow .5s ease-out both;
191
- background:linear-gradient(180deg,#ff6b6b,#8b0000) !important;
192
- }
193
- .state-danger .myco-player { animation: myco-recoil .5s ease both !important; }
194
- @keyframes poison-pulse {
195
- 0%,100%{filter:drop-shadow(0 0 12px rgba(255,50,80,.7));}
196
- 50% {filter:drop-shadow(0 0 32px rgba(255,50,80,1));}
197
- }
198
- @keyframes myco-recoil {
199
- 0% {transform:translateX(0) scaleX(1);}
200
- 30% {transform:translateX(-1.5rem) scaleX(-1);}
201
- 60% {transform:translateX(-.5rem) scaleX(-1);}
202
- 100%{transform:translateX(0) scaleX(1);}
203
- }
204
 
205
- /* ── STATE: game over ── */
206
- .state-game-over {
207
- animation:screen-shake .5s ease both !important;
208
- background:
209
- radial-gradient(circle at 50% 60%,rgba(255,50,50,.4),transparent 10rem),
210
- linear-gradient(180deg,#3b0a0a 0%,#6b1a1a 54%,#2a0505 100%) !important;
211
- }
212
- .state-game-over .shroom-cap {
213
- animation:shroom-explode .6s ease both !important;
214
- filter:drop-shadow(0 0 28px rgba(255,50,80,1)) !important;
215
- }
216
- .state-game-over .myco-player { animation:myco-die .7s ease both !important; }
217
-
218
- @keyframes screen-shake {
219
- 0%,100%{transform:translateX(0);}
220
- 15%{transform:translateX(-10px) rotate(-1deg);}
221
- 30%{transform:translateX(10px) rotate(1deg);}
222
- 45%{transform:translateX(-10px) rotate(-1deg);}
223
- 60%{transform:translateX(10px) rotate(1deg);}
224
- 75%{transform:translateX(-5px);}
225
- }
226
- @keyframes shroom-explode {
227
- 0% {transform:scale(1);}
228
- 50% {transform:scale(2); filter:brightness(2);}
229
- 100% {transform:scale(0); opacity:0;}
230
- }
231
- @keyframes myco-die {
232
- 0% {transform:rotate(0) scale(1);}
233
- 100% {transform:rotate(-90deg) scale(0.8) translateY(2rem); opacity:0.5;}
234
- }
235
  </style>
236
  """
237
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238
  def forest_scene(current, collection, position):
239
- """Renders the animated HTML stage with state-driven CSS."""
240
  px, py = position if position else (1, 1)
241
 
242
  state_class = "state-waiting"
243
- cap_emoji = ""
 
 
244
 
245
  if current:
246
- is_poison = current.get("name") in POISONOUS_MUSHROOM_NAMES or current.get("poison") == "Yes"
 
247
  is_picked = current.get("picked") == "Yes"
248
  is_game_over = current.get("game_over") == "Yes"
249
  rarity = current.get("rarity", "Common").lower()
250
 
 
 
 
251
  if is_game_over:
252
  state_class = "state-game-over"
253
  elif is_picked:
254
  state_class = "state-picked"
255
- elif is_poison:
256
- state_class = "state-danger"
257
  else:
258
  state_class = "state-discovered"
259
 
260
- sprite_pool = MUSHROOM_SPRITES.get("poison" if is_poison else rarity, MUSHROOM_SPRITES["common"])
261
- cap_emoji = sprite_pool[0] # Or use random.choice(sprite_pool)
 
 
 
 
 
 
 
262
 
263
  return f"""
264
  {SCENE_STYLES}
265
- <div class="forest-scene {state_class} pos-{px}-{py}">
266
  <div class="scene-hud">
267
- <span>📍 X:{px} Y:{py}</span>
268
- <span>{"🍄 Discovered!" if state_class != "state-waiting" else "🌿 Exploring..."}</span>
 
269
  </div>
270
  <div class="scene-stage">
271
  <span class="tree-left">🌲</span>
272
  <span class="tree-right">🌳</span>
273
- <span class="sparkle-one">✨</span>
274
- <span class="sparkle-two">✦</span>
275
- <span class="grass-a">🌿</span>
276
- <span class="grass-b">🌾</span>
277
- <span class="grass-c">🌿</span>
278
-
279
  <div class="ground-strip"></div>
280
 
281
  <div class="myco-player">🍄</div>
282
 
283
- <div class="mushroom-spot shroom-pos-1">
284
  <div class="shroom-cap">{cap_emoji}</div>
285
  <div class="shroom-stem"></div>
286
  </div>
@@ -288,7 +219,7 @@ def forest_scene(current, collection, position):
288
  </div>
289
  """
290
 
291
- # ── Supporting Markdown Renderers ──
292
  def mushroom_card(mush_obj, clue=None, secret=None, current=None):
293
  if not mush_obj: return "*No mushroom discovered...*"
294
  return f"**{mush_obj.name}**\nRarity: {mush_obj.rarity}\nHabitat: {mush_obj.habitat}\n{mush_obj.lore}"
@@ -319,4 +250,4 @@ def game_intro_markdown():
319
 
320
  def play_hook_markdown():
321
  return "What will Myco discover next?"
322
-
 
1
+ """Markdown & HTML renderers for the Myco Gradio interface — multiple digital art styles."""
2
 
3
  from html import escape
4
+ import hashlib
5
  from models.mushroom import Mushroom
6
 
7
  POISONOUS_MUSHROOM_NAMES = {
8
  "Ghost Gill", "Pepper Pixie", "Ruby Knuckle", "Clockwork Chanterelle",
9
  }
10
 
11
+ # Expanded sprites mapped to thematic vibes
12
  MUSHROOM_SPRITES = {
13
+ "poison": ["🔴", "💀", "🟥"],
14
+ "legendary": ["⭐", "🌟", "✨"],
15
+ "rare": ["💜", "🔵", "💎"],
16
+ "cyberpunk": ["👾", "⚡", "🔮"],
17
+ "pixel": ["👾", "🕹️", "🧱"],
18
+ "common": ["🍄", "🍄‍🟫", "🟫"],
19
  }
20
 
21
  SCENE_STYLES = """
22
  <style>
23
+ /* ── Base Scene Container ── */
24
  .forest-scene {
25
+ position: relative; isolation: isolate; overflow: hidden;
26
+ min-height: 22rem; padding: .75rem; border-radius: 28px;
27
+ transition: all 0.5s ease;
 
 
 
 
 
 
 
28
  contain: layout style;
29
+ color: #f9ffe9;
30
  }
31
 
32
+ /* ── STYLE 1: DEFAULT ORGANIC FOREST ── */
33
+ .theme-organic {
34
+ background:
35
+ radial-gradient(circle at 50% 72%, rgba(255,239,173,.26), transparent 8rem),
36
+ radial-gradient(circle at 18% 24%, rgba(134,225,153,.22), transparent 10rem),
37
+ linear-gradient(180deg, #123626 0%, #245c3c 54%, #523b20 100%);
38
+ border: 1px solid rgba(225,255,209,.25);
39
+ box-shadow: 0 18px 48px rgba(8,30,20,.26);
40
+ }
41
+
42
+ /* ── STYLE 2: CYBERPUNK NEON ── */
43
+ .theme-cyberpunk {
44
+ background: linear-gradient(180deg, #0d0116 0%, #1a0b2e 60%, #05000a 100%) !important;
45
+ border: 2px solid #ff007f !important;
46
+ box-shadow: 0 0 20px rgba(255, 0, 127, 0.4), inset 0 0 20px rgba(0, 242, 254, 0.2) !important;
47
+ font-family: 'Courier New', monospace;
48
+ }
49
+ .theme-cyberpunk .scene-hud { background: rgba(255, 0, 127, 0.2) !important; border: 1px solid #00f2fe; color: #00f2fe !important; }
50
+ .theme-cyberpunk .shroom-cap { filter: drop-shadow(0 0 15px #00f2fe) drop-shadow(0 0 30px #ff007f) !important; }
51
+ .theme-cyberpunk .shroom-stem { background: linear-gradient(180deg, #00f2fe, #ff007f) !important; width: 0.4rem !important; }
52
+
53
+ /* ── STYLE 3: 8-BIT PIXEL ART ── */
54
+ .theme-pixel {
55
+ background: repeating-conic-gradient(#2a2a2a 0% 25%, #1f1f1f 0% 50%) 50% / 20px 20px !important;
56
+ border: 4px dashed #ffcc00 !important;
57
+ image-rendering: pixelated;
58
+ }
59
+ .theme-pixel * { font-family: 'Courier New', monospace; font-weight: bold; }
60
+ .theme-pixel .shroom-cap { font-size: 3.5rem !important; transform: scale(1.1); filter: drop-shadow(4px 4px 0px #000); }
61
+ .theme-pixel .shroom-stem { background: #ffcc00 !important; width: 1.2rem !important; border: 3px solid #000; border-radius: 0px !important; }
62
+
63
+ /* ── STYLE 4: GLITCH ART ── */
64
+ .theme-glitch {
65
+ background: linear-gradient(45deg, #111, #221a2b, #0a1c1c) !important;
66
+ border: 2px solid #00ffcc !important;
67
+ }
68
+ .theme-glitch .shroom-cap {
69
+ animation: glitch-anim 1s linear infinite alternate !important;
70
+ text-shadow: 3px 0 0 rgba(255,0,0,.4), -3px 0 0 rgba(0,0,255,.4);
71
+ }
72
+ @keyframes glitch-anim {
73
+ 0% { transform: skew(0deg) scale(1); }
74
+ 20% { transform: skew(-4deg) scale(1.05); filter: hue-rotate(90deg); }
75
+ 40% { transform: skew(5deg) scale(0.95); }
76
+ 60% { transform: skew(-2deg) scale(1); filter: blur(1px); }
77
+ 80% { transform: skew(3deg) scale(1.02); }
78
+ 100% { transform: skew(0deg) scale(1); }
79
+ }
80
+
81
+ /* ── STYLE 5: SYNTHWAVE / VAPORWAVE ── */
82
+ .theme-synthwave {
83
+ background:
84
+ linear-gradient(0deg, rgba(255, 105, 180, 0.2) 1px, transparent 1px),
85
+ linear-gradient(90deg, rgba(255, 105, 180, 0.2) 1px, transparent 1px),
86
+ linear-gradient(180deg, #2b003a 0%, #0c0014 100%) !important;
87
+ background-size: 20px 20px, 20px 20px, auto;
88
+ border: 1px solid #ff69b4 !important;
89
+ }
90
+ .theme-synthwave .shroom-cap { filter: drop-shadow(0 -5px 10px #ff69b4) !important; animation: float-wave 3s ease-in-out infinite !important; }
91
+ @keyframes float-wave {
92
+ 0%, 100% { transform: translateY(0px) rotate(-3deg); }
93
+ 50% { transform: translateY(-10px) rotate(3deg); }
94
+ }
95
+
96
+ /* ── Core Layout Modules ── */
97
  .scene-hud {
98
+ position: relative; z-index: 3;
99
+ display: flex; flex-wrap: wrap; gap: .4rem;
100
+ padding: .5rem .75rem; border-radius: 999px;
101
+ background: rgba(13,38,28,.72); backdrop-filter: blur(6px);
102
+ font-size: .78rem; font-weight: 800;
103
  }
 
 
104
  .scene-stage {
105
+ position: relative; height: 14rem; margin: .6rem 0;
106
+ background: radial-gradient(ellipse at bottom, rgba(190,255,180,.12), transparent 70%);
107
+ border-radius: 22px; overflow: hidden;
 
 
108
  }
109
+ .scene-stage > * { position: absolute; line-height: 1; }
 
 
110
  .ground-strip {
111
+ bottom: 0; left: 0; right: 0; height: 35%;
112
+ background: linear-gradient(180deg, rgba(80,50,15,0) 0%, rgba(20,15,30,0.4) 100%);
113
+ border-radius: 0 0 22px 22px;
114
  }
115
 
116
+ /* Decor elements */
117
+ .tree-left { left: 4%; bottom: 30%; font-size: 5rem; opacity: 0.6; z-index: 1; }
118
+ .tree-right { right: 5%; bottom: 32%; font-size: 4.6rem; opacity: 0.6; z-index: 1; }
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  .myco-player {
120
+ font-size: 4.2rem; z-index: 5; bottom: 28%;
121
+ transition: left .38s cubic-bezier(.34,1.56,.64,1), bottom .38s cubic-bezier(.34,1.56,.64,1);
122
+ animation: myco-bob 2.4s ease-in-out infinite;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  }
124
 
125
+ /* Positioning systems */
126
+ .pos-0-0 .myco-player{left:12%;bottom:55%;} .pos-1-0 .myco-player{left:40%;bottom:55%;} .pos-2-0 .myco-player{left:66%;bottom:55%;}
127
+ .pos-0-1 .myco-player{left:12%;bottom:40%;} .pos-1-1 .myco-player{left:40%;bottom:40%;} .pos-2-1 .myco-player{left:66%;bottom:40%;}
128
+ .pos-0-2 .myco-player{left:12%;bottom:26%;} .pos-1-2 .myco-player{left:40%;bottom:26%;} .pos-2-2 .myco-player{left:66%;bottom:26%;}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
 
130
+ @keyframes myco-bob { 0%,100%{transform:translateY(0);} 50%{transform:translateY(-.4rem);} }
 
 
 
 
 
 
 
 
 
 
 
 
131
 
132
+ /* Mushroom Spot Architecture */
133
+ .mushroom-spot { z-index: 4; display: flex; flex-direction: column; align-items: center; gap: 0; right: 30%; bottom: 28%; }
134
+ .shroom-stem { width: .7rem; height: 1.2rem; border-radius: 2px; background: linear-gradient(180deg,#d4a96a,#8b5e2a); }
135
+ .shroom-cap { font-size: 2.8rem; line-height: 1; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3)); }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
 
137
+ /* State Modifications */
138
+ .state-waiting .mushroom-spot { display: none; }
139
+ .state-picked .shroom-cap { animation: shroom-fly .6s ease both; }
140
+ .state-picked .shroom-stem { display: none; }
141
+ @keyframes shroom-fly { 100% { transform: translateY(-10rem) scale(0); opacity: 0; } }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
 
143
+ .state-game-over { filter: grayscale(0.8) contrast(1.2); background: #220000 !important; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
  </style>
145
  """
146
 
147
+ def get_art_theme(mushroom_name: str) -> tuple[str, str]:
148
+ """Deterministically maps a mushroom name to an art style class and style title."""
149
+ if not mushroom_name:
150
+ return "theme-organic", "Organic"
151
+
152
+ # Generate a simple reliable hash index
153
+ hash_val = int(hashlib.md5(mushroom_name.encode('utf-8')).hexdigest(), 16)
154
+ themes = [
155
+ ("theme-organic", "🌲 Organic Form"),
156
+ ("theme-cyberpunk", "⚡ Neon Cyberpunk"),
157
+ ("theme-pixel", "🕹️ 8-Bit Pixel"),
158
+ ("theme-glitch", "👾 Glitch Art"),
159
+ ("theme-synthwave", "🌌 Synthwave Retro")
160
+ ]
161
+ return themes[hash_val % len(themes)]
162
+
163
  def forest_scene(current, collection, position):
164
+ """Renders the HTML stage injected with procedural style definitions."""
165
  px, py = position if position else (1, 1)
166
 
167
  state_class = "state-waiting"
168
+ theme_class = "theme-organic"
169
+ style_title = "Organic"
170
+ cap_emoji = "🍄"
171
 
172
  if current:
173
+ name = current.get("name", "")
174
+ is_poison = name in POISONOUS_MUSHROOM_NAMES or current.get("poison") == "Yes"
175
  is_picked = current.get("picked") == "Yes"
176
  is_game_over = current.get("game_over") == "Yes"
177
  rarity = current.get("rarity", "Common").lower()
178
 
179
+ # Extract emergent visual theme
180
+ theme_class, style_title = get_art_theme(name)
181
+
182
  if is_game_over:
183
  state_class = "state-game-over"
184
  elif is_picked:
185
  state_class = "state-picked"
 
 
186
  else:
187
  state_class = "state-discovered"
188
 
189
+ # Match emoji visuals based on rarity or art style
190
+ if theme_class == "theme-cyberpunk":
191
+ cap_emoji = MUSHROOM_SPRITES["cyberpunk"][hash(name) % len(MUSHROOM_SPRITES["cyberpunk"])]
192
+ elif theme_class == "theme-pixel":
193
+ cap_emoji = MUSHROOM_SPRITES["pixel"][hash(name) % len(MUSHROOM_SPRITES["pixel"])]
194
+ elif is_poison:
195
+ cap_emoji = MUSHROOM_SPRITES["poison"][0]
196
+ else:
197
+ cap_emoji = MUSHROOM_SPRITES.get(rarity, MUSHROOM_SPRITES["common"])[0]
198
 
199
  return f"""
200
  {SCENE_STYLES}
201
+ <div class="forest-scene {theme_class} {state_class} pos-{px}-{py}">
202
  <div class="scene-hud">
203
+ <span>📍 Region: X:{px} Y:{py}</span>
204
+ <span>Render Engine: {style_title}</span>
205
+ <span>{"🍄 Target Loaded" if state_class != "state-waiting" else "🌿 Scanning clearing..."}</span>
206
  </div>
207
  <div class="scene-stage">
208
  <span class="tree-left">🌲</span>
209
  <span class="tree-right">🌳</span>
 
 
 
 
 
 
210
  <div class="ground-strip"></div>
211
 
212
  <div class="myco-player">🍄</div>
213
 
214
+ <div class="mushroom-spot">
215
  <div class="shroom-cap">{cap_emoji}</div>
216
  <div class="shroom-stem"></div>
217
  </div>
 
219
  </div>
220
  """
221
 
222
+ # ── Retained Markdown Helpers for Gradio App Compatibility ──
223
  def mushroom_card(mush_obj, clue=None, secret=None, current=None):
224
  if not mush_obj: return "*No mushroom discovered...*"
225
  return f"**{mush_obj.name}**\nRarity: {mush_obj.rarity}\nHabitat: {mush_obj.habitat}\n{mush_obj.lore}"
 
250
 
251
  def play_hook_markdown():
252
  return "What will Myco discover next?"
253
+