.wq-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(7, 12, 22, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.wq-brand {
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #ffffff;
  text-decoration: none;
  font-size: 0.95rem;
}

.wq-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.wq-nav-link,
.wq-action {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #f5f6fb;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.78rem;
  text-decoration: none;
  line-height: 1;
  cursor: pointer;
}

.wq-nav-link[aria-current='page'] {
  background: rgba(255, 221, 0, 0.15);
  border-color: rgba(255, 221, 0, 0.55);
  color: #ffef99;
}

.wq-action:hover,
.wq-nav-link:hover {
  background: rgba(255, 255, 255, 0.16);
}

.wq-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1800;
  display: flex;
  justify-content: center;
  padding: 8px 12px;
  background: rgba(7, 12, 22, 0.8);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.wq-footer-text {
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

.wq-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.52);
  z-index: 1900;
}

.wq-overlay.active {
  display: flex;
}

.wq-overlay-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 14px 18px;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.72);
  font-size: 1rem;
  letter-spacing: 0.05em;
}

@media (max-width: 900px) {
  .wq-topbar {
    padding: 8px 10px;
  }

  .wq-brand {
    font-size: 0.82rem;
  }

  /* Scoped to the topbar so each game's full-width mobile `button` rule can't stretch
     these into a column that covers half the screen. */
  .wq-topbar .wq-nav-link,
  .wq-topbar .wq-action {
    width: auto;
    margin: 0;
    padding: 7px 9px;
    font-size: 0.72rem;
  }

  .wq-footer-text {
    font-size: 0.68rem;
    text-align: center;
  }
}

/* ==============================
   SHARED SCREEN LAYOUT
   ============================== */

/* The topbar and footer are fixed, so screens need room to clear them. `safe center`
   keeps content centred until it is taller than the viewport, then falls back to
   top-aligned so the start of a long end screen is never scrolled out of reach. */
body[data-game] .screen {
  overflow-y: auto;
  justify-content: safe center;
  padding-top: 64px;
  padding-bottom: 52px;
}

.wq-overlay-card span {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.6);
}

/* ==============================
   LEVEL SELECT
   ============================== */

.wq-level-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 420px;
  margin: 20px auto;
}

.wq-level-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 15px 20px;
  font-size: 1.05em;
  text-align: left;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.wq-level-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

.wq-level-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.wq-level-detail {
  color: #ffdd00;
  white-space: nowrap;
}

/* Standard / Easy switch above the level list. */
.wq-effort-toggle {
  display: flex;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

.wq-effort-btn {
  flex: 1;
  padding: 10px 12px;
  font-size: 0.95em;
  color: #dfe4ea;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  cursor: pointer;
}

.wq-effort-btn.active {
  color: #1a1a2e;
  background: #ffdd00;
  border-color: #ffdd00;
  font-weight: bold;
}

/* Fallback for pages whose own stylesheet does not define a locked-level style. */
.btn-gray {
  background: #57606f;
  color: #dfe4ea;
}

/* ==============================
   END SCREEN ACTIONS & SCORE SAVE
   ============================== */

.wq-end-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 18px 0 6px;
}

.wq-save-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
  text-align: center;
}

.wq-save-row input {
  padding: 9px 12px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  width: 200px;
  font-size: 1em;
}

.wq-save-row input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.wq-save-row button {
  padding: 9px 16px;
  font-size: 1em;
}

.wq-save-row button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.wq-save-row #saveStatus {
  flex-basis: 100%;
  margin: 4px 0 0;
  min-height: 1.2em;
  color: #ccc;
  font-size: 0.9em;
}

/* ==============================
   LEADERBOARD (shared default)
   ============================== */

.leaderboard-title {
  text-align: center;
  color: #ffdd00;
}

.leaderboard-card {
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 10px 18px;
  min-width: 280px;
  max-width: 420px;
  margin: 0 auto;
}

.leaderboard-card ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

.leaderboard-card li {
  padding: 6px 2px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #f1f2f6;
  font-size: 0.95em;
}

.leaderboard-card li:last-child {
  border-bottom: none;
}

/* Inline action inside a connection-status message (e.g. Reconnect). */
.wq-inline-btn {
  display: inline-block;
  margin-left: 6px;
  padding: 5px 12px;
  font-size: 0.85em;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
}

.wq-inline-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* The footer is fixed to the bottom edge, so lift each game's progress bar above it. */
body[data-game] #progressBarContainer {
  bottom: 42px;
}

/* Keyboard shortcuts mean little on a phone, and the footer wraps to two lines there. */
@media (max-width: 600px) {
  .wq-footer { display: none; }
  body[data-game] #progressBarContainer { bottom: 14px; }

  /* Four game links and five actions must still fit two rows on a phone - every game's HUD
     is placed below a two-row bar. The games' global button rules (uppercase, letter
     spacing) leak into the bar's buttons, so reset them here too. */
  .wq-topbar { gap: 8px; padding: 8px; }
  .wq-brand { font-size: 0.74rem; }
  .wq-nav { gap: 5px; }
  .wq-topbar .wq-nav-link,
  .wq-topbar .wq-action {
    padding: 6px 7px;
    font-size: 0.68rem;
    letter-spacing: normal;
    text-transform: none;
  }
}

/* ==============================
   IN-GAME BANNER
   ============================== */

.wq-banner {
  position: fixed;
  top: max(170px, 20vh);
  left: 50%;
  transform: translate(-50%, -12px);
  z-index: 1500;
  max-width: min(90vw, 640px);
  padding: 12px 26px;
  border-radius: 999px;
  background: rgba(7, 12, 22, 0.88);
  border: 2px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: 0.03em;
  text-align: center;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.wq-banner.active {
  opacity: 1;
  transform: translate(-50%, 0);
}

.wq-banner-warn { border-color: #ffa502; color: #ffd48a; }
.wq-banner-danger { border-color: #ff4757; color: #fff; background: rgba(120, 12, 24, 0.9); animation: wq-banner-pulse 0.8s ease-in-out infinite; }
.wq-banner-good { border-color: #2ed573; color: #b8f5cf; }

@keyframes wq-banner-pulse {
  50% { box-shadow: 0 0 0 6px rgba(255, 71, 87, 0.35), 0 8px 28px rgba(0, 0, 0, 0.45); }
}

@media (max-width: 900px) {
  .wq-banner {
    top: 190px;
    font-size: 1rem;
    padding: 10px 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .wq-banner, .wq-banner.active { transition: none; animation: none; }
}
