*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  /* ---- Core palette: "Aurora Ascent" ---- */
  --ink: #1c1330;
  --ink-soft: #2c2049;
  --paper: #fff9f0;
  --coral: #ff6a54;
  --coral-deep: #d43f2f;
  --amber: #ffb238;
  --amber-deep: #e8891b;
  --azure: #49c6ff;
  --azure-deep: #1f8fd6;
  --violet: #9b7bff;
  --violet-deep: #6a4fd9;
  --mint: #3fe0a8;
  --night: #120a24;

  --glass: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.16);
  --shadow-color: 250, 90, 60;

  --font-display: "Baloo 2", "Segoe UI", sans-serif;
  --font-body: "Manrope", "Quicksand", sans-serif;
}

html {
  height: 100%;
}

body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  position: relative;
  background: linear-gradient(160deg, #241a44 0%, #1a1333 45%, #12101f 100%);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

.stage {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Fullscreen fill: instead of locking to the 480/600 aspect ratio and
   letterboxing, the wrapper spans the entire viewport. The game's own
   logical CANVAS_WIDTH/CANVAS_HEIGHT (in script.js) are recalculated on
   resize to match the real screen ratio, so there are no bars on any
   device — phones (portrait & landscape), tablets, foldables, desktop. */
.game-wrapper {
  position: relative;
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  touch-action: none;
  background: var(--night);
}

/* subtle frame highlight along the top edge, like glass catching light */
.game-wrapper::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.22) inset;
}

/* Danger warning: pulsing red border shown for 2s before a tough enemy
   (Brute/Titan/Colossus) cuts the player's jump height, so the change
   never feels sudden. */
.game-wrapper.danger-warning::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: 0 0 0 6px rgba(255, 40, 60, 0.9) inset, 0 0 24px 4px rgba(255, 40, 60, 0.55) inset;
  animation: dangerWarnFlash 0.5s ease-in-out infinite;
}

@keyframes dangerWarnFlash {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 1; }
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(to top, #00c6fb 0%, #005bea 100%);
  cursor: pointer;
  touch-action: none;
}

/* ---------- HUD ---------- */
.game-ui {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 6;
  padding: 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px 6px 6px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(28, 19, 48, 0.68), rgba(18, 10, 36, 0.58));
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow:
    0 6px 18px rgba(0, 0, 0, 0.35),
    0 0 0 1px var(--glass-border) inset,
    0 1px 0 rgba(255, 255, 255, 0.14) inset;
}

.badge-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: var(--ink);
  background: linear-gradient(160deg, var(--amber) 0%, var(--coral) 100%);
  box-shadow: 0 2px 6px rgba(255, 122, 60, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.25) inset;
}

.badge-best .badge-icon {
  background: linear-gradient(160deg, #ffe27a 0%, #ffb238 100%);
  box-shadow: 0 2px 6px rgba(255, 178, 56, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.3) inset;
}

.badge-text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.badge-label {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: rgba(255, 255, 255, 0.55);
}

.badge-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  color: #fff;
  min-width: 1ch;
  text-align: left;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
}

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: clamp(10px, 4%, 24px);
  text-align: center;
  overflow-y: auto;
  background:
    radial-gradient(720px 420px at 50% 8%, rgba(155, 123, 255, 0.22), transparent 60%),
    linear-gradient(180deg, rgba(18, 10, 36, 0.94), rgba(12, 21, 38, 0.96));
}

.overlay.hidden {
  display: none;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  margin-bottom: 10px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #ffd9a0;
  background: rgba(255, 178, 56, 0.12);
  box-shadow: 0 0 0 1px rgba(255, 178, 56, 0.35) inset;
}

.overlay-start h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.6rem, 9vh, 2.7rem);
  margin: 0 0 4px;
  letter-spacing: 0.005em;
  background: linear-gradient(180deg, #fff6df 0%, var(--amber) 55%, var(--coral) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 0 rgba(212, 63, 47, 0.55)) drop-shadow(0 14px 26px rgba(0, 0, 0, 0.45));
}

.overlay-start .tagline {
  color: rgba(255, 255, 255, 0.66);
  margin: 0 0 16px;
  font-size: 0.96rem;
  font-weight: 600;
  max-width: 30ch;
}

/* Very short viewports (phone in landscape): trim the decorative
   mascot and copy so the Play button always stays reachable. */
@media (max-height: 420px) {
  .hero-blob {
    width: 46px;
    height: 44px;
    margin-bottom: 2px;
  }
  .bird-flap-sprite {
    transform: scale(1.1);
  }
  .eyebrow {
    margin-bottom: 4px;
  }
  .overlay-start .tagline {
    display: none;
  }
  .chip-row {
    margin-bottom: 4px;
  }
  .btn-start {
    margin-top: 6px;
    padding: 9px 28px;
    font-size: 1rem;
  }
  .score-recap {
    margin-bottom: 0;
  }
  .score-recap-item {
    padding: 6px 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-blob,
  .bird-flap-sprite,
  .btn-start,
  .eyebrow,
  .ctrl-skill {
    animation: none !important;
  }
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--glass);
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.8rem;
  font-weight: 600;
  box-shadow: 0 0 0 1px var(--glass-border) inset;
}

.chip kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.7em;
  padding: 3px 7px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.08));
  border-radius: 7px;
  font-family: var(--font-body);
  font-size: 0.85em;
  font-weight: 700;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(255, 255, 255, 0.12) inset;
}

.mode-btn-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.mode-btn-row .btn-start {
  margin-top: 18px;
}

.btn-mode-basic {
  background: linear-gradient(180deg, #bfe9ff 0%, var(--azure) 46%, var(--azure-deep) 100%);
  box-shadow:
    0 7px 0 var(--azure-deep),
    0 16px 30px rgba(31, 143, 214, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.25) inset;
}

.btn-mode-basic:hover {
  box-shadow:
    0 9px 0 var(--azure-deep),
    0 20px 34px rgba(31, 143, 214, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.3) inset;
}

.btn-mode-basic:active {
  box-shadow:
    0 3px 0 var(--azure-deep),
    0 8px 18px rgba(31, 143, 214, 0.32),
    0 0 0 1px rgba(255, 255, 255, 0.2) inset;
}

@media (max-width: 420px) {
  .mode-btn-row {
    gap: 10px;
  }
  .mode-btn-row .btn-start {
    padding: 13px 30px;
    font-size: 1.05rem;
  }
}

.btn-start {
  position: relative;
  margin-top: 18px;
  padding: 15px 46px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: 0.02em;
  color: var(--ink);
  background: linear-gradient(180deg, #ffd977 0%, var(--amber-deep) 46%, var(--coral) 100%);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
  box-shadow:
    0 7px 0 var(--coral-deep),
    0 16px 30px rgba(255, 106, 84, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.25) inset;
  transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease;
  animation: startPulse 2.6s ease-in-out infinite;
}

.btn-start::after {
  content: "";
  position: absolute;
  top: 0;
  left: -60%;
  width: 45%;
  height: 100%;
  background: linear-gradient(115deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: skewX(-18deg);
  animation: startSheen 3.4s ease-in-out infinite;
}

@keyframes startSheen {
  0%, 25% { left: -60%; }
  55%, 100% { left: 130%; }
}

@keyframes startPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.08); }
}

.btn-start:hover {
  transform: translateY(-2px);
  filter: brightness(1.05);
  box-shadow:
    0 9px 0 var(--coral-deep),
    0 20px 34px rgba(255, 106, 84, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.3) inset;
}

.btn-start:active {
  transform: translateY(4px);
  animation-play-state: paused;
  box-shadow:
    0 3px 0 var(--coral-deep),
    0 8px 18px rgba(255, 106, 84, 0.32),
    0 0 0 1px rgba(255, 255, 255, 0.2) inset;
}

.btn-start:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.overlay-gameover h2 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 2.15rem;
  margin: 0 0 2px;
  background: linear-gradient(180deg, #ffcdbd 0%, var(--coral) 65%, var(--violet) 130%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 rgba(106, 79, 217, 0.35)) drop-shadow(0 10px 22px rgba(0, 0, 0, 0.4));
}

.gameover-msg {
  color: rgba(255, 255, 255, 0.68);
  font-weight: 600;
  margin: 0 0 18px;
  max-width: 30ch;
}

.score-recap {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
}

.score-recap-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 12px 24px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.03));
  box-shadow: 0 0 0 1px var(--glass-border) inset, 0 6px 16px rgba(0, 0, 0, 0.25);
  min-width: 88px;
}

.score-recap-item.is-best {
  background: linear-gradient(180deg, rgba(255, 178, 56, 0.18), rgba(255, 106, 84, 0.07));
  box-shadow: 0 0 0 1px rgba(255, 178, 56, 0.4) inset, 0 6px 16px rgba(0, 0, 0, 0.25);
}

.score-recap-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.5);
}

.score-recap-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.65rem;
  color: var(--amber);
  text-shadow: 0 2px 10px rgba(255, 178, 56, 0.35);
}

/* ---------- Hero mascot (start screen bird) ---------- */
.hero-blob {
  position: relative;
  width: 80px;
  height: 76px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: heroFloat 2.4s ease-in-out infinite;
}

.hero-blob::before {
  /* soft contact shadow grounding the mascot */
  content: "";
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 56%;
  height: 10px;
  transform: translateX(-50%);
  background: radial-gradient(50% 100% at 50% 50%, rgba(0, 0, 0, 0.4), transparent 75%);
  animation: heroShadow 2.4s ease-in-out infinite;
}

/* Animated bird sprite (reused across start / game-over icons) - flips
   through the 3 wing-flap frames stacked in images/my_bird.png. */
.bird-flap-sprite {
  display: block;
  width: 34px;
  height: 24px;
  background-image: url("images/my_bird.png");
  background-repeat: no-repeat;
  background-position: 0 0;
  image-rendering: pixelated;
  transform: scale(1.9);
  animation: birdFlapFrames 0.45s steps(1) infinite;
}

@keyframes birdFlapFrames {
  0% { background-position: 0 0; }
  25% { background-position: 0 -26px; }
  50% { background-position: 0 -52px; }
  75% { background-position: 0 -26px; }
  100% { background-position: 0 0; }
}

@keyframes heroFloat {
  0%, 100% { transform: translateY(0) scaleY(1); }
  50% { transform: translateY(-11px) scaleY(1.04); }
}

@keyframes heroShadow {
  0%, 100% { opacity: 0.55; transform: translateX(-50%) scale(1); }
  50% { opacity: 0.3; transform: translateX(-50%) scale(0.78); }
}

/* ---------- Mobile control bar ---------- */
.mobile-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 6;
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}

.mobile-controls .ctrl-btn {
  pointer-events: auto;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.05));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  box-shadow:
    0 6px 18px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.18) inset,
    0 1px 0 rgba(255, 255, 255, 0.22) inset;
  transition: transform 0.1s, background 0.1s, box-shadow 0.1s;
}

.mobile-controls .ctrl-btn:active,
.mobile-controls .ctrl-btn.active {
  background: linear-gradient(180deg, #ffd977, var(--coral));
  color: var(--ink);
  transform: scale(0.92);
  box-shadow:
    0 3px 10px rgba(255, 106, 84, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.3) inset;
}

@media (hover: hover) {
  .mobile-controls .ctrl-btn:hover {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0.1));
  }
}

/* ---------- Skill button (center control) ---------- */
.ctrl-skill {
  position: relative;
  overflow: hidden;
}

.ctrl-skill .skill-icon {
  position: relative;
  z-index: 1;
  color: rgba(255, 255, 255, 0.32);
  transition: color 0.2s ease;
}

.ctrl-skill:disabled {
  opacity: 0.6;
  cursor: default;
}

.ctrl-skill.has-skill {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.06));
  box-shadow:
    0 6px 18px var(--skill-glow, rgba(155, 123, 255, 0.5)),
    0 0 0 1px rgba(230, 217, 255, 0.35) inset,
    0 1px 0 rgba(255, 255, 255, 0.22) inset;
  animation: skillPulse 2.2s ease-in-out infinite;
}

.ctrl-skill.has-skill .skill-icon {
  color: var(--skill-color, #f1e9ff);
}

.ctrl-skill.has-skill:active,
.ctrl-skill.has-skill.active {
  background: var(--skill-color, var(--violet));
  color: var(--ink);
  transform: scale(0.92);
  animation-play-state: paused;
}

.ctrl-skill.has-skill:active .skill-icon,
.ctrl-skill.has-skill.active .skill-icon {
  color: var(--ink);
}

@keyframes skillPulse {
  0%, 100% {
    box-shadow:
      0 6px 18px var(--skill-glow, rgba(155, 123, 255, 0.5)),
      0 0 0 1px rgba(230, 217, 255, 0.35) inset,
      0 1px 0 rgba(255, 255, 255, 0.22) inset;
  }
  50% {
    box-shadow:
      0 6px 24px var(--skill-glow-strong, rgba(155, 123, 255, 0.78)),
      0 0 0 1px rgba(230, 217, 255, 0.45) inset,
      0 1px 0 rgba(255, 255, 255, 0.3) inset;
  }
}

.ctrl-skill .skill-cooldown-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(rgba(8, 4, 20, 0.72) calc(var(--cd, 0) * 360deg), transparent 0deg);
  pointer-events: none;
}

.ctrl-skill.is-cooling {
  animation: none;
}

.ctrl-skill .skill-cooldown-text {
  position: absolute;
  z-index: 2;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 16px;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
  pointer-events: none;
}

.overlay-start .mobile-hint {
  display: none;
}

@media (pointer: coarse) {
  .overlay-start .mobile-hint {
    display: inline-flex;
  }
}

@media (max-width: 380px) {
  .overlay-start h1 { font-size: 2.15rem; }
  .btn-start { padding: 13px 38px; font-size: 1.05rem; }
}

@media (max-height: 420px) {
  .mobile-controls {
    padding: 10px 14px;
  }
  .mobile-controls .ctrl-btn {
    width: 48px;
    height: 48px;
  }
  .badge {
    padding: 5px 12px 5px 5px;
  }
  .badge-value {
    font-size: 15px;
  }
  .ctrl-skill .skill-cooldown-text {
    font-size: 13px;
  }
}
