*{box-sizing:border-box}
:root{--red:#dc2626;--red-dark:#991b1b;--orange:#f97316;--brown:#b45309;--gold:#fbbf24;--green:#10b981;--cream:#fff7df;--theme-page-start:#fff1c9;--theme-page-end:#ffd34f;--theme-text:#3b2415;--theme-primary:#dc2626;--theme-primary-dark:#991b1b;--theme-accent:#f97316;--theme-wall:#b45309;--theme-dot:#ef4444;--theme-goal:#10b981;--theme-goal-dark:#065f46;--theme-card:#fff;--theme-panel-border:#f87171;--theme-dpad:#7f1d1d;--theme-dpad-button:#f97316;--theme-button-text:#fff;--theme-muted:#7c2d12;--theme-canvas:#fff;--theme-border:#b45309}
html,body{width:100%;min-height:100%;margin:0!important;padding:0!important;overflow-x:hidden}
html{background:#ffd968}
body.stm-game-page{font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;background:linear-gradient(135deg,var(--theme-page-start),var(--theme-page-end));min-height:100vh;color:var(--theme-text);transition:background .25s ease,color .2s ease}
body.stm-game-page header,body.stm-game-page footer,body.stm-game-page nav,body.stm-game-page .site-header,body.stm-game-page .site-footer,body.stm-game-page .main-navigation{display:none!important}
body.stm-game-page #page,body.stm-game-page #content,body.stm-game-page .site,body.stm-game-page .site-content,body.stm-game-page main{width:100%!important;max-width:none!important;margin:0!important;padding:0!important}
.stm-app{width:100%;min-height:100vh}
.stm-container{width:100%;max-width:620px;min-height:100vh;margin:0 auto;padding:12px 12px 28px;display:block}
.stm-screen{width:100%}
.stm-hidden{display:none!important}
.stm-topbar,.stm-game-topbar{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:10px}.stm-topbar-actions,.stm-game-actions{display:flex;align-items:center;gap:7px}.stm-theme-button{width:42px;height:42px;padding:0;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;color:var(--theme-muted)}.stm-theme-gradient-icon{width:25px;height:25px;border-radius:50%;display:block;background:var(--theme-icon-color);border:0;box-shadow:0 2px 6px rgba(0,0,0,.28),inset 0 -2px 4px rgba(0,0,0,.18);transition:background .25s ease,box-shadow .25s ease}.stm-theme-gradient-icon:before,.stm-theme-gradient-icon:after{display:none}.stm-theme-button-game{flex:0 0 42px}.stm-theme-small-button{padding:8px 11px;font-size:.75rem;color:var(--theme-muted)}
.stm-brand-mini{font-size:.92rem;font-weight:900;color:var(--theme-muted)}
.stm-icon-button{width:42px;height:42px;border:0;border-radius:50%;background:var(--theme-card);box-shadow:0 3px 10px rgba(0,0,0,.16);font-size:1.15rem;cursor:pointer}
.stm-title{margin:4px 0 4px;text-align:center;color:var(--red-dark);font-size:clamp(2rem,9vw,3.2rem);line-height:1.02;font-weight:900;letter-spacing:.01em;text-shadow:2px 2px 4px rgba(0,0,0,.25)}
.stm-subtitle{text-align:center;margin:0 0 12px;font-size:.95rem;font-weight:750;color:var(--theme-muted)}
.stm-instructions{background:var(--theme-card);border:2px solid #f59e0b;border-radius:15px;padding:13px 15px;box-shadow:0 5px 14px rgba(0,0,0,.12);margin-bottom:12px}
.stm-instructions h2,.stm-level-heading h2{margin:0 0 7px;font-size:1.08rem;color:var(--theme-primary-dark)}
.stm-instructions ol{margin:0;padding-left:21px;font-size:.86rem;line-height:1.55;color:#4b3324}
.stm-progress-card{background:rgba(255,255,255,.94);border:2px solid var(--theme-panel-border);border-radius:14px;padding:11px 13px;margin-bottom:13px;box-shadow:0 5px 12px rgba(0,0,0,.12)}
.stm-progress-card>div:first-child{display:flex;justify-content:space-between;font-size:.88rem;font-weight:800}
.stm-progress-track{height:9px;background:#fee2e2;border-radius:99px;overflow:hidden;margin-top:7px}
#home-progress-bar{display:block;height:100%;width:0;background:linear-gradient(90deg,#ef4444,#f97316);border-radius:99px}
.stm-level-heading{display:flex;align-items:center;justify-content:space-between;gap:8px;margin:0 2px 8px}
.stm-level-heading h2{margin:0;font-size:1.2rem}
#unlocked-label{font-size:.76rem;font-weight:800;color:var(--theme-muted)}
.stm-level-grid{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:7px;padding:5px;border-radius:14px;background:rgba(255,255,255,.28);}
.stm-level-button{min-width:0;min-height:48px;border:1px solid #e7a11a;background:var(--theme-card);border-radius:12px;padding:6px 2px;font-weight:900;font-size:.82rem;line-height:1;color:var(--theme-muted);box-shadow:0 2px 5px rgba(0,0,0,.12);cursor:pointer;box-sizing:border-box;transition:transform .08s ease}
.stm-level-button.unlocked{background:var(--theme-card)}
.stm-level-button.current{background:var(--theme-primary);color:#fff;border-color:var(--theme-primary-dark)}
.stm-level-button.completed{background:#10b981;color:#fff;border-color:#047857}
.stm-level-button.locked{background:#eadcc1;color:#9a846a;cursor:not-allowed;box-shadow:none}
.stm-level-button:active{transform:scale(.96)}

.stm-game-topbar{margin-bottom:7px;min-height:42px}
.stm-small-button{border:0;border-radius:999px;background:var(--theme-card);color:var(--theme-muted);font-weight:850;padding:9px 13px;box-shadow:0 3px 9px rgba(0,0,0,.15);cursor:pointer}
.stm-game-level{font-weight:900;color:var(--theme-primary-dark)}
.stm-best{font-size:.82rem;font-weight:800;color:var(--theme-muted)}
.stm-status-panel{width:100%;min-height:46px;display:flex;flex-direction:column;justify-content:center;gap:3px;padding:9px 11px;background:var(--theme-card);border-radius:14px;box-shadow:0 5px 14px rgba(0,0,0,.14);border:2px solid var(--theme-panel-border);margin-bottom:10px}
.stm-status-row{width:100%;display:flex;justify-content:space-between;align-items:center;gap:10px}
.stm-time{font-weight:850;color:#374151;white-space:nowrap;font-size:.9rem}.stm-time span{color:var(--red)}
.stm-message{font-weight:900;color:#ea580c;text-align:center;font-size:.9rem;min-height:1.15em}.stm-best{font-size:.82rem;font-weight:800;color:var(--theme-muted);white-space:nowrap}
#spiceMazeCanvas{display:block;width:min(100%,520px);height:auto;aspect-ratio:9/16;margin:0 auto;background:var(--theme-card);border:6px solid var(--theme-border);border-radius:16px;box-shadow:0 10px 20px rgba(0,0,0,.28),inset 0 0 15px rgba(180,83,9,.5);touch-action:none}
.stm-controls{width:100%;display:flex;flex-wrap:wrap;justify-content:center;align-items:center;gap:8px;margin-top:10px}
.stm-primary-button,.stm-secondary-button{border:0;color:#fff;font-weight:900;font-size:1rem;padding:12px 25px;border-radius:999px;cursor:pointer;box-shadow:0 6px 13px rgba(0,0,0,.22)}
.stm-primary-button{background:var(--theme-primary)}.stm-secondary-button{background:var(--theme-goal)}
.stm-dpad{width:190px;margin:11px auto 0;padding:9px;border-radius:16px;background:var(--theme-dpad);box-shadow:0 12px 24px rgba(0,0,0,.28);display:flex;flex-direction:column;align-items:center;gap:5px}
.stm-dpad-row{display:flex;gap:6px}.stm-dpad-button{width:54px;height:54px;border:0;background:var(--theme-dpad-button);color:#fff;font-size:1.5rem;font-weight:900;border-radius:10px;box-shadow:0 4px 7px rgba(0,0,0,.22);user-select:none;touch-action:manipulation}.stm-dpad-button:active{transform:scale(.94)}.stm-dpad-spacer{width:54px;height:54px}
.stm-help{text-align:center;color:rgba(127,29,29,.82);font-size:.78rem;font-weight:650;margin-top:8px}
.stm-modal{position:fixed;inset:0;z-index:99999;background:rgba(40,20,0,.48);display:flex;align-items:flex-end;justify-content:center;padding:12px}
.stm-modal-card{width:min(100%,560px);max-height:82vh;overflow:auto;background:#fffaf0;border-radius:20px 20px 12px 12px;padding:15px;box-shadow:0 20px 60px rgba(0,0,0,.3)}
.stm-modal-head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:8px}.stm-modal-head h2{margin:0;color:var(--theme-primary-dark);font-size:1.3rem}
.stm-setting-row{width:100%;display:flex;align-items:center;justify-content:space-between;border:0;border-bottom:1px solid #ead8b8;background:transparent;padding:15px 4px;text-align:left;font-size:1rem;font-weight:800;color:#4b3324;cursor:pointer}.stm-setting-row.danger{color:#b91c1c}
.stm-content-body{font-size:.9rem;line-height:1.6;color:#4b3324}.stm-content-body h1,.stm-content-body h2,.stm-content-body h3{color:var(--theme-primary-dark)}
@media(max-width:420px){.stm-container{padding:9px 9px 22px}.stm-level-grid{grid-template-columns:repeat(5,minmax(0,1fr));gap:6px}.stm-level-button{min-height:44px;padding:7px 1px;font-size:.74rem}.stm-instructions{font-size:.84rem}.stm-modal{padding:8px}.stm-modal-card{padding:13px}}
.stm-pause-button{border:0;border-radius:999px;background:#7c2d12;color:#fff;font-weight:900;padding:9px 12px;box-shadow:0 3px 9px rgba(0,0,0,.18);cursor:pointer;white-space:nowrap}
.stm-pause-button:active{transform:scale(.96)}
.stm-pause-card{text-align:center;max-width:380px;align-self:center;border-radius:20px}
.stm-pause-card .stm-modal-head{justify-content:center}.stm-pause-card h2{font-size:1.55rem}
.stm-pause-text{font-weight:700;color:#6b4b36;margin:5px 0 16px}.stm-pause-actions{display:flex;flex-direction:column;gap:9px}
.stm-pause-actions button{width:100%}
@media(max-width:420px){.stm-pause-button{padding:8px 9px;font-size:.78rem}.stm-best{font-size:.72rem}}


/* Classic pause icon: drawn with CSS so it does not depend on a modern/emoji font. */
.stm-pause-button{display:inline-flex;align-items:center;justify-content:center;gap:7px;}
.stm-pause-icon{display:inline-flex;width:12px;height:15px;gap:3px;flex:0 0 auto;}
.stm-pause-icon::before,.stm-pause-icon::after{content:'';display:block;width:4px;height:15px;background:currentColor;border-radius:0;}


.stm-level-load-area{display:flex;flex-direction:column;align-items:center;gap:8px;margin:12px 2px 4px;}
.stm-levels-loaded-label{font-size:.75rem;font-weight:800;color:var(--theme-muted);text-align:center;}
.stm-load-more-button{border:0;border-radius:999px;background:var(--theme-primary);color:#fff;font-weight:900;font-size:.92rem;padding:11px 20px;box-shadow:0 4px 10px rgba(0,0,0,.18);cursor:pointer;min-width:220px;}
.stm-load-more-button:active{transform:scale(.97)}
.stm-load-more-button:disabled{opacity:.7;cursor:wait}
.stm-load-more-button.stm-loading{background:#b45309}

.stm-theme-card{align-self:center;max-width:430px}.stm-theme-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}.stm-theme-option{border:2px solid #ead8b8;background:var(--theme-card);border-radius:14px;padding:10px;display:flex;align-items:center;gap:10px;cursor:pointer;color:var(--theme-text);font-weight:900}.stm-theme-option.selected{border-color:var(--theme-primary);box-shadow:0 0 0 2px color-mix(in srgb,var(--theme-primary) 20%,transparent)}.stm-theme-swatch{width:42px;height:42px;border-radius:10px;display:block;flex:0 0 auto;border:2px solid rgba(0,0,0,.12)}.stm-theme-swatch.classic{background:linear-gradient(135deg,#fff1c9,#ffd34f)}.stm-theme-swatch.ocean{background:linear-gradient(135deg,#dff7ff,#7dd3fc)}.stm-theme-swatch.forest{background:linear-gradient(135deg,#ecfdf5,#86efac)}.stm-theme-swatch.sunset{background:linear-gradient(135deg,#fff1f2,#fdba74)}.stm-theme-swatch.midnight{background:linear-gradient(135deg,#111827,#312e81)}
@media(max-width:420px){.stm-game-actions{gap:5px}.stm-theme-small-button{padding:8px 8px;font-size:.7rem}.stm-theme-grid{gap:8px}.stm-theme-option{padding:8px;font-size:.82rem}.stm-theme-swatch{width:36px;height:36px}}


/* Theme-aware text contrast fixes, especially for the dark Purple theme. */
.stm-title{color:var(--theme-text)!important}
.stm-instructions ol,.stm-setting-row,.stm-content-body,.stm-pause-text{color:var(--theme-text)}
.stm-time{color:var(--theme-text)}
.stm-message{color:var(--theme-primary-dark)}
.stm-help{color:var(--theme-muted)}
.stm-instructions,.stm-progress-card,.stm-status-panel,.stm-level-button,.stm-theme-option{color:var(--theme-text)}
body[data-theme="midnight"] .stm-progress-card{background:#1f2937;color:#f8fafc}
body[data-theme="midnight"] .stm-progress-track{background:#374151}
body[data-theme="midnight"] .stm-level-grid{background:rgba(15,23,42,.38)}
body[data-theme="midnight"] .stm-level-button.locked{background:#374151;color:#cbd5e1;border-color:#475569}
body[data-theme="midnight"] .stm-instructions{border-color:#6366f1}
body[data-theme="midnight"] .stm-modal-card{background:#1f2937;color:#f8fafc}
body[data-theme="midnight"] .stm-modal-head h2,body[data-theme="midnight"] .stm-content-body h1,body[data-theme="midnight"] .stm-content-body h2,body[data-theme="midnight"] .stm-content-body h3{color:#ddd6fe}
body[data-theme="midnight"] .stm-setting-row,body[data-theme="midnight"] .stm-content-body,body[data-theme="midnight"] .stm-pause-text{color:#f8fafc}
body[data-theme="midnight"] .stm-theme-option{background:#111827;color:#f8fafc;border-color:#4b5563}
body[data-theme="midnight"] .stm-icon-button{background:#374151;color:#f8fafc}
body[data-theme="midnight"] .stm-time span{color:#fda4af}

.stm-timeout-card{align-self:center;max-width:430px;text-align:center}
.stm-timeout-card .stm-modal-head{justify-content:center}
.stm-timeout-card .stm-modal-head h2{color:var(--theme-primary-dark)}
.stm-timeout-status{min-height:1.3em;font-size:.82rem;font-weight:800;color:var(--theme-muted);margin:8px 0}
.stm-timeout-actions{display:flex;flex-direction:column;gap:10px}
.stm-timeout-actions button{width:100%}
.stm-timeout-actions button:disabled{opacity:.6;cursor:wait}

/* 3D board presentation: raised frame, deep bevel and tactile controls. */
#spiceMazeCanvas{
  border-width:7px;
  border-radius:18px;
  box-shadow:0 16px 0 rgba(80,45,15,.22),0 22px 30px rgba(0,0,0,.28),inset 0 2px 5px rgba(255,255,255,.55);
  transform:perspective(900px) rotateX(1.2deg);
}
.stm-dpad-button{
  box-shadow:0 5px 0 rgba(0,0,0,.28),0 8px 12px rgba(0,0,0,.2),inset 0 2px 2px rgba(255,255,255,.28);
  transition:transform .09s ease,box-shadow .09s ease;
}
.stm-dpad-button:active{
  transform:translateY(3px) scale(.97);
  box-shadow:0 2px 0 rgba(0,0,0,.25),inset 0 2px 4px rgba(0,0,0,.18);
}
.stm-level-button{
  box-shadow:0 4px 0 rgba(100,55,10,.22),0 6px 10px rgba(0,0,0,.12);
}
.stm-level-button:active{transform:translateY(2px) scale(.97);box-shadow:0 1px 0 rgba(100,55,10,.2)}


/* 3D level journey: raised stepping-stone nodes along a winding adventure route. */
.stm-level-grid{
  position:relative;
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:15px 12px;
  padding:22px 12px 26px;
  border-radius:22px;
  overflow:hidden;
  background:linear-gradient(160deg,rgba(101,67,33,.16),rgba(255,255,255,.18));
  perspective:900px;
}
.stm-level-grid::before{
  content:"";
  position:absolute;
  z-index:0;
  top:0;bottom:0;left:50%;width:9px;
  transform:translateX(-50%);
  border-radius:99px;
  background:repeating-linear-gradient(to bottom,#a87945 0 13px,#e9c78b 13px 22px);
  box-shadow:inset 0 2px 3px rgba(255,255,255,.55),0 4px 7px rgba(48,29,9,.22);
  opacity:.72;
}
.stm-level-button{
  position:relative;z-index:1;
  min-height:62px;
  border:2px solid rgba(255,255,255,.72);
  border-radius:18px 18px 15px 15px;
  transform:translateY(-3px);
  box-shadow:0 7px 0 rgba(67,45,22,.28),0 11px 15px rgba(0,0,0,.18),inset 0 2px 3px rgba(255,255,255,.6);
  font-size:1rem;
  text-shadow:0 1px 1px rgba(0,0,0,.12);
  transition:transform .16s ease,filter .16s ease,box-shadow .16s ease;
}
.stm-level-button:nth-child(3n+1){transform:translateX(5px) translateY(-2px)}
.stm-level-button:nth-child(3n+2){transform:translateY(7px)}
.stm-level-button:nth-child(3n){transform:translateX(-5px) translateY(-2px)}
.stm-level-button.completed{
  background:linear-gradient(145deg,#86efac,#059669 72%,#047857);
  color:#fff;border-color:#d1fae5;
}
.stm-level-button.completed::after{content:"✓";display:block;font-size:.65rem;line-height:1;margin-top:4px;color:#ecfdf5}
.stm-level-button.current{
  background:linear-gradient(145deg,#fff1a8,#f59e0b 68%,#b45309);
  color:#4a2508;border:2px solid #fff7cc;
  box-shadow:0 8px 0 #92400e,0 13px 19px rgba(0,0,0,.24),0 0 18px rgba(251,191,36,.55),inset 0 2px 4px #fff;
  animation:stm-current-level-pulse 1.8s ease-in-out infinite;
}
.stm-level-button.current::after{content:"YOU ARE HERE";display:block;font-size:.48rem;letter-spacing:.04em;line-height:1.2;margin-top:4px;color:#78350f}
.stm-level-button.locked{
  background:linear-gradient(145deg,#e5e7eb,#9ca3af 72%,#6b7280);
  color:#f9fafb;border-color:#f3f4f6;
  box-shadow:0 6px 0 #4b5563,0 9px 12px rgba(0,0,0,.14),inset 0 2px 3px rgba(255,255,255,.55);
  text-shadow:0 1px 2px rgba(0,0,0,.35);
}
.stm-level-button.locked::after{content:"🔒";display:block;font-size:.62rem;line-height:1;margin-top:4px}
.stm-level-button:active:not(:disabled){transform:translateY(3px) scale(.97);box-shadow:0 2px 0 rgba(67,45,22,.3),inset 0 2px 4px rgba(0,0,0,.12)}
@keyframes stm-current-level-pulse{0%,100%{filter:brightness(1)}50%{filter:brightness(1.12)}}
@media(max-width:420px){
 .stm-level-grid{gap:13px 8px;padding:18px 7px 22px}
 .stm-level-button{min-height:56px;font-size:.88rem;border-radius:15px}
}
body[data-theme="midnight"] .stm-level-grid{background:linear-gradient(160deg,rgba(15,23,42,.72),rgba(51,65,85,.58))}


/* Completed levels are intentionally tucked away until the player expands them. */
.stm-completed-levels{margin:0 0 14px;border:1px solid rgba(120,80,35,.22);border-radius:16px;background:rgba(255,255,255,.34);overflow:hidden;}
.stm-completed-levels>summary{cursor:pointer;list-style:none;padding:13px 16px;font-weight:900;color:var(--theme-primary-dark);display:flex;align-items:center;justify-content:space-between;gap:10px;}
.stm-completed-levels>summary::-webkit-details-marker{display:none}
.stm-completed-levels>summary::after{content:'＋';font-size:1.1rem;font-weight:900}
.stm-completed-levels[open]>summary::after{content:'−'}
.stm-completed-levels #completed-levels-label{padding:0 14px;margin:0 0 8px}
.stm-completed-levels .stm-level-grid{margin:0 9px 10px}
.stm-completed-levels #load-completed-levels{display:block;margin:0 auto 12px}


/* HARD MODE: larger board, neon feedback and high-energy arcade styling. */
#spiceMazeCanvas{
  width:min(100%,580px)!important;
  max-width:580px;
  border:5px solid var(--theme-accent);
  border-radius:18px;
  box-shadow:
    0 0 0 3px rgba(255,255,255,.72),
    0 0 18px color-mix(in srgb,var(--theme-accent) 72%,transparent),
    0 14px 28px rgba(0,0,0,.32),
    inset 0 0 18px rgba(255,255,255,.16);
  animation:stm-board-pulse 2.2s ease-in-out infinite;
}
@keyframes stm-board-pulse{
  0%,100%{filter:saturate(1);box-shadow:0 0 0 3px rgba(255,255,255,.65),0 0 14px color-mix(in srgb,var(--theme-accent) 58%,transparent),0 14px 28px rgba(0,0,0,.30)}
  50%{filter:saturate(1.28);box-shadow:0 0 0 3px rgba(255,255,255,.9),0 0 25px color-mix(in srgb,var(--theme-accent) 88%,transparent),0 14px 30px rgba(0,0,0,.34)}
}
.stm-status-panel{
  background:linear-gradient(120deg,var(--theme-card),color-mix(in srgb,var(--theme-accent) 16%,var(--theme-card)));
  border:2px solid var(--theme-accent);
  box-shadow:0 5px 15px rgba(0,0,0,.16),0 0 12px color-mix(in srgb,var(--theme-accent) 28%,transparent);
  transition:background .2s ease,border-color .2s ease,box-shadow .2s ease;
}
.stm-time{
  padding:5px 10px;
  border-radius:999px;
  background:color-mix(in srgb,var(--theme-accent) 16%,var(--theme-card));
  border:1px solid color-mix(in srgb,var(--theme-accent) 55%,transparent);
}
.stm-time span{font-variant-numeric:tabular-nums;font-weight:950;color:var(--theme-primary)}
.stm-time-warning{
  border-color:#f59e0b!important;
  background:linear-gradient(110deg,#fff7ed,#fef3c7)!important;
  box-shadow:0 0 16px rgba(245,158,11,.38)!important;
}
.stm-time-warning .stm-time span{color:#c2410c!important}
.stm-time-critical{
  border-color:#ef4444!important;
  background:linear-gradient(110deg,#fff1f2,#fee2e2)!important;
  box-shadow:0 0 22px rgba(239,68,68,.55)!important;
  animation:stm-danger-pulse .55s ease-in-out infinite alternate;
}
.stm-time-critical .stm-time span{color:#dc2626!important}
@keyframes stm-danger-pulse{from{transform:scale(1)}to{transform:scale(1.018)}}
.stm-dpad{
  border:2px solid color-mix(in srgb,var(--theme-accent) 65%,white);
  box-shadow:0 12px 25px rgba(0,0,0,.28),0 0 18px color-mix(in srgb,var(--theme-accent) 38%,transparent);
}
.stm-dpad-button{
  background:linear-gradient(145deg,var(--theme-accent),var(--theme-primary));
  border:1px solid rgba(255,255,255,.35);
  box-shadow:0 4px 0 color-mix(in srgb,var(--theme-primary-dark) 78%,black),0 7px 12px rgba(0,0,0,.22);
}
.stm-dpad-button:active{transform:translateY(3px) scale(.96);box-shadow:0 1px 0 var(--theme-primary-dark)}
.stm-primary-button{
  background:linear-gradient(110deg,var(--theme-primary),var(--theme-accent));
  box-shadow:0 7px 18px color-mix(in srgb,var(--theme-primary) 35%,transparent);
}
.stm-game-level{
  padding:7px 12px;
  border-radius:999px;
  color:#fff;
  background:linear-gradient(110deg,var(--theme-primary),var(--theme-accent));
  box-shadow:0 4px 12px rgba(0,0,0,.2);
}
@media(max-width:420px){
  #spiceMazeCanvas{border-width:4px;border-radius:14px}
}
@media(prefers-reduced-motion:reduce){
  #spiceMazeCanvas,.stm-time-critical{animation:none!important}
}

/* Direct-touch portrait board: no on-screen arrow pad. */
#d-pad{display:none!important}
.stm-help{margin:6px auto 0;text-align:center;font-size:.76rem;font-weight:800;letter-spacing:.01em}
#spiceMazeCanvas{aspect-ratio:9/16;max-width:100%;touch-action:none;user-select:none;-webkit-user-select:none;}
.stm-game-topbar,.stm-status-panel{position:relative;z-index:2}
@media(max-height:700px){.stm-container{padding-top:6px;padding-bottom:8px}.stm-game-topbar{margin-bottom:4px}.stm-status-panel{margin-bottom:5px;padding:6px 9px}.stm-help{margin-top:3px}}


/* FIX: enforce a true portrait canvas and prevent theme CSS from stretching it. */
#spiceMazeCanvas{display:block!important;width:min(100%,520px)!important;height:auto!important;aspect-ratio:9/16!important;max-width:100%!important;min-height:420px;background:var(--theme-canvas,#fff);touch-action:none!important;object-fit:fill;}

/* Dot Escape clean portrait board polish */
.stm-container{max-width:560px;padding:10px 10px 22px}
.stm-game-topbar{min-height:48px;margin:0 0 9px;align-items:center}
.stm-game-level{font-size:1.18rem;letter-spacing:.01em}
.stm-small-button,.stm-pause-button{min-height:42px}
.stm-status-panel{min-height:58px;padding:10px 13px;margin-bottom:10px;border:2px solid var(--theme-primary);border-radius:16px;background:var(--theme-card);box-shadow:0 5px 14px rgba(15,23,42,.12)}
.stm-time{font-size:1rem;font-weight:900}
.stm-time span{font-variant-numeric:tabular-nums;font-size:1.08rem;color:var(--theme-primary)}
.stm-message{font-size:.95rem;min-height:1.2em}
#spiceMazeCanvas{display:block;width:min(100%,520px);height:auto;aspect-ratio:9/16;margin:0 auto;background:#f4f7fb;border:4px solid #172b46;border-radius:18px;box-shadow:0 8px 22px rgba(15,23,42,.24),0 0 0 3px rgba(255,255,255,.72);touch-action:none;user-select:none;-webkit-user-select:none}
.stm-help{margin:10px auto 0;padding:8px 12px;max-width:520px;border-radius:999px;background:rgba(255,255,255,.78);color:var(--theme-text);font-size:.84rem;font-weight:850;box-shadow:0 3px 10px rgba(15,23,42,.08)}
.stm-time-warning{border-color:#f59e0b!important;box-shadow:0 0 0 3px rgba(245,158,11,.12),0 5px 14px rgba(15,23,42,.12)!important}
.stm-time-critical{border-color:#ef4444!important;animation:stmTimerPulse .65s ease-in-out infinite alternate}
@keyframes stmTimerPulse{from{box-shadow:0 0 0 2px rgba(239,68,68,.10)}to{box-shadow:0 0 0 6px rgba(239,68,68,.24)}}
@media(max-width:420px){.stm-container{padding:8px 8px 18px}.stm-game-level{font-size:1.05rem}.stm-status-panel{margin-bottom:9px}.stm-help{font-size:.78rem}}

/* Dot Escape device-adaptive square board: final override of legacy portrait/3D rules */
#spiceMazeCanvas{
  display:block!important;
  width:min(100%,520px)!important;
  max-width:100%!important;
  height:auto!important;
  aspect-ratio:1 / 1!important;
  min-height:0!important;
  box-sizing:border-box!important;
  border:0!important;
  outline:4px solid #263b59!important;
  outline-offset:-4px!important;
  border-radius:18px!important;
  transform:none!important;
  filter:none!important;
  background:#f4f7fb!important;
  box-shadow:0 8px 22px rgba(15,23,42,.18),0 0 0 3px rgba(255,255,255,.9)!important;
  touch-action:none!important;
  user-select:none!important;
  -webkit-user-select:none!important;
  -webkit-touch-callout:none!important;
  cursor:grab;
}
#spiceMazeCanvas.stm-dragging{cursor:grabbing;box-shadow:0 0 0 4px rgba(249,115,22,.24),0 10px 26px rgba(15,23,42,.24)!important}
.stm-container{width:100%;max-width:560px;margin:0 auto;padding:8px 12px 18px;box-sizing:border-box}
.stm-game-topbar,.stm-status-panel{width:100%;box-sizing:border-box}
.stm-status-panel{margin:8px 0 10px}
.stm-help{max-width:520px;margin:10px auto 0;text-align:center;line-height:1.35}
@media(max-width:420px){
  .stm-container{padding:6px 10px 14px}
  #spiceMazeCanvas{outline-width:3px!important;border-radius:14px!important}
  .stm-game-topbar{gap:6px}
  .stm-status-panel{padding:8px 10px}
}

/* FINAL: true vertical mobile maze, retaining the full dense 65x65 layout */
#spiceMazeCanvas{
 display:block!important;
 width:min(100%,520px)!important;
 max-width:100%!important;
 height:auto!important;
 aspect-ratio:9 / 16!important;
 min-height:0!important;
 box-sizing:border-box!important;
 margin:0 auto!important;
 border:4px solid #182b49!important;
 border-radius:16px!important;
 outline:0!important;
 transform:none!important;
 filter:none!important;
 background:#f4f7fb!important;
 box-shadow:0 8px 22px rgba(15,23,42,.22),0 0 0 3px rgba(255,255,255,.92)!important;
 touch-action:none!important;
 user-select:none!important;
 -webkit-user-select:none!important;
 -webkit-touch-callout:none!important;
}
#spiceMazeCanvas.stm-dragging{
 box-shadow:0 0 0 4px rgba(255,23,79,.20),0 10px 26px rgba(15,23,42,.25)!important;
}
.stm-container{width:100%;max-width:560px;margin:0 auto;padding:8px 10px 14px;box-sizing:border-box}
.stm-game-topbar,.stm-status-panel{width:100%;box-sizing:border-box}
.stm-status-panel{margin:7px 0 9px}
.stm-help{max-width:520px;margin:8px auto 0;text-align:center;line-height:1.3}
@media(max-width:420px){
 .stm-container{padding:5px 8px 10px}
 #spiceMazeCanvas{border-width:3px!important;border-radius:12px!important}
 .stm-status-panel{padding:7px 9px;margin:5px 0 7px}
 .stm-help{font-size:.76rem;margin-top:6px}
}

/* Reference-matched vertical board and fully theme-reactive presentation */
#spiceMazeCanvas{
 display:block!important;width:min(100%,520px)!important;max-width:100%!important;
 height:auto!important;aspect-ratio:9 / 16!important;min-height:0!important;
 box-sizing:border-box!important;margin:0 auto!important;
 border:5px solid var(--theme-border)!important;border-radius:18px!important;
 outline:0!important;transform:none!important;filter:none!important;
 background:var(--theme-canvas)!important;
 box-shadow:0 9px 20px rgba(15,23,42,.20),0 0 0 3px rgba(255,255,255,.88)!important;
 touch-action:none!important;user-select:none!important;-webkit-user-select:none!important;
 -webkit-touch-callout:none!important;
}
.stm-container{width:100%;max-width:560px;margin:0 auto;padding:7px 10px 14px;box-sizing:border-box}
.stm-game-topbar,.stm-status-panel{width:100%;box-sizing:border-box}
.stm-status-panel{margin:7px 0 9px;background:var(--theme-card)!important;border-color:var(--theme-panel-border)!important}
.stm-help{max-width:520px;margin:8px auto 0;text-align:center;line-height:1.3;color:var(--theme-muted)!important}
body.stm-game-page{background:linear-gradient(180deg,var(--theme-page-start),var(--theme-page-end))!important;color:var(--theme-text)!important}
.stm-game-page .stm-game-topbar,.stm-game-page .stm-level-header{color:var(--theme-text)}
.stm-game-page button{transition:transform .12s ease,filter .12s ease}
.stm-game-page button:active{transform:scale(.97)}
@media(max-width:420px){
 .stm-container{padding:5px 8px 10px}
 #spiceMazeCanvas{border-width:4px!important;border-radius:14px!important}
 .stm-status-panel{padding:7px 9px;margin:5px 0 7px}
 .stm-help{font-size:.76rem;margin-top:6px}
}

/* Version 4.1: raised 3D board frame, keeping the reference layout */
#spiceMazeCanvas{
 border:5px solid var(--theme-border)!important;
 border-radius:18px!important;
 box-shadow:
   0 5px 0 color-mix(in srgb,var(--theme-primary-dark) 65%,#241307),
   0 11px 20px rgba(20,10,5,.28),
   0 0 0 3px rgba(255,255,255,.82)!important;
 transform:none!important;
}

/* Themed level-complete popup: keep actions inside the modal, never below the board */
.stm-win-card{
  align-self:center!important;
  width:min(92%,440px)!important;
  max-height:80vh;
  border:3px solid var(--theme-panel-border)!important;
  border-radius:24px!important;
  padding:22px 18px 20px!important;
  text-align:center;
  color:var(--theme-text)!important;
  background:var(--theme-card)!important;
  box-shadow:0 22px 60px rgba(0,0,0,.34),inset 0 2px 0 rgba(255,255,255,.7)!important;
  animation:stmWinPopupIn .22s ease-out both;
}
.stm-win-card .stm-modal-head{justify-content:center;margin:5px 0 6px}
.stm-win-card .stm-modal-head h2{font-size:1.45rem;color:var(--theme-primary-dark)!important}
.stm-win-card .stm-pause-text{color:var(--theme-text)!important;margin:8px 0 18px}
.stm-win-burst{
  width:66px;height:66px;margin:0 auto 8px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;
  color:#fff;font-size:2.2rem;
  background:radial-gradient(circle at 32% 25%,#fff7c2 0%,var(--theme-accent) 36%,var(--theme-primary-dark) 100%);
  box-shadow:0 6px 0 color-mix(in srgb,var(--theme-primary-dark) 72%,#241307),0 10px 20px rgba(0,0,0,.22),inset 0 2px 5px rgba(255,255,255,.7);
}
.stm-win-actions{display:flex;flex-direction:column;gap:10px}
.stm-win-actions button{width:100%;min-height:48px}
.stm-win-actions .stm-primary-button{background:var(--theme-primary)!important;color:var(--theme-button-text)!important}
.stm-win-actions .stm-secondary-button{background:var(--theme-goal)!important;color:#fff!important}
@keyframes stmWinPopupIn{from{opacity:0;transform:translateY(14px) scale(.96)}to{opacity:1;transform:translateY(0) scale(1)}}
