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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: 'Fredoka', 'Comic Sans MS', ui-rounded, sans-serif;
  background: #b48cff;
}

#game { position: fixed; inset: 0; display: block; }

#ui { position: fixed; inset: 0; pointer-events: none; }
#ui .screen, #ui #hud, #ui #toast { pointer-events: none; }
#ui .screen { pointer-events: auto; }
#ui button { pointer-events: auto; }

.hidden { display: none !important; }

/* ---------- Screens ---------- */
.screen {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, rgba(255, 214, 245, 0.55), rgba(120, 82, 190, 0.55));
  backdrop-filter: blur(4px);
}

.panel {
  background: linear-gradient(180deg, #fff7fd, #ffeef9);
  border: 6px solid #ffd166;
  border-radius: 36px;
  box-shadow: 0 18px 50px rgba(90, 50, 140, 0.35), inset 0 2px 0 #ffffff;
  padding: 40px 52px;
  text-align: center;
  max-width: 860px;
  width: min(92vw, 860px);
  max-height: 92vh;
  overflow-y: auto;
}

.title-panel h1 {
  font-size: clamp(48px, 8vw, 84px);
  font-weight: 700;
  color: #8c4bd8;
  text-shadow: 0 4px 0 #ffd166, 0 8px 22px rgba(140, 75, 216, 0.3);
  letter-spacing: 1px;
}

.title-sparkles { font-size: 30px; margin-bottom: 6px; }

.tagline {
  font-size: 22px; font-weight: 600; color: #ff6fb5; margin-top: 10px;
}

.subtitle {
  font-size: 17px; color: #9a7bc8; margin: 14px 0 26px;
}

h2 { font-size: 40px; color: #8c4bd8; margin-bottom: 20px; font-weight: 700; }

/* ---------- Buttons ---------- */
.big-btn {
  display: block;
  margin: 12px auto;
  min-width: 260px;
  padding: 16px 36px;
  font-family: inherit;
  font-size: 24px; font-weight: 700;
  border: none; border-radius: 999px;
  cursor: pointer;
  color: #6b3fa0;
  box-shadow: 0 6px 0 rgba(0,0,0,0.12), 0 10px 24px rgba(120, 70, 190, 0.25);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.big-btn:hover { transform: translateY(-3px) scale(1.03); }
.big-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,0.12); }
.big-btn.yellow { background: linear-gradient(180deg, #ffe58a, #ffd166); }
.big-btn.pink   { background: linear-gradient(180deg, #ffc0e3, #ff9ff3); }
.big-btn.purple { background: linear-gradient(180deg, #d3b6ff, #b983ff); color: #4d2a80; }

.small-btn {
  margin-top: 18px;
  padding: 10px 26px;
  font-family: inherit;
  font-size: 17px; font-weight: 600;
  border: none; border-radius: 999px;
  background: #efe2ff; color: #8c5ad0;
  cursor: pointer;
}
.small-btn:hover { background: #e3ceff; }

/* ---------- Character cards ---------- */
.char-cards { display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; }

.char-card {
  width: 220px;
  padding: 22px 16px 18px;
  border: 5px solid #ffb8de;
  border-radius: 28px;
  background: linear-gradient(180deg, #ffffff, #fff0f8);
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s;
  position: relative;
}
.char-card:hover {
  transform: translateY(-6px) scale(1.04);
  box-shadow: 0 16px 34px rgba(150, 80, 200, 0.3);
  border-color: #ffd166;
}
.wolf-card { background: linear-gradient(180deg, #f4edff, #e4d5ff); border-color: #b983ff; }

.char-emoji { font-size: 64px; }
.char-wings { font-size: 24px; margin-top: -14px; }
.char-name { font-size: 26px; font-weight: 700; color: #7c3fd0; margin-top: 6px; }
.char-desc { font-size: 14px; color: #9a7bc8; margin: 8px 0 12px; min-height: 56px; }
.char-goal {
  font-size: 12.5px; font-weight: 600;
  padding: 6px 10px; border-radius: 999px; display: inline-block;
}
.pink-tag   { background: #ffdcef; color: #d1478f; }
.purple-tag { background: #e9dcff; color: #8148c9; }
.yellow-tag { background: #fff1c2; color: #b07d1a; }

/* ---------- Level grid ---------- */
.level-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin: 10px 0 6px;
}
.level-btn {
  padding: 16px 6px 12px;
  border: 4px solid #ffd166;
  border-radius: 22px;
  background: linear-gradient(180deg, #fffdf4, #fff3d0);
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.1s ease;
}
.level-btn:hover:not(:disabled) { transform: scale(1.06); }
.level-btn .lv-num { font-size: 28px; font-weight: 700; color: #d19b1d; }
.level-btn .lv-name { font-size: 12px; font-weight: 600; color: #9a7bc8; margin-top: 4px; }
.level-btn .lv-done { font-size: 14px; margin-top: 2px; min-height: 18px; }
.level-btn:disabled {
  filter: grayscale(0.9) opacity(0.55);
  cursor: not-allowed;
}
.level-btn.night { background: linear-gradient(180deg, #efe6ff, #d9c6ff); border-color: #b983ff; }
.level-btn.night .lv-num { color: #7c3fd0; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; }
.hud-top {
  position: absolute; top: 14px; left: 0; right: 0;
  display: flex; align-items: center; justify-content: center;
  gap: 10px; flex-wrap: wrap;
  padding: 0 14px;
}
.hud-pill {
  background: rgba(255, 251, 240, 0.92);
  border: 3px solid #ffd166;
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 19px; font-weight: 700; color: #8c4bd8;
  box-shadow: 0 4px 14px rgba(110, 60, 180, 0.2);
}
.hud-level { color: #ff6fb5; }
.hud-btn {
  pointer-events: auto;
  background: rgba(255, 251, 240, 0.92);
  border: 3px solid #ffb8de;
  border-radius: 50%;
  width: 46px; height: 46px;
  font-size: 20px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(110, 60, 180, 0.2);
}
.hud-btn:hover { transform: scale(1.08); }

.hud-help {
  position: absolute; bottom: 14px; left: 50%;
  transform: translateX(-50%);
  background: rgba(70, 40, 120, 0.55);
  color: #fff4fb;
  border-radius: 999px;
  padding: 7px 20px;
  font-size: 15px; font-weight: 500;
  white-space: nowrap;
}

#stamina-wrap {
  position: absolute; bottom: 52px; left: 50%;
  transform: translateX(-50%);
  width: 220px; height: 16px;
  background: rgba(70, 40, 120, 0.45);
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.6);
  overflow: hidden;
}
#stamina-bar {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #ffd166, #ff9ff3);
  border-radius: 999px;
  transition: width 0.1s linear;
}

/* ---------- Toast + flash ---------- */
#toast {
  position: absolute; top: 20%; left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 251, 240, 0.95);
  border: 4px solid #ff9ff3;
  border-radius: 24px;
  padding: 16px 34px;
  font-size: 26px; font-weight: 700; color: #8c4bd8;
  box-shadow: 0 10px 30px rgba(140, 75, 216, 0.3);
  text-align: center;
  max-width: 80vw;
  animation: toast-pop 0.35s ease;
}
@keyframes toast-pop {
  0% { transform: translateX(-50%) scale(0.6); opacity: 0; }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

#popups { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.popup {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 26px; font-weight: 700; color: #ffd166;
  text-shadow: 0 2px 0 #d1478f, 0 4px 14px rgba(140, 75, 216, 0.6);
  animation: popup-float 1.3s ease-out forwards;
  white-space: nowrap;
}
@keyframes popup-float {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  15%  { opacity: 1; transform: translate(-50%, -60%) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -180%) scale(1); }
}

.hud-pill.hit { animation: hit-pulse 0.6s ease; }
@keyframes hit-pulse {
  0% { transform: scale(1); }
  30% { transform: scale(1.3); background: #ffd9ec; border-color: #ff6fb5; }
  100% { transform: scale(1); }
}

.title-sparkles { animation: sparkle-bob 2.6s ease-in-out infinite; }
@keyframes sparkle-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

#flash {
  position: absolute; inset: 0;
  background: #ff9ff3;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}
#flash.on { opacity: 0.45; transition: opacity 0.05s ease; }

/* ---------- Complete / victory ---------- */
.rating { font-size: 52px; margin: 8px 0 4px; letter-spacing: 6px; }
.trophy { font-size: 90px; }
#complete-text, #gameover-text, #screen-victory p {
  font-size: 19px; color: #9a7bc8; margin-bottom: 20px;
}

@media (max-width: 700px) {
  .panel { padding: 26px 18px; }
  .level-grid { grid-template-columns: repeat(3, 1fr); }
  .char-card { width: 160px; }
  .char-desc { min-height: 76px; }
}
