:root {
  --bg-1: #15002b;
  --bg-2: #2a004e;
  --neon-pink: #ff3cac;
  --neon-blue: #29d8ff;
  --neon-yellow: #ffe66d;
  --text: #f7f1ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, #35135a 0%, transparent 35%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
}

.game-wrapper {
  width: min(96vw, 720px);
  padding: 0.8rem 0.9rem 1rem;
  border: 3px solid var(--neon-blue);
  border-radius: 16px;
  background: rgba(5, 0, 12, 0.72);
  box-shadow: 0 0 14px var(--neon-blue), 0 0 30px rgba(41, 216, 255, 0.3);
}

h1 {
  margin: 0;
  text-align: center;
  color: var(--neon-yellow);
  text-shadow: 0 0 8px var(--neon-yellow);
  letter-spacing: 1px;
}

.subtitle {
  margin: 0.3rem 0 1rem;
  text-align: center;
  color: var(--neon-pink);
}

.hud {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-size: 1rem;
}

.status-column {
  display: grid;
  gap: 0.3rem;
}

.hud-actions {
  display: inline-flex;
  gap: 0.4rem;
}

.lives-hud {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.lives-icons {
  display: inline-flex;
  gap: 0.25rem;
  vertical-align: middle;
}

.life-icon {
  width: 22px;
  height: 22px;
  background-image: url("duck-whole-source.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.45));
}

.life-icon.lost {
  opacity: 0.2;
  filter: grayscale(1);
}

#restartBtn,
#highscoreBtn,
.submit-score-btn {
  border: 2px solid var(--neon-pink);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 0.55rem 0.8rem;
  min-height: 44px;
  cursor: pointer;
  touch-action: manipulation;
}

#restartBtn:hover,
#highscoreBtn:hover,
.submit-score-btn:hover {
  background: rgba(255, 60, 172, 0.15);
}

.game-area {
  position: relative;
  width: 100%;
  height: clamp(340px, 62dvh, 520px);
  border: 3px solid var(--neon-pink);
  border-radius: 12px;
  overflow: hidden;
  background:
    linear-gradient(to top, rgba(0, 0, 0, 0.35), rgba(255, 255, 255, 0.02)),
    repeating-linear-gradient(
      to right,
      rgba(41, 216, 255, 0.15) 0,
      rgba(41, 216, 255, 0.15) 2px,
      transparent 2px,
      transparent 40px
    );
  background-size: cover, auto;
  background-position: center, center;
  background-repeat: no-repeat, repeat;
  touch-action: none;
}

.game-area::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("logo.png") center / contain no-repeat;
  opacity: 0.16;
  filter: invert(1) saturate(1.1) contrast(1.08);
  mix-blend-mode: screen;
  pointer-events: none;
}

.sprite {
  position: absolute;
  font-size: 2rem;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  user-select: none;
  filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.8));
}

.duck {
  width: 70px;
  height: 70px;
  background-image: url("duck-whole-source.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  animation: bob 0.9s ease-in-out infinite alternate;
  touch-action: manipulation;
}

.duck.flat {
  width: 96px;
  height: 64px;
  background-image: url("duck-flat-source.png");
  animation: none;
}

.floating-points {
  position: absolute;
  transform: translate(-50%, -52%);
  pointer-events: none;
  display: grid;
  justify-items: center;
  gap: 0.1rem;
  font-weight: 700;
  animation: float-up 1.25s ease-out forwards;
  z-index: 3;
}

.floating-points-streak {
  color: var(--neon-pink);
  font-size: 0.82rem;
  text-shadow: 0 0 8px rgba(255, 60, 172, 0.75);
}

.floating-points-score {
  color: var(--neon-yellow);
  font-size: 1rem;
  text-shadow: 0 0 8px rgba(255, 230, 109, 0.85);
}

@keyframes bob {
  from { transform: translateY(-1px); }
  to { transform: translateY(2px); }
}

@keyframes float-up {
  from {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -120%);
  }
}

.message {
  margin: 0.9rem 0 0;
  text-align: center;
  min-height: 1.3rem;
}

.player-panel {
  margin-top: 0.9rem;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.6rem;
}

.submit-score-btn {
  grid-column: 1 / -1;
}

.field {
  display: grid;
  gap: 0.2rem;
  font-size: 0.9rem;
}

.field input {
  border: 2px solid rgba(41, 216, 255, 0.45);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  padding: 0.5rem 0.55rem;
  font-size: 16px;
}

.highscore {
  margin-top: 0.9rem;
  border: 1px solid rgba(255, 60, 172, 0.4);
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
  background: rgba(0, 0, 0, 0.22);
}

.highscore-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
}

.highscore h2 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  color: var(--neon-yellow);
}

.highscore-mode-info {
  margin: 0.2rem 0 0.55rem;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.86);
}

#highscoreList {
  margin: 0;
  padding-left: 1.1rem;
}

#highscoreList li {
  margin: 0.1rem 0;
}

@media (max-width: 560px) {
  .game-wrapper {
    width: 100%;
    border-width: 2px;
    border-radius: 12px;
    padding: 0.7rem 0.65rem 0.8rem;
  }

  h1 {
    font-size: 1.45rem;
  }

  .subtitle {
    font-size: 0.95rem;
    margin-bottom: 0.8rem;
  }

  .hud {
    align-items: stretch;
    gap: 0.45rem;
    font-size: 0.95rem;
  }

  .status-column {
    flex: 1 1 100%;
    gap: 0.25rem;
  }

  .hud-actions {
    flex: 1 1 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
  }

  #restartBtn,
  #highscoreBtn {
    width: 100%;
  }

  .game-area {
    height: clamp(300px, 52dvh, 430px);
    border-radius: 10px;
  }

  .duck {
    width: 92px;
    height: 92px;
  }

  .duck.flat {
    width: 112px;
    height: 74px;
  }

  .message {
    font-size: 0.95rem;
    line-height: 1.35;
  }

  .player-panel {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .field {
    font-size: 0.95rem;
  }

  .field input {
    min-height: 44px;
  }

  .highscore {
    padding: 0.55rem 0.6rem;
  }
}

@media (max-width: 420px) {
  h1 {
    font-size: 1.3rem;
  }

  .subtitle {
    font-size: 0.9rem;
  }

  .hud {
    font-size: 0.9rem;
  }

  .hud-actions {
    grid-template-columns: 1fr;
  }

  .game-area {
    height: clamp(270px, 50dvh, 380px);
  }

  .duck {
    width: 88px;
    height: 88px;
  }

  .duck.flat {
    width: 108px;
    height: 70px;
  }
}
