/* ==========================================================================
   Flappy Bull — stylesheet
   ========================================================================== */

:root {
  --bg-deep: #05060f;
  --navy: #0b0f2b;
  --navy-2: #131a44;
  --gold: #ffcf4d;
  --gold-2: #ffb400;
  --green: #22e07a;
  --green-2: #0fa858;
  --red: #ff4d5e;
  --red-2: #d92a3c;
  --blue: #4dd0ff;
  --white: #f5f7ff;
  --muted: #a9b0d6;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg-deep);
  font-family: 'Trebuchet MS', 'Segoe UI', Verdana, Arial, sans-serif;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ---------- generic screens ---------- */

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--white);
  padding: calc(var(--safe-top) + 16px) calc(var(--safe-right) + 16px)
    calc(var(--safe-bottom) + 16px) calc(var(--safe-left) + 16px);
  opacity: 1;
  transition: opacity 0.35s ease, transform 0.35s ease;
  z-index: 10;
  overflow-y: auto;
}

.screen.screen-off {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.98) translateY(6px);
}

/* ---------- loading screen ---------- */

#loadingScreen {
  background: radial-gradient(ellipse at 50% 30%, var(--navy-2) 0%, var(--bg-deep) 75%);
  z-index: 50;
}

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.loading-bull {
  font-size: 64px;
  animation: bob 1.1s ease-in-out infinite;
  filter: drop-shadow(0 0 18px rgba(255, 180, 0, 0.55));
}

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-14px) rotate(4deg); }
}

.loading-bar-track {
  width: min(260px, 70vw);
  height: 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
  border: 1px solid rgba(255, 207, 77, 0.4);
}

.loading-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--green-2), var(--gold));
  border-radius: 6px;
  transition: width 0.15s ease-out;
}

.loading-text {
  color: var(--muted);
  font-size: 14px;
  letter-spacing: 0.5px;
}

.dots span {
  animation: blink 1.4s infinite;
  opacity: 0;
}
.dots span:nth-child(1) { animation-delay: 0s; }
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 20% { opacity: 0; }
  40% { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------- title screen ---------- */

.ticker-wrap {
  position: absolute;
  top: calc(var(--safe-top) + 8px);
  left: 0;
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  background: rgba(0, 0, 0, 0.35);
  border-top: 1px solid rgba(34, 224, 122, 0.4);
  border-bottom: 1px solid rgba(34, 224, 122, 0.4);
  padding: 6px 0;
}

.ticker {
  display: inline-flex;
  gap: 28px;
  animation: ticker-scroll 22s linear infinite;
  padding-left: 100%;
}

.ticker span {
  color: var(--green);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.5px;
}

@keyframes ticker-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-100%); }
}

.title-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.game-title {
  font-family: 'Arial Black', 'Trebuchet MS', sans-serif;
  font-weight: 900;
  letter-spacing: 2px;
  margin: 0;
  color: var(--gold);
  -webkit-text-stroke: 2px #7a3d00;
  font-size: clamp(32px, 10vw, 62px);
  line-height: 1.05;
}

.small-glow {
  text-shadow: 0 0 18px rgba(255, 180, 0, 0.6);
}

.big-glow {
  animation: title-glow 2.4s ease-in-out infinite;
}

@keyframes title-glow {
  0%, 100% { text-shadow: 0 0 18px rgba(255, 180, 0, 0.55), 0 0 36px rgba(34, 224, 122, 0.25); }
  50% { text-shadow: 0 0 30px rgba(255, 180, 0, 0.85), 0 0 54px rgba(34, 224, 122, 0.45); }
}

.tagline {
  font-size: clamp(14px, 4vw, 18px);
  color: var(--green);
  font-weight: 700;
  letter-spacing: 1px;
  margin: 0;
  text-transform: uppercase;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.nfa {
  color: rgba(169, 176, 214, 0.6);
  font-size: 10px;
  letter-spacing: 0.5px;
  margin: 0;
}

.title-best {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 207, 77, 0.4);
  border-radius: 999px;
  padding: 6px 18px;
  font-weight: 700;
  font-size: 14px;
}

.title-best .label {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 1px;
}

.title-best #titleBestScore {
  color: var(--gold);
}

.btn-leaderboard {
  margin-top: -2px;
}

/* ---------- buttons ---------- */

.btn {
  border: none;
  border-radius: 16px;
  font-family: inherit;
  font-weight: 900;
  letter-spacing: 1px;
  cursor: pointer;
  outline: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.94);
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn-primary {
  background: linear-gradient(180deg, var(--green) 0%, var(--green-2) 100%);
  color: #04220f;
  box-shadow: 0 6px 0 #0a6b3a, 0 10px 24px rgba(15, 168, 88, 0.45);
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
  padding: 12px 28px;
  font-size: 14px;
  margin-top: 10px;
}

.small-btn {
  padding: 9px 18px;
  font-size: 12px;
  margin-top: 0;
}

.btn-play {
  font-size: clamp(20px, 6vw, 26px);
  padding: 16px 46px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-play-icon {
  font-size: 0.8em;
}

.secondary-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ---------- icon buttons ---------- */

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(11, 15, 43, 0.6);
  color: var(--white);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover {
  transform: scale(1.08);
  border-color: rgba(255, 207, 77, 0.6);
}

.icon-btn:active {
  transform: scale(0.9);
}

.title-icon-row {
  position: absolute;
  top: calc(var(--safe-top) + 46px);
  right: calc(var(--safe-right) + 12px);
  z-index: 20;
  display: flex;
  gap: 7px;
}

.title-icon-row .icon-btn {
  width: 38px;
  height: 38px;
  font-size: 15px;
}

.pause-btn {
  position: absolute;
  top: calc(var(--safe-top) + 16px);
  right: calc(var(--safe-right) + 16px);
}

/* Only interactive while the HUD is actually shown — otherwise this
   invisible button would sit on top of the title-screen icon row (same
   corner) and silently swallow clicks meant for music/sound/settings. */
#hud:not(.hud-off) .pause-btn {
  pointer-events: all;
}

/* ---------- HUD ---------- */

#hud {
  position: absolute;
  inset: 0;
  z-index: 15;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#hud.hud-off {
  opacity: 0;
  pointer-events: none;
}

.score-display {
  position: absolute;
  top: calc(var(--safe-top) + 18px);
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(36px, 10vw, 56px);
  font-weight: 900;
  color: var(--white);
  -webkit-text-stroke: 1.5px rgba(0, 0, 0, 0.6);
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
  font-variant-numeric: tabular-nums;
}

.score-display.score-pulse {
  animation: score-pulse 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.score-display.score-pulse-combo {
  animation: score-pulse-combo 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes score-pulse {
  0% { transform: translateX(-50%) scale(1); color: var(--white); }
  35% { transform: translateX(-50%) scale(1.22); color: var(--green); }
  100% { transform: translateX(-50%) scale(1); color: var(--white); }
}

@keyframes score-pulse-combo {
  0% { transform: translateX(-50%) scale(1); color: var(--white); }
  25% { transform: translateX(-50%) scale(1.5) rotate(-3deg); color: var(--gold); }
  50% { transform: translateX(-50%) scale(1.25) rotate(2deg); color: var(--gold); }
  100% { transform: translateX(-50%) scale(1) rotate(0deg); color: var(--white); }
}

/* ---------- milestone banner (every 25 pts) ---------- */

.milestone-banner {
  position: absolute;
  top: 18%;
  left: 50%;
  transform: translate(-50%, -10px) scale(0.85);
  z-index: 25;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(180deg, rgba(255, 207, 77, 0.95), rgba(255, 148, 0, 0.95));
  color: #2a1500;
  font-weight: 900;
  font-size: clamp(16px, 5vw, 24px);
  letter-spacing: 0.5px;
  padding: 10px 22px;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), 0 0 0 2px rgba(255, 255, 255, 0.25) inset;
  white-space: nowrap;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.milestone-banner.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
  animation: banner-pop 2.2s ease forwards;
}

@keyframes banner-pop {
  0% { transform: translate(-50%, -10px) scale(0.7); opacity: 0; }
  12% { transform: translate(-50%, 0) scale(1.08); opacity: 1; }
  20% { transform: translate(-50%, 0) scale(1); opacity: 1; }
  82% { transform: translate(-50%, 0) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -8px) scale(0.92); opacity: 0; }
}

/* ---------- panels (pause / game over / leaderboard) ---------- */

.panel {
  background: linear-gradient(180deg, rgba(19, 26, 68, 0.96) 0%, rgba(8, 10, 28, 0.98) 100%);
  border: 2px solid rgba(255, 207, 77, 0.5);
  border-radius: 22px;
  padding: 26px 28px 28px;
  width: min(360px, 90vw);
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.panel-title {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 2px;
  margin: 0;
  color: var(--gold);
}

.rekt-title {
  color: var(--red);
  text-shadow: 0 0 18px rgba(255, 77, 94, 0.6);
}

.pause-flavor {
  color: var(--muted);
  font-size: 13px;
  margin: -6px 0 4px;
}

.degen-quote {
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
  margin: -4px 0 2px;
  text-align: center;
}

.score-rows {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 10px 16px;
}

.score-row .label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
}

.score-row .value {
  font-size: 22px;
  font-weight: 900;
  color: var(--white);
  font-variant-numeric: tabular-nums;
}

.new-best-badge {
  background: linear-gradient(90deg, var(--gold-2), var(--gold));
  color: #3a2400;
  font-weight: 900;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 999px;
  letter-spacing: 0.5px;
  animation: pop-badge 0.5s ease;
}

@keyframes pop-badge {
  0% { transform: scale(0); }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* ---------- score submission ---------- */

.submit-score-box {
  display: flex;
  gap: 8px;
  width: 100%;
}

.name-input {
  flex: 1;
  min-width: 0;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  color: var(--white);
  font-family: inherit;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 0 12px;
  font-size: 14px;
}

.name-input::placeholder {
  color: rgba(245, 247, 255, 0.4);
  text-transform: none;
  letter-spacing: normal;
}

.name-input:focus {
  outline: none;
  border-color: var(--gold);
}

.submit-status {
  font-size: 12px;
  color: var(--green);
  margin: -4px 0 0;
  text-align: center;
}

/* ---------- leaderboard ---------- */

.leaderboard-panel {
  width: min(380px, 92vw);
}

.lb-mode-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  margin-top: -6px;
}

.lb-badge-global {
  color: var(--green);
  background: rgba(34, 224, 122, 0.12);
}

.lb-badge-local {
  color: var(--gold);
  background: rgba(255, 207, 77, 0.12);
}

.leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 46vh;
  overflow-y: auto;
}

.lb-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 14px;
}

.lb-row-mine {
  background: rgba(255, 207, 77, 0.16);
  border: 1px solid rgba(255, 207, 77, 0.5);
}

.lb-rank {
  font-weight: 900;
  color: var(--gold);
  font-size: 15px;
}

.lb-name {
  font-weight: 700;
  letter-spacing: 0.5px;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-score {
  font-weight: 900;
  color: var(--green);
  font-variant-numeric: tabular-nums;
}

.lb-loading,
.lb-empty {
  list-style: none;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 18px 8px;
}

/* ---------- title screen extras: floaters, coming-soon, version tag ---------- */

.title-floaters {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}

.floater-candle {
  position: absolute;
  bottom: 14%;
  width: 10px;
  height: 34px;
  border-radius: 3px;
  opacity: 0.35;
  animation: floater-drift 9s ease-in-out infinite;
}

.fc1 { left: 12%; background: var(--green); animation-delay: 0s; animation-duration: 8s; }
.fc2 { left: 78%; background: var(--red); animation-delay: -3s; animation-duration: 10s; }
.fc3 { left: 45%; background: var(--gold); animation-delay: -6s; animation-duration: 11s; width: 8px; height: 26px; }

@keyframes floater-drift {
  0%, 100% { transform: translateY(0) rotate(0deg); opacity: 0.25; }
  50% { transform: translateY(-38px) rotate(6deg); opacity: 0.45; }
}

.floater-bull {
  position: absolute;
  top: 10%;
  left: 6%;
  font-size: 26px;
  opacity: 0.18;
  animation: floater-bull-drift 14s ease-in-out infinite;
  filter: drop-shadow(0 0 10px rgba(255, 207, 77, 0.4));
}

@keyframes floater-bull-drift {
  0%, 100% { transform: translate(0, 0) rotate(-4deg); }
  50% { transform: translate(10px, 16px) rotate(4deg); }
}

.coming-soon-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: -2px;
}

.btn-disabled {
  position: relative;
  padding-right: 34px;
  font-size: 11px;
}

.soon-tag {
  position: absolute;
  top: -8px;
  right: -6px;
  background: var(--gold);
  color: #3a2400;
  font-size: 8px;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 999px;
  letter-spacing: 0.5px;
}

.version-tag {
  position: absolute;
  bottom: calc(var(--safe-bottom) + 6px);
  left: calc(var(--safe-left) + 10px);
  font-size: 10px;
  color: rgba(169, 176, 214, 0.4);
  letter-spacing: 0.5px;
  z-index: 5;
}

/* ---------- floating X (Twitter) follow button ---------- */

.x-follow-btn {
  position: fixed;
  right: calc(var(--safe-right) + 14px);
  bottom: calc(var(--safe-bottom) + 14px);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(11, 15, 43, 0.7);
  border: 2px solid rgba(255, 255, 255, 0.28);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 900;
  text-decoration: none;
  z-index: 30;
  backdrop-filter: blur(4px);
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.18s ease, border-color 0.18s ease, opacity 0.3s ease;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  opacity: 0.75;
}

.x-follow-btn:hover,
.x-follow-btn:focus-visible {
  opacity: 1;
  transform: scale(1.1) rotate(-6deg);
  border-color: rgba(255, 255, 255, 0.75);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.12), 0 6px 20px rgba(0, 0, 0, 0.45);
}

.x-follow-btn.playing-dim {
  opacity: 0.32;
  transform: scale(0.88);
}

/* ---------- settings screen ---------- */

.settings-panel {
  width: min(320px, 90vw);
}

.settings-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 12px 16px;
}

.settings-row .label {
  font-size: 13px;
  font-weight: 700;
  color: var(--white);
  letter-spacing: 0.5px;
}

.settings-toggle {
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
  font-weight: 900;
  font-size: 11px;
  letter-spacing: 0.5px;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}

.settings-toggle.on {
  background: rgba(34, 224, 122, 0.18);
  border-color: rgba(34, 224, 122, 0.6);
  color: var(--green);
}

.settings-toggle:active {
  transform: scale(0.92);
}

/* ---------- utility ---------- */

.hidden {
  display: none !important;
}

@media (max-width: 420px) {
  .panel {
    padding: 22px 18px 22px;
  }
}

@media (orientation: landscape) and (max-height: 480px) {
  .ticker-wrap { padding: 3px 0; }
  .title-content { gap: 4px; margin-top: 4px; }
  .game-title { font-size: clamp(20px, 5vw, 30px); }
  .btn-play { padding: 8px 26px; font-size: 16px; }
  .hint, .nfa { display: none; }
  .panel { padding: 14px 16px; max-height: 92vh; }
  .panel-title { font-size: 20px; }
}
