/* Arcade styling for Ballroom Blitz */
/* Fonts ship with the game (SIL OFL 1.1, licenses in assets/fonts/): the arcade's security policy
   blocks third-party font hosts, and players shouldn't ping Google just to read a button */
@font-face { font-family: 'Outfit'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('../assets/fonts/outfit-latin-ext.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Outfit'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('../assets/fonts/outfit-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Bungee'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../assets/fonts/bungee-latin-ext.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Bungee'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../assets/fonts/bungee-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --primary: #f59e0b;
  --primary-glow: rgba(245, 158, 11, 0.45);
  --accent: #ef4444;
  --bg-dark: #090d16;
  --panel-bg: rgba(15, 23, 42, 0.78);
  --panel-border: rgba(255, 255, 255, 0.14);
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  touch-action: none;
  overscroll-behavior: none;
}

button { font-family: inherit; }
.hidden { display: none !important; }

#game-container {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

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

/* --- HUD --- */
#hud-top {
  position: absolute;
  top: calc(12px + var(--safe-top));
  left: calc(12px + var(--safe-left));
  right: calc(12px + var(--safe-right));
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 12px;
  pointer-events: none;
  z-index: 10;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.on-title #hud-top,
.on-title #bird-queue-bar,
.on-title #active-bird-pill {
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
}

.level-badge, .score-card, .hud-btn, #bird-queue-bar {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.level-badge {
  border-radius: 14px;
  padding: 8px 14px;
  max-width: 340px;
  justify-self: start;
}

#level-num {
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--text-muted);
}

#level-title {
  font-family: 'Bungee', cursive;
  font-size: 1.05rem;
  font-weight: 400;
  color: var(--primary);
  text-shadow: 0 2px 8px var(--primary-glow);
  line-height: 1.2;
}

#level-subtitle {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-weight: 600;
  line-height: 1.3;
}

.score-card {
  border-radius: 16px;
  padding: 6px 18px 8px;
  text-align: center;
  min-width: 190px;
}

#score-display {
  font-family: 'Bungee', cursive;
  font-size: 1.8rem;
  color: #fbbf24;
  line-height: 1.1;
  text-shadow: 0 2px 10px rgba(251, 191, 36, 0.5);
  font-variant-numeric: tabular-nums;
}

#score-display.bump { animation: bump 0.18s ease-out; }
@keyframes bump {
  0% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

#star-track {
  position: relative;
  height: 6px;
  margin: 6px 6px 4px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}

#star-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, #f59e0b, #facc15);
  transition: width 0.35s ease;
}

.star-mark {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -52%);
  font-size: 13px;
  color: #475569;
  text-shadow: 0 1px 2px #000;
  transition: color 0.2s, transform 0.2s;
}

.star-mark.earned {
  color: #fde047;
  transform: translate(-50%, -52%) scale(1.25);
}

.score-sub {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.citizens-left { color: #fca5a5; }

.hud-right {
  display: flex;
  gap: 8px;
  justify-self: end;
  pointer-events: auto;
}

.hud-btn {
  border-radius: 12px;
  width: 44px;
  height: 44px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.2rem;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s, box-shadow 0.15s;
}

.hud-btn:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: 0 6px 20px var(--primary-glow);
}

.hud-btn:active { transform: translateY(1px); }
.hud-btn.off { opacity: 0.45; }
.hud-btn:focus-visible, button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* --- SPECIAL BANNER --- */
#special-indicator {
  position: absolute;
  top: calc(118px + var(--safe-top));
  left: 50%;
  transform: translate(-50%, -8px) scale(0.9);
  opacity: 0;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  padding: 9px 22px;
  border-radius: 30px;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.8px;
  box-shadow: 0 0 24px rgba(239, 68, 68, 0.6);
  pointer-events: none;
  z-index: 12;
  white-space: nowrap;
  transition: opacity 0.2s, transform 0.2s;
}

#special-indicator.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
  animation: pulseSpecial 0.8s 0.2s infinite alternate ease-in-out;
}

@keyframes pulseSpecial {
  0% { filter: brightness(1); }
  100% { filter: brightness(1.25); box-shadow: 0 0 34px rgba(250, 204, 21, 0.8); }
}

/* --- QUEUE --- */
/* A vertical column on the left edge, above the birds waiting on the ground, so it never covers them */
#bird-queue-bar {
  position: absolute;
  bottom: calc(150px + var(--safe-bottom));
  left: calc(12px + var(--safe-left));
  max-height: calc(100% - 150px - 84px - var(--safe-bottom) - var(--safe-top));
  border-radius: 16px;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 10;
  pointer-events: none;
  transition: opacity 0.3s;
}

#bird-queue-bar.empty { opacity: 0; }
#bird-queue-list { pointer-events: auto; }

.queue-label {
  font-size: 0.56rem;
  text-align: center;
  line-height: 1.1;
  font-weight: 900;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 1px;
}

#bird-queue-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  padding: 2px;
}
#bird-queue-list::-webkit-scrollbar { display: none; }

.queue-bird-icon {
  position: relative;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #1e293b;
  border: 2px solid #3b82f6;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: visible;
  padding: 0;
  cursor: pointer;
  transition: transform 0.12s;
}

.queue-bird-icon canvas { border-radius: 50%; }

.queue-bird-icon:hover { transform: scale(1.12); }

.queue-mat-badge {
  position: absolute;
  bottom: -5px;
  right: -5px;
  padding: 1px 4px;
  border-radius: 6px;
  font-size: 0.48rem;
  font-weight: 900;
  letter-spacing: 0.3px;
  line-height: 1.25;
  border: 1px solid rgba(15, 23, 42, 0.9);
  pointer-events: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.45);
}

#active-bird-pill {
  position: absolute;
  bottom: calc(14px + var(--safe-bottom));
  left: calc(18px + var(--safe-left));
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 12px;
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-left: 4px solid var(--char, #facc15);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  transition: opacity 0.2s ease;
  max-width: calc(100vw - 36px - var(--safe-left) - var(--safe-right));
}

#active-bird-pill.hidden { display: none; }

.active-bird-name {
  font-family: 'Bungee', cursive;
  font-size: 0.72rem;
  color: #f8fafc;
  white-space: nowrap;
}

.active-bird-spec {
  font-size: 0.68rem;
  font-weight: 800;
  color: #fde68a;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.active-bird-mat {
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 0.4px;
  padding: 2px 7px;
  border-radius: 999px;
  text-transform: uppercase;
  white-space: nowrap;
}

#btn-restart.armed {
  border-color: #f87171;
  background: rgba(185, 28, 28, 0.88);
  color: #fef2f2;
  font-size: 0.82rem;
  font-weight: 900;
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.35), 0 8px 24px rgba(0, 0, 0, 0.35);
}

/* --- FULLSCREEN BUTTON & IPHONE TIP --- */
#btn-fullscreen[hidden] { display: none; }
#btn-fullscreen .fs-exit { display: none; }
body.is-fullscreen #btn-fullscreen .fs-enter { display: none; }
body.is-fullscreen #btn-fullscreen .fs-exit { display: block; }

.app-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px auto 0;
  max-width: 620px;
  padding: 6px 6px 6px 14px;
  border-radius: 12px;
  background: rgba(30, 41, 59, 0.92);
  border: 1px solid rgba(250, 204, 21, 0.45);
  color: #fef3c7;
  font-size: 0.82rem;
  line-height: 1.35;
  text-align: left;
  pointer-events: auto;
}
.app-banner[hidden] { display: none; }
.app-banner span { flex: 1; }
.app-banner-get {
  flex: none;
  padding: 8px 14px;
  border-radius: 999px;
  background: #facc15;
  color: #1c1917;
  font-weight: 900;
  font-size: 0.8rem;
  text-decoration: none;
  white-space: nowrap;
}
.app-banner-close {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.1);
  color: #fef3c7;
  font-size: 0.9rem;
  cursor: pointer;
}

/* --- STORY --- */
/* The panel always shows whole (never cropped), letterboxed over a blurred copy of itself;
   the caption sits underneath it rather than on top of the art. */
.story {
  position: absolute;
  inset: 0;
  z-index: 200;
  background: #05070d;
  display: flex;
  flex-direction: column;
  padding: calc(10px + var(--safe-top)) calc(10px + var(--safe-right)) calc(10px + var(--safe-bottom)) calc(10px + var(--safe-left));
  gap: 10px;
}
.story.hidden { display: none; }
.story-art {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  border-radius: 14px;
  cursor: pointer;
}
.story-img-fill {
  position: absolute;
  inset: -40px;
  width: calc(100% + 80px);
  height: calc(100% + 80px);
  object-fit: cover;
  filter: blur(28px) brightness(0.45) saturate(1.2);
}
.story-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.6));
}
.story-card {
  flex: none;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  margin: 0 auto;
  width: min(980px, 100%);
  padding: 12px 16px;
  border-radius: 16px;
  background: #0b1220;
  border: 1px solid rgba(250, 204, 21, 0.35);
}
.story-portrait {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #facc15;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  background: #1e293b;
}
.story-kicker {
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #fca5a5;
}
.story-title {
  font-family: 'Bungee', cursive;
  font-weight: 400;
  font-size: 1.15rem;
  color: #facc15;
  margin: 2px 0 6px;
  line-height: 1.15;
}
.story-text { font-size: 1rem; line-height: 1.45; color: #f1f5f9; margin: 0; }
.story-sign { margin-top: 6px; font-size: 0.78rem; color: var(--text-muted); font-style: italic; }
.story-meters { display: grid; gap: 4px; margin-top: 10px; }
.story-meters:empty { display: none; }
.story-meter {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.8rem;
  padding: 5px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 800;
}
.story-meter strong { color: #facc15; }
.story-actions { display: flex; flex-direction: column; gap: 8px; }
.story-actions button { white-space: nowrap; }
.story-actions [hidden] { display: none; }

/* Henderson's notes and news flashes have no panel: just the card, centred over a dim backdrop */
.story--card {
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(9, 13, 22, 0.8), rgba(5, 7, 13, 0.97));
}
.story--card .story-art { display: none; }
.story--card .story-card { width: min(640px, 100%); }
.story--news .story-kicker { color: #fff; background: #dc2626; display: inline-block; padding: 2px 8px; border-radius: 4px; }
.story--news .story-title { font-family: 'Outfit', sans-serif; font-weight: 900; color: #fff; font-size: 1.2rem; }

.story--turn .story-card { animation: storyIn 0.3s ease-out; }
.story--turn .story-img { animation: storyArt 0.45s ease-out; }
@keyframes storyIn { from { transform: translateY(8px); } to { transform: none; } }
@keyframes storyArt { from { opacity: 0; transform: scale(1.02); } to { opacity: 1; transform: none; } }

/* Landscape phones: slim caption so the panel keeps most of the height */
@media (max-height: 500px) {
  .story { padding: 6px; gap: 6px; }
  .story-art { border-radius: 10px; }
  .story-card { gap: 10px; padding: 6px 10px; border-radius: 12px; }
  .story-portrait { width: 40px; height: 40px; border-width: 2px; }
  .story-kicker { font-size: 0.58rem; }
  .story-title { font-size: 0.85rem; margin: 0 0 2px; }
  .story-text { font-size: 0.78rem; line-height: 1.3; }
  .story-sign { display: none; }
  .story-meters { margin-top: 6px; }
  .story-meter { font-size: 0.66rem; padding: 3px 8px; }
  .story-actions { flex-direction: row; }
  .story-actions button { padding: 7px 14px !important; font-size: 0.8rem !important; }
}
@media (max-width: 560px) {
  .story-card { grid-template-columns: auto 1fr; }
  .story-actions { grid-column: 1 / -1; flex-direction: row; justify-content: flex-end; }
}

/* --- HINT --- */
#hint {
  position: absolute;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(250, 204, 21, 0.5);
  color: #fef3c7;
  font-weight: 800;
  font-size: 0.95rem;
  padding: 10px 18px;
  border-radius: 999px;
  z-index: 11;
  pointer-events: none;
  animation: hintFloat 1.4s infinite alternate ease-in-out;
  white-space: nowrap;
}

@keyframes hintFloat {
  from { transform: translate(-50%, 0); }
  to { transform: translate(-50%, -6px); }
}

/* --- LEVEL BANNER --- */
#level-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -60%);
  text-align: center;
  z-index: 15;
  pointer-events: none;
  padding: 20px 36px;
  background: radial-gradient(ellipse at center, rgba(9, 13, 22, 0.75), rgba(9, 13, 22, 0) 70%);
  animation: bannerIn 0.5s cubic-bezier(0.2, 1.4, 0.4, 1) both;
  max-width: 92vw;
}

#level-banner.out { animation: bannerOut 0.35s ease-in both; }

@keyframes bannerIn {
  from { opacity: 0; transform: translate(-50%, -40%) scale(0.85); }
  to { opacity: 1; transform: translate(-50%, -60%) scale(1); }
}

@keyframes bannerOut {
  to { opacity: 0; transform: translate(-50%, -80%) scale(1.05); }
}

#banner-num {
  font-weight: 900;
  letter-spacing: 4px;
  font-size: 0.8rem;
  color: #fde68a;
}

#banner-title {
  font-family: 'Bungee', cursive;
  font-size: clamp(1.6rem, 5vw, 3rem);
  color: #fff;
  text-shadow: 0 4px 0 #b45309, 0 8px 24px rgba(0, 0, 0, 0.6);
  line-height: 1.1;
  margin: 4px 0 8px;
}

#banner-sub {
  font-weight: 700;
  color: #e2e8f0;
  text-shadow: 0 2px 6px #000;
  font-size: 1rem;
}

#banner-lineup {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}

#banner-lineup canvas {
  background: rgba(15, 23, 42, 0.8);
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
}

.banner-skip {
  margin-top: 12px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.55);
  text-transform: uppercase;
}

/* --- TITLE SCREEN --- */
#title-screen {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(ellipse at center, rgba(9, 13, 22, 0.55) 0%, rgba(9, 13, 22, 0.88) 75%);
  padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
  overflow-y: auto;
  touch-action: pan-y;
  /* Centered when it fits; scrollable from the top when it doesn't (plain centering clips the top) */
  align-items: flex-start;
}

.title-inner {
  margin: auto 0;
  text-align: center;
  max-width: 880px;
  width: 100%;
  animation: modalPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.title-kicker {
  font-weight: 900;
  letter-spacing: 4px;
  font-size: 0.72rem;
  color: #fca5a5;
}

.title-logo {
  font-family: 'Bungee', cursive;
  font-weight: 400;
  font-size: clamp(2.6rem, 9vw, 5.4rem);
  line-height: 0.95;
  margin: 6px 0 8px;
  color: #facc15;
  text-shadow: 0 5px 0 #b45309, 0 10px 0 #7c2d12, 0 18px 30px rgba(0, 0, 0, 0.6);
  transform: rotate(-2deg);
}

.title-logo span:last-child { color: #f87171; text-shadow: 0 5px 0 #991b1b, 0 10px 0 #450a0a, 0 18px 30px rgba(0, 0, 0, 0.6); }

.title-sub {
  color: #cbd5e1;
  font-weight: 700;
  margin-bottom: 22px;
}

.roster {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 22px;
  text-align: left;
}

.roster-card {
  display: flex;
  gap: 12px;
  align-items: center;
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-left: 4px solid var(--char);
  border-radius: 14px;
  padding: 10px 12px;
}

.roster-thumb { flex: none; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5)); }
.roster-info { min-width: 0; }
.roster-name { font-family: 'Bungee', cursive; font-size: 0.95rem; }
.roster-special { font-weight: 900; font-size: 0.75rem; color: #fde047; letter-spacing: 0.5px; }
.roster-desc { font-size: 0.75rem; color: var(--text-muted); line-height: 1.3; margin-top: 2px; }

.roster-chip {
  display: inline-block;
  margin-top: 5px;
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--char) 30%, transparent);
  border: 1px solid var(--char);
}

.title-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-big {
  font-size: 1.4rem !important;
  padding: 14px 44px !important;
  animation: pulsePlay 1.2s infinite alternate ease-in-out;
}

@keyframes pulsePlay {
  to { transform: scale(1.05); box-shadow: 0 8px 30px rgba(245, 158, 11, 0.7); }
}

.title-help {
  margin-top: 18px;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}

#rotate-hint {
  display: none;
  position: absolute;
  top: calc(140px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.85);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.75rem;
  font-weight: 800;
  z-index: 9;
  pointer-events: none;
  white-space: nowrap;
}

@media (orientation: portrait) and (max-width: 700px) {
  #rotate-hint { display: block; }
  .on-title #rotate-hint { display: none; }
}

/* --- MODALS --- */
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(9, 13, 22, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 16px;
}

.modal-content {
  background: linear-gradient(160deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 24px;
  padding: 28px;
  max-width: 440px;
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
  animation: modalPop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  touch-action: pan-y;
}

.modal-content.wide { max-width: 620px; }

@keyframes modalPop {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-title {
  font-family: 'Bungee', cursive;
  font-weight: 400;
  font-size: 1.8rem;
  color: #facc15;
  margin-bottom: 6px;
  text-shadow: 0 3px 0 #92400e, 0 6px 16px rgba(250, 204, 21, 0.35);
}

.modal-title.lose { color: #f87171; text-shadow: 0 3px 0 #7f1d1d, 0 6px 16px rgba(239, 68, 68, 0.35); }

.modal-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 18px;
}

#stars-total { color: #fde047; font-weight: 900; letter-spacing: 1px; }

.modal-stars {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 8px;
  margin: 4px 0 18px;
}

.modal-stars .star {
  font-size: 3rem;
  line-height: 1;
  color: #334155;
  text-shadow: 0 3px 0 #0f172a;
  transition: color 0.1s;
}

.modal-stars .star.big { font-size: 4rem; }

.modal-stars .star.on {
  color: #fde047;
  text-shadow: 0 3px 0 #b45309, 0 0 24px rgba(250, 204, 21, 0.8);
  animation: starPop 0.45s cubic-bezier(0.2, 1.8, 0.4, 1);
}

@keyframes starPop {
  0% { transform: scale(2.2) rotate(-30deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

.modal-stat-box {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
  font-weight: 700;
}

.stat-big .stat-val { font-family: 'Bungee', cursive; font-size: 1.5rem; color: #fbbf24; }
.stat-val { font-weight: 800; color: #38bdf8; font-variant-numeric: tabular-nums; }

.new-best {
  align-self: center;
  font-weight: 900;
  font-size: 0.75rem;
  letter-spacing: 2px;
  color: #0f172a;
  background: #4ade80;
  border-radius: 999px;
  padding: 3px 12px;
  animation: pulseSpecial 0.6s infinite alternate;
}

.modal-btn-row {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.btn-primary {
  background: linear-gradient(135deg, #fbbf24, #d97706);
  border: none;
  border-bottom: 4px solid #92400e;
  border-radius: 14px;
  padding: 11px 24px;
  font-family: 'Bungee', cursive;
  font-size: 1rem;
  color: #1c1917;
  cursor: pointer;
  box-shadow: 0 6px 20px var(--primary-glow);
  transition: transform 0.12s ease, filter 0.12s;
}

.btn-primary:hover { transform: translateY(-2px); filter: brightness(1.08); }
.btn-primary:active { transform: translateY(2px); border-bottom-width: 2px; }

/* The arcade links are <a>s styled as the buttons beside them */
a.hud-btn, a.btn-secondary { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 11px 18px;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
}

.btn-secondary:hover { background: rgba(255, 255, 255, 0.15); }

/* --- WORLD HALL OF FAME (js/hof.js): the level's world top 10 on the win card --- */
.hof {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 20px;
  text-align: left;
}

.hof-heading {
  font-family: 'Bungee', cursive;
  font-weight: 400;
  font-size: 0.85rem;
  letter-spacing: 1px;
  color: #facc15;
  text-align: center;
  margin-bottom: 8px;
}

.hof-rows { list-style: none; display: flex; flex-direction: column; gap: 2px; }

.hof-rows li {
  display: grid;
  grid-template-columns: 1.6em 3.2em 1fr auto;
  gap: 8px;
  align-items: baseline;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.hof-rows li:nth-child(odd) { background: rgba(255, 255, 255, 0.04); }
.hof-rows li.you { background: rgba(250, 204, 21, 0.18); outline: 1px solid rgba(250, 204, 21, 0.6); }
.hof-rows .hof-empty { display: block; text-align: center; color: var(--text-muted); font-weight: 600; padding: 6px; }
.hof-rank { color: var(--text-muted); text-align: right; }
.hof-name { font-family: 'Bungee', cursive; font-weight: 400; letter-spacing: 1px; color: #fff; }
.hof-score { color: #fbbf24; text-align: right; }
.hof-stats { color: var(--text-muted); font-size: 0.72rem; white-space: nowrap; }
.hof-stars { color: #fde047; letter-spacing: -1px; margin-right: 4px; }

.hof-form {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed rgba(255, 255, 255, 0.18);
  text-align: center;
}

.hof-form-title { font-family: 'Bungee', cursive; font-size: 1rem; color: #4ade80; }
.hof-label { display: block; font-size: 0.8rem; font-weight: 700; color: #cbd5e1; margin: 2px 0 8px; }

.hof-entry {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: stretch;
  flex-wrap: wrap;
}

.hof-initials {
  width: 5.2em;
  padding: 8px 6px;
  border-radius: 12px;
  border: 2px solid rgba(250, 204, 21, 0.6);
  background: #0f172a;
  color: #fff;
  font-family: 'Bungee', cursive;
  font-size: 1.15rem; /* 16px+ so phones don't zoom in on focus */
  letter-spacing: 4px;
  text-align: center;
  text-transform: uppercase;
  user-select: text;
  -webkit-user-select: text;
}

.hof-initials:focus { outline: none; border-color: #facc15; box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.3); }
.hof-initials::placeholder { color: #334155; }

/* Gold like the primary buttons, but not one: Enter on the card still means NEXT LEVEL */
.hof-sign {
  background: linear-gradient(135deg, #fbbf24, #d97706);
  border: none;
  border-bottom: 4px solid #92400e;
  border-radius: 12px;
  padding: 8px 16px;
  font-family: 'Bungee', cursive;
  font-size: 0.9rem;
  color: #1c1917;
  cursor: pointer;
}

.hof-sign:disabled { filter: grayscale(0.7); cursor: default; }
.hof-sign:active { transform: translateY(2px); border-bottom-width: 2px; }
.hof-skip { padding: 8px 14px; font-size: 0.85rem; }
.hof-form-msg { min-height: 1.2em; margin-top: 6px; font-size: 0.78rem; font-weight: 700; color: #fde68a; }
.hof-privacy { margin-top: 4px; font-size: 0.7rem; line-height: 1.35; color: var(--text-muted); }

.hof-msg { margin-top: 10px; font-size: 0.8rem; font-weight: 700; text-align: center; color: #cbd5e1; }
.hof-msg.good { color: #4ade80; }
.hof-msg.bad { color: #fca5a5; }

/* In the stage list: erase what this browser signed */
.hof-erase {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  justify-content: center;
  align-items: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.hof-erase .btn-secondary { padding: 7px 12px; font-size: 0.75rem; }
.hof-erase-msg { flex-basis: 100%; text-align: center; min-height: 1em; color: #fde68a; font-weight: 700; }

@media (pointer: coarse) {
  .hof-sign, .hof-skip, .hof-initials, .hof-erase .btn-secondary { min-height: 44px; }
}

/* Landscape phones: the world board sits beside the score instead of below it */
@media (max-height: 500px) and (min-width: 600px) {
  #win-modal .modal-content.with-hof {
    max-width: 780px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
    column-gap: 18px;
    align-items: start;
  }
  #win-modal .modal-content.with-hof > * { grid-column: 1; }
  #win-modal .modal-content.with-hof > #win-hof { grid-column: 2; grid-row: 1 / span 5; margin-bottom: 0; }
  .hof-rows li { font-size: 0.75rem; padding: 1px 6px; }
  #win-modal .modal-content.with-hof .modal-btn-row button { padding-left: 12px; padding-right: 12px; white-space: nowrap; }
}

/* --- LEVEL SELECT --- */
.levels-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px;
  max-height: 62vh;
  overflow-y: auto;
  text-align: left;
}

.episode-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}

.episode-num {
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--text-muted);
}

.episode-name {
  font-family: 'Bungee', cursive;
  font-size: 1rem;
  flex: 1;
}

.episode-stars {
  font-weight: 900;
  font-size: 0.8rem;
  color: #fde047;
}

.episode-story-btn {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(250, 204, 21, 0.45);
  background: rgba(30, 41, 59, 0.85);
  color: #fef08a;
  font-family: 'Outfit', sans-serif;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.4px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}

.episode-story-btn:hover {
  background: rgba(51, 65, 85, 0.95);
  border-color: #facc15;
}

@media (pointer: coarse) {
  .episode-story-btn { min-height: 44px; padding: 6px 12px; }
}

.episode-grid {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 6px;
}

.level-card.locked {
  cursor: not-allowed;
  opacity: 0.45;
  filter: grayscale(0.8);
}

.level-card.locked:hover { transform: none; border-color: var(--panel-border); }

@media (max-width: 560px) {
  .episode-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

.level-card {
  --tint: #38bdf8;
  position: relative;
  background: linear-gradient(160deg, color-mix(in srgb, var(--tint) 28%, #0f172a), #0f172a 70%);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 8px 2px 6px;
  text-align: center;
  cursor: pointer;
  color: var(--text);
  transition: transform 0.15s ease, border-color 0.15s;
}

.level-card.theme-white_house { --tint: #3b82f6; }
.level-card.theme-fast_food { --tint: #f59e0b; }
.level-card.theme-concert { --tint: #a855f7; }
.level-card.theme-palm_vault { --tint: #ec4899; }
.level-card.theme-citadel { --tint: #64748b; }
.level-card.theme-kennedy { --tint: #c25b7a; }
.level-card.theme-lincoln { --tint: #e2c79a; }
.level-card.theme-mall { --tint: #22c55e; }
.level-card.theme-capitol { --tint: #f0b97a; }

.level-card:hover, .level-card.active {
  border-color: var(--primary);
  transform: translateY(-3px);
}

.level-card-num {
  font-family: 'Bungee', cursive;
  font-size: 1.25rem;
  color: #fff;
  line-height: 1;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
}

.level-card-title {
  font-size: 0.72rem;
  font-weight: 800;
  margin: 6px 0 4px;
  line-height: 1.25;
  min-height: 2.5em;
}

.level-card-stars { font-size: 0.72rem; letter-spacing: 0; color: #fde047; white-space: nowrap; }
.level-card-stars .dim { color: #334155; }

.level-card-score {
  font-size: 0.66rem;
  font-weight: 800;
  color: var(--text-muted);
  margin-top: 2px;
  letter-spacing: 1px;
}

/* Pulling the launcher back drags your thumb across the Next Up bar: fade it out of the way */
body.aim-drag #bird-queue-bar,
body.aim-drag #active-bird-pill { opacity: 0; pointer-events: none; }

/* Touch screens keep 44px targets even when the HUD shrinks */
@media (pointer: coarse) {
  .hud-btn { width: 44px !important; height: 44px !important; }
  .queue-bird-icon { width: 42px; height: 42px; }
}

/* --- SMALL SCREENS --- */
@media (max-width: 760px), (max-height: 500px) {
  #hud-top { gap: 8px; top: calc(8px + var(--safe-top)); left: calc(8px + var(--safe-left)); right: calc(8px + var(--safe-right)); }
  #level-subtitle { display: none; }
  #level-title { font-size: 0.8rem; }
  .level-badge { padding: 6px 10px; }
  .score-card { min-width: 140px; padding: 4px 12px 6px; }
  #score-display { font-size: 1.3rem; }
  .hud-btn { width: 36px; height: 36px; font-size: 1rem; border-radius: 10px; }
  .hud-right { gap: 5px; }
  #special-indicator { top: calc(84px + var(--safe-top)); font-size: 0.78rem; padding: 7px 16px; }
  #bird-queue-bar { left: calc(8px + var(--safe-left)); padding: 6px 4px; max-height: calc(100% - 150px - 60px - var(--safe-bottom) - var(--safe-top)); }
  #active-bird-pill { bottom: calc(8px + var(--safe-bottom)); left: calc(8px + var(--safe-left)); padding: 5px 9px; gap: 6px; }
  .active-bird-spec { display: none; }
  .active-bird-name { font-size: 0.65rem; }
  .active-bird-mat { font-size: 0.58rem; padding: 2px 6px; }
  .queue-label { display: none; }
  .roster-desc { display: none; }
  .modal-content { padding: 20px; }
  .modal-stars .star { font-size: 2.3rem; }
  .modal-stars .star.big { font-size: 3rem; }
}

@media (max-width: 560px) {
  .hud-left { display: none; }
  #hud-top { grid-template-columns: auto 1fr; }
  .hud-center { justify-self: start; }
  .roster { grid-template-columns: 1fr; }
  #hint { white-space: normal; width: 88vw; text-align: center; }
}

@media (max-height: 500px) {
  #banner-title { font-size: 1.5rem; }
  #banner-sub { font-size: 0.8rem; }
  #banner-lineup { margin-top: 8px; }
  #level-banner { padding: 10px 24px; transform: translate(-50%, -50%); }
  @keyframes bannerIn {
    from { opacity: 0; transform: translate(-50%, -30%) scale(0.85); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  }
  /* Landscape phones: the whole title screen fits without scrolling, all six birds in one row */
  #title-screen { padding-top: calc(8px + var(--safe-top)); padding-bottom: calc(8px + var(--safe-bottom)); }
  .title-kicker { font-size: 0.6rem; letter-spacing: 3px; }
  .title-logo { font-size: 2.1rem; margin: 2px 0 4px; }
  .title-sub { font-size: 0.72rem; margin-bottom: 8px; }
  .roster { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin-bottom: 10px; }
  .roster-card { flex-direction: column; text-align: center; padding: 6px 4px; gap: 2px; border-left-width: 3px; }
  .roster-thumb { width: 46px !important; height: 46px !important; }
  .roster-name { font-size: 0.62rem; line-height: 1.15; }
  .roster-special { font-size: 0.55rem; letter-spacing: 0; }
  .roster-chip { display: inline-block; font-size: 0.5rem; padding: 1px 5px; margin-top: 1px; }
  .btn-big { font-size: 1.1rem !important; padding: 9px 32px !important; }
  .title-buttons .btn-secondary { padding-top: 9px; padding-bottom: 9px; }
  .app-banner { margin-top: 8px; font-size: 0.72rem; padding: 4px 4px 4px 12px; }
  .app-banner-get { padding: 6px 12px; font-size: 0.72rem; }
  .title-help { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

/* --- Parody notice (studio/resistance-intro.js) in Ballroom Blitz's own look: the stage-list panel,
   the title logo's gold and red lettering, and the gold PLAY button --- */
.rs-intro .rs-warn {
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  padding: 24px 26px 20px;
  background: linear-gradient(160deg, #1e293b 0%, #0f172a 100%);
  border: 2px solid rgba(251, 191, 36, 0.55);
  border-radius: 24px;
  box-shadow: 0 0 0 6px rgba(15, 23, 42, 0.6), 0 25px 60px rgba(0, 0, 0, 0.7), 0 0 50px rgba(245, 158, 11, 0.18);
  color: #cbd5e1;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  animation: modalPop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.rs-intro .rs-warn-studio { font-family: 'Outfit', sans-serif; font-weight: 800; font-size: 11px; letter-spacing: 0.3em; color: #fbbf24; }
.rs-intro .rs-warn-pill {
  font-family: 'Bungee', cursive; font-weight: 400; font-size: 12px; letter-spacing: 0.12em;
  color: #fff; background: #b91c1c; border: 0; border-bottom: 3px solid #7f1d1d; border-radius: 8px;
  padding: 5px 14px; transform: rotate(-3deg);
}
.rs-intro .rs-warn h2 {
  margin: 16px 0 14px;
  font-family: 'Outfit', sans-serif; font-weight: 900; font-size: clamp(20px, 5.6vw, 26px); color: #f8fafc;
}
.rs-intro .rs-warn h2 .rs-warn-game {
  display: block;
  margin-bottom: 6px;
  font-family: 'Bungee', cursive; font-weight: 400; font-size: clamp(30px, 9vw, 42px); line-height: 1;
  color: #facc15; text-shadow: 0 3px 0 #b45309, 0 6px 0 #7c2d12, 0 10px 18px rgba(0, 0, 0, 0.6);
  transform: rotate(-2deg);
}
.rs-intro .rs-warn p { font-size: 14px; line-height: 1.5; }
.rs-intro .rs-warn .rs-warn-joke { color: #fde68a; font-weight: 600; }
.rs-intro .rs-warn .rs-warn-credits { font-size: 11px; color: #64748b; border-top: 1px dashed rgba(251, 191, 36, 0.3); }
.rs-intro .rs-warn-btn {
  margin-top: 18px; padding: 13px 16px;
  font-family: 'Bungee', cursive; font-weight: 400; font-size: 17px; letter-spacing: 0.04em; color: #1c1917;
  background: linear-gradient(135deg, #fbbf24, #d97706);
  border: 0; border-bottom: 4px solid #92400e; border-radius: 14px;
  box-shadow: 0 6px 20px var(--primary-glow);
}
.rs-intro .rs-warn-btn:active { transform: translateY(2px); border-bottom-width: 2px; box-shadow: 0 3px 12px var(--primary-glow); }
/* Landscape phones: the name and "is a parody." share a line so the whole card and its button fit */
@media (max-height: 560px) {
  .rs-intro .rs-warn { width: min(560px, calc(100vw - 32px)); padding: 10px 18px 10px; }
  .rs-intro .rs-warn-pill { margin-top: 6px; padding: 3px 12px; font-size: 11px; }
  .rs-intro .rs-warn h2 { margin: 8px 0 6px; font-size: 18px; }
  .rs-intro .rs-warn h2 .rs-warn-game { display: inline-block; margin: 0 6px 0 0; font-size: 22px; }
  .rs-intro .rs-warn p { font-size: 12px; line-height: 1.35; margin-bottom: 4px; }
  .rs-intro .rs-warn .rs-warn-credits { margin-top: 6px; padding-top: 6px; font-size: 9.5px; }
  .rs-intro .rs-warn-btn { margin-top: 8px; padding: 8px; font-size: 14px; }
}
