@font-face {
  font-family: "BoldPixels";
  src: url("fonts/BoldPixels.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #050b14;
  color: #ffffff;
  font-family: "BoldPixels", sans-serif;
}

#stage-shell {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 20% 18%, rgba(255, 255, 255, 0.14), transparent 35%),
    radial-gradient(circle at 80% 84%, rgba(255, 255, 255, 0.08), transparent 36%),
    linear-gradient(180deg, #0f2238 0%, #06111d 100%);
}

#stage {
  width: 1920px;
  height: 1080px;
  position: relative;
  overflow: hidden;
  transform-origin: top left;
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.45);
  cursor: none;
}

#bg-layer {
  position: absolute;
  inset: 0;
  background-image: url("assets/background.jpg");
  background-repeat: repeat-x;
  background-size: auto 100%;
  background-position: 0 0;
  animation: bg-scroll 48s linear infinite;
  z-index: 0;
}

#bg-layer.paused {
  animation-play-state: paused;
}

@keyframes bg-scroll {
  from {
    background-position-x: 0;
  }
  to {
    background-position-x: -7680px;
  }
}

#playfield {
  position: absolute;
  inset: 0;
  z-index: 2;
}

#bird {
  position: absolute;
  width: 112px;
  height: 90px;
  left: 300px;
  top: 480px;
  transform-origin: center;
  background: center / contain no-repeat;
  cursor: pointer;
  z-index: 4;
  filter: drop-shadow(0 7px 9px rgba(0, 0, 0, 0.42));
}

.pre-jump-hint {
  position: absolute;
  z-index: 6;
  color: rgba(255, 255, 255, 0.86);
  font-size: 18px;
  letter-spacing: 0.4px;
  pointer-events: none;
  opacity: 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  transition: opacity 120ms ease;
  white-space: nowrap;
}

.pre-jump-hint.visible {
  opacity: 1;
}

.bird-trail {
  position: absolute;
  width: 112px;
  height: 90px;
  background: center / contain no-repeat;
  pointer-events: none;
  z-index: 3;
  opacity: 0;
  filter: blur(0.8px) saturate(0.8) drop-shadow(0 2px 5px rgba(255, 255, 255, 0.06));
  transform-origin: center;
}

.trajectory-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.obstacle {
  position: absolute;
  background-position: left top;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  z-index: 3;
}

.extra {
  position: absolute;
  width: 64px;
  height: 64px;
  background: url("assets/extra.png") center / contain no-repeat;
  z-index: 5;
  animation: extra-float 0.9s ease-in-out infinite alternate;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
}

@keyframes extra-float {
  from {
    transform: translateY(-3px) scale(1);
  }
  to {
    transform: translateY(3px) scale(1.04);
  }
}

#score-panel {
  position: absolute;
  top: 0;
  left: 0;
  width: 485px;
  height: 84px;
  background: url("assets/score-bg.png") center / 100% 100% no-repeat;
  z-index: 7;
  padding: 8px 26px;
  pointer-events: none;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.45);
}

#score-panel p {
  margin: 0;
  line-height: 0.95;
  color: #ffffff;
}

#editor-panel {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 420px;
  z-index: 11;
  padding: 18px 18px 20px;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.24);
  background: linear-gradient(180deg, rgba(10, 30, 47, 0.94), rgba(7, 16, 30, 0.95));
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  user-select: none;
}

#editor-panel h3 {
  margin: 0 0 14px;
  font-size: 34px;
  letter-spacing: 1px;
}

#editor-panel .editor-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px 2px 4px;
  font-size: 20px;
  color: #e5f4ff;
}

#editor-panel input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: #4bd4ff;
}

.best-label {
  margin-left: 50px;
  margin-top: 0px;
  font-size: 30px;
  opacity: 0.95;
}

.your-label {
  margin-left: 50px;
  margin-top: -24px;
  font-size: 42px;
}

.score-float {
  position: absolute;
  z-index: 10;
  color: #fff2ab;
  font-size: 52px;
  line-height: 1;
  pointer-events: none;
  text-shadow: 0 3px 8px rgba(0, 0, 0, 0.45);
  will-change: transform, opacity;
}

.firework {
  position: absolute;
  width: 0;
  height: 0;
  z-index: 10;
  pointer-events: none;
}

.firework .spark {
  position: absolute;
  left: 0;
  top: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffffff, #ffd85e 58%, #ff8a00 100%);
  box-shadow: 0 0 10px rgba(255, 196, 64, 0.8);
  animation: spark-burst 700ms ease-out forwards;
  transform: translate(0, 0) scale(1);
}

@keyframes spark-burst {
  from {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  to {
    transform: translate(var(--dx), var(--dy)) scale(0.15);
    opacity: 0;
  }
}

.screen-overlay {
  position: absolute;
  inset: 0;
  z-index: 9;
  background-position: left top;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 260ms ease;
}

.screen-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

#start-screen {
  background-image: url("assets/screen-1.png");
}

.start-screen-flappy {
  position: absolute;
  left: 140px;
  top: 50%;
  transform: translateY(-50%);
  display: block;
  width: 320px;
  height: auto;
  pointer-events: none;
}

#game-over-screen {
  background-image: url("assets/screen-end.png");
}

#game-over-screen.best {
  background-image: url("assets/screen-best.png");
}

.hit-sequence {
  position: absolute;
  z-index: 12;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.hit-sequence img {
  display: block;
}

@media (max-width: 1920px), (max-height: 1080px) {
  #stage {
    box-shadow: none;
  }
}

/* ===== MOBILE RESPONSIVE ===== */
@media (pointer: coarse) {
  /* Na urządzeniach dotykowych przywracamy kursor */
  #stage {
    cursor: default;
  }

  /* Ukryj panel edytora na mobile - nie jest potrzebny */
  #editor-panel {
    display: none !important;
  }

  /* Hint tekstowy większy na mobile */
  .pre-jump-hint {
    font-size: 22px;
  }

  /* Trochę większy panel wyników */
  #score-panel {
    transform-origin: top left;
  }
}

/* Orientacja pionowa - komunikat z prośbą o obrót */
#rotate-hint {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #050b14;
  color: #fff;
  font-family: "BoldPixels", sans-serif;
  font-size: 28px;
  text-align: center;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 32px;
}

#rotate-hint svg {
  width: 72px;
  height: 72px;
  opacity: 0.7;
  animation: rotate-icon 2s ease-in-out infinite;
}

@keyframes rotate-icon {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(90deg); }
}

@media (max-width: 767px) and (orientation: portrait) {
  #rotate-hint {
    display: flex;
  }

  #stage-shell {
    display: none;
  }
}


#top-list-panel {
  position: absolute;
  top: 100px;
  right: 28px;
  width: 340px;
  z-index: 8;
  padding: 16px 20px 18px;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  background: linear-gradient(
    180deg,
    rgba(8, 22, 40, 0.88) 0%,
    rgba(4, 12, 24, 0.92) 100%
  );
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  backdrop-filter: blur(2px);
}

.top-list-header {
  margin: 0 0 12px;
  font-size: 30px;
  letter-spacing: 2px;
  color: #ffd85e;
  text-align: center;
  text-shadow: 0 2px 8px rgba(255, 196, 64, 0.45);
}

.top-list-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 4px 2px;
  font-size: 19px;
  color: #d8eeff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.top-list-row:last-child {
  border-bottom: none;
}

.top-list-gold {
  color: #ffd85e;
  font-size: 22px;
  text-shadow: 0 2px 6px rgba(255, 196, 64, 0.4);
}

.top-list-rank {
  width: 36px;
  flex-shrink: 0;
  opacity: 0.72;
  font-size: 16px;
}

.top-list-gold .top-list-rank {
  opacity: 1;
  font-size: 18px;
}

.top-list-nick {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-list-score {
  flex-shrink: 0;
  text-align: right;
  min-width: 52px;
  color: #4bd4ff;
}

.top-list-gold .top-list-score {
  color: #ffd85e;
}

/* Na mobile chowamy top-listę (za mało miejsca) */
@media (pointer: coarse) {
  #top-list-panel {
    display: none !important;
  }
}

#nick-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 13;
  width: 560px;
  padding: 36px 40px 32px;
  border-radius: 18px;
  border: 2px solid rgba(255, 215, 94, 0.45);
  background: linear-gradient(
    180deg,
    rgba(12, 28, 50, 0.97) 0%,
    rgba(6, 14, 28, 0.98) 100%
  );
  box-shadow:
    0 0 60px rgba(255, 196, 64, 0.18),
    0 16px 48px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  pointer-events: auto;
  animation: nick-pop 220ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes nick-pop {
  from { opacity: 0; transform: translate(-50%, -46%) scale(0.88); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1);    }
}

.nick-title {
  margin: 0;
  font-size: 38px;
  color: #ffd85e;
  text-shadow: 0 2px 12px rgba(255, 196, 64, 0.5);
  text-align: center;
  letter-spacing: 1px;
}

.nick-subtitle {
  margin: -8px 0 0;
  font-size: 24px;
  color: #b8d8f0;
  text-align: center;
  opacity: 0.85;
}

.nick-input {
  width: 100%;
  padding: 14px 18px;
  border-radius: 10px;
  border: 2px solid rgba(75, 212, 255, 0.5);
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
  font-family: "BoldPixels", sans-serif;
  font-size: 28px;
  text-align: center;
  outline: none;
  caret-color: #4bd4ff;
  transition: border-color 150ms ease, background 150ms ease;
  letter-spacing: 1px;
}

.nick-input::placeholder {
  color: rgba(255, 255, 255, 0.28);
  font-size: 22px;
}

.nick-input:focus {
  border-color: #4bd4ff;
  background: rgba(255, 255, 255, 0.1);
}

.nick-btn {
  padding: 14px 48px;
  border-radius: 10px;
  border: 2px solid rgba(75, 212, 255, 0.6);
  background: linear-gradient(180deg, rgba(75, 212, 255, 0.22), rgba(30, 120, 180, 0.28));
  color: #ffffff;
  font-family: "BoldPixels", sans-serif;
  font-size: 26px;
  letter-spacing: 2px;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, transform 80ms ease;
}

.nick-btn:hover {
  background: linear-gradient(180deg, rgba(75, 212, 255, 0.38), rgba(30, 120, 180, 0.44));
  border-color: #4bd4ff;
}

.nick-btn:active {
  transform: scale(0.96);
}

.nick-countdown {
  margin: -6px 0 0;
  font-size: 20px;
  color: rgba(255, 255, 255, 0.38);
  text-align: center;
}
