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

:root {
  --sky-top: #7ec8ff;
  --sky-bottom: #c9f0ff;
  --accent: #ffb703;
  --accent-2: #ff6b6b;
  --accent-3: #43d17a;
  --ink: #243b53;
  --ink-soft: #5a7a9c;
  --glass-bg: rgba(255, 255, 255, 0.16);
  --glass-border: rgba(255, 255, 255, 0.55);
  --panel: #26447d;
  --shadow-lg: 0 14px 30px rgba(10, 30, 60, 0.35);
  font-family: 'Nunito', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #7ec8ff;
  font-family: 'Nunito', sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

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

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  z-index: 10;
  transition: opacity .35s ease;
}

.screen.hidden {
  display: none;
  opacity: 0;
  pointer-events: none;
}

h1,
h2 {
  font-family: 'Baloo 2', sans-serif;
  margin: 0;
}

/* ---------------- Preloader ---------------- */
#preloader {
  background: linear-gradient(180deg, var(--sky-top), var(--sky-bottom));
  overflow: hidden;
}

.sky-anim {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, .5), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(255, 255, 255, .35), transparent 45%);
  animation: skyDrift 12s ease-in-out infinite alternate;
}

@keyframes skyDrift {
  from {
    transform: scale(1) translate(0, 0);
  }

  to {
    transform: scale(1.1) translate(-2%, 2%);
  }
}

.cloud {
  position: absolute;
  width: 140px;
  height: 50px;
  background: #fff;
  border-radius: 50px;
  opacity: .85;
  filter: blur(1px);
  box-shadow: 30px -20px 0 -6px #fff, -30px 10px 0 -10px #fff;
  animation: cloudMove linear infinite;
}

.cloud.c1 {
  top: 12%;
  left: -20%;
  width: 160px;
  height: 60px;
  animation-duration: 26s;
}

.cloud.c2 {
  top: 55%;
  left: -30%;
  width: 110px;
  height: 44px;
  animation-duration: 34s;
  animation-delay: -8s;
}

.cloud.c3 {
  top: 30%;
  left: -25%;
  width: 90px;
  height: 36px;
  animation-duration: 20s;
  animation-delay: -4s;
}

@keyframes cloudMove {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(140vw);
  }
}

.preloader-content {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 0 24px;
}

.preloader-chicken {
  font-size: 72px;
  animation: chickenHop 0.6s ease-in-out infinite;
  filter: drop-shadow(0 10px 8px rgba(0, 0, 0, .25));
}

@keyframes chickenHop {

  0%,
  100% {
    transform: translateY(0) scaleX(1) scaleY(1);
  }

  35% {
    transform: translateY(-26px) scaleX(0.92) scaleY(1.08);
  }

  55% {
    transform: translateY(0) scaleX(1.12) scaleY(0.88);
  }

  70% {
    transform: translateY(0) scaleX(1) scaleY(1);
  }
}

.game-logo {
  font-size: 34px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 1px;
  text-shadow: 0 3px 0 rgba(0, 0, 0, .15), 0 8px 16px rgba(0, 0, 0, .25);
  margin: 6px 0 22px;
}

.game-logo span {
  color: var(--accent);
}

.game-logo.small {
  font-size: 26px;
  margin-bottom: 14px;
}

.progress-track {
  width: min(280px, 70vw);
  height: 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .35);
  border: 2px solid rgba(255, 255, 255, .6);
  overflow: hidden;
  margin: 0 auto;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .15);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-3), #7CFFB2);
  border-radius: 999px;
  transition: width .25s ease;
}

.progress-pct {
  margin-top: 8px;
  color: #fff;
  font-weight: 800;
  text-shadow: 0 2px 4px rgba(0, 0, 0, .2);
}

.loading-tip {
  margin-top: 18px;
  color: rgba(255, 255, 255, .92);
  font-size: 13px;
  font-weight: 700;
  min-height: 18px;
}

/* ---------------- Glass panels ---------------- */
.menu-glass,
.modal-glass {
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 28px;
  padding: 28px 26px 24px;
  width: min(360px, 88vw);
  text-align: center;
  box-shadow: var(--shadow-lg);
  color: #fff;
  max-height: 88vh;
  overflow-y: auto;
}

.menu-glass h1,
.modal-glass h2 {
  color: #fff;
}

.modal-glass h2 {
  font-size: 24px;
  letter-spacing: 1px;
  margin-bottom: 16px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, .25);
}

#main-menu {
  background: linear-gradient(180deg, var(--sky-top), var(--sky-bottom));
}

.menu-stat-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.stat-chip {
  background: #26447d;
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 800;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 5px;
  color: #fff;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .15);
}

.stat-chip.small {
  padding: 5px 10px;
  font-size: 12px;
}

/* ---------------- Buttons ---------------- */
.btn {
  border: none;
  cursor: pointer;
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  color: #fff;
  border-radius: 16px;
  transition: transform .08s ease, filter .15s ease, box-shadow .15s ease;
}

.btn:active {
  transform: translateY(2px) scale(.98);
  filter: brightness(.95);
}

.btn-primary {
  background: linear-gradient(180deg, #ffcb3d, var(--accent));
  box-shadow: 0 5px 0 #c98600, 0 10px 18px rgba(0, 0, 0, .28);
  color: #4a2e00;
}

.btn-lg {
  width: 100%;
  padding: 16px 0;
  font-size: 18px;
  margin: 8px 0;
  letter-spacing: .5px;
  margin-bottom: 20px
}

.btn-secondary {
  background: rgba(255, 255, 255, .15);
  border: 1px solid rgba(255, 255, 255, .35);
  box-shadow: 0 4px 0 rgba(0, 0, 0, .15);
  padding: 12px 14px;
  font-size: 14px;
  color: #fff;
  margin: 4px;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
  margin: 0;
}

.btn-round {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #26447d;
  border: 1px solid rgba(255, 255, 255, .4);
  font-size: 20px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .15);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-round.small {
  width: 38px;
  height: 38px;
  font-size: 16px;
}

.menu-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 14px 0;
}

.menu-row.secondary-row {
  flex-wrap: wrap;
}

/* ---------------- How to Play ---------------- */
.howto-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 10px 0 18px;
}

.howto-item {
  font-size: 12px;
  color: #e9f2ff;
}

.howto-item p {
  margin: 6px 0 0;
}

.howto-hand {
  font-size: 30px;
  position: relative;
}

.howto-icon {
  font-size: 30px;
}

.swipe-arrow {
  position: absolute;
  top: -6px;
  right: -14px;
  font-size: 16px;
  font-weight: 900;
  color: var(--accent-3);
  animation: swipeFloat 1s ease-in-out infinite;
}

@keyframes swipeFloat {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-6px);
  }
}

.dont-show {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  margin-bottom: 12px;
  color: #dce8f5;
}

/* ---------------- HUD ---------------- */
#hud {
  align-items: stretch;
  justify-content: flex-start;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: max(14px, env(safe-area-inset-top)) 16px 0;
}

.hud-score-wrap {
  text-align: left;
  background: #142955;
  padding: 10px;
  border-radius: 30px;
  padding-top: 22px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .15);
}

.hud-score {
  font-family: 'Baloo 2', sans-serif;
  font-size: 40px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 3px 0 rgba(0, 0, 0, .2), 0 6px 14px rgba(0, 0, 0, .25);
  line-height: 1;
}

.hud-combo {
  color: var(--accent);
  font-weight: 800;
  font-size: 14px;
  height: 18px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, .3);
}

.hud-lives {
  display: flex;
  gap: 3px;
  margin: 2px 0 4px;
}

.hud-lives .heart {
  font-size: 18px;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .3));
  transition: transform .2s ease;
}

.hud-lives .heart.lost {
  opacity: .3;
  transform: scale(0.85);
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-powerups {
  position: absolute;
  top: 100px;
  left: 16px;
  display: flex;
  gap: 8px;
  flex-direction: column;
}

.powerup-chip {
  background: rgba(255, 255, 255, .85);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 800;
  font-size: 12px;
  color: #243b53;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .2);
  display: flex;
  align-items: center;
  gap: 6px;
}

.powerup-chip .bar {
  width: 36px;
  height: 5px;
  background: #dfe8f0;
  border-radius: 4px;
  overflow: hidden;
}

.powerup-chip .bar i {
  display: block;
  height: 100%;
  background: var(--accent-3);
}

.floating-text-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.floating-text {
  position: absolute;
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  font-size: 20px;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, .35);
  animation: floatUp 1s ease-out forwards;
  pointer-events: none;
}

@keyframes floatUp {
  0% {
    transform: translateY(0) scale(.6);
    opacity: 0;
  }

  15% {
    opacity: 1;
    transform: translateY(-6px) scale(1.15);
  }

  100% {
    transform: translateY(-70px) scale(1);
    opacity: 0;
  }
}

/* ---------------- Mobile Controls ---------------- */
#mobile-controls {
  pointer-events: none;
  justify-content: flex-end;
  align-items: flex-end;
}

.dpad {
  pointer-events: auto;
  position: relative;
  width: 170px;
  height: 170px;
  margin: 0 20px 24px 0;
  align-self: flex-end;
}

.dpad-btn {
  position: absolute;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: rgba(255, 255, 255, .28);
  border: 1px solid rgba(255, 255, 255, .5);
  color: #fff;
  font-size: 22px;
  font-weight: 800;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .18);
  backdrop-filter: blur(6px);
}

.dpad-btn.up {
  top: 0;
  left: 57px;
}

.dpad-btn.down {
  top: 114px;
  left: 57px;
}

.dpad-btn.left {
  top: 57px;
  left: 0;
}

.dpad-btn.right {
  top: 57px;
  left: 114px;
}

.dpad-btn:active {
  background: rgba(255, 255, 255, .5);
  transform: translateY(2px);
}

/* ---------------- Pause / Game Over ---------------- */
#pause-menu,
#game-over,
#reward-popup,
#settings-menu,
#how-to-play-modal {
  background: rgba(10, 20, 35, .55);
  backdrop-filter: blur(3px);
}

.go-title {
  font-size: 30px;
  color: #fff;
  letter-spacing: 1px;
  margin-bottom: 14px;
  text-shadow: 0 3px 10px rgba(0, 0, 0, .4);
}

.go-score-block {
  margin-bottom: 10px;
}

.go-label {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #cbdcee;
}

.go-score {
  font-family: 'Baloo 2', sans-serif;
  font-size: 52px;
  font-weight: 800;
  color: var(--accent);
  text-shadow: 0 4px 0 rgba(0, 0, 0, .2);
  animation: scorePop .5s ease;
}

@keyframes scorePop {
  from {
    transform: scale(0.3);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

.go-best-row {
  color: #dce8f5;
  font-size: 14px;
  margin-bottom: 6px;
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
}

.new-best {
  background: var(--accent-2);
  color: #fff;
  font-weight: 800;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  animation: pulseBadge .6s ease-in-out infinite alternate;
}

@keyframes pulseBadge {
  from {
    transform: scale(1);
  }

  to {
    transform: scale(1.1);
  }
}

.go-coins-row {
  color: #ffd76b;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 14px;
}

.reward-glass {
  text-align: center;
}

.reward-icon {
  font-size: 56px;
  animation: rewardBounce .7s ease-in-out infinite;
}

@keyframes rewardBounce {

  0%,
  100% {
    transform: translateY(0) rotate(-4deg);
  }

  50% {
    transform: translateY(-14px) rotate(4deg);
  }
}

.reward-amount {
  font-family: 'Baloo 2', sans-serif;
  font-size: 30px;
  color: var(--accent);
  margin: 10px 0 18px;
  font-weight: 800;
}

/* ---------------- Settings ---------------- */
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
}

.switch {
  position: relative;
  width: 44px;
  height: 24px;
  display: inline-block;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, .25);
  border-radius: 999px;
  transition: .2s;
  cursor: pointer;
}

.slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: .2s;
}

.switch input:checked+.slider {
  background: var(--accent-3);
}

.switch input:checked+.slider::before {
  transform: translateX(20px);
}

#fps-counter {
  position: fixed;
  top: 6px;
  left: 6px;
  color: rgba(255, 255, 255, .6);
  font-size: 10px;
  font-family: monospace;
  z-index: 999;
  pointer-events: none;
}

/* ---------------- Responsive ---------------- */
@media (max-width:420px) {
  .hud-score {
    font-size: 32px;
  }

  .game-logo {
    font-size: 28px;
  }

  .howto-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
}

@media (min-width: 820px) {
  .dpad {
    display: none;
  }

  /* desktop uses keyboard */
}