/* ===== CLAYMORPHISM DESIGN SYSTEM =====
   Palette: warm pastel clay world — everything soft, puffy, squishable.
   No sharp edges. Every surface feels like it could dent if you pressed it.
*/
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@600;700;800;900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&display=swap');

:root{
  /* Core clay palette */
  --bg:         #F2EBE0;        /* warm parchment — the table the clay sits on */
  --bg-deep:    #E8DDD0;        /* slightly darker for depth */
  --clay-cream: #FFF8F0;        /* lightest clay surface */
  --clay-bone:  #F5E6D3;        /* main neutral block */
  --clay-blue:  #89C4E1;        /* player — sky blue clay */
  --clay-coral: #F4967A;        /* key / accent warm */
  --clay-mint:  #7ECBA1;        /* gate / green elements */
  --clay-lav:   #C4A8E0;        /* numbered — soft purple */
  --clay-gold:  #F4CC6B;        /* clear burst, win */
  --clay-steel: #9BAFC0;        /* anchor — muted steel */
  --clay-teal:  #6BBFBD;        /* accent / plate */
  --clay-glass: #B8E4EE;        /* glass — icy pale */
  --clay-heavy: #8A9BAA;        /* heavy — dark clay */

  /* Drop shadows that make things look pressed from clay */
  --shadow-sm:  0 4px 0 rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.08);
  --shadow-md:  0 6px 0 rgba(0,0,0,0.14), 0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg:  0 8px 0 rgba(0,0,0,0.15), 0 6px 24px rgba(0,0,0,0.12);
  --shadow-inset: inset 0 2px 6px rgba(255,255,255,0.6), inset 0 -2px 4px rgba(0,0,0,0.08);

  /* Text */
  --text-dark:  #4A3728;
  --text-mid:   #7A6355;
  --text-light: #A89080;

  /* Radii — generously round, everything is a blob */
  --r-sm:  12px;
  --r-md:  20px;
  --r-lg:  28px;
  --r-xl:  40px;

  /* ----- Theme hooks -----
     Every neutral clay surface, menu backdrop and editor panel reads one of
     these instead of a hardcoded colour, so the dark theme (body.theme-dark,
     near the end of this file) is a single palette override. Light values
     below reproduce the original look exactly. */
  --clay-surface: linear-gradient(160deg,#fff 0%,var(--clay-cream) 100%); /* puffy neutral surface (was #fff→cream) */
  --menu-glow: #FFF5EA;          /* warm centre of the full-screen menu radials */
  --menu-edge: var(--bg-deep);   /* their darker outer edge */
  --panel:     rgba(255,248,240,0.92); /* translucent editor panels */
}

*{margin:0;padding:0;box-sizing:border-box;-webkit-tap-highlight-color:transparent}
/* Kill the grey/blue box mobile WebKit paints over tapped interactive elements. */
button,a,input,select,textarea,[role="button"],.ed-tool,.cl-filter,.level-cell,
.clay-toggle,.world-card,.rate-star{-webkit-tap-highlight-color:transparent}
html,body{
  height:100%;overflow:hidden;
  background:var(--bg);
  font-family:'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
  color:var(--text-dark);
}
#app{position:fixed;inset:0;touch-action:none}
canvas{display:block;touch-action:none}

/* ===== HUD — clay pill labels ===== */
.hud{position:fixed;left:0;right:0;pointer-events:none;user-select:none}
.top{
  top:0;padding:18px 20px;
  display:flex;justify-content:space-between;align-items:flex-start;
  pointer-events:none;
}

/* Logo pill */
.title-pill{
  background:var(--clay-cream);
  border-radius:var(--r-xl);
  padding:10px 20px 12px;
  box-shadow:var(--shadow-md);
  display:inline-block;
}
.title{
  font-size:18px;font-weight:900;letter-spacing:.3em;
  color:var(--clay-blue);
  text-shadow:0 2px 0 rgba(0,0,0,0.10);
  padding-left:.3em;
}
.sub{
  font-size:9px;font-weight:700;letter-spacing:.18em;
  color:var(--text-light);margin-top:2px;text-transform:uppercase;
}

/* Info pill — top right */
.goal-pill{
  background:var(--clay-cream);
  border-radius:var(--r-xl);
  padding:10px 16px 12px;
  box-shadow:var(--shadow-md);
  text-align:right;
  display:inline-block;
}
.goal{font-size:10px;font-weight:700;letter-spacing:.1em;color:var(--text-mid);line-height:1.7}
.goal b{color:var(--clay-coral);font-weight:800}

/* ===== Bottom bar ===== */
.bottom{
  bottom:0;padding:16px 20px 22px;
  display:flex;justify-content:space-between;align-items:flex-end;
}

/* Moves counter — little clay chip */
.moves-chip{
  background:var(--clay-cream);
  border-radius:var(--r-lg);
  padding:10px 18px 13px;
  box-shadow:var(--shadow-sm);
  pointer-events:none;
}
.moves-label{font-size:9px;font-weight:800;letter-spacing:.22em;color:var(--text-light);text-transform:uppercase}
.moves-num{font-size:28px;font-weight:900;color:var(--text-dark);line-height:1;margin-top:2px}

/* Clay buttons — the signature element: puffy with a thick bottom shadow */
.controls{display:flex;gap:10px;pointer-events:auto}
button{
  pointer-events:auto;
  background:var(--clay-cream);
  border:none;
  color:var(--text-mid);
  font-family:'Nunito',sans-serif;
  font-size:10px;font-weight:800;
  letter-spacing:.16em;
  padding:11px 16px 14px;
  border-radius:var(--r-lg);
  cursor:pointer;
  box-shadow:var(--shadow-sm);
  transition:transform .12s, box-shadow .12s;
  text-transform:uppercase;
  /* inner highlight — clay's soft top face */
  background: var(--clay-surface);
}
button:hover{
  transform:translateY(-2px);
  box-shadow:0 8px 0 rgba(0,0,0,0.14), 0 4px 18px rgba(0,0,0,0.10);
  color:var(--text-dark);
}
button:active{
  transform:translateY(3px);
  box-shadow:0 2px 0 rgba(0,0,0,0.14), 0 1px 6px rgba(0,0,0,0.08);
}
button:focus-visible{outline:3px solid var(--clay-blue);outline-offset:3px}

/* Character-switch button — only shown in split levels (two halves on the
   board). Tinted player-blue so it reads as "this is about your characters",
   and it pulses to pull the eye toward the new control. */
#switchBtn{
  background:linear-gradient(160deg,#B7E0F2 0%,var(--clay-blue) 100%);
  color:#1C4A63;
}
#switchBtn.attention{animation:switchPulse 1.15s ease-in-out infinite}
#switchBtn:hover,#switchBtn:active{animation:none}
@keyframes switchPulse{
  0%,100%{transform:translateY(0);   box-shadow:0 5px 0 rgba(50,110,140,.30), 0 0 0 0 rgba(137,196,225,.60)}
  50%    {transform:translateY(-2px);box-shadow:0 7px 0 rgba(50,110,140,.30), 0 0 0 9px rgba(137,196,225,0)}
}

/* Merge prompt — appears (top-centre, below the title pills) when a level
   only counts the win once the two halves have fused back into one. */
#mergeHint{
  position:fixed;left:50%;top:88px;transform:translateX(-50%);
  display:none;align-items:center;gap:8px;
  background:linear-gradient(160deg,#FFE2D6 0%,var(--clay-coral) 100%);
  color:#7A3020;font-family:'Nunito',sans-serif;font-size:11px;font-weight:800;
  letter-spacing:.12em;text-transform:uppercase;line-height:1;
  padding:10px 16px 12px;border-radius:var(--r-lg);
  box-shadow:0 5px 0 rgba(140,40,0,.18), 0 6px 18px rgba(0,0,0,.12);
  pointer-events:none;z-index:40;
  animation:mergePulse 1.5s ease-in-out infinite;
}
#mergeHint.show{display:inline-flex}
#mergeHint .mh-icon{font-size:14px;line-height:1}
@keyframes mergePulse{
  0%,100%{opacity:.9;transform:translateX(-50%) translateY(0)}
  50%    {opacity:1; transform:translateX(-50%) translateY(-2px)}
}

/* ===== Hint ===== */
.hint{
  position:fixed;left:50%;transform:translateX(-50%);
  bottom:90px;text-align:center;
  pointer-events:none;transition:opacity .5s;
}
.keys{display:inline-flex;gap:6px;margin-bottom:8px}
.key{
  width:30px;height:30px;
  background:var(--clay-surface);
  border-radius:var(--r-sm);
  box-shadow:var(--shadow-sm);
  display:grid;place-items:center;
  font-size:14px;color:var(--text-mid);font-weight:700;
}
.hint-text{
  font-size:10px;font-weight:700;letter-spacing:.15em;
  color:var(--text-light);text-transform:uppercase;
}

/* ===== Win Banner ===== */
.banner{
  position:fixed;inset:0;display:grid;place-items:center;
  pointer-events:none;opacity:0;transition:opacity .5s, visibility .5s;
  visibility:hidden;
  /* frosted clay overlay */
  background:rgba(242,235,224,0.85);
  backdrop-filter:blur(8px);
}
.banner.show{opacity:1;pointer-events:auto;visibility:visible}
.banner-inner{text-align:center}

.banner-card{
  background:var(--clay-surface);
  border-radius:var(--r-xl);
  padding:40px 52px 44px;
  box-shadow:var(--shadow-lg), 0 0 0 3px rgba(255,255,255,0.8);
  display:inline-block;
}
.banner h1{
  font-size:36px;font-weight:900;letter-spacing:.28em;
  color:var(--clay-gold);
  text-shadow:0 4px 0 rgba(0,0,0,0.10);
  padding-left:.28em;
}
.banner p{
  font-size:11px;font-weight:700;letter-spacing:.2em;
  color:var(--text-mid);margin-top:12px;text-transform:uppercase;
}
.banner button{
  margin-top:28px;
  background:linear-gradient(160deg,#ffe79a,var(--clay-gold));
  color:var(--text-dark);
  box-shadow:0 6px 0 rgba(180,140,0,0.35), 0 4px 16px rgba(0,0,0,0.12);
  font-size:11px;letter-spacing:.2em;padding:13px 28px 16px;
}
.banner button:hover{
  box-shadow:0 9px 0 rgba(180,140,0,0.35), 0 6px 20px rgba(0,0,0,0.14);
  transform:translateY(-2px);
  color:var(--text-dark);
}

/* ===== Menu screens ===== */
.menu{
  position:fixed;inset:0;
  background:var(--bg);
  z-index:20;
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  padding:40px;text-align:center;
  transition:opacity .35s, visibility .35s;
  /* subtle radial warm glow from center */
  background:radial-gradient(ellipse 70% 60% at 50% 45%, var(--menu-glow) 0%, var(--menu-edge) 100%);
}
/* visibility:hidden cascades to ALL descendants, blocking hover/click on buttons inside */
.menu.hidden{opacity:0;visibility:hidden}

/* Big brand mark — like a clay stamp */
.menu .brand{
  font-size:72px;font-weight:900;letter-spacing:.35em;
  background:linear-gradient(160deg,var(--clay-blue),#5BA8D4);
  -webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text;
  text-shadow:none;
  margin-bottom:0;padding-left:.35em;
  filter:drop-shadow(0 4px 0 rgba(0,0,0,0.10));
}
.menu .tag{
  font-size:11px;font-weight:800;letter-spacing:.28em;
  color:var(--text-light);margin-bottom:42px;text-transform:uppercase;
}
.menu .mlabel{
  font-size:10px;font-weight:800;letter-spacing:.28em;
  color:var(--text-light);margin-bottom:22px;text-transform:uppercase;
}
.menu .back{
  position:absolute;top:24px;left:24px;
  background:var(--clay-surface);
  border-radius:var(--r-xl);
  box-shadow:var(--shadow-sm);
  color:var(--text-mid);
  font-size:10px;font-weight:800;letter-spacing:.14em;
  padding:10px 18px 13px;
}

/* World cards — clay tiles that look pressable */
.world-grid{display:flex;gap:18px;flex-wrap:wrap;justify-content:center}
.world-card{
  width:220px;
  padding:24px 22px 28px;
  background:var(--clay-surface);
  border-radius:var(--r-lg);
  box-shadow:var(--shadow-md);
  cursor:pointer;
  transition:transform .15s, box-shadow .15s;
  text-align:left;
  position:relative;overflow:hidden;
}
/* colored top stripe per world */
.world-card::before{
  content:'';position:absolute;top:0;left:0;right:0;height:5px;
  border-radius:var(--r-lg) var(--r-lg) 0 0;
  background:var(--card-accent,var(--clay-blue));
}
.world-card:hover{transform:translateY(-4px);box-shadow:0 10px 0 rgba(0,0,0,0.13),0 6px 24px rgba(0,0,0,0.11)}
.world-card:active{transform:translateY(2px);box-shadow:var(--shadow-sm)}
.world-card .wnum{font-size:10px;font-weight:800;letter-spacing:.28em;color:var(--text-light);text-transform:uppercase;margin-top:4px}
.world-card .wname{font-size:20px;font-weight:900;letter-spacing:.08em;color:var(--text-dark);margin:8px 0 10px}
.world-card .wdesc{font-size:11px;font-weight:600;line-height:1.65;color:var(--text-mid)}
.world-card .wmeta{
  font-size:9px;font-weight:800;letter-spacing:.18em;
  color:var(--card-accent,var(--clay-blue));
  margin-top:16px;text-transform:uppercase;
}

/* Level select — a grid of clay pills */
.level-grid{
  display:grid;grid-template-columns:repeat(5,90px);
  gap:12px;justify-content:center;max-width:570px;
}
.level-cell{
  height:90px;
  background:var(--clay-surface);
  border-radius:var(--r-md);
  box-shadow:var(--shadow-sm);
  cursor:pointer;
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:5px;
  transition:transform .14s, box-shadow .14s;
}
.level-cell:hover{transform:translateY(-3px);box-shadow:var(--shadow-md)}
.level-cell:active{transform:translateY(2px);box-shadow:0 2px 0 rgba(0,0,0,0.12)}
.level-cell .lnum{font-size:26px;font-weight:900;color:var(--text-dark)}
.level-cell .lname{font-size:8px;font-weight:700;letter-spacing:.06em;color:var(--text-light);text-align:center;padding:0 5px;line-height:1.3;text-transform:uppercase}

/* Start button */
.menu .startbtn{
  margin-top:36px;font-size:11px;letter-spacing:.22em;padding:14px 30px 17px;
  background:linear-gradient(160deg,var(--clay-blue),#6AB8D4);
  color:#fff;font-weight:800;
  box-shadow:0 6px 0 rgba(0,90,140,0.25), 0 4px 16px rgba(0,0,0,0.12);
}
.menu .startbtn:hover{
  box-shadow:0 9px 0 rgba(0,90,140,0.28), 0 6px 20px rgba(0,0,0,0.14);
  color:#fff;
}

/* ===== SPLASH SCREEN ===== */
/* ===== Intro splash: two timed panels on a clean, flat background.
   Sits above the title screen (#splash) so nothing else shows through;
   the JS driver in MenuController fades each panel in/out, then reveals
   the title screen underneath. ===== */
#intro{
  position:fixed;inset:0;z-index:200;
  background:#000;   /* black by default — shows the instant the page paints, behind the logo panel */
  display:flex;align-items:center;justify-content:center;
  transition:opacity .6s ease, background-color .9s ease;
}
#intro.intro-light{background:var(--bg)}   /* ease to the normal tone for the author panel */
#intro.fade-out{opacity:0;pointer-events:none}
#intro.gone{display:none}
.intro-panel{
  position:absolute;
  display:flex;align-items:center;justify-content:center;
  opacity:0;
  transition:opacity .9s ease;
  pointer-events:none;
}
.intro-panel.show{opacity:1}
.intro-logo{
  width:min(48vw,380px);height:auto;
  filter:drop-shadow(0 10px 28px rgba(0,0,0,0.10));
}
.intro-author{
  font-family:'Fredoka One','Nunito',sans-serif;
  font-size:clamp(30px,7vw,56px);letter-spacing:.04em;
  color:var(--text-mid);text-align:center;padding:0 24px;
}

#splash{
  position:fixed;inset:0;z-index:100;
  background:radial-gradient(ellipse 80% 70% at 50% 50%, var(--menu-glow) 0%, var(--menu-edge) 100%);
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  transition:opacity .7s ease;
}
#splash.fade-out{opacity:0;pointer-events:none}   /* fade smoothly; .gone removes it from layout after */
#splash.gone{display:none}
.splash-logo-wrap{
  display:flex;flex-direction:column;align-items:center;
  animation:splashBounce .9s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes splashBounce{
  0%{opacity:0;transform:scale(0.4) translateY(30px)}
  100%{opacity:1;transform:scale(1) translateY(0)}
}
.splash-stamp{
  width:140px;height:140px;
  background:linear-gradient(145deg,#A4D8F0 0%,#89C4E1 60%,#6AADD0 100%);
  border-radius:36px;
  box-shadow:0 10px 0 rgba(0,80,140,0.22), 0 6px 32px rgba(0,0,0,0.14), inset 0 3px 8px rgba(255,255,255,0.5);
  display:flex;align-items:center;justify-content:center;
  margin-bottom:24px;
}
.splash-stamp-letter{
  font-family:'Fredoka One','Nunito',sans-serif;
  font-size:72px;color:#fff;
  text-shadow:0 4px 0 rgba(0,60,120,0.20);
  letter-spacing:-.02em;
  line-height:1;
}
.splash-game-title{
  font-family:'Fredoka One','Nunito',sans-serif;
  font-size:52px;letter-spacing:.18em;padding-left:.18em;
  background:linear-gradient(160deg,#89C4E1,#5BA8D4);
  -webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text;
  filter:drop-shadow(0 3px 0 rgba(0,0,0,0.09));
  margin-bottom:6px;
}
.splash-tagline{
  font-size:11px;font-weight:700;letter-spacing:.3em;
  color:var(--text-light);text-transform:uppercase;margin-bottom:36px;
}
.splash-divider{
  width:180px;height:2px;
  background:linear-gradient(90deg,transparent,rgba(0,0,0,0.08),transparent);
  margin:0 auto 24px;
}
.splash-studio{
  font-size:14px;font-weight:800;letter-spacing:.06em;color:var(--text-mid);
  margin-bottom:4px;
}
.splash-author{
  font-size:11px;font-weight:600;letter-spacing:.12em;color:var(--text-light);
}
.splash-tap{
  margin-top:48px;
  font-size:10px;font-weight:800;letter-spacing:.28em;
  color:var(--text-light);text-transform:uppercase;
  animation:pulse 1.8s ease-in-out infinite;
}
@keyframes pulse{0%,100%{opacity:.4}50%{opacity:1}}

/* ---- title-screen auth (Google sign-in / guest) ---- */
.splash-auth{
  margin-top:40px;
  display:flex;flex-direction:column;align-items:center;gap:12px;width:260px;
}
.splash-btn{
  width:100%;padding:13px 20px 15px;
  border-radius:var(--r-xl);
  border:none;cursor:pointer;
  font-family:'Nunito',sans-serif;
  font-size:13px;font-weight:800;letter-spacing:.06em;
  display:flex;align-items:center;justify-content:center;gap:10px;
  transition:transform .12s, box-shadow .12s, opacity .12s;
}
.splash-btn:disabled{opacity:.5;cursor:default;transform:none}
.splash-btn-google{
  background:#fff;color:#3c4043;
  box-shadow:0 5px 0 rgba(0,0,0,0.10), 0 3px 14px rgba(0,0,0,0.10);
}
.splash-btn-google:not(:disabled):hover{transform:translateY(-2px);box-shadow:0 8px 0 rgba(0,0,0,0.10),0 5px 18px rgba(0,0,0,0.12)}
.splash-btn-google:not(:disabled):active{transform:translateY(2px);box-shadow:0 2px 0 rgba(0,0,0,0.10)}
.splash-btn-google .g-icon{flex-shrink:0;display:block}
.splash-btn-guest{
  background:var(--clay-surface);
  color:var(--text-mid);
  box-shadow:var(--shadow-sm);
  text-transform:uppercase;letter-spacing:.14em;font-size:12px;
}
.splash-btn-guest:hover{transform:translateY(-2px);box-shadow:var(--shadow-md);color:var(--text-dark)}
.splash-btn-guest:active{transform:translateY(2px);box-shadow:0 2px 0 rgba(0,0,0,0.10)}
.splash-auth-status{
  min-height:14px;
  font-size:11px;font-weight:700;letter-spacing:.04em;
  color:var(--text-light);text-align:center;
}
.splash-auth-status.is-error{color:#C2552F}

/* ---- signed-in account chip (top-right) — icon only, opens the panel ---- */
#userBadge{
  position:fixed;top:16px;right:16px;z-index:120;
  display:flex;align-items:center;justify-content:center;
  padding:3px;border:none;border-radius:50%;cursor:pointer;
  background:var(--clay-surface);
  box-shadow:var(--shadow-sm);
  transition:transform .12s, box-shadow .12s;
}
#userBadge:hover{transform:translateY(-1px);box-shadow:var(--shadow-md)}
#userBadge:active{transform:translateY(1px)}
#userBadge.hidden{display:none}
#userAvatar{
  width:34px;height:34px;border-radius:50%;object-fit:cover;flex-shrink:0;
  box-shadow:0 1px 5px rgba(0,0,0,0.22);background:#cdd6e2;display:block;
}
/* Initial-letter fallback shown when a signed-in account has no photo. */
.avatar-fallback{
  display:grid;place-items:center;flex-shrink:0;
  width:34px;height:34px;border-radius:50%;
  background:linear-gradient(160deg,var(--clay-blue),#6FA8C8);color:#fff;
  font-family:'Nunito',sans-serif;font-weight:900;font-size:15px;
  box-shadow:0 1px 5px rgba(0,0,0,0.22);text-transform:uppercase;
}
#upInitial{width:46px;height:46px;font-size:20px}

/* ---- account panel (popover under the badge) ---- */
#userPanel{
  position:fixed;top:62px;right:16px;z-index:121;
  width:248px;padding:16px;border-radius:var(--r-lg);
  background:var(--panel);box-shadow:var(--shadow-md);
  font-family:'Nunito',sans-serif;color:var(--text-dark);
}
#userPanel.hidden{display:none}
.up-head{display:flex;align-items:center;gap:11px;margin-bottom:14px}
#upAvatar{
  width:46px;height:46px;border-radius:50%;object-fit:cover;flex-shrink:0;
  box-shadow:0 1px 5px rgba(0,0,0,0.22);background:#cdd6e2;
}
.up-id{min-width:0;flex:1}
.up-name{font-weight:900;font-size:14px;letter-spacing:.02em;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.up-email{font-weight:700;font-size:10px;color:var(--text-light);margin-top:2px;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.up-stats{
  display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin-bottom:14px;
  padding:12px 4px;border-top:1px solid rgba(128,128,128,0.18);
  border-bottom:1px solid rgba(128,128,128,0.18);
}
.up-stat{display:flex;flex-direction:column;align-items:center;line-height:1.1;text-align:center}
.up-stat b{font-size:18px;font-weight:900;color:var(--text-dark)}
.up-stat small{font-size:8px;font-weight:800;letter-spacing:.08em;color:var(--text-light);
  text-transform:uppercase;margin-top:4px}
.up-signout{
  width:100%;border:none;cursor:pointer;
  padding:10px 14px 12px;border-radius:var(--r-md);
  background:linear-gradient(160deg,#FFD6CC,#F4B09A);color:#7A3020;
  box-shadow:0 4px 0 rgba(140,40,0,0.15);
  font-family:'Nunito',sans-serif;font-weight:800;font-size:11px;letter-spacing:.1em;
  text-transform:uppercase;
}
.up-signout:hover{transform:translateY(-1px)}
.up-signout:active{transform:translateY(2px);box-shadow:0 2px 0 rgba(140,40,0,0.15)}

/* ===== MAIN MENU ===== */
#mainMenu{
  position:fixed;inset:0;z-index:50;
  background:radial-gradient(ellipse 70% 60% at 42%, var(--menu-glow) 0%, var(--menu-edge) 100%);
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  padding:40px;
  transition:opacity .35s, visibility .35s;
}
#mainMenu.hidden{opacity:0;visibility:hidden}
.mm-logo{
  font-family:'Fredoka One','Nunito',sans-serif;
  font-size:68px;letter-spacing:.22em;padding-left:.22em;
  background:linear-gradient(160deg,#89C4E1 0%,#5BA8D4 100%);
  -webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text;
  filter:drop-shadow(0 4px 0 rgba(0,0,0,0.09));
  margin-bottom:4px;
}
.mm-tag{
  font-size:11px;font-weight:700;letter-spacing:.3em;
  color:var(--text-light);margin-bottom:44px;text-transform:uppercase;
}
/* Two side-by-side sections: core campaign (left) + extra modes/tools (right). */
.mm-buttons{
  display:flex;flex-direction:row;align-items:center;justify-content:center;gap:44px;
}
.mm-col{display:flex;flex-direction:column;gap:12px;width:220px}
.mm-col-head{
  font-size:10px;font-weight:800;letter-spacing:.24em;text-transform:uppercase;
  color:var(--text-light);text-align:center;margin-bottom:2px;
}
/* Right section is highlighted to set the extra modes apart from the campaign. */
.mm-col-right{
  width:212px;                 /* narrower + smaller buttons so the campaign column leads */
  padding:12px;border-radius:var(--r-xl);
  background:linear-gradient(160deg, rgba(183,154,225,0.08), rgba(160,200,235,0.05));
  box-shadow:inset 0 0 0 1.5px rgba(150,120,200,0.15);
}
.mm-col-right .mm-col-head{color:#7a5cc0}
/* De-emphasize the secondary section: smaller, lighter buttons. */
.mm-col-right .mm-btn{padding:9px 16px 11px;font-size:11px;letter-spacing:.1em}
/* …except Level Editor — the spotlight CTA: full size (like Exit), poppy, glowing. */
#mmEditor{
  margin-top:4px;
  padding:14px 24px 17px;font-size:13px;letter-spacing:.14em;
  background:linear-gradient(160deg,#FF9A4D 0%,#FF4E72 100%);
  color:#fff;
  box-shadow:0 6px 0 rgba(170,40,70,0.30), 0 4px 18px rgba(255,90,120,0.30);
  text-shadow:0 2px 0 rgba(150,30,60,0.28);
  animation:mmEditorGlow 2.4s ease-in-out infinite;
}
#mmEditor:hover{transform:translateY(-3px);box-shadow:0 9px 0 rgba(170,40,70,0.30),0 7px 24px rgba(255,90,120,0.45)}
#mmEditor:active{transform:translateY(3px);box-shadow:0 2px 0 rgba(170,40,70,0.30)}
@keyframes mmEditorGlow{
  0%,100%{filter:drop-shadow(0 0 0 rgba(255,90,120,0))}
  50%{filter:drop-shadow(0 0 11px rgba(255,95,120,0.7))}
}
@media (prefers-reduced-motion:reduce){ #mmEditor{animation:none} }
.mm-btn{
  width:100%;padding:14px 24px 17px;
  border-radius:var(--r-xl);
  border:none;cursor:pointer;
  font-family:'Nunito',sans-serif;
  font-size:13px;font-weight:800;letter-spacing:.14em;
  text-transform:uppercase;white-space:nowrap;
  transition:transform .12s, box-shadow .12s;
  position:relative;
}
.mm-btn-primary{
  background:linear-gradient(160deg,#A4D8F0 0%,#89C4E1 100%);
  color:#fff;
  box-shadow:0 6px 0 rgba(0,80,140,0.22), 0 4px 18px rgba(0,0,0,0.12);
  text-shadow:0 2px 0 rgba(0,60,120,0.18);
}
.mm-btn-primary:hover{transform:translateY(-3px);box-shadow:0 9px 0 rgba(0,80,140,0.22),0 6px 22px rgba(0,0,0,0.13)}
.mm-btn-primary:active{transform:translateY(3px);box-shadow:0 2px 0 rgba(0,80,140,0.22)}
.mm-btn-secondary{
  background:var(--clay-surface);
  color:var(--text-mid);
  box-shadow:var(--shadow-sm);
}
.mm-btn-secondary:hover{transform:translateY(-2px);box-shadow:var(--shadow-md);color:var(--text-dark)}
.mm-btn-secondary:active{transform:translateY(2px);box-shadow:0 2px 0 rgba(0,0,0,0.10)}
.mm-btn-danger{
  background:linear-gradient(160deg,#FFD6CC,#F4B09A);
  color:#7A3020;
  box-shadow:0 5px 0 rgba(140,40,0,0.18), 0 3px 14px rgba(0,0,0,0.10);
}
.mm-btn-danger:hover{transform:translateY(-2px);box-shadow:0 8px 0 rgba(140,40,0,0.18),0 5px 18px rgba(0,0,0,0.12)}
.mm-btn-danger:active{transform:translateY(2px)}
/* Highlighted action for the right-side modes/tools. */
.mm-btn-feature{
  background:linear-gradient(160deg,#D8C4F0,#B79AE1);
  color:#3f2070;
  box-shadow:0 5px 0 rgba(80,40,130,0.20), 0 3px 14px rgba(0,0,0,0.10);
  text-shadow:0 1px 0 rgba(255,255,255,0.25);
}
.mm-btn-feature:hover{transform:translateY(-2px);box-shadow:0 8px 0 rgba(80,40,130,0.20),0 5px 18px rgba(0,0,0,0.12)}
.mm-btn-feature:active{transform:translateY(2px);box-shadow:0 2px 0 rgba(80,40,130,0.20)}
/* Locked modes (Daily/Weekly/Monthly) — visible but not yet playable. */
.mm-btn-locked{
  background:var(--clay-surface);
  color:var(--text-light);
  box-shadow:var(--shadow-sm);
  opacity:.6;cursor:not-allowed;
}
.mm-btn:disabled{cursor:not-allowed}
.mm-btn-locked:hover{transform:none;box-shadow:var(--shadow-sm)}
/* Neutralize the hover lift on any locked/gated (aria-disabled) button. */
.mm-btn[aria-disabled="true"]:hover{transform:none}
.mm-user{
  margin-top:26px;display:flex;align-items:center;gap:10px;
  font-size:11px;font-weight:700;letter-spacing:.04em;color:var(--text-mid);
}
.mm-user-action{
  background:none;border:none;cursor:pointer;
  font-family:'Nunito',sans-serif;
  font-size:11px;font-weight:800;letter-spacing:.06em;
  color:var(--text-light);text-decoration:underline;text-underline-offset:3px;
  padding:2px 4px;
}
.mm-user-action:hover{color:var(--text-dark)}
.mm-version{
  margin-top:14px;font-size:9px;font-weight:700;letter-spacing:.2em;
  color:var(--text-light);text-transform:uppercase;
}

/* ===== SCREENS (Worlds, Settings, Level Select) ===== */
.screen{
  position:fixed;inset:0;z-index:40;
  background:radial-gradient(ellipse 70% 60% at 50% 45%, var(--menu-glow) 0%, var(--menu-edge) 100%);
  display:flex;flex-direction:column;align-items:center;
  padding:0;
  transition:opacity .35s, transform .35s;
  overflow:hidden;
}
.screen.hidden{opacity:0;pointer-events:none;transform:translateY(20px);visibility:hidden}
.screen-header{
  width:100%;
  display:flex;align-items:center;gap:14px;
  padding:22px 24px 20px;
  flex-shrink:0;
}
.screen-back{
  width:44px;height:44px;
  background:var(--clay-surface);
  border-radius:var(--r-md);
  box-shadow:var(--shadow-sm);
  border:none;cursor:pointer;
  font-size:18px;color:var(--text-mid);
  display:grid;place-items:center;
  transition:transform .12s, box-shadow .12s;
  flex-shrink:0;
}
.screen-back:hover{transform:translateY(-2px);box-shadow:var(--shadow-md);color:var(--text-dark)}
.screen-title{
  font-family:'Fredoka One','Nunito',sans-serif;
  font-size:26px;letter-spacing:.06em;color:var(--text-dark);
}
.screen-body{
  flex:1;overflow-y:auto;overflow-x:hidden;width:100%;
  padding:0 24px 32px;
}
.screen-body::-webkit-scrollbar{width:0}

/* ===== WORLDS MAP ===== */
.worlds-path{
  display:flex;flex-direction:column;gap:0;
  max-width:560px;margin:0 auto;
}
.world-node{
  display:flex;align-items:stretch;gap:0;
  margin-bottom:0;
  position:relative;
}
/* the spine connecting worlds */
.world-node::before{
  content:'';position:absolute;left:42px;top:80px;bottom:-24px;
  width:4px;
  background:linear-gradient(180deg,var(--node-color,#89C4E1), transparent);
  border-radius:2px;
  opacity:.35;
  z-index:0;
}
.world-node:last-child::before{display:none}

.world-node-left{
  width:88px;flex-shrink:0;
  display:flex;flex-direction:column;align-items:center;padding-top:16px;
  position:relative;z-index:1;
}
.world-icon{
  width:64px;height:64px;
  border-radius:20px;
  display:flex;align-items:center;justify-content:center;
  font-size:28px;
  box-shadow:0 6px 0 rgba(0,0,0,0.12), 0 3px 14px rgba(0,0,0,0.10);
  background:var(--node-gradient);
  flex-shrink:0;
}
.world-num-label{
  font-size:9px;font-weight:800;letter-spacing:.2em;
  color:var(--text-light);text-transform:uppercase;margin-top:8px;
}
.world-node-right{
  flex:1;padding:16px 0 24px 16px;
}
.world-name{
  font-family:'Fredoka One','Nunito',sans-serif;
  font-size:20px;letter-spacing:.04em;color:var(--text-dark);margin-bottom:4px;
}
.world-desc{
  font-size:11px;font-weight:600;line-height:1.6;color:var(--text-mid);margin-bottom:14px;
}
/* Level dots row */
.level-dots{
  display:flex;flex-wrap:wrap;gap:8px;
}
.level-dot{
  width:38px;height:38px;
  border-radius:var(--r-sm);
  display:flex;align-items:center;justify-content:center;
  cursor:pointer;
  transition:transform .12s, box-shadow .12s;
  position:relative;
}
.level-dot:hover{transform:translateY(-3px);box-shadow:var(--shadow-md)!important}
.level-dot:active{transform:translateY(2px)}
.level-dot-num{font-size:11px;font-weight:900;line-height:1}
.level-dot-label{font-size:7px;font-weight:700;text-align:center;line-height:1.2;padding:0 2px}
/* states */
.ld-done{
  background:linear-gradient(145deg,#A8DDBE,#7ECBA1);
  box-shadow:0 4px 0 rgba(0,100,60,0.18), 0 2px 10px rgba(0,0,0,0.10);
  color:#1A4A30;
}
.ld-current{
  background:linear-gradient(145deg,#A4D8F0,#89C4E1);
  box-shadow:0 4px 0 rgba(0,80,140,0.22), 0 2px 10px rgba(0,0,0,0.12);
  color:#fff;
  animation:dotPulse 1.8s ease-in-out infinite;
}
@keyframes dotPulse{
  0%,100%{box-shadow:0 4px 0 rgba(0,80,140,0.22),0 2px 10px rgba(0,0,0,0.12),0 0 0 0 rgba(137,196,225,0.6)}
  50%{box-shadow:0 4px 0 rgba(0,80,140,0.22),0 2px 10px rgba(0,0,0,0.12),0 0 0 8px rgba(137,196,225,0)}
}
.ld-locked{
  background:linear-gradient(145deg,#E8E0D6,#D8CEBE);
  box-shadow:0 3px 0 rgba(0,0,0,0.10), 0 1px 6px rgba(0,0,0,0.07);
  color:var(--text-light);
  cursor:not-allowed;
}
.level-dot-tick{font-size:14px;line-height:1}
.level-dot-lock{font-size:13px;line-height:1}

/* ===== SETTINGS PANEL ===== */
.settings-sections{
  display:flex;flex-direction:column;gap:20px;
  max-width:440px;margin:0 auto;
}
.settings-section{
  background:var(--clay-surface);
  border-radius:var(--r-lg);
  box-shadow:var(--shadow-sm);
  overflow:hidden;
}
.settings-section-label{
  font-size:9px;font-weight:800;letter-spacing:.28em;
  color:var(--text-light);text-transform:uppercase;
  padding:16px 20px 0;
  margin-bottom:4px;
}
.setting-row{
  display:flex;align-items:center;justify-content:space-between;
  padding:14px 20px;
  border-bottom:1px solid rgba(0,0,0,0.05);
  gap:16px;
}
.setting-row:last-child{border-bottom:none}
.setting-label{
  font-size:13px;font-weight:700;color:var(--text-dark);
}
.setting-sub{
  font-size:10px;font-weight:600;color:var(--text-light);margin-top:1px;
}
.setting-sub.setting-locked{color:#C2552F;font-weight:800}
/* Clay toggle switch */
.clay-toggle{
  width:52px;height:28px;
  border-radius:14px;
  background:linear-gradient(160deg,#D8CEBE,#C8B8A8);
  box-shadow:inset 0 2px 5px rgba(0,0,0,0.12);
  position:relative;cursor:pointer;
  transition:background .25s;
  flex-shrink:0;border:none;
  outline:none;
}
.clay-toggle.on{
  background:linear-gradient(160deg,#A4D8F0,#7EC4E1);
  box-shadow:inset 0 2px 5px rgba(0,0,0,0.10),0 0 0 2px rgba(137,196,225,0.3);
}
.clay-toggle::after{
  content:'';
  position:absolute;
  width:22px;height:22px;
  border-radius:11px;
  background:linear-gradient(145deg,#fff,#F5EDE4);
  box-shadow:0 3px 0 rgba(0,0,0,0.14),0 2px 8px rgba(0,0,0,0.12);
  top:3px;left:3px;
  transition:transform .22s cubic-bezier(0.34,1.56,0.64,1);
}
.clay-toggle.on::after{transform:translateX(24px)}

/* Keybind rows */
.keybind-row{
  display:flex;align-items:center;justify-content:space-between;
  padding:12px 20px;
  border-bottom:1px solid rgba(0,0,0,0.05);
  gap:12px;
}
.keybind-row:last-child{border-bottom:none}
.keybind-action{font-size:12px;font-weight:700;color:var(--text-dark)}
.keybind-keys{display:flex;gap:6px}
.keybind-key{
  min-width:32px;height:32px;padding:0 8px;
  background:var(--clay-surface);
  border-radius:8px;
  box-shadow:0 3px 0 rgba(0,0,0,0.12),0 1px 6px rgba(0,0,0,0.08);
  display:flex;align-items:center;justify-content:center;
  font-size:11px;font-weight:800;color:var(--text-mid);
  cursor:pointer;transition:transform .1s, box-shadow .1s;
  border:none;font-family:'Nunito',sans-serif;
  position:relative;
}
.keybind-key:hover{transform:translateY(-2px);box-shadow:0 5px 0 rgba(0,0,0,0.12),0 2px 10px rgba(0,0,0,0.10);color:var(--text-dark)}
.keybind-key:active{transform:translateY(2px);box-shadow:0 1px 0 rgba(0,0,0,0.12)}
.keybind-key.listening{
  background:linear-gradient(145deg,#A4D8F0,#89C4E1);
  color:#fff;
  box-shadow:0 3px 0 rgba(0,80,140,0.22),0 0 0 3px rgba(137,196,225,0.4);
  animation:keyPulse .6s ease-in-out infinite alternate;
}
@keyframes keyPulse{0%{opacity:.8}100%{opacity:1}}

/* ===== EXISTING MENU SCREENS (World select / Level select) ===== */
.menu{
  position:fixed;inset:0;
  z-index:20;
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  padding:40px;text-align:center;
  transition:opacity .35s;
  background:radial-gradient(ellipse 70% 60% at 50% 45%, var(--menu-glow) 0%, var(--menu-edge) 100%);
}
.menu.hidden{opacity:0;pointer-events:none}
.menu .brand{
  font-size:72px;font-weight:900;letter-spacing:.35em;
  background:linear-gradient(160deg,var(--clay-blue),#5BA8D4);
  -webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text;
  text-shadow:none;
  margin-bottom:0;padding-left:.35em;
  filter:drop-shadow(0 4px 0 rgba(0,0,0,0.10));
}
.menu .tag{font-size:11px;font-weight:800;letter-spacing:.28em;color:var(--text-light);margin-bottom:42px;text-transform:uppercase}
.menu .mlabel{font-size:10px;font-weight:800;letter-spacing:.28em;color:var(--text-light);margin-bottom:22px;text-transform:uppercase}
.menu .back{
  position:absolute;top:24px;left:24px;
  background:var(--clay-surface);
  border-radius:var(--r-xl);box-shadow:var(--shadow-sm);
  color:var(--text-mid);font-size:10px;font-weight:800;letter-spacing:.14em;
  padding:10px 18px 13px;border:none;cursor:pointer;font-family:'Nunito',sans-serif;
}
.world-grid{display:flex;gap:18px;flex-wrap:wrap;justify-content:center}
.world-card{
  width:220px;padding:24px 22px 28px;
  background:var(--clay-surface);
  border-radius:var(--r-lg);box-shadow:var(--shadow-md);
  cursor:pointer;transition:transform .15s, box-shadow .15s;
  text-align:left;position:relative;overflow:hidden;
}
.world-card::before{content:'';position:absolute;top:0;left:0;right:0;height:5px;border-radius:var(--r-lg) var(--r-lg) 0 0;background:var(--card-accent,var(--clay-blue))}
.world-card:hover{transform:translateY(-4px);box-shadow:0 10px 0 rgba(0,0,0,0.13),0 6px 24px rgba(0,0,0,0.11)}
.world-card:active{transform:translateY(2px);box-shadow:var(--shadow-sm)}
.world-card .wnum{font-size:10px;font-weight:800;letter-spacing:.28em;color:var(--text-light);text-transform:uppercase;margin-top:4px}
.world-card .wname{font-size:20px;font-weight:900;letter-spacing:.08em;color:var(--text-dark);margin:8px 0 10px}
.world-card .wdesc{font-size:11px;font-weight:600;line-height:1.65;color:var(--text-mid)}
.world-card .wmeta{font-size:9px;font-weight:800;letter-spacing:.18em;color:var(--card-accent,var(--clay-blue));margin-top:16px;text-transform:uppercase}
.level-grid{display:grid;grid-template-columns:repeat(5,90px);gap:12px;justify-content:center;max-width:570px}
.level-cell{height:90px;background:var(--clay-surface);border-radius:var(--r-md);box-shadow:var(--shadow-sm);cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:5px;transition:transform .14s, box-shadow .14s}
.level-cell:hover{transform:translateY(-3px);box-shadow:var(--shadow-md)}
.level-cell:active{transform:translateY(2px);box-shadow:0 2px 0 rgba(0,0,0,0.12)}
.level-cell .lnum{font-size:26px;font-weight:900;color:var(--text-dark)}
.level-cell .lname{font-size:8px;font-weight:700;letter-spacing:.06em;color:var(--text-light);text-align:center;padding:0 5px;line-height:1.3;text-transform:uppercase}
.menu .startbtn{margin-top:36px;font-size:11px;letter-spacing:.22em;padding:14px 30px 17px;background:linear-gradient(160deg,var(--clay-blue),#6AB8D4);color:#fff;font-weight:800;box-shadow:0 6px 0 rgba(0,90,140,0.25), 0 4px 16px rgba(0,0,0,0.12);border:none;cursor:pointer;font-family:'Nunito',sans-serif;border-radius:var(--r-xl)}
.menu .startbtn:hover{box-shadow:0 9px 0 rgba(0,90,140,0.28), 0 6px 20px rgba(0,0,0,0.14);color:#fff}

/* ============================================================
   MOBILE / NARROW SCREENS
   Goal: nothing leaves the viewport on a phone. Full-screen menus
   become vertically scrollable (so short/landscape phones don't clip
   their content), the in-game HUD pills shrink and wrap, and every
   card/panel is capped to the viewport width. The 3D board itself is
   kept fully on-screen by SceneManager.placeCamera (pulls back on
   narrow aspect ratios) — these rules only handle the DOM overlays.
   ============================================================ */
@media (max-width:560px){
  /* ----- In-game HUD ----- */
  .top{padding:12px 14px;gap:8px}
  .title-pill{padding:8px 14px 10px}
  .title{font-size:15px}
  .sub{font-size:8px;letter-spacing:.12em}
  /* Cap the goal pill so it can't collide with the title pill. */
  .goal-pill{padding:8px 12px 10px;max-width:46vw}
  .goal{font-size:9px;line-height:1.5}
  .bottom{padding:12px 14px 18px;flex-wrap:wrap;gap:9px}
  .moves-chip{padding:8px 14px 10px}
  .moves-num{font-size:22px}
  .controls{gap:7px;flex-wrap:wrap;justify-content:flex-end}
  button{padding:10px 12px 13px;font-size:9px}
  /* Hint moves to the top, tucked just under the HUD top pills (instead of
     floating above the bottom control bar where space is tight on phones). */
  .hint{top:104px;bottom:auto;font-size:9px;padding:0 14px;width:100%}
  .hint .keys{margin-bottom:5px}
  .hint .key{width:24px;height:24px;font-size:13px}
  #mergeHint{font-size:9px;padding:8px 12px 10px;max-width:92vw;white-space:nowrap}

  /* ----- Full-screen menus: allow scrolling, never clip; hide the scrollbar ----- */
  #splash,#mainMenu,.menu,.screen{
    justify-content:flex-start;
    overflow-y:auto;overflow-x:hidden;
    -webkit-overflow-scrolling:touch;
    scrollbar-width:none;              /* Firefox */
    -ms-overflow-style:none;           /* old Edge/IE */
  }
  #splash::-webkit-scrollbar,#mainMenu::-webkit-scrollbar,
  .menu::-webkit-scrollbar,.screen::-webkit-scrollbar{display:none}  /* WebKit */
  #splash,#mainMenu,.menu{padding:48px 16px;min-height:100%}
  /* keep the splash auth/logo group vertically centred when it fits */
  .splash-logo-wrap{margin:auto 0}

  /* ----- Splash ----- */
  #splash .splash-game-title{font-size:38px}
  .splash-stamp{width:104px;height:104px;border-radius:28px;margin-bottom:18px}
  .splash-stamp-letter{font-size:52px}
  .splash-auth{width:min(86vw,280px);margin-top:30px}

  /* ----- Main menu ----- */
  .mm-logo{font-size:50px}
  .mm-tag{margin-bottom:28px}
  .mm-buttons{flex-direction:column;align-items:center;gap:22px;width:100%}
  .mm-col{width:min(90vw,300px)}
  .mm-col-right{width:min(92vw,320px)}
  .mm-btn{padding:13px 18px 15px;font-size:12px}

  /* ----- Generic screens (Worlds / Settings / Community / My Levels) ----- */
  .screen-header{padding:16px 16px 14px}
  .screen-title{font-size:22px}
  .screen-body{padding:0 14px 28px}

  /* Worlds map */
  .world-node-left{width:64px}
  .world-icon{width:52px;height:52px;font-size:23px}
  .world-node::before{left:32px;top:66px}
  .world-node-right{padding:14px 0 22px 12px}
  .world-name{font-size:18px}
  .level-dot{width:34px;height:34px}

  /* Old world/level select (back-compat menus) */
  .menu .brand{font-size:50px}
  .world-grid{flex-direction:column;gap:12px}
  .world-card{width:min(86vw,320px)}
  .level-grid{grid-template-columns:repeat(3,1fr);gap:10px;max-width:92vw;width:100%}
  .level-cell{height:78px}

  /* Settings */
  .settings-sections{max-width:100%}
  .setting-row{padding:13px 16px;gap:12px}

  /* Community */
  .community-filters{gap:6px;padding-bottom:10px}
  .cl-filter{padding:7px 11px;font-size:10px}
  .community-card{padding:12px 13px;gap:10px}
  .cl-name{font-size:14px}
  .cl-actions .ed-btn{padding:10px 14px}

  /* ----- Win banner ----- */
  .banner-card{padding:30px 26px 34px;max-width:88vw}
  .banner h1{font-size:30px}

  /* ----- Rate overlay ----- */
  .rate-card{min-width:0;width:min(88vw,340px);padding:24px 22px}
  .rate-star{font-size:32px}

  /* ----- Hint pill over the board ----- */
  .hint-arrow-pill{padding:9px 18px 11px}
  .hint-arrow-dir{font-size:24px}

  /* ----- Account chip + panel ----- */
  #userBadge{top:12px;right:12px}
  #userPanel{top:58px;right:12px;width:min(80vw,248px)}

  /* NOTE: the level-editor mobile rules live in their own @media block at the
     very end of this file — the editor's base styles are defined *below* this
     block, so an override placed here would lose the source-order tie. */
}

/* ----- Very small phones ----- */
@media (max-width:380px){
  .top{padding:10px 10px}
  .goal-pill{max-width:44vw}
  .mm-logo{font-size:42px}
  #splash .splash-game-title{font-size:32px}
  .level-grid{grid-template-columns:repeat(2,1fr)}
  .controls{gap:5px}
  button{padding:9px 10px 12px;font-size:8px;letter-spacing:.1em}
  /* (Editor-rail tweaks for very small phones live in the mobile-editor
     @media block at the end of the file — see the note there.) */
}

/* ----- Landscape phones: short height, keep menus reachable ----- */
@media (max-height:480px) and (orientation:landscape){
  #splash,#mainMenu,.menu,.screen{justify-content:flex-start;overflow-y:auto}
  #splash,#mainMenu,.menu{padding:24px 16px}
  .mm-logo{font-size:38px;margin-bottom:2px}
  .mm-tag{margin-bottom:16px}
  .splash-stamp{width:84px;height:84px;margin-bottom:12px}
  .splash-stamp-letter{font-size:42px}
  .splash-auth{margin-top:18px}
}
/* Hint button — warm gold accent */
#hintBtn{
  background:linear-gradient(160deg,#FFF3C4,#F4CC6B);
  color:#7A5500;
  box-shadow:0 5px 0 rgba(140,100,0,0.20), 0 3px 12px rgba(0,0,0,0.10);
  position:relative;
}
#hintBtn:hover{
  box-shadow:0 8px 0 rgba(140,100,0,0.22), 0 4px 16px rgba(0,0,0,0.12);
  color:#5A3800;
}
#hintBtn.used{
  background:linear-gradient(160deg,#E8DDD0,var(--clay-cream));
  color:var(--text-light);
  box-shadow:var(--shadow-sm);
}

/* Hint direction label — floats above the 3D canvas */
#hintLabel{
  position:fixed;left:50%;top:50%;
  transform:translate(-50%,-50%);
  pointer-events:none;
  z-index:8;
  display:none;
}
.hint-arrow-pill{
  background:linear-gradient(160deg,#FFF8E0,#F4CC6B);
  border-radius:var(--r-xl);
  padding:10px 22px 13px;
  box-shadow:0 6px 0 rgba(140,100,0,0.22), 0 4px 20px rgba(244,204,107,0.4);
  display:flex;align-items:center;gap:10px;
  animation:hintFloat 1.2s ease-in-out infinite alternate;
  white-space:nowrap;
}
@keyframes hintFloat{
  0%{transform:translateY(0);box-shadow:0 6px 0 rgba(140,100,0,0.22),0 4px 20px rgba(244,204,107,0.4)}
  100%{transform:translateY(-6px);box-shadow:0 12px 0 rgba(140,100,0,0.18),0 8px 28px rgba(244,204,107,0.5)}
}
.hint-arrow-dir{font-size:28px;line-height:1}
.hint-arrow-text{font-size:11px;font-weight:800;letter-spacing:.16em;color:#6A4400;text-transform:uppercase}

/* Hint counter badge */
.hint-badge{
  background:#7ECBA1;color:#fff;
  border-radius:10px;padding:1px 7px;
  font-size:9px;font-weight:800;
  position:absolute;top:-6px;right:-6px;
  box-shadow:0 2px 0 rgba(0,80,40,0.18);
  pointer-events:none;
}
/* Devil dialogue bubble */
.devil-bubble{
  background:var(--clay-surface);
  border-radius:var(--r-lg);
  padding:11px 15px 13px;
  box-shadow:var(--shadow-md);
  position:relative;
  font-size:12px;font-weight:700;
  color:var(--text-dark);
  line-height:1.55;
  font-style:italic;
}
.devil-bubble::after{
  content:'';
  position:absolute;bottom:-10px;left:22px;
  border:6px solid transparent;
  border-top-color:var(--clay-cream);
  border-bottom:none;
}

/* Save toast */
#saveToast{
  position:fixed;bottom:80px;left:50%;transform:translateX(-50%);
  background:linear-gradient(160deg,#A4DDBC,#7ECBA1);
  color:#1A4A30;font-family:'Nunito',sans-serif;
  font-size:10px;font-weight:800;letter-spacing:.16em;text-transform:uppercase;
  padding:8px 18px 10px;border-radius:var(--r-xl);
  box-shadow:0 4px 0 rgba(0,100,60,0.18),0 2px 12px rgba(0,0,0,0.10);
  pointer-events:none;opacity:0;
  transition:opacity .3s;
  z-index:15;
}
#saveToast.show{opacity:1}

/* ===== CUTSCENE ===== */
#csOverlay{
  position:fixed;inset:0;z-index:30;
  pointer-events:auto;display:none;
  background:transparent;
}
#csOverlay.active{display:block}
#csOverlay.dim{background:transparent}

.cs-bubble{
  position:fixed;
  max-width:230px;min-width:150px;
  background:var(--clay-surface);
  border-radius:var(--r-xl);
  padding:13px 18px 16px;
  box-shadow:var(--shadow-lg);
  font-size:13px;font-weight:700;
  color:var(--text-dark);line-height:1.55;
  pointer-events:none;
  opacity:0;transform:scale(0.8) translateY(12px);
  transition:opacity .4s cubic-bezier(0.34,1.56,0.64,1), transform .4s cubic-bezier(0.34,1.56,0.64,1);
  z-index:31;
}
.cs-bubble.show{opacity:1;transform:scale(1) translateY(0)}
/* Devil bubble — bottom-left tail */
#csBubbleDevil::after{
  content:'';position:absolute;bottom:-11px;left:22px;
  border:7px solid transparent;
  border-top-color:var(--clay-cream);border-bottom:none;
}
/* Player bubble — bottom-right tail */
#csBubblePlayer::after{
  content:'';position:absolute;bottom:-11px;right:22px;
  border:7px solid transparent;
  border-top-color:var(--clay-cream);border-bottom:none;
}
.cs-speaker{
  font-size:9px;font-weight:800;letter-spacing:.2em;
  text-transform:uppercase;margin-bottom:6px;opacity:.55;
}
#csBubbleDevil .cs-speaker{color:#C03030}
#csBubblePlayer .cs-speaker{color:#2888AA}
#csSkip{
  position:fixed;bottom:36px;left:50%;transform:translateX(-50%);
  font-size:10px;font-weight:800;letter-spacing:.22em;text-transform:uppercase;
  color:var(--text-light);
  background:var(--clay-surface);
  border-radius:var(--r-xl);padding:9px 22px 11px;
  box-shadow:var(--shadow-sm);border:none;cursor:pointer;
  font-family:'Nunito',sans-serif;
  opacity:0;transition:opacity .4s;pointer-events:none;
  z-index:32;
}
#csSkip.show{opacity:1;pointer-events:auto}

/* ===== LEVEL EDITOR ===== */
/* Transparent overlay: the container ignores pointer events so clicks fall
   through to the 3D board; only the bars/rails opt back in. */
#editorScreen{position:fixed;inset:0;z-index:45;pointer-events:none;user-select:none}
#editorScreen.hidden{display:none}

/* Close button stays pinned at the top-left (its original position). */
.ed-exit{
  position:fixed;top:12px;left:16px;
  width:40px;padding:9px 0;text-align:center;
  background:linear-gradient(160deg,#FFD6CC,#F4B09A);color:#7A3020;
  pointer-events:auto;
}
/* Mobile-only edge handles that slide the rails in/out. Hidden on desktop,
   where the rails are freely draggable instead (revealed in the media query). */
.ed-edge-btn{display:none}

/* Every other top-bar control lives in a draggable vertical rail (default: right edge). */
.editor-actions{
  position:fixed;top:12px;right:16px;
  display:flex;flex-direction:column;align-items:stretch;gap:10px;
  width:166px;max-height:calc(100vh - 24px);
  pointer-events:auto;
}
/* Cream panel behind the controls — matches the tool palette's surface. */
.editor-actions-panel{
  display:flex;flex-direction:column;gap:8px;
  padding:12px;border-radius:var(--r-lg);
  background:var(--panel);box-shadow:var(--shadow-md);
  overflow-y:auto;flex:1 1 auto;min-height:0;
}
.editor-actions .ed-name{
  width:100%;text-align:center;
  padding:9px 14px 10px;border:none;border-radius:var(--r-md);
  background:var(--clay-cream);box-shadow:var(--shadow-inset);
  font-family:'Nunito',sans-serif;font-weight:800;font-size:13px;color:var(--text-dark);
  outline:none;
}
.editor-actions .ed-btn{width:100%}

/* Drag grip shared by the two repositionable panels. */
.ed-grip{
  cursor:grab;user-select:none;touch-action:none;flex:0 0 auto;
  display:flex;align-items:center;justify-content:center;gap:6px;
  padding:6px 8px;border-radius:var(--r-md);
  background:var(--panel);box-shadow:var(--shadow-sm);
  font-size:9px;font-weight:800;letter-spacing:.2em;color:var(--text-light);text-transform:uppercase;
}
.ed-grip:active{cursor:grabbing}

.ed-btn{
  border:none;cursor:pointer;
  padding:9px 14px 10px;border-radius:var(--r-md);
  background:var(--clay-surface);
  color:var(--text-mid);
  box-shadow:var(--shadow-sm);
  font-family:'Nunito',sans-serif;font-weight:800;font-size:11px;letter-spacing:.06em;
  transition:transform .12s, box-shadow .12s, color .12s;
}
.ed-btn:hover{transform:translateY(-2px);box-shadow:var(--shadow-md);color:var(--text-dark)}
.ed-btn:active{transform:translateY(2px);box-shadow:0 2px 0 rgba(0,0,0,0.10)}
.ed-test{background:linear-gradient(160deg,#A4D8F0,#7EC4E1);color:#0c5070}
.ed-save{background:linear-gradient(160deg,#A4DDBC,#7ECBA1);color:#155c3a}
.ed-publish{background:linear-gradient(160deg,#D8C4F0,#B79AE1);color:#3f2070}
.ed-unpublish{background:linear-gradient(160deg,#E8DDF2,#D3C4E4);color:#6a5a82}
/* Publish/Unpublish kept together, set off from the editing actions above by a
   gap and a faint divider that follows the theme. */
.ed-publish-group{
  display:flex;flex-direction:column;gap:8px;
  margin-top:6px;padding-top:12px;
  border-top:1px solid rgba(128,128,128,0.22);
}

/* Read-only stats for a published level, pinned at the top center of the editor.
   pointer-events:none so it never blocks board clicks; capped so it clears the
   left palette and the right actions rail. */
.editor-stats{
  position:fixed;top:12px;left:50%;transform:translateX(-50%);
  z-index:5;pointer-events:none;
  display:flex;flex-direction:column;align-items:center;gap:8px;
  padding:10px 20px 12px;border-radius:var(--r-lg);
  background:var(--panel);box-shadow:var(--shadow-md);
  max-width:min(540px,calc(100vw - 400px));
}
.editor-stats .es-title{
  font-size:10px;font-weight:800;letter-spacing:.14em;text-transform:uppercase;color:#7a5cc0;
}
.editor-stats .es-stats{display:flex;gap:20px;flex-wrap:wrap;justify-content:center}
.editor-stats .es-stat{display:flex;flex-direction:column;align-items:center;line-height:1.15}
.editor-stats .es-stat b{font-size:15px;font-weight:900;color:var(--text-dark)}
.editor-stats .es-stat small{font-size:9px;font-weight:700;letter-spacing:.06em;color:var(--text-light);text-transform:uppercase;margin-top:3px}
.editor-stats .es-rate{display:flex;align-items:center;gap:6px}
.editor-stats .es-rate .cl-star{font-size:13px}

/* ===== COMMUNITY LEVELS ===== */
.community-filters{
  position:sticky;top:0;z-index:2;
  display:flex;gap:8px;flex-wrap:wrap;justify-content:center;
  max-width:520px;margin:0 auto;padding:4px 0 12px;
  background:linear-gradient(to bottom, var(--menu-glow) 70%, transparent);
}
.cl-filter{
  border:none;cursor:pointer;
  background:var(--clay-surface);color:var(--text-mid);
  box-shadow:var(--shadow-sm);border-radius:999px;
  padding:8px 14px;font-family:'Nunito',sans-serif;
  font-weight:800;font-size:11px;letter-spacing:.04em;
  transition:transform .1s, box-shadow .1s, color .12s;
}
.cl-filter:hover{transform:translateY(-1px);color:var(--text-dark)}
.cl-filter.active{
  background:linear-gradient(160deg,#A4D8F0 0%,#89C4E1 100%);color:#fff;
  box-shadow:0 4px 0 rgba(0,80,140,0.20),0 2px 10px rgba(0,0,0,0.10);
}
.community-list{display:flex;flex-direction:column;gap:12px;width:100%;max-width:520px;margin:0 auto;padding:0 2px 24px}
.community-empty{color:var(--text-light);font-weight:700;text-align:center;padding:48px 16px;font-size:13px;line-height:1.6}
.community-loading{display:flex;flex-direction:column;align-items:center;gap:14px;padding:48px 16px;color:var(--text-light);font-weight:700;font-size:12px}
.cl-spinner{
  width:34px;height:34px;border-radius:50%;
  border:4px solid rgba(128,128,128,0.25);
  border-top-color:#89C4E1;
  animation:clSpin .8s linear infinite;
}
@keyframes clSpin{to{transform:rotate(360deg)}}
.cl-sentinel{height:1px}
.community-card{
  display:flex;align-items:center;gap:12px;
  background:var(--clay-surface);box-shadow:var(--shadow-sm);
  border-radius:var(--r-lg);padding:14px 16px;
}
.community-card.is-solved{box-shadow:0 4px 0 rgba(0,120,70,0.16),0 2px 10px rgba(0,0,0,0.08)}
.cl-info{flex:1;min-width:0}
.cl-top{display:flex;align-items:center;gap:8px}
.cl-name{font-family:'Nunito',sans-serif;font-weight:800;font-size:15px;color:var(--text-dark);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.cl-badge{font-size:9px;font-weight:800;letter-spacing:.08em;text-transform:uppercase;padding:3px 8px;border-radius:999px;flex-shrink:0}
.cl-new{background:rgba(120,160,210,0.18);color:#3f6da0}
.cl-played{background:rgba(160,140,90,0.20);color:#7a5a14}
.cl-solved{background:rgba(120,200,150,0.22);color:#15603a}
.cl-by{font-size:10px;font-weight:700;color:var(--text-light);margin-top:3px}
.cl-ratings{display:flex;gap:16px;margin-top:7px;flex-wrap:wrap;align-items:center}
.cl-rate-row{font-size:11px;font-weight:700;color:var(--text-mid);display:inline-flex;align-items:center;gap:4px}
.cl-rate-row small{color:var(--text-light);font-weight:600}
.cl-star{color:rgba(128,128,128,0.35);font-size:12px}
.cl-star.on{color:#F4B400}
.cl-actions{flex-shrink:0}
.cl-actions .ed-btn{width:auto;padding:11px 18px}

/* Rating overlay (in-game, after a community solve) */
#rateOverlay{position:fixed;inset:0;z-index:200;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,0.45)}
#rateOverlay.hidden{display:none}
.rate-card{
  background:var(--panel);border-radius:var(--r-xl);box-shadow:var(--shadow-md);
  padding:28px 34px;text-align:center;
  display:flex;flex-direction:column;align-items:center;gap:10px;min-width:280px;
  animation:splashBounce .5s cubic-bezier(0.34,1.56,0.64,1) both;
}
.rate-title{font-family:'Fredoka One','Nunito',sans-serif;font-size:26px;color:var(--text-dark)}
.rate-sub{font-size:13px;font-weight:700;color:var(--text-mid)}
.rate-stars{display:flex;gap:6px;margin:6px 0}
.rate-star{background:none;border:none;cursor:pointer;font-size:36px;line-height:1;color:rgba(128,128,128,0.35);transition:transform .1s,color .12s;padding:0 2px}
.rate-star:hover{transform:scale(1.15)}
.rate-star.on{color:#F4B400}
.rate-note{font-size:11px;font-weight:700;color:var(--text-light);min-height:14px}
.rate-actions{display:flex;gap:10px;margin-top:4px}
.rate-skip,.rate-next{
  border:none;cursor:pointer;
  border-radius:var(--r-md);padding:10px 22px;
  font-family:'Nunito',sans-serif;font-weight:800;font-size:12px;letter-spacing:.06em;
  text-transform:uppercase;box-shadow:var(--shadow-sm);
  transition:transform .12s, box-shadow .12s, color .12s;
}
.rate-skip{background:var(--clay-surface);color:var(--text-mid)}
.rate-skip:hover{color:var(--text-dark)}
.rate-next{
  background:linear-gradient(160deg,#A4D8F0 0%,#89C4E1 100%);color:#fff;
  box-shadow:0 5px 0 rgba(0,80,140,0.22),0 3px 14px rgba(0,0,0,0.10);
  text-shadow:0 2px 0 rgba(0,60,120,0.18);
}
.rate-next:hover{transform:translateY(-2px);box-shadow:0 8px 0 rgba(0,80,140,0.22),0 5px 18px rgba(0,0,0,0.12)}
.rate-next:active{transform:translateY(2px);box-shadow:0 2px 0 rgba(0,80,140,0.22)}
.ed-btn:disabled{opacity:.5;cursor:default;transform:none;box-shadow:var(--shadow-sm)}
.ed-danger{background:linear-gradient(160deg,#FFD6CC,#F4B09A);color:#7A3020}

/* Left tool rail */
.editor-side{
  position:fixed;top:74px;left:16px;
  display:flex;flex-direction:column;gap:10px;
  max-height:calc(100vh - 88px);
  pointer-events:auto;
}
.editor-palette{
  display:flex;flex-direction:column;gap:7px;
  padding:12px;border-radius:var(--r-lg);
  background:var(--panel);box-shadow:var(--shadow-md);
  overflow-y:auto;overflow-x:hidden;flex:1 1 auto;min-height:0;
}
/* Vertical scroll indicator only (horizontal scrolling is disabled). The bar
   stays invisible until you hover the palette, then a thumb fades in that sits
   close to the panel background with just a little contrast — a translucent
   neutral reads as a subtle shade on both the light and dark panel. The track
   width is reserved at all times so revealing the thumb never shifts the tool
   buttons. */
.editor-palette{scrollbar-width:thin;scrollbar-color:transparent transparent}
.editor-palette:hover{scrollbar-color:rgba(128,128,128,0.32) transparent}
.editor-palette::-webkit-scrollbar{width:8px}
/* Inset the track by the panel's corner radius so the thumb stays within the
   straight edges and never bleeds into (or gets clipped by) the rounded corners. */
.editor-palette::-webkit-scrollbar-track{background:transparent;margin:var(--r-lg) 0}
.editor-palette::-webkit-scrollbar-thumb{
  background:transparent;border-radius:8px;
  border:2px solid transparent;background-clip:padding-box;
  transition:background .2s ease;
}
.editor-palette:hover::-webkit-scrollbar-thumb{background:rgba(128,128,128,0.32);background-clip:padding-box}
.editor-palette:hover::-webkit-scrollbar-thumb:hover{background:rgba(128,128,128,0.5)}
.ed-tool{
  display:flex;align-items:center;gap:9px;
  width:142px;padding:8px 11px;border:none;cursor:pointer;
  border-radius:var(--r-md);
  background:var(--clay-surface);
  box-shadow:var(--shadow-sm);
  font-family:'Nunito',sans-serif;font-weight:800;font-size:12px;color:var(--text-mid);
  transition:transform .1s, box-shadow .1s;
}
.ed-tool:hover{transform:translateY(-1px);color:var(--text-dark)}
.ed-tool.active{
  background:linear-gradient(160deg,#FCE9BE,#F4CC6B);color:#7a5a14;
  box-shadow:0 4px 0 rgba(150,110,10,0.22),0 2px 10px rgba(0,0,0,0.12);
}
.ed-tool-icon{font-size:18px;line-height:1;width:22px;text-align:center}
.ed-tool-name{flex:1;text-align:left}
.ed-tool-lock{font-size:12px;margin-left:auto;opacity:.8}
/* Locked tools: greyed and inert (still hoverable for the tip). */
.ed-tool.locked{opacity:.5;cursor:not-allowed;filter:grayscale(.55)}
.ed-tool.locked:hover{transform:none;color:var(--text-mid)}
.ed-flag.locked{opacity:.5}
.ed-flag.locked .clay-toggle{cursor:not-allowed}

/* Hover tooltip — dark pill, distinct from the cream panels. */
#edTooltip{
  position:fixed;display:none;z-index:50;pointer-events:none;
  max-width:200px;padding:8px 12px;border-radius:var(--r-md);
  background:var(--text-dark);color:#FFF8F0;
  font-size:11px;font-weight:700;line-height:1.45;letter-spacing:.01em;
  box-shadow:var(--shadow-md);
}

.editor-params{
  display:flex;flex-direction:column;gap:8px;
  padding:12px;border-radius:var(--r-lg);
  background:var(--panel);box-shadow:var(--shadow-md);
}
.ed-param,.ed-flag{
  display:flex;align-items:center;justify-content:space-between;gap:10px;
  font-size:11px;font-weight:800;letter-spacing:.06em;color:var(--text-mid);text-transform:uppercase;
}
.ed-param input{
  width:54px;padding:6px 8px;border:none;border-radius:var(--r-sm);
  background:var(--clay-cream);box-shadow:var(--shadow-inset);
  font-family:'Nunito',sans-serif;font-weight:800;font-size:13px;color:var(--text-dark);
  text-align:center;outline:none;
}

.editor-hint{
  position:fixed;bottom:20px;left:50%;transform:translateX(-50%);
  pointer-events:none;
  font-size:10px;font-weight:700;letter-spacing:.1em;color:var(--text-mid);text-transform:uppercase;
  background:rgba(255,248,240,0.85);padding:8px 18px 9px;border-radius:var(--r-xl);
  box-shadow:var(--shadow-sm);
}

/* Test bar */
#editorTestBar{
  position:fixed;top:14px;left:50%;transform:translateX(-50%);z-index:46;
  display:flex;align-items:center;gap:14px;
  padding:8px 10px 8px 18px;border-radius:var(--r-xl);
  background:rgba(255,248,240,0.96);box-shadow:var(--shadow-md);
}
#editorTestBar.hidden{display:none}
.etb-label{font-size:11px;font-weight:900;letter-spacing:.18em;color:var(--clay-coral)}

/* My Levels list */
.my-levels-list{display:flex;flex-direction:column;gap:12px;max-width:560px;margin:0 auto}
.my-level{
  display:flex;align-items:center;gap:14px;
  padding:14px 18px;border-radius:var(--r-lg);
  background:var(--clay-surface);box-shadow:var(--shadow-sm);
}
.my-level-info{flex:1;min-width:0}
.my-level-name{font-size:15px;font-weight:900;color:var(--text-dark);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.my-level-when{font-size:10px;font-weight:700;letter-spacing:.06em;color:var(--text-light);margin-top:3px}
/* Community rating, shown only on published levels (filled async from Firestore). */
.my-level-rating{display:flex;align-items:center;gap:5px;margin-top:5px;font-size:12px;font-weight:800;color:var(--text-mid)}
.my-level-rating .cl-star{font-size:12px}
.my-level-rating small{font-size:10px;font-weight:700;color:var(--text-light)}
.my-level-actions{display:flex;gap:7px;flex-shrink:0}
.my-empty{text-align:center;color:var(--text-light);font-weight:700;font-size:13px;padding:40px 0}

/* JSON modal */
#jsonModal{
  position:fixed;inset:0;z-index:60;
  display:flex;align-items:center;justify-content:center;
  background:rgba(60,45,32,0.45);backdrop-filter:blur(3px);
}
#jsonModal.hidden{display:none}
.json-card{
  width:min(560px,92vw);
  padding:22px;border-radius:var(--r-lg);
  background:var(--clay-surface);box-shadow:var(--shadow-lg);
}
.json-title{font-size:14px;font-weight:900;letter-spacing:.04em;color:var(--text-dark);margin-bottom:14px}
#jsonText{
  width:100%;height:300px;resize:vertical;
  padding:14px;border:none;border-radius:var(--r-md);
  background:var(--bg-deep);box-shadow:var(--shadow-inset);
  font-family:'SFMono-Regular',Consolas,'Liberation Mono',monospace;font-size:12px;line-height:1.5;color:var(--text-dark);
  outline:none;
}
.json-actions{display:flex;gap:9px;justify-content:flex-end;margin-top:16px}

/* ============================================================
   DARK THEME — body.theme-dark
   A single palette override. Everything neutral reads the theme
   hooks (--clay-surface / --menu-glow / --menu-edge / --panel)
   or the core vars below, so flipping them re-skins the whole UI.
   The accent clays (blue/coral/mint/gold/…) are left vivid — they
   pop against the dark surfaces. The handful of rules below patch
   spots that hardcoded a light colour the variables don't reach.
   Toggled in Settings ▸ Display; persisted as settings.theme.
   ============================================================ */
body.theme-dark{
  /* backgrounds, surfaces, panels */
  --bg:         #14161b;   /* deep slate "table" */
  --bg-deep:    #0d0f13;
  --clay-cream: #2a2f3a;   /* base of the neutral surface gradient */
  --clay-bone:  #3a4150;
  --clay-surface: linear-gradient(160deg,#3c4354 0%,#2a2f3a 100%);
  --menu-glow:  #232a37;   /* centre of the menu radials */
  --menu-edge:  #0c0e12;   /* their outer edge */
  --panel:      rgba(30,35,46,0.94);

  /* text — flipped to near-white */
  --text-dark:  #eef1f6;
  --text-mid:   #b7bfcc;
  --text-light: #7f8896;

  /* shadows — deeper, with a faint top sheen instead of a bright one */
  --shadow-sm:  0 4px 0 rgba(0,0,0,0.50), 0 2px 8px rgba(0,0,0,0.55);
  --shadow-md:  0 6px 0 rgba(0,0,0,0.55), 0 4px 16px rgba(0,0,0,0.60);
  --shadow-lg:  0 8px 0 rgba(0,0,0,0.60), 0 6px 24px rgba(0,0,0,0.65);
  --shadow-inset: inset 0 2px 6px rgba(255,255,255,0.05), inset 0 -2px 4px rgba(0,0,0,0.45);
}

/* Frosted win/overlay washes were light-tinted — darken so they dim, not glare. */
body.theme-dark .banner{background:rgba(13,15,19,0.85)}

/* Hairline dividers used near-black alpha (invisible on dark) → use white alpha. */
body.theme-dark .setting-row,
body.theme-dark .keybind-row{border-bottom-color:rgba(255,255,255,0.07)}
body.theme-dark .splash-divider{
  background:linear-gradient(90deg,transparent,rgba(255,255,255,0.14),transparent);
}

/* Toggle track (off state) — was a light clay; match the dark surface. */
body.theme-dark .clay-toggle{background:linear-gradient(160deg,#3a4150,#2a2f3a)}

/* "Used hint" and "locked level" used light grey gradients — re-tone for dark. */
body.theme-dark #hintBtn.used{background:var(--clay-surface);color:var(--text-light)}
body.theme-dark .ld-locked{
  background:linear-gradient(145deg,#2f3540,#262b34);
  box-shadow:0 3px 0 rgba(0,0,0,0.35),0 1px 6px rgba(0,0,0,0.4);
}

/* Editor tooltip paints text-dark as its background → would be light-on-light. */
body.theme-dark #edTooltip{background:#05070b}

/* ============================================================
   MOBILE LEVEL EDITOR — slide-in rails (must come AFTER the editor's
   base styles above so these overrides win the source-order tie; the
   shared mobile @media block higher up is defined *before* those base
   rules and would otherwise lose). On phones the two rails are hidden
   off the side edges and slid in by the edge handles; tapping the board
   centre closes them (wired in EditorController).
   ============================================================ */
@media (max-width:560px){
  /* No dragging on phones — the edge handles drive the rails instead. */
  .ed-grip{display:none}

  /* Palette rail: parked off the left edge until .open slides it in. */
  .editor-side{
    top:64px;left:10px;max-height:calc(100% - 78px);z-index:46;
    transform:translateX(calc(-100% - 24px));
    transition:transform .26s cubic-bezier(.22,.61,.36,1);
  }
  .editor-side.open{transform:translateX(0)}

  /* Actions rail: parked off the right edge until .open slides it in. */
  .editor-actions{
    top:10px;right:10px;width:150px;max-height:calc(100% - 20px);z-index:46;
    transform:translateX(calc(100% + 24px));
    transition:transform .26s cubic-bezier(.22,.61,.36,1);
  }
  .editor-actions.open{transform:translateX(0)}

  .ed-tool{width:124px;font-size:11px;padding:7px 9px}
  .editor-palette{padding:10px}

  /* Edge handles — vertical tabs pinned to each side, centred vertically. */
  .ed-edge-btn{
    display:flex;flex-direction:column;align-items:center;justify-content:center;gap:5px;
    position:fixed;top:50%;transform:translateY(-50%);z-index:47;
    width:34px;padding:16px 0;border:none;cursor:pointer;pointer-events:auto;
    background:var(--clay-surface);color:var(--text-mid);
    box-shadow:var(--shadow-md);font-size:17px;
  }
  .ed-edge-btn span{
    font-family:'Nunito',sans-serif;font-weight:800;font-size:8px;letter-spacing:.12em;
    text-transform:uppercase;writing-mode:vertical-rl;text-orientation:mixed;
  }
  .ed-edge-left{left:0;border-radius:0 var(--r-md) var(--r-md) 0}
  .ed-edge-right{right:0;border-radius:var(--r-md) 0 0 var(--r-md)}
  .ed-edge-btn.active{background:linear-gradient(160deg,#FCE9BE,#F4CC6B);color:#7a5a14}
}

/* Very small phones: tighten the rails so the board keeps a usable strip. */
@media (max-width:380px){
  .editor-side{left:6px}
  .editor-actions{right:6px;width:132px}
  .ed-tool{width:114px}
}
