byte-vortex commited on
Commit
8bc7828
Β·
verified Β·
1 Parent(s): 05c5edf

Deploy Myco from CI

Browse files
Files changed (1) hide show
  1. ui/renderers.py +66 -256
ui/renderers.py CHANGED
@@ -1,5 +1,6 @@
1
  """Markdown renderers for the Myco Gradio interface."""
2
 
 
3
  from html import escape
4
  from game.progression import (
5
  AREA_UNLOCKS, current_area, next_area, next_mystery,
@@ -12,235 +13,97 @@ POISONOUS_MUSHROOM_NAMES = {
12
  "Ghost Gill", "Pepper Pixie", "Ruby Knuckle", "Clockwork Chanterelle",
13
  }
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  # ── Inline CSS + keyframes injected once into the scene ──────────────────────
16
  SCENE_STYLES = """
17
  <style>
18
- /* ── Base scene ── */
19
  .forest-scene {
20
- position: relative; isolation: isolate;
21
- overflow: hidden; min-height: 20rem;
22
- padding: 0.75rem; border-radius: 28px;
23
- background:
24
- radial-gradient(circle at 50% 72%, rgba(255,239,173,.26), transparent 8rem),
25
- radial-gradient(circle at 18% 24%, rgba(134,225,153,.22), transparent 10rem),
26
- linear-gradient(180deg,#123626 0%,#245c3c 54%,#523b20 100%);
27
- border: 1px solid rgba(225,255,209,.25);
28
- box-shadow: 0 18px 48px rgba(8,30,20,.26);
29
- color: #f9ffe9;
30
  }
31
-
32
- /* ── HUD bar ── */
33
  .scene-hud {
34
- position: relative; z-index: 3;
35
- display: flex; flex-wrap: wrap; gap: .4rem;
36
- padding: .5rem .75rem; border-radius: 999px;
37
- background: rgba(13,38,28,.72); backdrop-filter: blur(6px);
38
- font-size: .8rem; font-weight: 800;
39
  }
40
-
41
- /* ── Stage ── */
42
  .scene-stage {
43
- position: relative; height: 13rem;
44
- margin: .6rem 0;
45
- background:
46
- linear-gradient(transparent 62%, rgba(106,79,33,.55) 63%),
47
- radial-gradient(ellipse at bottom, rgba(190,255,180,.2), transparent 60%);
48
  border-radius: 22px; overflow: hidden;
49
  }
50
  .scene-stage span { position: absolute; line-height:1; }
51
-
52
- /* ── Trees / grass ── */
53
  .tree-left { left:6%; bottom:18%; font-size:5rem; filter:drop-shadow(0 8px 12px rgba(0,0,0,.28)); }
54
  .tree-right { right:7%; bottom:20%; font-size:4.75rem; filter:drop-shadow(0 8px 12px rgba(0,0,0,.28)); }
55
  .grass-one { left:26%; bottom:14%; font-size:2.4rem; }
56
  .grass-two { right:28%;bottom:16%; font-size:2.2rem; }
57
-
58
- /* ── Sparkles ── */
59
  .sparkle-one { left:34%; top:18%; font-size:1.8rem; animation:twinkle 1.8s ease-in-out infinite; }
60
  .sparkle-two { right:33%; top:24%; font-size:1.6rem; animation:twinkle 2.2s ease-in-out infinite reverse; }
61
- @keyframes twinkle {
62
- 0%,100%{opacity:.3;transform:scale(.85);}
63
- 50%{opacity:1;transform:scale(1.18);}
64
- }
65
-
66
- /* ── Myco player β€” position grid ── */
67
  .myco-player {
68
  font-size:4rem; z-index:2;
69
  transition: left .32s cubic-bezier(.34,1.56,.64,1), bottom .32s cubic-bezier(.34,1.56,.64,1);
70
  animation: myco-bob 2.4s ease-in-out infinite;
71
  filter:drop-shadow(0 6px 14px rgba(255,92,92,.28));
72
  }
73
- @keyframes myco-bob {
74
- 0%,100%{transform:translateY(0);}
75
- 50%{transform:translateY(-.45rem);}
76
- }
77
- .pos-0-0 .myco-player{left:14%;bottom:62%;}
78
- .pos-1-0 .myco-player{left:41%;bottom:62%;}
79
- .pos-2-0 .myco-player{left:67%;bottom:62%;}
80
- .pos-0-1 .myco-player{left:14%;bottom:36%;}
81
- .pos-1-1 .myco-player{left:41%;bottom:36%;}
82
- .pos-2-1 .myco-player{left:67%;bottom:36%;}
83
- .pos-0-2 .myco-player{left:14%;bottom:13%;}
84
- .pos-1-2 .myco-player{left:41%;bottom:13%;}
85
- .pos-2-2 .myco-player{left:67%;bottom:13%;}
86
-
87
- /* ── Mushroom sprite ── */
88
  .mushroom-sprite {
89
- right:33%; bottom:22%; font-size:3.6rem; z-index:2;
90
  filter:drop-shadow(0 6px 14px rgba(0,0,0,.3));
91
  }
92
-
93
- /* ── STATE: waiting (no mushroom) ── */
94
  .state-waiting .mushroom-sprite { opacity:0; }
95
-
96
- /* ── STATE: discovered β€” mushroom pops up, Myco runs toward it ── */
97
- .state-discovered .mushroom-sprite {
98
- animation: shroom-popup 0.7s cubic-bezier(.34,1.56,.64,1) both;
99
- }
100
- .state-discovered .myco-player {
101
- animation: myco-bob 2.4s ease-in-out infinite,
102
- myco-run-in 0.6s cubic-bezier(.34,1.56,.64,1) both;
103
- }
104
- @keyframes shroom-popup {
105
- 0% { opacity:0; transform:translateY(3rem) scale(.2); }
106
- 60% { opacity:1; transform:translateY(-.4rem) scale(1.18); }
107
- 100% { opacity:1; transform:translateY(0) scale(1); }
108
- }
109
- @keyframes myco-run-in {
110
- 0% { transform:translateX(-3rem) scaleX(-1); }
111
- 100% { transform:translateX(0) scaleX(1); }
112
- }
113
-
114
- /* ── STATE: picked β€” mushroom flies up and disappears ── */
115
- .state-picked .mushroom-sprite {
116
- animation: shroom-catch 0.55s cubic-bezier(.34,1.56,.64,1) both;
117
- }
118
- .state-picked .myco-player {
119
- animation: myco-bob 2.4s ease-in-out infinite,
120
- myco-catch-jump 0.55s ease both;
121
- }
122
- @keyframes shroom-catch {
123
- 0% { opacity:1; transform:translateY(0) scale(1); }
124
- 40% { opacity:1; transform:translateY(-2.5rem) scale(1.3) rotate(15deg); }
125
- 100% { opacity:0; transform:translateY(-5rem) scale(.2) rotate(40deg); }
126
- }
127
- @keyframes myco-catch-jump {
128
- 0%,100%{ transform:translateY(0); }
129
- 40% { transform:translateY(-1.4rem) scale(1.1); }
130
- }
131
-
132
- /* ── STATE: danger (poison, not yet picked) ── */
133
- .state-danger .mushroom-sprite {
134
- animation: shroom-popup 0.7s cubic-bezier(.34,1.56,.64,1) both,
135
- poison-pulse 1.2s ease-in-out infinite 0.7s;
136
- filter: drop-shadow(0 0 18px rgba(255,62,91,.9));
137
- }
138
- .state-danger .myco-player {
139
- animation: myco-bob 2.4s ease-in-out infinite,
140
- myco-recoil 0.5s ease both;
141
- }
142
- @keyframes poison-pulse {
143
- 0%,100%{ filter:drop-shadow(0 0 10px rgba(255,62,91,.6)); }
144
- 50% { filter:drop-shadow(0 0 28px rgba(255,62,91,1)); }
145
- }
146
- @keyframes myco-recoil {
147
- 0% { transform:translateX(0); }
148
- 30% { transform:translateX(-1.2rem); }
149
- 60% { transform:translateX(.4rem); }
150
- 100%{ transform:translateX(0); }
151
- }
152
-
153
- /* ── STATE: game over ── */
154
- .state-game-over .forest-scene,
155
- .state-game-over {
156
- animation: screen-shake .45s ease both;
157
- background:
158
- radial-gradient(circle at 50% 72%, rgba(255,62,91,.35), transparent 8rem),
159
- linear-gradient(180deg,#3b0a0a 0%,#6b1a1a 54%,#2a0a0a 100%) !important;
160
- }
161
- .state-game-over .mushroom-sprite {
162
- animation: shroom-explode .6s ease both;
163
- filter: drop-shadow(0 0 24px rgba(255,62,91,1));
164
- }
165
- .state-game-over .myco-player {
166
- animation: myco-fall .6s ease both;
167
- }
168
- @keyframes screen-shake {
169
- 0%,100%{ transform:translateX(0); }
170
- 20% { transform:translateX(-8px); }
171
- 40% { transform:translateX(8px); }
172
- 60% { transform:translateX(-5px); }
173
- 80% { transform:translateX(5px); }
174
- }
175
- @keyframes shroom-explode {
176
- 0% { transform:scale(1) rotate(0); opacity:1; }
177
- 50% { transform:scale(1.8) rotate(20deg); opacity:.8; }
178
- 100%{ transform:scale(0) rotate(90deg); opacity:0; }
179
- }
180
- @keyframes myco-fall {
181
- 0% { transform:rotate(0) translateY(0); opacity:1; }
182
- 100%{ transform:rotate(-90deg) translateY(2rem); opacity:.4; }
183
- }
184
-
185
- /* ── Rarity glows ── */
186
- .rarity-rare .mushroom-sprite { filter:drop-shadow(0 0 18px rgba(138,220,255,.9)); }
187
  .rarity-legendary .mushroom-sprite{ filter:drop-shadow(0 0 28px rgba(255,215,0,1)); animation:legendary-pulse 1s ease-in-out infinite 0.7s; }
188
- @keyframes legendary-pulse {
189
- 0%,100%{ filter:drop-shadow(0 0 18px rgba(255,215,0,.7)); transform:scale(1); }
190
- 50% { filter:drop-shadow(0 0 36px rgba(255,215,0,1)); transform:scale(1.1); }
191
- }
192
-
193
- /* ── Mini map grid ── */
194
- .forest-map {
195
- display:grid; grid-template-columns:repeat(3,1fr);
196
- gap:.3rem; margin:.4rem auto .6rem;
197
- max-width:9rem; padding:.4rem;
198
- border:1px solid rgba(255,255,255,.18); border-radius:14px;
199
- background:rgba(13,38,28,.58);
200
- }
201
- .map-tile {
202
- display:grid; min-height:1.7rem; place-items:center;
203
- border-radius:8px; background:rgba(255,255,255,.1); font-weight:900;
204
- }
205
  .map-tile.active { background:rgba(255,224,138,.92); color:#3d2c00!important; }
206
-
207
- /* ── Caption ── */
208
- .scene-caption {
209
- display:flex; justify-content:space-between; gap:.6rem;
210
- padding:.55rem .8rem; border-radius:14px;
211
- background:rgba(13,38,28,.68); backdrop-filter:blur(6px);
212
- align-items:center;
213
- }
214
  .scene-caption span { color:#d9f4d4; }
215
-
216
- /* ── Score burst ── */
217
- .score-burst {
218
- margin:.65rem auto 0; max-width:520px;
219
- padding:.5rem .85rem; border-radius:999px;
220
- background:rgba(255,224,112,.18); border:1px solid rgba(255,244,190,.36);
221
- color:#fff7d6; font-weight:900; text-align:center;
222
- animation:score-pop .56s ease both;
223
- }
224
- @keyframes score-pop {
225
- 0%{transform:scale(.92);opacity:0;}
226
- 45%{transform:scale(1.06);opacity:1;}
227
- 100%{transform:scale(1);opacity:1;}
228
- }
229
- .state-game-over .score-burst {
230
- background:rgba(130,0,30,.45); border-color:rgba(255,120,140,.55);
231
- }
232
-
233
- /* ── Story moment ── */
234
- .story-moment {
235
- margin:.75rem auto 0; max-width:760px;
236
- padding:.8rem 1rem; border:1px solid rgba(255,234,166,.3);
237
- border-radius:18px; background:rgba(25,18,45,.72);
238
- color:#fff7d6; box-shadow:0 0 24px rgba(165,111,255,.22);
239
- }
240
  .story-moment strong,.story-moment span { display:block; }
241
  .story-moment span { margin-top:.2rem; color:#f6e7b2; }
242
-
243
- /* ── Suppress Gradio white flash ── */
244
  .generating .forest-scene, .pending .forest-scene { opacity:.88!important; }
245
  .progress-level,.progress-level-inner { display:none!important; }
246
  div.gradio-html { background:transparent!important; }
@@ -248,55 +111,6 @@ div.gradio-html { background:transparent!important; }
248
  </style>
249
  """
250
 
251
- def hero_markdown() -> str:
252
- return """
253
- <div class="myco-hero">
254
- <div class="myco-mascot">πŸ„</div>
255
- <div>
256
- <p class="eyebrow">Tiny AI forest game</p>
257
- <h1>Myco</h1>
258
- <p>Follow an AI mushroom companion through a glowing forest. Every discovery starts with Myco's intuition.</p>
259
- </div>
260
- </div>
261
- """
262
-
263
- def home_forest_markdown() -> str:
264
- return """
265
- <div class="home-forest-postcard" aria-label="Animated Myco forest postcard">
266
- <div class="home-sky">
267
- <span class="home-milky-way" title="Milky Way">🌌</span>
268
- <span class="home-star star-one">✨</span>
269
- <span class="home-star star-two">✦</span>
270
- <span class="home-star star-three">✧</span>
271
- </div>
272
- <div class="home-forest-floor">
273
- <span class="home-tree left">🌲</span>
274
- <span class="home-grass grass-left">🌿</span>
275
- <span class="home-myco" title="Myco">πŸ„</span>
276
- <span class="home-brown-mushroom" title="Brown mushroom">πŸ„β€πŸŸ«</span>
277
- <span class="home-grass grass-right">πŸƒ</span>
278
- <span class="home-tree right">🌳</span>
279
- <span class="home-moon">πŸŒ–</span>
280
- </div>
281
- <p><strong>The Milky Way is awake.</strong> Myco hears a brown mushroom whispering your first clue.</p>
282
- <span class="home-whisper">"Tap Play. Let's find what the forest is hiding."</span>
283
- </div>
284
- """
285
-
286
- def play_hook_markdown() -> str:
287
- return """
288
- <div class="play-hook">
289
- <p class="eyebrow">Mission</p>
290
- <h2>Goal: follow clues until Myco remembers the Impossible Mushroom.</h2>
291
- <div class="hook-steps">
292
- <span>1 Β· Move through the forest</span>
293
- <span>2 Β· Search Clearing β€” mushroom pops up!</span>
294
- <span>3 Β· Myco reacts Β· Pick, Study, or Follow Whisper</span>
295
- </div>
296
- <p>Every clue advances one mystery. Follow whispers to reveal why the MycoDex is regrowing a forest that vanished.</p>
297
- </div>
298
- """
299
-
300
  def forest_scene(
301
  current: MushroomState | None,
302
  collection: CollectionState | None,
@@ -310,7 +124,7 @@ def forest_scene(
310
  if current is None:
311
  mushroom_name = "Hidden mushroom"
312
  rarity = "common"
313
- sprite = "✨"
314
  status = "The moss is listening. Click Search Clearing to wake the forest."
315
  omen = "Myco is waiting to sense the first spore."
316
  event_label = "🌌 Dreaming Forest"
@@ -323,7 +137,7 @@ def forest_scene(
323
  else:
324
  mushroom_name = current.get("name", "Mystery mushroom")
325
  rarity = current.get("rarity", "Common").lower()
326
- sprite = "πŸ„β€πŸŸ«"
327
  game_over = current.get("game_over") == "Yes"
328
  studied = current.get("studied") == "Yes"
329
  event_label = f"{current.get('event_emoji','✨')} {current.get('event_title','Strange Omen')}"
@@ -334,15 +148,11 @@ def forest_scene(
334
  reward_text = current.get("reward_text", "Decide whether to risk the pickup.")
335
  state_cls = _scene_state_class(current)
336
  status = f"A {rarity} {mushroom_name} breaks through the moss!"
337
- if game_over:
338
- status = f"πŸ’€ GAME OVER: {mushroom_name} was poisonous!"
339
  omen = "New field note unlocked." if studied else "Ask Myco what the forest is hiding."
340
- if current.get("picked") == "Yes":
341
- omen = "βœ… Picked! Move to the next clearing."
342
- if game_over:
343
- omen = "Press Search Clearing to start a new run."
344
 
345
- # Unique key forces browser to re-run CSS animations on every render
346
  import time
347
  anim_key = str(int(time.time() * 1000))[-6:]
348
 
@@ -364,7 +174,7 @@ def forest_scene(
364
  <span class="grass grass-one">🌿</span>
365
  <span class="grass grass-two">πŸƒ</span>
366
  <span class="myco-player" title="Myco">πŸ„</span>
367
- <span class="mushroom-sprite" title="{escape(mushroom_name)}">{sprite if current else "✨"}</span>
368
  <span class="sparkle sparkle-one">✨</span>
369
  <span class="sparkle sparkle-two">✦</span>
370
  </div>
 
1
  """Markdown renderers for the Myco Gradio interface."""
2
 
3
+ import hashlib
4
  from html import escape
5
  from game.progression import (
6
  AREA_UNLOCKS, current_area, next_area, next_mystery,
 
13
  "Ghost Gill", "Pepper Pixie", "Ruby Knuckle", "Clockwork Chanterelle",
14
  }
15
 
16
+ # ── 8-BIT MATRIX BLUEPRINTS ──
17
+ MATRIX_DOME = [[0,0,0,1,1,1,1,0,0,0],[0,0,1,2,2,3,2,1,0,0],[0,1,2,2,3,2,2,2,1,0],[1,2,3,2,2,2,3,2,2,1],[1,1,1,1,1,4,1,1,1,1],[0,0,0,0,1,4,1,0,0,0],[0,0,0,0,1,4,1,0,0,0],[0,0,0,0,1,1,1,0,0,0]]
18
+ MATRIX_SKULL = [[0,0,1,1,1,1,1,1,0,0],[0,1,2,2,2,2,2,2,1,0],[1,2,1,2,2,2,1,2,2,1],[1,2,1,2,2,2,1,2,2,1],[0,1,2,2,1,1,2,2,1,0],[0,0,1,2,1,1,2,1,0,0],[0,0,1,4,4,4,4,1,0,0],[0,0,0,1,1,1,1,0,0,0]]
19
+ MATRIX_FLAT = [[0,0,1,1,1,1,1,1,0,0],[0,1,3,2,2,2,3,2,1,0],[1,2,2,2,3,2,2,2,2,1],[1,1,1,1,4,4,1,1,1,1],[0,0,0,1,4,4,1,0,0,0],[0,0,0,1,4,4,1,0,0,0],[0,0,1,4,4,4,4,1,0,0],[0,0,1,1,1,1,1,1,0,0]]
20
+ MATRIX_STAR = [[0,0,0,0,1,1,0,0,0,0],[0,1,0,1,2,2,1,0,1,0],[1,2,1,2,2,2,2,1,2,1],[0,1,2,3,2,2,3,2,1,0],[0,0,1,1,4,4,1,1,0,0],[0,0,0,1,4,4,1,0,0,0],[0,0,0,1,4,4,1,0,0,0],[0,0,0,1,1,1,1,0,0,0]]
21
+
22
+ def generate_mushroom_sprite(name: str) -> str:
23
+ """Generates the procedural pixel mushroom visual."""
24
+ hash_val = int(hashlib.md5(name.encode('utf-8')).hexdigest(), 16)
25
+ shapes = [MATRIX_DOME, MATRIX_SKULL, MATRIX_FLAT, MATRIX_STAR]
26
+ matrix = shapes[hash_val % len(shapes)]
27
+ palettes = [("#d62828", "#f77f00", "#fcbf49"), ("#00f2fe", "#ff007f", "#25003e"), ("#ffb703", "#ffffff", "#fb8500")]
28
+ c_cap, c_spot, c_stem = palettes[hash_val % len(palettes)]
29
+ color_map = {1: "#121214", 2: c_cap, 3: c_spot, 4: c_stem}
30
+ px_scale = 5
31
+ shadows = [f"{c*px_scale}px {r*px_scale}px 0 {color_map[v]}"
32
+ for r, row in enumerate(matrix) for c, v in enumerate(row) if v in color_map]
33
+ return f'<div style="width:{px_scale}px; height:{px_scale}px; box-shadow: {", ".join(shadows)}; margin: 0 auto; transform: scale(1.4);"></div>'
34
+
35
  # ── Inline CSS + keyframes injected once into the scene ──────────────────────
36
  SCENE_STYLES = """
37
  <style>
 
38
  .forest-scene {
39
+ position: relative; isolation: isolate; overflow: hidden; min-height: 20rem; padding: 0.75rem; border-radius: 28px;
40
+ background: radial-gradient(circle at 50% 72%, rgba(255,239,173,.26), transparent 8rem), radial-gradient(circle at 18% 24%, rgba(134,225,153,.22), transparent 10rem), linear-gradient(180deg,#123626 0%,#245c3c 54%,#523b20 100%);
41
+ border: 1px solid rgba(225,255,209,.25); box-shadow: 0 18px 48px rgba(8,30,20,.26); color: #f9ffe9;
 
 
 
 
 
 
 
42
  }
 
 
43
  .scene-hud {
44
+ position: relative; z-index: 3; display: flex; flex-wrap: wrap; gap: .4rem; padding: .5rem .75rem; border-radius: 999px;
45
+ background: rgba(13,38,28,.72); backdrop-filter: blur(6px); font-size: .8rem; font-weight: 800;
 
 
 
46
  }
 
 
47
  .scene-stage {
48
+ position: relative; height: 13rem; margin: .6rem 0;
49
+ background: linear-gradient(transparent 62%, rgba(106,79,33,.55) 63%), radial-gradient(ellipse at bottom, rgba(190,255,180,.2), transparent 60%);
 
 
 
50
  border-radius: 22px; overflow: hidden;
51
  }
52
  .scene-stage span { position: absolute; line-height:1; }
 
 
53
  .tree-left { left:6%; bottom:18%; font-size:5rem; filter:drop-shadow(0 8px 12px rgba(0,0,0,.28)); }
54
  .tree-right { right:7%; bottom:20%; font-size:4.75rem; filter:drop-shadow(0 8px 12px rgba(0,0,0,.28)); }
55
  .grass-one { left:26%; bottom:14%; font-size:2.4rem; }
56
  .grass-two { right:28%;bottom:16%; font-size:2.2rem; }
 
 
57
  .sparkle-one { left:34%; top:18%; font-size:1.8rem; animation:twinkle 1.8s ease-in-out infinite; }
58
  .sparkle-two { right:33%; top:24%; font-size:1.6rem; animation:twinkle 2.2s ease-in-out infinite reverse; }
59
+ @keyframes twinkle { 0%,100%{opacity:.3;transform:scale(.85);} 50%{opacity:1;transform:scale(1.18);} }
 
 
 
 
 
60
  .myco-player {
61
  font-size:4rem; z-index:2;
62
  transition: left .32s cubic-bezier(.34,1.56,.64,1), bottom .32s cubic-bezier(.34,1.56,.64,1);
63
  animation: myco-bob 2.4s ease-in-out infinite;
64
  filter:drop-shadow(0 6px 14px rgba(255,92,92,.28));
65
  }
66
+ @keyframes myco-bob { 0%,100%{transform:translateY(0);} 50%{transform:translateY(-.45rem);} }
67
+ .pos-0-0 .myco-player{left:14%;bottom:62%;} .pos-1-0 .myco-player{left:41%;bottom:62%;} .pos-2-0 .myco-player{left:67%;bottom:62%;}
68
+ .pos-0-1 .myco-player{left:14%;bottom:36%;} .pos-1-1 .myco-player{left:41%;bottom:36%;} .pos-2-1 .myco-player{left:67%;bottom:36%;}
69
+ .pos-0-2 .myco-player{left:14%;bottom:13%;} .pos-1-2 .myco-player{left:41%;bottom:13%;} .pos-2-2 .myco-player{left:67%;bottom:13%;}
 
 
 
 
 
 
 
 
 
 
 
70
  .mushroom-sprite {
71
+ position: absolute; right:33%; bottom:22%; z-index:2;
72
  filter:drop-shadow(0 6px 14px rgba(0,0,0,.3));
73
  }
 
 
74
  .state-waiting .mushroom-sprite { opacity:0; }
75
+ .state-discovered .mushroom-sprite { animation: shroom-popup 0.7s cubic-bezier(.34,1.56,.64,1) both; }
76
+ .state-discovered .myco-player { animation: myco-bob 2.4s ease-in-out infinite, myco-run-in 0.6s cubic-bezier(.34,1.56,.64,1) both; }
77
+ @keyframes shroom-popup { 0%{ opacity:0; transform:translateY(3rem) scale(.2); } 60%{ opacity:1; transform:translateY(-.4rem) scale(1.18); } 100%{ opacity:1; transform:translateY(0) scale(1); } }
78
+ @keyframes myco-run-in { 0%{ transform:translateX(-3rem) scaleX(-1); } 100%{ transform:translateX(0) scaleX(1); } }
79
+ .state-picked .mushroom-sprite { animation: shroom-catch 0.55s cubic-bezier(.34,1.56,.64,1) both; }
80
+ .state-picked .myco-player { animation: myco-bob 2.4s ease-in-out infinite, myco-catch-jump 0.55s ease both; }
81
+ @keyframes shroom-catch { 0%{ opacity:1; transform:translateY(0) scale(1); } 40%{ opacity:1; transform:translateY(-2.5rem) scale(1.3) rotate(15deg); } 100%{ opacity:0; transform:translateY(-5rem) scale(.2) rotate(40deg); } }
82
+ @keyframes myco-catch-jump { 0%,100%{ transform:translateY(0); } 40%{ transform:translateY(-1.4rem) scale(1.1); } }
83
+ .state-danger .mushroom-sprite { animation: shroom-popup 0.7s cubic-bezier(.34,1.56,.64,1) both, poison-pulse 1.2s ease-in-out infinite 0.7s; filter: drop-shadow(0 0 18px rgba(255,62,91,.9)); }
84
+ .state-danger .myco-player { animation: myco-bob 2.4s ease-in-out infinite, myco-recoil 0.5s ease both; }
85
+ @keyframes poison-pulse { 0%,100%{ filter:drop-shadow(0 0 10px rgba(255,62,91,.6)); } 50%{ filter:drop-shadow(0 0 28px rgba(255,62,91,1)); } }
86
+ @keyframes myco-recoil { 0%{ transform:translateX(0); } 30%{ transform:translateX(-1.2rem); } 60%{ transform:translateX(.4rem); } 100%{ transform:translateX(0); } }
87
+ .state-game-over .forest-scene, .state-game-over { animation: screen-shake .45s ease both; background: radial-gradient(circle at 50% 72%, rgba(255,62,91,.35), transparent 8rem), linear-gradient(180deg,#3b0a0a 0%,#6b1a1a 54%,#2a0a0a 100%) !important; }
88
+ .state-game-over .mushroom-sprite { animation: shroom-explode .6s ease both; filter: drop-shadow(0 0 24px rgba(255,62,91,1)); }
89
+ .state-game-over .myco-player { animation: myco-fall .6s ease both; }
90
+ @keyframes screen-shake { 0%,100%{ transform:translateX(0); } 20%{ transform:translateX(-8px); } 40%{ transform:translateX(8px); } 60%{ transform:translateX(-5px); } 80%{ transform:translateX(5px); } }
91
+ @keyframes shroom-explode { 0%{ transform:scale(1) rotate(0); opacity:1; } 50%{ transform:scale(1.8) rotate(20deg); opacity:.8; } 100%{ transform:scale(0) rotate(90deg); opacity:0; } }
92
+ @keyframes myco-fall { 0%{ transform:rotate(0) translateY(0); opacity:1; } 100%{ transform:rotate(-90deg) translateY(2rem); opacity:.4; } }
93
+ .rarity-rare .mushroom-sprite { filter:drop-shadow(0 0 18px rgba(138,220,255,.9)); }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  .rarity-legendary .mushroom-sprite{ filter:drop-shadow(0 0 28px rgba(255,215,0,1)); animation:legendary-pulse 1s ease-in-out infinite 0.7s; }
95
+ @keyframes legendary-pulse { 0%,100%{ filter:drop-shadow(0 0 18px rgba(255,215,0,.7)); transform:scale(1); } 50%{ filter:drop-shadow(0 0 36px rgba(255,215,0,1)); transform:scale(1.1); } }
96
+ .forest-map { display:grid; grid-template-columns:repeat(3,1fr); gap:.3rem; margin:.4rem auto .6rem; max-width:9rem; padding:.4rem; border:1px solid rgba(255,255,255,.18); border-radius:14px; background:rgba(13,38,28,.58); }
97
+ .map-tile { display:grid; min-height:1.7rem; place-items:center; border-radius:8px; background:rgba(255,255,255,.1); font-weight:900; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  .map-tile.active { background:rgba(255,224,138,.92); color:#3d2c00!important; }
99
+ .scene-caption { display:flex; justify-content:space-between; gap:.6rem; padding:.55rem .8rem; border-radius:14px; background:rgba(13,38,28,.68); backdrop-filter:blur(6px); align-items:center; }
 
 
 
 
 
 
 
100
  .scene-caption span { color:#d9f4d4; }
101
+ .score-burst { margin:.65rem auto 0; max-width:520px; padding:.5rem .85rem; border-radius:999px; background:rgba(255,224,112,.18); border:1px solid rgba(255,244,190,.36); color:#fff7d6; font-weight:900; text-align:center; animation:score-pop .56s ease both; }
102
+ @keyframes score-pop { 0%{transform:scale(.92);opacity:0;} 45%{transform:scale(1.06);opacity:1;} 100%{transform:scale(1);opacity:1;} }
103
+ .state-game-over .score-burst { background:rgba(130,0,30,.45); border-color:rgba(255,120,140,.55); }
104
+ .story-moment { margin:.75rem auto 0; max-width:760px; padding:.8rem 1rem; border:1px solid rgba(255,234,166,.3); border-radius:18px; background:rgba(25,18,45,.72); color:#fff7d6; box-shadow:0 0 24px rgba(165,111,255,.22); }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  .story-moment strong,.story-moment span { display:block; }
106
  .story-moment span { margin-top:.2rem; color:#f6e7b2; }
 
 
107
  .generating .forest-scene, .pending .forest-scene { opacity:.88!important; }
108
  .progress-level,.progress-level-inner { display:none!important; }
109
  div.gradio-html { background:transparent!important; }
 
111
  </style>
112
  """
113
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  def forest_scene(
115
  current: MushroomState | None,
116
  collection: CollectionState | None,
 
124
  if current is None:
125
  mushroom_name = "Hidden mushroom"
126
  rarity = "common"
127
+ sprite_html = "✨"
128
  status = "The moss is listening. Click Search Clearing to wake the forest."
129
  omen = "Myco is waiting to sense the first spore."
130
  event_label = "🌌 Dreaming Forest"
 
137
  else:
138
  mushroom_name = current.get("name", "Mystery mushroom")
139
  rarity = current.get("rarity", "Common").lower()
140
+ sprite_html = generate_mushroom_sprite(mushroom_name)
141
  game_over = current.get("game_over") == "Yes"
142
  studied = current.get("studied") == "Yes"
143
  event_label = f"{current.get('event_emoji','✨')} {current.get('event_title','Strange Omen')}"
 
148
  reward_text = current.get("reward_text", "Decide whether to risk the pickup.")
149
  state_cls = _scene_state_class(current)
150
  status = f"A {rarity} {mushroom_name} breaks through the moss!"
151
+ if game_over: status = f"πŸ’€ GAME OVER: {mushroom_name} was poisonous!"
 
152
  omen = "New field note unlocked." if studied else "Ask Myco what the forest is hiding."
153
+ if current.get("picked") == "Yes": omen = "βœ… Picked! Move to the next clearing."
154
+ if game_over: omen = "Press Search Clearing to start a new run."
 
 
155
 
 
156
  import time
157
  anim_key = str(int(time.time() * 1000))[-6:]
158
 
 
174
  <span class="grass grass-one">🌿</span>
175
  <span class="grass grass-two">πŸƒ</span>
176
  <span class="myco-player" title="Myco">πŸ„</span>
177
+ <div class="mushroom-sprite" title="{escape(mushroom_name)}">{sprite_html}</div>
178
  <span class="sparkle sparkle-one">✨</span>
179
  <span class="sparkle sparkle-two">✦</span>
180
  </div>