/* ============ SLIME SQUAD ============ */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --green: #4ade80;
  --red: #f87171;
  --blue: #60a5fa;
  --yellow: #facc15;
  --purple: #c084fc;
  --bg-deep: #0f0a1e;
  --panel: rgba(20, 12, 45, 0.92);
  --panel-border: #6d28d9;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  font-family: "Trebuchet MS", "Comic Sans MS", system-ui, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  color: #fff;
}

#game-wrap { position: fixed; inset: 0; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- screens ---------- */
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 18px;
  background: radial-gradient(ellipse at 50% 30%, #2a1b52 0%, var(--bg-deep) 75%);
  z-index: 20;
  padding: 20px;
  text-align: center;
}
.screen.overlay { background: rgba(10, 5, 25, 0.82); backdrop-filter: blur(3px); }
.hidden { display: none !important; }

h1 {
  font-size: clamp(44px, 10vw, 92px);
  letter-spacing: 4px;
  background: linear-gradient(180deg, #a7f3d0, var(--green) 45%, #16a34a);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 0 #14532d) drop-shadow(0 8px 18px rgba(74, 222, 128, .35));
  animation: bob 2.4s ease-in-out infinite;
}
@keyframes bob { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-8px) } }

.tagline {
  font-size: clamp(16px, 3vw, 26px);
  color: var(--yellow);
  font-weight: bold;
  letter-spacing: 6px;
  text-shadow: 0 2px 0 #92400e;
}

.title-slimes { display: flex; justify-content: center; gap: 10px; margin-bottom: 6px; }
.tslime {
  width: 42px; height: 34px; display: inline-block;
  border-radius: 50% 50% 42% 42% / 62% 62% 38% 38%;
  animation: bounce 1.1s ease-in-out infinite;
  box-shadow: inset -6px -6px 0 rgba(0,0,0,.18);
}
.tslime.green { background: var(--green); }
.tslime.red { background: var(--red); animation-delay: .15s; }
.tslime.blue { background: var(--blue); animation-delay: .3s; }
.tslime.yellow { background: var(--yellow); animation-delay: .45s; }
@keyframes bounce { 0%,100% { transform: translateY(0) scaleX(1) } 40% { transform: translateY(-16px) scaleX(.95) } 70% { transform: translateY(0) scaleX(1.08) scaleY(.9) } }

h2 {
  font-size: clamp(30px, 6vw, 52px);
  color: var(--yellow);
  letter-spacing: 3px;
  text-shadow: 0 3px 0 #92400e, 0 6px 14px rgba(0,0,0,.5);
}
.pop-title { animation: pop .35s cubic-bezier(.2, 2.2, .4, 1) both; }
@keyframes pop { from { transform: scale(.3); opacity: 0 } to { transform: scale(1); opacity: 1 } }

/* ---------- buttons ---------- */
.big-btn {
  font-family: inherit;
  font-size: clamp(18px, 3.4vw, 26px);
  font-weight: bold;
  letter-spacing: 2px;
  color: #fff;
  background: linear-gradient(180deg, #8b5cf6, #6d28d9);
  border: 3px solid #c4b5fd;
  border-radius: 16px;
  padding: 14px 38px;
  cursor: pointer;
  box-shadow: 0 5px 0 #4c1d95, 0 8px 16px rgba(0,0,0,.45);
  transition: transform .08s, box-shadow .08s, filter .15s;
  min-width: 240px;
}
.big-btn:hover { filter: brightness(1.15); transform: translateY(-2px); }
.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #4c1d95; }
.big-btn.small-btn { font-size: clamp(14px, 2.6vw, 19px); padding: 10px 26px; min-width: 200px; }
.big-btn.locked { filter: grayscale(.85) brightness(.7); }
.big-btn.go-btn { background: linear-gradient(180deg, #4ade80, #16a34a); border-color: #bbf7d0; box-shadow: 0 5px 0 #14532d, 0 8px 16px rgba(0,0,0,.45); }
.big-btn.go-btn:active { box-shadow: 0 2px 0 #14532d; }
.title-buttons, .row-buttons { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.row-buttons { flex-direction: row; flex-wrap: wrap; justify-content: center; }

.corner-btn {
  position: absolute; top: max(10px, env(safe-area-inset-top)); right: 12px;
  font-size: 22px; width: 48px; height: 48px;
  background: var(--panel); color: #fff;
  border: 2px solid var(--panel-border); border-radius: 12px;
  cursor: pointer; z-index: 30;
}
#btn-pause { position: static; pointer-events: auto; }

.coin-chip { background: rgba(0,0,0,.35); border-radius: 20px; padding: 2px 10px; font-size: .8em; }
.coin-chip.big { font-size: 1em; padding: 4px 14px; }

.title-stats { font-size: clamp(13px, 2.4vw, 17px); color: #c4b5fd; line-height: 1.7; }

/* ---------- character select ---------- */
.char-grid { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.char-card {
  width: 128px; padding: 14px 8px 10px;
  background: var(--panel);
  border: 3px solid #4c1d95; border-radius: 18px;
  cursor: pointer;
  transition: transform .12s, border-color .12s, box-shadow .12s;
}
.char-card:hover { transform: translateY(-4px); }
.char-card.selected { border-color: var(--yellow); box-shadow: 0 0 22px rgba(250, 204, 21, .45); transform: translateY(-4px) scale(1.05); }
.char-card.locked-card { filter: grayscale(1) brightness(.55); }
.char-card canvas { width: 84px; height: 84px; image-rendering: pixelated; }
.char-card .cname { font-weight: bold; font-size: 17px; margin-top: 4px; }
.char-card .clock { font-size: 12px; color: #fca5a5; margin-top: 4px; line-height: 1.3; }
.char-info {
  min-height: 84px; max-width: 560px;
  background: var(--panel); border: 2px solid var(--panel-border);
  border-radius: 14px; padding: 12px 20px;
  font-size: clamp(14px, 2.6vw, 18px); line-height: 1.55;
}
.char-info b { color: var(--yellow); }

/* ---------- shop ---------- */
.shop-sub { color: #c4b5fd; font-size: clamp(14px, 2.6vw, 18px); }
.shop-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px; width: min(92vw, 720px);
  max-height: 52vh; overflow-y: auto; padding: 4px;
}
.shop-item {
  background: var(--panel); border: 2px solid var(--panel-border);
  border-radius: 14px; padding: 12px; text-align: left;
  display: flex; flex-direction: column; gap: 6px;
}
.shop-item .s-head { display: flex; justify-content: space-between; align-items: center; font-weight: bold; font-size: 16px; }
.shop-item .s-desc { font-size: 13px; color: #ddd6fe; line-height: 1.4; }
.shop-item .s-pips { display: flex; gap: 4px; }
.shop-item .pip { width: 18px; height: 8px; border-radius: 4px; background: #3b2a63; }
.shop-item .pip.on { background: var(--green); }
.shop-item button {
  font-family: inherit; font-weight: bold; font-size: 15px;
  padding: 8px; border-radius: 10px; cursor: pointer;
  background: linear-gradient(180deg, var(--yellow), #d97706);
  border: 2px solid #fef08a; color: #451a03;
}
.shop-item button:disabled { filter: grayscale(.8) brightness(.6); cursor: default; }

/* ---------- help ---------- */
.help-body {
  max-width: 620px; background: var(--panel);
  border: 2px solid var(--panel-border); border-radius: 16px;
  padding: 18px 24px; text-align: left;
  font-size: clamp(14px, 2.7vw, 19px); line-height: 1.9;
}
.help-body b { color: var(--yellow); }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 10; }
.hud-top {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: max(10px, env(safe-area-inset-top)) 12px 0;
  gap: 10px;
}
.hud-left { display: flex; flex-direction: column; gap: 5px; width: min(34vw, 260px); }
.bar { position: relative; height: 22px; border-radius: 11px; background: rgba(0,0,0,.55); border: 2px solid rgba(255,255,255,.25); overflow: hidden; }
.bar span {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: bold; text-shadow: 0 1px 2px #000;
}
#hp-fill { height: 100%; width: 100%; background: linear-gradient(180deg, #4ade80, #16a34a); border-radius: 8px; transition: width .15s; }
#hp-fill.low { background: linear-gradient(180deg, #f87171, #b91c1c); }
.xp-bar { height: 16px; }
#xp-fill { height: 100%; width: 0%; background: linear-gradient(180deg, #a78bfa, #7c3aed); border-radius: 8px; transition: width .15s; }
.hud-mid { text-align: center; }
#timer { font-size: clamp(26px, 5vw, 40px); font-weight: bold; text-shadow: 0 2px 0 #000, 0 4px 10px rgba(0,0,0,.6); letter-spacing: 2px; }
#boss-warn { color: var(--red); font-weight: bold; font-size: clamp(15px, 3vw, 22px); animation: blink .5s steps(2) infinite; text-shadow: 0 2px 4px #000; }
@keyframes blink { to { opacity: .25 } }
.hud-right { display: flex; align-items: center; gap: 10px; font-size: clamp(15px, 3vw, 20px); font-weight: bold; text-shadow: 0 2px 3px #000; }
#boss-bar-wrap { position: absolute; top: 64px; left: 50%; transform: translateX(-50%); width: min(70vw, 480px); }
.boss-bar { height: 20px; border-color: #fca5a5; }
#boss-fill { height: 100%; width: 100%; background: linear-gradient(180deg, #f87171, #991b1b); transition: width .12s; }

/* ---------- upgrade cards ---------- */
.upgrade-cards { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.up-card {
  width: min(200px, 28vw); min-width: 150px;
  background: linear-gradient(180deg, #2a1b52, #17102e);
  border: 3px solid var(--panel-border); border-radius: 18px;
  padding: 20px 14px; cursor: pointer;
  transition: transform .12s, border-color .12s, box-shadow .12s;
  animation: cardIn .35s cubic-bezier(.2, 1.6, .4, 1) both;
}
.up-card:nth-child(2) { animation-delay: .07s; }
.up-card:nth-child(3) { animation-delay: .14s; }
@keyframes cardIn { from { transform: translateY(40px) scale(.8); opacity: 0 } to { transform: none; opacity: 1 } }
.up-card:hover { transform: translateY(-6px) scale(1.04); border-color: var(--yellow); box-shadow: 0 0 24px rgba(250, 204, 21, .35); }
.up-card .u-icon { font-size: 44px; }
.up-card .u-name { font-weight: bold; font-size: 18px; color: var(--yellow); margin: 8px 0 6px; }
.up-card .u-desc { font-size: 14px; color: #ddd6fe; line-height: 1.4; }
.up-card .u-tag { display: inline-block; margin-top: 8px; font-size: 11px; background: #4c1d95; padding: 2px 10px; border-radius: 10px; color: #c4b5fd; }
.up-card.new-weapon { border-color: var(--green); }

/* ---------- end screen ---------- */
.end-stats {
  background: var(--panel); border: 2px solid var(--panel-border);
  border-radius: 16px; padding: 16px 30px;
  font-size: clamp(16px, 3vw, 22px); line-height: 2;
}
.end-stats b { color: var(--yellow); }
.end-unlocks { color: var(--green); font-weight: bold; font-size: clamp(15px, 3vw, 20px); line-height: 1.8; }
#end-title.win {
  background: linear-gradient(180deg, #fef08a, var(--yellow) 50%, #d97706);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 3px 0 #92400e);
}

/* ---------- joystick ---------- */
#joy-base {
  position: absolute; width: 110px; height: 110px;
  border-radius: 50%; background: rgba(255,255,255,.08);
  border: 2px solid rgba(255,255,255,.25);
  z-index: 15; pointer-events: none;
  transform: translate(-50%, -50%);
}
#joy-stick {
  position: absolute; left: 50%; top: 50%; width: 48px; height: 48px;
  border-radius: 50%; background: rgba(255,255,255,.35);
  transform: translate(-50%, -50%);
}

@media (max-width: 600px) {
  .hud-left { width: 40vw; }
  .up-card { width: 80vw; max-width: 320px; padding: 12px; animation-name: cardInM; }
  @keyframes cardInM { from { transform: translateY(30px); opacity: 0 } to { transform: none; opacity: 1 } }
  .up-card .u-icon { font-size: 30px; }
  .upgrade-cards { flex-direction: column; align-items: center; gap: 10px; }
}
