/* FLAPPY CHAMP — a Btown Games production */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --navy: #0e2238;
  --navy-2: #16324e;
  --cream: #f6efdc;
  --cream-dim: #d9ccae;
  --sun: #f2a24a;
  --champ: #3fa860;
  --champ-deep: #2e8149;
  --red: #c9502f;
}

html, body {
  height: 100%;
  overscroll-behavior: none;
  background: var(--navy);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#app { position: fixed; inset: 0; overflow: hidden; }

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

.hidden { display: none !important; }

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

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

#score {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 4vh);
  left: 0; right: 0;
  text-align: center;
  font-size: clamp(44px, 9vh, 72px);
  font-weight: 900;
  color: var(--cream);
  -webkit-text-stroke: 2px rgba(14, 34, 56, 0.55);
  text-shadow: 0 4px 0 rgba(14, 34, 56, 0.35);
}
#score.pop { animation: pop 0.28s ease-out; }
@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.28); }
  100% { transform: scale(1); }
}

#hint {
  position: absolute;
  top: 58%;
  left: 0; right: 0;
  text-align: center;
  font-size: clamp(15px, 2.4vh, 20px);
  font-weight: 800;
  letter-spacing: 0.22em;
  color: var(--cream);
  text-shadow: 0 2px 6px rgba(14, 34, 56, 0.6);
  animation: bob 1.1s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(0); opacity: 0.95; }
  50% { transform: translateY(7px); opacity: 0.65; }
}

#mute {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  right: calc(env(safe-area-inset-right, 0px) + 10px);
  z-index: 30;
  font-size: 20px;
  width: 44px; height: 44px;
  border-radius: 12px;
  border: 2px solid rgba(246, 239, 220, 0.25);
  background: rgba(14, 34, 56, 0.55);
  color: var(--cream);
  cursor: pointer;
  touch-action: manipulation;
}

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

.screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px calc(env(safe-area-inset-bottom, 0px) + 10px);
}

.menu-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.2vh;
  width: 100%;
  max-width: 420px;
  flex: 1;
  justify-content: center;
  min-height: 0;
}

/* wordmark */
#logo { text-align: center; user-select: none; }
.l-flappy {
  display: block;
  font-size: clamp(20px, 3.4vh, 30px);
  font-weight: 900;
  letter-spacing: 0.55em;
  margin-left: 0.55em; /* optical centering vs letterspacing */
  color: var(--sun);
  text-shadow: 0 2px 0 rgba(14, 34, 56, 0.8);
}
.l-champ { display: block; margin-top: 0.5vh; }
.l-champ i {
  display: inline-block;
  font-style: normal;
  font-weight: 900;
  font-size: clamp(44px, min(11vh, 16.5vw), 96px);
  line-height: 1;
  color: var(--champ);
  -webkit-text-stroke: 2.5px var(--navy);
  text-shadow: 0 5px 0 var(--navy), 0 8px 18px rgba(0, 0, 0, 0.4);
  animation: wave 2.4s ease-in-out infinite;
}
.l-champ i:nth-child(2) { animation-delay: 0.15s; color: #4cb56d; }
.l-champ i:nth-child(3) { animation-delay: 0.3s; }
.l-champ i:nth-child(4) { animation-delay: 0.45s; color: #4cb56d; }
.l-champ i:nth-child(5) { animation-delay: 0.6s; }
@keyframes wave {
  0%, 100% { transform: translateY(0) rotate(-1.5deg); }
  50% { transform: translateY(-9px) rotate(1.5deg); }
}

#tagline {
  text-align: center;
  color: var(--cream);
  font-size: clamp(13px, 2vh, 16px);
  font-weight: 600;
  line-height: 1.45;
  text-shadow: 0 1px 4px rgba(14, 34, 56, 0.8);
}

.big-btn {
  font-size: clamp(19px, 3vh, 24px);
  font-weight: 900;
  letter-spacing: 0.14em;
  color: var(--navy);
  background: linear-gradient(180deg, #ffc24e, var(--sun));
  border: 3px solid var(--navy);
  border-radius: 16px;
  padding: 14px 44px;
  box-shadow: 0 5px 0 var(--navy), 0 10px 22px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.06s ease;
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--navy); }

#howto { text-align: center; }
#howto .key {
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--cream);
  border: 1.5px solid rgba(246, 239, 220, 0.4);
  border-radius: 8px;
  padding: 4px 10px;
  margin: 0 4px;
  background: rgba(14, 34, 56, 0.5);
}
.howto-sub {
  margin-top: 7px;
  font-size: 12px;
  color: var(--cream-dim);
  font-style: italic;
  text-shadow: 0 1px 3px rgba(14, 34, 56, 0.8);
}

#best-line {
  min-height: 1.2em;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--cream);
  text-shadow: 0 1px 4px rgba(14, 34, 56, 0.9);
}

#credit, #credit-go {
  flex: none;
  text-align: center;
  font-size: 12px;
  color: var(--cream-dim);
  text-shadow: 0 1px 3px rgba(14, 34, 56, 0.9);
  padding-bottom: 4px;
}
#credit a, #credit-go a {
  color: var(--sun);
  font-weight: 700;
  text-decoration: none;
}
#credit a:active, #credit-go a:active { text-decoration: underline; }

/* ---------------------------------------------------------------- game over */

#gameover { background: rgba(10, 24, 40, 0.45); }

#go-card {
  width: min(92vw, 400px);
  background: linear-gradient(180deg, rgba(22, 50, 78, 0.96), rgba(14, 34, 56, 0.96));
  border: 2.5px solid rgba(246, 239, 220, 0.22);
  border-radius: 22px;
  padding: 18px 18px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  max-height: calc(100dvh - 70px);
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

#go-title {
  font-size: clamp(26px, 4.4vh, 36px);
  font-weight: 900;
  letter-spacing: 0.12em;
  color: #6fc9e8;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
  transform: rotate(-2deg);
}
#go-title.new-best { color: var(--sun); }

#go-row {
  display: flex;
  align-items: center;
  gap: 18px;
}
#medal { width: 84px; height: 84px; }
#go-nums {
  display: grid;
  grid-template-columns: auto auto;
  gap: 1px 14px;
  align-items: baseline;
}
.go-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--cream-dim);
}
#go-score, #go-best {
  font-size: 30px;
  font-weight: 900;
  color: var(--cream);
  text-align: right;
}
#go-score { color: var(--sun); font-size: 38px; }

#medal-line {
  min-height: 1em;
  font-size: 13px;
  font-weight: 700;
  color: var(--cream);
}

#go-btns { display: flex; gap: 10px; align-items: center; }
#go-btns .big-btn { padding: 11px 26px; font-size: 17px; }
.chip-btn {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--cream);
  background: rgba(246, 239, 220, 0.1);
  border: 2px solid rgba(246, 239, 220, 0.3);
  border-radius: 12px;
  padding: 11px 16px;
  cursor: pointer;
  touch-action: manipulation;
}
.chip-btn:active { background: rgba(246, 239, 220, 0.22); }

#brief-cta {
  display: block;
  text-align: center;
  text-decoration: none;
  color: var(--cream);
  font-size: 13px;
  line-height: 1.5;
  background: linear-gradient(180deg, rgba(63, 168, 96, 0.28), rgba(63, 168, 96, 0.16));
  border: 2px solid rgba(63, 168, 96, 0.55);
  border-radius: 14px;
  padding: 10px 18px;
  width: 100%;
}
#brief-cta strong { color: #6fd694; font-size: 14px; }
#brief-cta:active { background: rgba(63, 168, 96, 0.35); }

.go-sub {
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--cream-dim);
  text-transform: uppercase;
}

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

.lb {
  width: 100%;
  background: rgba(10, 24, 40, 0.55);
  border: 2px solid rgba(111, 201, 232, 0.28);
  border-radius: 14px;
  padding: 10px 12px 12px;
}
.lb-tabs { display: flex; gap: 6px; justify-content: center; }
.lb-chip {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--cream);
  background: rgba(246, 239, 220, 0.08);
  border: 1.5px solid rgba(246, 239, 220, 0.28);
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
  touch-action: manipulation;
}
.lb-chip.sel {
  background: rgba(242, 162, 74, 0.25);
  border-color: var(--sun);
  color: #ffd9a0;
}
.lb-status {
  font-size: 12px;
  color: #9fd4e8;
  margin: 7px 0 2px;
  text-align: center;
  min-height: 1.1em;
}
.lb ol {
  list-style: none;
  margin: 6px 0 0;
  max-height: 24vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
.lb li {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--cream);
}
.lb li .rank { width: 24px; text-align: right; opacity: 0.7; font-size: 12px; flex: none; }
.lb li .nm { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.lb li .sc { font-weight: 900; color: var(--sun); }
.lb li.me { background: rgba(63, 168, 96, 0.32); outline: 1.5px solid rgba(111, 214, 148, 0.5); }
.lb-form { display: flex; gap: 8px; justify-content: center; margin-top: 9px; }
.lb-form input {
  flex: 1;
  min-width: 0;
  font-size: 16px; /* ≥16px so iOS doesn't zoom the page */
  font-weight: 600;
  color: var(--cream);
  background: rgba(14, 34, 56, 0.8);
  border: 2px solid rgba(111, 201, 232, 0.4);
  border-radius: 10px;
  padding: 8px 12px;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}
.lb-form input:focus { border-color: var(--sun); }
.lb-form input::placeholder { color: rgba(217, 204, 174, 0.5); }
.lb-rename { margin-top: 8px; opacity: 0.85; }

/* ---------------------------------------------------------------- desktop */

@media (min-width: 700px) {
  #go-card { padding: 22px 26px 18px; }
  .lb ol { max-height: 30vh; }
}
