* { box-sizing: border-box; margin: 0; padding: 0; }

/* Custom cursor: red heart (the player avatar) — applied site-wide.
   Uses the same bezier as the in-game heart drawn in drawPlayer(). */
*, *::before, *::after {
  cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="-16 -16 32 32"><path d="M0,8.4 C15.6,2.4 10.8,-12 0,-4.8 C-10.8,-12 -15.6,2.4 0,8.4 Z" fill="%23ff2040" stroke="%23ffffff" stroke-width="1.5" stroke-linejoin="round"/></svg>') 16 16, auto !important;
}

body {
  background: #111;
  color: #eee;
  font-family: 'Courier New', monospace;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.screen {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.hidden { display: none !important; }

h1 {
  font-size: 48px;
  letter-spacing: 4px;
  margin-bottom: 10px;
  color: #ff5050;
  text-shadow: 0 0 10px rgba(255, 80, 80, 0.5);
}

.subtitle {
  font-size: 18px;
  color: #888;
  margin-bottom: 30px;
}

#diffRow {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.diffBtn {
  background: #222;
  border: 2px solid #444;
  color: #ccc;
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 2px;
  padding: 8px 18px;
  cursor: pointer;
  transition: all 0.1s;
}

.diffBtn:hover { border-color: #888; color: #fff; }

.diffBtn.selected[data-diff="easy"]   { border-color: #44ff66; color: #44ff66; box-shadow: 0 0 8px rgba(68,255,102,0.4); }
.diffBtn.selected[data-diff="medium"] { border-color: #ffcc44; color: #ffcc44; box-shadow: 0 0 8px rgba(255,204,68,0.4); }
.diffBtn.selected[data-diff="hard"]   { border-color: #ff3030; color: #ff3030; box-shadow: 0 0 8px rgba(255,48,48,0.4); }

#diffNote {
  font-size: 12px;
  color: #888;
  margin-bottom: 14px;
  min-height: 16px;
}

#mobileToggleBtn {
  background: #222;
  border: 2px solid #444;
  color: #ccc;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 2px;
  padding: 6px 14px;
  cursor: pointer;
  margin-bottom: 16px;
}
#mobileToggleBtn:hover { border-color: #888; color: #fff; }
body.is-mobile #mobileToggleBtn {
  border-color: #4488ff;
  color: #aacfff;
  box-shadow: 0 0 8px rgba(80, 140, 255, 0.4);
}

#bossGrid {
  display: grid;
  grid-template-columns: repeat(5, 120px);
  gap: 14px;
}

.bossBtn {
  width: 120px;
  height: 120px;
  background: #222;
  border: 2px solid #444;
  color: #eee;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s, border-color 0.1s;
}

.bossBtn:not(:disabled):hover {
  border-color: #ff5050;
  transform: scale(1.05);
}

.bossBtn.locked { opacity: 0.4; cursor: not-allowed; }

.bossIcon { font-size: 48px; }
.bossName { font-size: 11px; margin-top: 6px; }

#fightScreen {
  position: relative;
  padding: 0;
  justify-content: flex-start;
}

#hud {
  width: 800px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #1a1a1a;
  border-bottom: 1px solid #333;
}

#hearts { display: flex; gap: 6px; font-size: 24px; }
.heart { color: #ff3030; text-shadow: 0 0 4px rgba(255, 0, 0, 0.6); }
.heart.empty { color: #333; text-shadow: none; }

#waveLabel { font-size: 18px; letter-spacing: 2px; }
#waveTimer { font-size: 22px; color: #ffcc44; min-width: 30px; text-align: right; }

#game {
  background: #0a0f0a;
  display: block;
}

#flashOverlay {
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 100%;
  background: rgba(255, 0, 0, 0);
  pointer-events: none;
  transition: background 0.15s;
}

.bang {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 64px;
  font-weight: bold;
  color: #ff3030;
  text-shadow: 0 0 12px rgba(255, 0, 0, 0.8);
  pointer-events: none;
  animation: bangPulse 0.6s infinite alternate;
}

#leftBang { left: 4px; }
#rightBang { right: 4px; }

@keyframes bangPulse {
  from { opacity: 0.5; transform: translateY(-50%) scale(1); }
  to { opacity: 1; transform: translateY(-50%) scale(1.15); }
}

#cutsceneScreen {
  position: relative;
  background: #0a0f0a;
  padding: 0;
  justify-content: flex-start;
}

#cutsceneBlack {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 1;
  pointer-events: none;
  transition: opacity 0.5s ease;
  z-index: 5;
}

#cutsceneScreen.revealed #cutsceneBlack { opacity: 0; }

#cutsceneStage {
  position: relative;
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#cutsceneBoss {
  width: 220px;
  height: 220px;
  background: #5b3920;
  border-radius: 50%;
  position: relative;
  margin-top: 100px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

#cutsceneScreen.revealed #cutsceneBoss { opacity: 1; transform: translateY(0); }

.cutEye {
  position: absolute;
  top: 78px;
  width: 32px;
  height: 32px;
  background: white;
  border-radius: 50%;
}
.cutEye.left { left: 62px; }
.cutEye.right { left: 124px; }

.pupil {
  position: absolute;
  top: 12px;
  left: 9px;
  width: 14px;
  height: 14px;
  background: #000;
  border-radius: 50%;
}

.cutBrow {
  position: absolute;
  top: 64px;
  width: 32px;
  height: 4px;
  background: #1a2a10;
  border-radius: 2px;
}
/* Angry: inner ends down */
#cutsceneScreen.mood-angry .cutBrow.left  { left: 55px;  transform: rotate(20deg); }
#cutsceneScreen.mood-angry .cutBrow.right { left: 130px; transform: rotate(-20deg); }
#cutsceneScreen.mood-angry .pupil { top: 8px; left: 9px; }

/* Sad: inner ends up */
#cutsceneScreen.mood-sad .cutBrow { top: 70px; }
#cutsceneScreen.mood-sad .cutBrow.left  { left: 55px;  transform: rotate(-15deg); }
#cutsceneScreen.mood-sad .cutBrow.right { left: 130px; transform: rotate(15deg); }
#cutsceneScreen.mood-sad .pupil { top: 17px; left: 9px; }

.cutHighlight {
  position: absolute;
  top: 30px;
  left: 50px;
  width: 40px;
  height: 18px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 50%;
}

/* Rich Man extras — only visible in appearance-rich */
.cutHat, .cutMonocle, .cutMustache { display: none; }

#cutsceneScreen.appearance-rich #cutsceneBoss { background: #f0c8a0; }

#cutsceneScreen.appearance-rich .cutHat {
  display: block;
  position: absolute;
  top: -55px;
  left: 30px;
  width: 160px;
  height: 70px;
  background: transparent;
}
#cutsceneScreen.appearance-rich .cutHat::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 160px;
  height: 12px;
  background: #1a1a1a;
  border-radius: 4px;
}
#cutsceneScreen.appearance-rich .cutHat::after {
  content: '';
  position: absolute;
  top: 0;
  left: 30px;
  width: 100px;
  height: 60px;
  background: #1a1a1a;
  border-top: 3px solid #1a1a1a;
  border-bottom: 6px solid #d4a614;
  border-radius: 4px 4px 0 0;
}

#cutsceneScreen.appearance-rich .cutMonocle {
  display: block;
  position: absolute;
  top: 70px;
  left: 116px;
  width: 48px;
  height: 48px;
  border: 3px solid #d4a614;
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(255, 220, 80, 0.4);
}

#cutsceneScreen.appearance-rich .cutMustache {
  display: block;
  position: absolute;
  top: 142px;
  width: 36px;
  height: 10px;
  background: #5a3a1a;
  border-radius: 50%;
}
#cutsceneScreen.appearance-rich .cutMustache.left  { left: 70px;  transform: rotate(-12deg); }
#cutsceneScreen.appearance-rich .cutMustache.right { left: 116px; transform: rotate(12deg); }

/* Hide green highlight when in rich appearance */
#cutsceneScreen.appearance-rich .cutHighlight { display: none; }

/* Bobber (bomb with eyes) appearance */
.cutFuse, .cutSpark { display: none; }
#cutsceneScreen.appearance-bobber #cutsceneBoss { background: #1a1a1a; }
#cutsceneScreen.appearance-bobber .cutHighlight { background: rgba(255, 255, 255, 0.18); }
#cutsceneScreen.appearance-bobber .cutBrow { background: #444; }
#cutsceneScreen.appearance-bobber .cutFuse {
  display: block;
  position: absolute;
  top: -56px;
  left: 100px;
  width: 4px;
  height: 60px;
  background: #6a4a2a;
  border-radius: 2px;
  transform: rotate(15deg);
  transform-origin: bottom center;
}
#cutsceneScreen.appearance-bobber .cutSpark {
  display: block;
  position: absolute;
  top: -8px;
  left: -8px;
  width: 20px;
  height: 20px;
  background: radial-gradient(circle, #ffff44 0%, #ff8800 50%, transparent 80%);
  border-radius: 50%;
  animation: spark 0.4s infinite alternate;
}
@keyframes spark {
  from { transform: scale(0.7); opacity: 0.7; }
  to   { transform: scale(1.2); opacity: 1; }
}
#cutsceneScreen.appearance-bobber #cutsceneDialogue .speaker { color: #ff8844; }
#cutsceneScreen.appearance-bobber #cutsceneDialogue { border-color: #555; }

/* Mathematician appearance */
.cutMortarboard, .cutTassel, .cutGlasses { display: none; }
#cutsceneScreen.appearance-math #cutsceneBoss { background: #f0c8a0; }
#cutsceneScreen.appearance-math .cutHighlight { display: none; }
#cutsceneScreen.appearance-math .cutEye { display: none; }
#cutsceneScreen.appearance-math .cutBrow { display: none; }
#cutsceneScreen.appearance-math .cutMortarboard {
  display: block;
  position: absolute;
  top: -32px;
  left: 30px;
  width: 160px;
  height: 12px;
  background: #1a1a1a;
  border-radius: 2px;
  z-index: 2;
}
#cutsceneScreen.appearance-math .cutMortarboard::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 8px;
  width: 144px;
  height: 8px;
  background: #1a1a1a;
  transform: skew(-12deg, 0);
  border-radius: 2px;
}
#cutsceneScreen.appearance-math .cutTassel {
  display: block;
  position: absolute;
  top: -32px;
  left: 184px;
  width: 4px;
  height: 50px;
  background: #ffaa22;
  border-radius: 2px;
  z-index: 2;
}
#cutsceneScreen.appearance-math .cutTassel::after {
  content: '';
  position: absolute;
  top: 50px;
  left: -4px;
  width: 12px;
  height: 14px;
  background: #ffaa22;
  border-radius: 2px;
}
#cutsceneScreen.appearance-math .cutGlasses {
  display: block;
  position: absolute;
  top: 76px;
  width: 50px;
  height: 50px;
  background: #fff;
  border: 3px solid #1a1a1a;
}
#cutsceneScreen.appearance-math .cutGlasses.left  { left: 50px; }
#cutsceneScreen.appearance-math .cutGlasses.right { left: 120px; }
#cutsceneScreen.appearance-math .cutGlasses::before {
  content: '';
  position: absolute;
  top: 18px;
  left: 18px;
  width: 10px;
  height: 10px;
  background: #000;
  border-radius: 50%;
}
#cutsceneScreen.appearance-math .cutMustache {
  display: block;
  position: absolute;
  top: 152px;
  width: 32px;
  height: 6px;
  background: #5a3a1a;
  border-radius: 2px;
}
#cutsceneScreen.appearance-math .cutMustache.left  { left: 70px; }
#cutsceneScreen.appearance-math .cutMustache.right { left: 118px; }
#cutsceneScreen.appearance-math #cutsceneDialogue .speaker { color: #99ddff; }
#cutsceneScreen.appearance-math #cutsceneDialogue { border-color: #99ddff; }

/* Cursed Baby appearance */
#cutsceneScreen.appearance-baby #cutsceneBoss { background: #f0c8a0; }
#cutsceneScreen.appearance-baby .cutHighlight { background: rgba(40, 20, 10, 0.45); top: 70px; left: 30px; width: 30px; height: 30px; border-radius: 50%; }
#cutsceneScreen.appearance-baby .cutBrow { display: none; }
#cutsceneScreen.appearance-baby .cutEye { top: 70px; }
#cutsceneScreen.appearance-baby .pupil { top: 8px; left: 8px; }
#cutsceneScreen.appearance-baby #cutsceneDialogue .speaker { color: #7ed058; }
#cutsceneScreen.appearance-baby #cutsceneDialogue { border-color: #7ed058; }
/* Green goo dripping using box-shadow trick on the boss head */
#cutsceneScreen.appearance-baby #cutsceneBoss::after {
  content: '';
  position: absolute;
  bottom: -20px;
  left: 30px;
  width: 12px;
  height: 60px;
  background: linear-gradient(to bottom, #7ed058 60%, rgba(126, 208, 88, 0));
  border-radius: 6px;
  box-shadow:
    50px 0 0 #7ed058,
    50px 10px 0 #7ed058,
    100px -10px 0 #7ed058;
}
#cutsceneScreen.appearance-baby #cutsceneBoss::before {
  content: '';
  position: absolute;
  top: 130px;
  left: 100px;
  width: 8px;
  height: 30px;
  background: #7ed058;
  border-radius: 4px;
}

/* Default speaker color is green; gold for rich */
#cutsceneScreen.appearance-rich #cutsceneDialogue .speaker { color: #ffd84a; }
#cutsceneScreen.appearance-rich #cutsceneDialogue { border-color: #d4a614; }

/* Hacker — dark hooded figure with a glowing-green eye glow */
#cutsceneScreen.appearance-hacker #cutsceneBoss { background: #0a0a0a; }
#cutsceneScreen.appearance-hacker .cutHat,
#cutsceneScreen.appearance-hacker .cutFuse,
#cutsceneScreen.appearance-hacker .cutMortarboard,
#cutsceneScreen.appearance-hacker .cutTassel,
#cutsceneScreen.appearance-hacker .cutGlasses,
#cutsceneScreen.appearance-hacker .cutMonocle,
#cutsceneScreen.appearance-hacker .cutMustache { display: none; }
#cutsceneScreen.appearance-hacker .cutHighlight {
  background: rgba(102, 255, 102, 0.18);
  top: 30px; left: 30px; width: 110px; height: 60px;
  border-radius: 60px 60px 0 0;
}
#cutsceneScreen.appearance-hacker .cutEye {
  background: #66ff66;
  box-shadow: 0 0 14px #66ff66, 0 0 28px #00ff00;
  top: 80px;
  width: 18px; height: 14px;
  border-radius: 4px;
}
#cutsceneScreen.appearance-hacker .pupil { display: none; }
#cutsceneScreen.appearance-hacker .cutBrow {
  background: #66ff66;
  box-shadow: 0 0 6px #66ff66;
}
#cutsceneScreen.appearance-hacker #cutsceneDialogue .speaker { color: #66ff66; }
#cutsceneScreen.appearance-hacker #cutsceneDialogue {
  border-color: #66ff66;
  font-family: monospace;
}
#cutsceneScreen.appearance-hacker #cutsceneBoss::after {
  content: '01010111 0F 0xDEAD';
  position: absolute;
  bottom: 6px; left: 8px; right: 8px;
  color: rgba(102, 255, 102, 0.45);
  font: 10px monospace;
  text-align: center;
  pointer-events: none;
}

/* Martial Artist — skin head, red gi top, black belt, red headband */
#cutsceneScreen.appearance-martial #cutsceneBoss { background: #f0c8a0; }
#cutsceneScreen.appearance-martial .cutHat,
#cutsceneScreen.appearance-martial .cutFuse,
#cutsceneScreen.appearance-martial .cutMortarboard,
#cutsceneScreen.appearance-martial .cutTassel,
#cutsceneScreen.appearance-martial .cutGlasses,
#cutsceneScreen.appearance-martial .cutMonocle,
#cutsceneScreen.appearance-martial .cutMustache,
#cutsceneScreen.appearance-martial .cutHighlight { display: none; }
#cutsceneScreen.appearance-martial .cutEye {
  background: #fff;
  width: 14px; height: 9px; top: 70px;
  border: 2px solid #1a1a1a;
}
#cutsceneScreen.appearance-martial .pupil {
  background: #1a1a1a; width: 4px; height: 4px;
  top: 1px; left: 4px;
}
#cutsceneScreen.appearance-martial .cutBrow {
  background: #1a1a1a;
  height: 3px;
  top: 60px;
  width: 18px;
}
/* Red headband across top */
#cutsceneScreen.appearance-martial #cutsceneBoss::before {
  content: '';
  position: absolute;
  top: 38px; left: 12px; right: 12px;
  height: 14px;
  background: #ee2020;
  border-bottom: 2px solid #aa1010;
}
/* Red gi top + black belt at the bottom of the head */
#cutsceneScreen.appearance-martial #cutsceneBoss::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 56px;
  background: linear-gradient(
    to bottom,
    #aa1818 0,
    #aa1818 38px,
    #1a1a1a 38px,
    #1a1a1a 46px,
    #aa1818 46px
  );
}
#cutsceneScreen.appearance-martial #cutsceneDialogue .speaker { color: #ee4040; }
#cutsceneScreen.appearance-martial #cutsceneDialogue { border-color: #aa1818; }

/* Create Battle button */
#createBattleBtn {
  position: absolute;
  top: 80px;
  right: 24px;
  background: linear-gradient(135deg, #66ff99, #66ccff);
  border: 3px solid #ffffff;
  color: #1a1a1a;
  font-family: monospace;
  font-weight: bold;
  font-size: 14px;
  letter-spacing: 1px;
  padding: 12px 18px;
  cursor: pointer;
  border-radius: 28px;
  box-shadow: 0 4px 20px rgba(100, 255, 200, 0.5);
  z-index: 10;
}
#createBattleBtn:hover { transform: scale(1.05); }

/* Creator screen layout */
#creatorScreen {
  background: #14201a;
  color: #d8e8c8;
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
  flex-direction: column;
}
#creatorBody { min-height: 0; }

/* Use the OS cursor inside the editor instead of the site-wide heart cursor */
#creatorScreen,
#creatorScreen *,
#creatorScreen *::before,
#creatorScreen *::after {
  cursor: auto !important;
}
#creatorScreen button,
#creatorScreen .creatorThingBtn,
#creatorScreen .creatorSwatch { cursor: pointer !important; }
#creatorScreen input,
#creatorScreen select { cursor: text !important; }
#creatorScreen input[type="checkbox"],
#creatorScreen input[type="number"] { cursor: pointer !important; }
#creatorScreen .creatorPx,
#creatorScreen #creatorPlayCanvas { cursor: crosshair !important; }
#creatorTopBar {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  background: #0e1612;
  border-bottom: 2px solid #3a5a3a;
  align-items: center;
}
#creatorTopBar input,
#creatorTopBar button {
  font-family: monospace;
  font-size: 14px;
  padding: 8px 12px;
  border: 2px solid #3a5a3a;
  background: #1a2a1a;
  color: #d8e8c8;
  cursor: pointer;
}
#creatorTopBar input { flex: 1; max-width: 280px; cursor: text; }
#creatorPlayBtn { background: #2a6020; color: #ffffff; }
#creatorSaveBtn { background: #2a4a70; color: #ffffff; }

#creatorBody {
  display: grid;
  grid-template-columns: 200px 1fr 320px;
  gap: 12px;
  padding: 12px 16px;
  flex: 1;
  overflow: hidden;
}
#creatorBody h3 {
  margin: 4px 0 8px 0;
  letter-spacing: 1px;
  color: #9bc44b;
  font-size: 13px;
}
#creatorBody h3 small { color: #6f8b58; font-weight: normal; font-size: 10px; margin-left: 4px; }

/* Things list */
#creatorThingsCol { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
#creatorThingsList { display: flex; flex-direction: column; gap: 4px; max-height: 360px; overflow-y: auto; }
.creatorThingBtn {
  font-family: monospace;
  font-size: 13px;
  padding: 8px 10px;
  border: 2px solid #3a5a3a;
  background: #1a2a1a;
  color: #d8e8c8;
  cursor: pointer;
  text-align: left;
}
.creatorThingBtn.selected {
  background: #2a4a30;
  border-color: #9bc44b;
  color: #ffffff;
}
#creatorAddThingBtn,
#creatorDelThingBtn {
  font-family: monospace;
  font-size: 12px;
  padding: 8px 10px;
  border: 2px solid #3a5a3a;
  background: #1a2a1a;
  color: #d8e8c8;
  cursor: pointer;
}
#creatorAddThingBtn { background: #224a2a; }
#creatorDelThingBtn { background: #4a2222; }

/* Editor */
#creatorEditorCol { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
#creatorPaletteRow {
  display: flex; gap: 4px; flex-wrap: wrap;
  background: #0a120c;
  padding: 6px;
  border: 2px solid #3a5a3a;
}
.creatorSwatch {
  width: 22px; height: 22px;
  border: 2px solid #3a5a3a;
  cursor: pointer;
}
.creatorSwatch.selected { border-color: #ffffff; box-shadow: 0 0 6px #ffffff; }
.creatorSwatch.eraser {
  background: repeating-conic-gradient(#666 0 25%, #ccc 0 50%);
  background-size: 6px 6px;
  color: #000;
  text-align: center;
  font-size: 10px;
  font-weight: bold;
  line-height: 22px;
}
#creatorPixelGrid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 16), 1fr);
  width: 320px;
  height: 320px;
  background: #1a1a1a;
  border: 2px solid #3a5a3a;
  user-select: none;
}
.creatorPx {
  border: 1px solid rgba(60, 60, 60, 0.4);
  cursor: crosshair;
}

/* Behavior + spawners panel */
#creatorBehaviorCol { display: flex; flex-direction: column; gap: 6px; }
#creatorBehaviorCol label {
  display: flex; align-items: center; gap: 8px;
  font-family: monospace; font-size: 12px; color: #d8e8c8;
}
#creatorBehaviorCol input,
#creatorBehaviorCol select {
  flex: 1;
  padding: 6px 8px;
  border: 2px solid #3a5a3a;
  background: #1a2a1a;
  color: #d8e8c8;
  font-family: monospace;
}
#creatorBehaviorCol .hint { font-size: 11px; color: #8aa078; line-height: 1.3; margin: 4px 0; }
#creatorPlayCanvas {
  display: block;
  width: 100%;
  height: auto;
  background: #1a2a1a;
  border: 2px solid #3a5a3a;
  cursor: crosshair;
}

/* Chat box */
#creatorChat {
  background: #0e1612;
  border-top: 2px solid #3a5a3a;
  padding: 8px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 0 0 auto;
}
#creatorChatLog {
  max-height: 90px;
  overflow-y: auto;
  font-family: monospace;
  font-size: 12px;
  background: #1a2a1a;
  border: 2px solid #2a3a2a;
  padding: 6px 8px;
}
#creatorChatLog:empty::before {
  content: 'tell me what to change ↓';
  color: #6f8b58;
}
.creatorChatLine { padding: 1px 0; line-height: 1.3; }
.creatorChatLine.you { color: #aaffaa; }
.creatorChatLine.bot { color: #ffeebb; }
#creatorChatForm {
  display: flex;
  gap: 6px;
}
#creatorChatInput {
  flex: 1;
  padding: 8px 10px !important;
  font-family: monospace;
  font-size: 13px;
  background: #1a2a1a;
  color: #d8e8c8;
  border: 2px solid #3a5a3a;
}
#creatorChatForm button {
  padding: 8px 18px;
  font-family: monospace;
  font-weight: bold;
  letter-spacing: 1px;
  background: #2a4a30;
  color: #fff;
  border: 2px solid #9bc44b;
  cursor: pointer;
}
#creatorChatForm button:hover { background: #3a6a40; }

/* Toast */
#creatorToast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #2a6020;
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 20px;
  font-family: monospace;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 100;
}
#creatorToast.show { opacity: 1; }

/* Side fidget battle button */
#fidgetBattleBtn {
  position: absolute;
  top: 24px;
  right: 24px;
  background: linear-gradient(135deg, #ff66cc, #66ccff 50%, #ffcc66);
  border: 3px solid #ffffff;
  color: #1a1a1a;
  font-family: monospace;
  font-weight: bold;
  font-size: 14px;
  letter-spacing: 1px;
  padding: 12px 18px;
  cursor: pointer;
  border-radius: 28px;
  box-shadow: 0 4px 20px rgba(255, 100, 200, 0.5);
  z-index: 10;
}
#fidgetBattleBtn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 28px rgba(255, 100, 200, 0.75);
}

/* Fidget cutscene appearance — purple twisty cone vibe */
#cutsceneScreen.appearance-fidget #cutsceneBoss {
  background: linear-gradient(135deg, #c9a4d6 0%, #5a3c80 100%);
  box-shadow: inset 0 0 40px rgba(255, 200, 255, 0.4);
}
#cutsceneScreen.appearance-fidget .cutHat,
#cutsceneScreen.appearance-fidget .cutFuse,
#cutsceneScreen.appearance-fidget .cutMortarboard,
#cutsceneScreen.appearance-fidget .cutTassel,
#cutsceneScreen.appearance-fidget .cutGlasses,
#cutsceneScreen.appearance-fidget .cutMonocle,
#cutsceneScreen.appearance-fidget .cutMustache,
#cutsceneScreen.appearance-fidget .cutHighlight { display: none; }
#cutsceneScreen.appearance-fidget .cutEye {
  background: #ffffff;
  width: 10px; height: 10px;
  top: 80px;
  border-radius: 50%;
}
#cutsceneScreen.appearance-fidget .pupil {
  background: #1a1a1a; width: 4px; height: 4px;
  top: 3px; left: 3px;
}
#cutsceneScreen.appearance-fidget .cutBrow { display: none; }
#cutsceneScreen.appearance-fidget #cutsceneDialogue .speaker { color: #ffaaee; }
#cutsceneScreen.appearance-fidget #cutsceneDialogue { border-color: #ff66cc; }

/* Galaxy Chip — purple cosmic head with glowing eyes */
#cutsceneScreen.appearance-galaxy #cutsceneBoss {
  background: radial-gradient(circle at 30% 30%, #5a30a0 0%, #2a0a50 70%, #08021a 100%);
  box-shadow: 0 0 40px rgba(180, 100, 255, 0.55), inset 0 0 30px rgba(180, 100, 255, 0.4);
}
#cutsceneScreen.appearance-galaxy .cutHat,
#cutsceneScreen.appearance-galaxy .cutFuse,
#cutsceneScreen.appearance-galaxy .cutMortarboard,
#cutsceneScreen.appearance-galaxy .cutTassel,
#cutsceneScreen.appearance-galaxy .cutGlasses,
#cutsceneScreen.appearance-galaxy .cutMonocle,
#cutsceneScreen.appearance-galaxy .cutMustache,
#cutsceneScreen.appearance-galaxy .cutHighlight { display: none; }
#cutsceneScreen.appearance-galaxy .cutEye {
  background: #ffffaa;
  box-shadow: 0 0 16px #ffeebb, 0 0 32px #ff80ff;
  width: 16px; height: 14px;
  border-radius: 50%;
  top: 80px;
}
#cutsceneScreen.appearance-galaxy .pupil {
  background: #1a1a1a; width: 4px; height: 4px;
  top: 5px; left: 6px;
}
#cutsceneScreen.appearance-galaxy .cutBrow { display: none; }
/* Spiraling galaxy hint over the head */
#cutsceneScreen.appearance-galaxy #cutsceneBoss::before {
  content: '';
  position: absolute;
  top: 30px; left: 50%;
  width: 90px; height: 90px;
  margin-left: -45px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 200, 0.4) 0%, transparent 30%),
    conic-gradient(from 0deg, rgba(255,255,255,0.2), rgba(180,100,255,0.5), rgba(255,255,255,0.2));
  filter: blur(4px);
  pointer-events: none;
}
#cutsceneScreen.appearance-galaxy #cutsceneDialogue .speaker { color: #cca8ff; }
#cutsceneScreen.appearance-galaxy #cutsceneDialogue { border-color: #6a30c0; }

/* Cursed Chip — dark purple void with red eyes */
#cutsceneScreen.appearance-cursed #cutsceneBoss {
  background: radial-gradient(circle at 50% 50%, #3a1058 0%, #200a30 60%, #08020e 100%);
  box-shadow: 0 0 40px rgba(220, 30, 220, 0.5), inset 0 0 30px rgba(220, 30, 220, 0.3);
}
#cutsceneScreen.appearance-cursed .cutHat,
#cutsceneScreen.appearance-cursed .cutFuse,
#cutsceneScreen.appearance-cursed .cutMortarboard,
#cutsceneScreen.appearance-cursed .cutTassel,
#cutsceneScreen.appearance-cursed .cutGlasses,
#cutsceneScreen.appearance-cursed .cutMonocle,
#cutsceneScreen.appearance-cursed .cutMustache,
#cutsceneScreen.appearance-cursed .cutHighlight { display: none; }
#cutsceneScreen.appearance-cursed .cutEye {
  background: #ff4040;
  box-shadow: 0 0 14px #ff2020, 0 0 28px #ff0000;
  width: 16px; height: 14px; top: 80px;
  border-radius: 4px;
}
#cutsceneScreen.appearance-cursed .pupil {
  background: #1a0000; width: 4px; height: 4px;
  top: 5px; left: 6px;
}
#cutsceneScreen.appearance-cursed .cutBrow { display: none; }
#cutsceneScreen.appearance-cursed #cutsceneDialogue .speaker { color: #ff66cc; }
#cutsceneScreen.appearance-cursed #cutsceneDialogue { border-color: #aa30c0; }

/* Death — pitch black with a glowing skull */
#cutsceneScreen.appearance-death #cutsceneBoss {
  background: radial-gradient(circle at 50% 50%, #1a0000 0%, #000000 70%);
  box-shadow: 0 0 50px rgba(255, 30, 30, 0.5), inset 0 0 40px rgba(0, 0, 0, 0.9);
}
#cutsceneScreen.appearance-death .cutHat,
#cutsceneScreen.appearance-death .cutFuse,
#cutsceneScreen.appearance-death .cutMortarboard,
#cutsceneScreen.appearance-death .cutTassel,
#cutsceneScreen.appearance-death .cutGlasses,
#cutsceneScreen.appearance-death .cutMonocle,
#cutsceneScreen.appearance-death .cutMustache,
#cutsceneScreen.appearance-death .cutHighlight { display: none; }
#cutsceneScreen.appearance-death .cutEye {
  background: #ff2020;
  box-shadow: 0 0 18px #ff0000, 0 0 36px #ff0000;
  width: 14px; height: 14px; top: 78px;
  border-radius: 50%;
}
#cutsceneScreen.appearance-death .pupil { display: none; }
#cutsceneScreen.appearance-death .cutBrow { display: none; }
#cutsceneScreen.appearance-death #cutsceneBoss::before {
  content: '';
  position: absolute;
  top: 60px; left: 50%;
  width: 80px; height: 90px;
  margin-left: -40px;
  background: #e8e4d0;
  border-radius: 50% 50% 35% 35%;
  z-index: -1;
}
#cutsceneScreen.appearance-death #cutsceneBoss::after {
  content: '';
  position: absolute;
  bottom: 4px; left: 12px; right: 12px;
  height: 36px;
  background: linear-gradient(to bottom, transparent 0%, #0a0010 70%);
}
#cutsceneScreen.appearance-death #cutsceneDialogue .speaker { color: #ff4040; letter-spacing: 4px; }
#cutsceneScreen.appearance-death #cutsceneDialogue { border-color: #880000; background: #0a0000; }

#cutsceneDialogue {
  position: absolute;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%);
  width: 640px;
  background: #14201a;
  border: 3px solid #3a5a3a;
  padding: 20px 24px 18px;
  opacity: 0;
  transition: opacity 0.4s ease;
}

#cutsceneScreen.dialogue-shown #cutsceneDialogue { opacity: 1; }

#cutsceneDialogue .speaker {
  font-size: 14px;
  letter-spacing: 3px;
  color: #9bc44b;
  margin-bottom: 8px;
}

#cutsceneDialogue .text {
  font-size: 18px;
  line-height: 1.5;
  color: #eee;
  min-height: 56px;
  margin-bottom: 14px;
}

#cutsceneContinue {
  background: #222;
  border: 2px solid #555;
  color: #eee;
  padding: 8px 18px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.3s ease;
}
#cutsceneContinue.ready { opacity: 1; }
#cutsceneContinue:hover { border-color: #ff5050; }

#winScreen h1 { color: #44ff66; text-shadow: 0 0 10px rgba(68, 255, 102, 0.5); }
#loseScreen h1 { color: #888; }
#tieScreen h1 { color: #ff8844; text-shadow: 0 0 10px rgba(255, 136, 68, 0.5); }
#tieScreen p { margin-bottom: 30px; }
#tieRetryBtn, #tieBackBtn {
  background: #222;
  border: 2px solid #555;
  color: #eee;
  padding: 12px 24px;
  font-family: inherit;
  font-size: 16px;
  cursor: pointer;
  margin: 6px;
}
#tieRetryBtn:hover, #tieBackBtn:hover { border-color: #ff5050; }

/* ========================================
   Mobile controls (joystick + buttons)
   ======================================== */
#mobileControls { display: none; }
body.is-mobile #mobileControls {
  display: block;
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
}

body.is-mobile #joystickBase {
  position: absolute;
  bottom: 28px;
  left: 28px;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 3px solid rgba(255, 255, 255, 0.25);
  pointer-events: auto;
  touch-action: none;
}
body.is-mobile #joystickThumb {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 56px;
  height: 56px;
  margin-top: -28px;
  margin-left: -28px;
  border-radius: 50%;
  background: rgba(255, 100, 100, 0.85);
  border: 2px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 0 12px rgba(255, 80, 80, 0.6);
  pointer-events: none;
}

body.is-mobile .mobileBtn {
  position: absolute;
  bottom: 36px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.5);
  color: #fff;
  font-family: 'Courier New', monospace;
  font-size: 16px;
  font-weight: bold;
  letter-spacing: 2px;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
body.is-mobile .mobileBtn:active { transform: scale(0.92); }
body.is-mobile #dashBtn   { right: 140px; background: rgba(80, 180, 255, 0.7); }
body.is-mobile #attackBtn { right: 30px;  background: rgba(255, 80, 80, 0.7);  width: 110px; height: 110px; bottom: 26px; }

/* Make canvas / fight screen scale on smaller screens */
@media (max-width: 900px) {
  body { display: block; overflow: auto; }
  .screen { padding: 4px; }
  #fightScreen { padding: 0; }
  #hud { width: 100%; max-width: 100vw; }
  #game {
    width: 100vw;
    max-width: 100vw;
    height: auto;
    aspect-ratio: 800 / 600;
  }
  #flashOverlay { width: 100vw; }
  #bossGrid {
    grid-template-columns: repeat(auto-fit, 110px);
    max-width: 90vw;
  }
  .bossBtn { width: 110px; height: 110px; }
  .bossIcon { font-size: 40px; }
  h1 { font-size: 32px; }
}

#winScreen p, #loseScreen p { margin-bottom: 30px; }

#winBackBtn, #loseRetryBtn, #loseBackBtn {
  background: #222;
  border: 2px solid #555;
  color: #eee;
  padding: 12px 24px;
  font-family: inherit;
  font-size: 16px;
  cursor: pointer;
  margin: 6px;
}

#winBackBtn:hover, #loseRetryBtn:hover, #loseBackBtn:hover {
  border-color: #ff5050;
}
