@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;700;800&display=swap');

:root {
  --blue: #3a8dff;
  --blue-dark: #1f4fa8;
  --green: #5cff9d;
  --pink: #ff6fb5;
  --yellow: #ffd84a;
  --panel: rgba(20, 28, 60, 0.92);
  --text: #fff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0b1030;
  font-family: 'Baloo 2', 'Arial Rounded MT Bold', system-ui, sans-serif;
  color: var(--text);
  user-select: none;
}

#game { display: block; width: 100vw; height: 100vh; }

.hidden { display: none !important; }

/* HUD */
#hud {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 12px 16px; pointer-events: none; gap: 12px;
}
#hud > * { pointer-events: auto; }
.hud-left, .hud-right { display: flex; gap: 8px; flex-wrap: wrap; }
.hud-left { flex-direction: column; align-items: flex-start; }
.hud-center { flex: 1; max-width: 380px; text-align: center; }

.pill {
  background: var(--panel);
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 18px; font-weight: 700;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  white-space: nowrap;
}

.danger-label { font-weight: 800; font-size: 15px; text-shadow: 0 2px 4px #000; }
.danger-bar {
  height: 18px; border-radius: 9px; background: rgba(0,0,0,0.5);
  border: 2px solid rgba(255,255,255,0.3); overflow: hidden;
}
#danger-fill {
  height: 100%; width: 10%;
  background: linear-gradient(90deg, #ffd84a, #ff8a3d, #ff3d5a);
  transition: width 0.4s;
}
#danger-fill.pulse { animation: pulse 0.6s infinite alternate; }
@keyframes pulse { from { filter: brightness(1); } to { filter: brightness(1.8); } }

#mission-hud {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px; pointer-events: none;
}

#mission-hud { pointer-events: auto; align-items: center; }
#mission-hud .btn { pointer-events: auto; }
.minibar { display: inline-block; width: 160px; height: 14px; border-radius: 7px; background: rgba(0,0,0,0.5); vertical-align: middle; overflow: hidden; margin-left: 6px; }
.minibar span { display: block; height: 100%; background: linear-gradient(90deg, #ff3d5a, #ff8a3d); transition: width 0.2s; }
#hud-hearts.hurt { animation: shake 0.4s; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.btn {
  font-family: inherit; font-weight: 800; font-size: 20px;
  color: #fff; background: var(--blue);
  border: none; border-bottom: 4px solid var(--blue-dark);
  border-radius: 14px; padding: 10px 22px; cursor: pointer;
  transition: transform 0.08s, filter 0.15s;
}
.btn:hover { filter: brightness(1.15); transform: translateY(-1px); }
.btn:active { transform: translateY(2px); border-bottom-width: 2px; }
.btn.small { font-size: 15px; padding: 6px 12px; border-bottom-width: 3px; border-radius: 10px; }
.btn.green { background: #2fbf6b; border-bottom-color: #1b7f45; }
.btn.pink { background: var(--pink); border-bottom-color: #b33a7a; }
.btn.grey { background: #66708f; border-bottom-color: #3f4660; }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; filter: none; }

#prompt {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 3px solid var(--green);
  border-radius: 18px; padding: 12px 24px; font-size: 20px; font-weight: 700;
  text-align: center; box-shadow: 0 0 24px rgba(92,255,157,0.4);
  max-width: 90vw;
}
#prompt kbd, #controls-help kbd {
  background: #fff; color: #222; border-radius: 6px; padding: 0 8px;
  border-bottom: 3px solid #999; font-family: inherit;
}

#toast {
  position: fixed; top: 110px; left: 50%; transform: translateX(-50%);
  background: rgba(255, 216, 74, 0.95); color: #3a2a00;
  border-radius: 16px; padding: 10px 22px; font-size: 20px; font-weight: 800;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
  animation: pop 0.3s ease-out;
}
@keyframes pop { from { transform: translateX(-50%) scale(0.6); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }

#minimap-wrap {
  position: fixed; right: 16px; bottom: 16px;
  border-radius: 50%; overflow: hidden;
  border: 3px solid rgba(255,255,255,0.4);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
#minimap { display: block; }

#controls-help {
  position: fixed; left: 16px; bottom: 16px;
  background: var(--panel); border-radius: 14px; padding: 8px 14px;
  font-size: 14px; line-height: 1.7; opacity: 0.85;
}

/* Overlay panels */
#overlay {
  position: fixed; inset: 0;
  background: rgba(5, 8, 25, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.panel {
  background: var(--panel);
  border: 3px solid rgba(255,255,255,0.18);
  border-radius: 28px;
  padding: 28px 32px;
  max-width: 760px; width: 100%;
  max-height: 92vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  text-align: center;
  animation: panelIn 0.25s ease-out;
}
@keyframes panelIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.panel h1 { font-size: 52px; margin: 0 0 4px; line-height: 1.05;
  background: linear-gradient(90deg, #5cff9d, #3a8dff, #ff6fb5);
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.panel h2 { font-size: 32px; margin: 0 0 10px; }
.panel p { font-size: 20px; line-height: 1.45; margin: 10px 0; }
.panel .row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.panel .sub { opacity: 0.75; font-size: 17px; }

.name-input {
  font-family: inherit; font-size: 26px; font-weight: 800; text-align: center;
  border-radius: 14px; border: 3px solid var(--blue); padding: 8px 14px;
  width: 280px; max-width: 100%; outline: none;
}
.chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }
.chip {
  font-family: inherit; font-size: 18px; font-weight: 700;
  background: rgba(255,255,255,0.12); color: #fff;
  border: 2px solid rgba(255,255,255,0.25); border-radius: 999px;
  padding: 4px 14px; cursor: pointer;
}
.chip:hover { background: rgba(92,255,157,0.25); border-color: var(--green); }

/* Shop */
.shop-tabs { display: flex; gap: 8px; justify-content: center; margin-bottom: 14px; flex-wrap: wrap; }
.shop-tabs .chip.active { background: var(--blue); border-color: #fff; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; text-align: left; }
.shop-item {
  background: rgba(255,255,255,0.07); border: 2px solid rgba(255,255,255,0.15);
  border-radius: 16px; padding: 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.shop-item .t { font-size: 19px; font-weight: 800; }
.shop-item .d { font-size: 15px; opacity: 0.8; flex: 1; }
.shop-item .lv { display: flex; gap: 4px; }
.shop-item .lv span { width: 18px; height: 8px; border-radius: 4px; background: rgba(255,255,255,0.2); }
.shop-item .lv span.on { background: var(--green); }
.shop-item.equipped { border-color: var(--green); }
.swatch { width: 28px; height: 28px; border-radius: 50%; display: inline-block; vertical-align: middle; border: 2px solid #fff; margin-right: 6px; }

.story-text { font-size: 21px; line-height: 1.5; min-height: 120px; }
.big-emoji { font-size: 64px; line-height: 1; }

@media (max-width: 700px) {
  .panel h1 { font-size: 36px; }
  .hud-center { display: none; }
}
