/* ==========================================================================
 * MOBILE-FIRST & DESKTOP RESPONSIVE LAYOUT + NATIVE APP DOCK NAVIGATION
 * ========================================================================== */

#fx-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 5;
}

/* Dynamic House Ambient Backdrop Morphing */
body[data-house="gryffindor"] {
  --house-glow: rgba(133, 27, 38, 0.42);
}
body[data-house="slytherin"] {
  --house-glow: rgba(20, 73, 50, 0.44);
}
body[data-house="ravenclaw"] {
  --house-glow: rgba(24, 52, 105, 0.46);
}
body[data-house="hufflepuff"] {
  --house-glow: rgba(156, 113, 24, 0.4);
}

body {
  background-image:
    radial-gradient(circle at 50% 0%, var(--house-glow, rgba(124, 24, 34, 0.38)) 0%, transparent 64%),
    radial-gradient(circle at 85% 85%, rgba(212, 175, 55, 0.16) 0%, transparent 52%),
    radial-gradient(circle at 15% 75%, rgba(76, 15, 21, 0.28) 0%, transparent 50%),
    linear-gradient(180deg, #0b0806 0%, #16110d 50%, #0b0806 100%);
  transition: background-image 0.6s ease;
}

.app-shell {
  position: relative;
  z-index: 10;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
 * TOP COMMAND HUD & MOBILE BOTTOM APP DOCK (ZERO OVERFLOW / ZERO CLIPPING)
 * ========================================================================== */
.top-hud {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  max-width: 100vw;
  overflow: hidden;
  background: rgba(14, 10, 8, 0.96);
  backdrop-filter: blur(16px);
  border-bottom: 2px solid var(--gold-imperial);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.85);
}

.top-hud::after {
  content: '';
  display: block;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--crimson-bright), var(--gold-bright), var(--crimson-bright), transparent);
}

.hud-inner {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0.55rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  box-sizing: border-box;
}

.hud-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
  min-width: 0;
  flex-shrink: 0;
}

.hud-crest-seal {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--crimson-gradient);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-wax);
  flex-shrink: 0;
}

.hud-brand-titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.hud-brand-eyebrow {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--gold-bright);
  font-weight: 800;
}

.hud-brand-main {
  font-family: var(--font-display);
  font-size: clamp(1rem, 1.4vw, 1.28rem);
  font-weight: 900;
  color: var(--parchment-light);
  letter-spacing: 0.02em;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-status-bar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 1 1 auto;
  min-width: 0;
  justify-content: flex-end;
}

.hud-team-pill {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.34rem 0.65rem;
  background: rgba(247, 241, 229, 0.08);
  border: 1.5px solid rgba(212, 175, 55, 0.55);
  border-radius: 4px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.hud-team-name {
  font-weight: 800;
  font-size: 0.88rem;
  color: var(--gold-bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1 1 auto;
}

.hud-role-tag {
  font-size: 0.7rem;
  font-weight: 900;
  padding: 0.15rem 0.42rem;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.hud-house-tag {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.15rem 0.42rem;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--crimson-rich);
  color: #fff;
  border: 1px solid var(--gold-imperial);
  white-space: nowrap;
  flex-shrink: 0;
}

.hud-timer-box {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.32rem 0.65rem;
  background: linear-gradient(135deg, #2a1c12 0%, #140d08 100%);
  border: 2px solid var(--gold-bright);
  border-radius: 4px;
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.25);
  flex-shrink: 0;
}

.hud-timer-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--parchment-deep);
  font-weight: 800;
}

.hud-timer-value {
  font-family: var(--font-numeral);
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--gold-bright);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Navigation Bar (Desktop Inline, Mobile Bottom App Dock) */
.hud-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.hud-nav-btn {
  appearance: none;
  background: rgba(255, 255, 255, 0.05);
  color: var(--parchment-light);
  border: 1.5px solid rgba(212, 175, 55, 0.4);
  padding: 0.46rem 0.75rem;
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.36rem;
}

.hud-nav-btn:hover {
  background: rgba(212, 175, 55, 0.18);
  border-color: var(--gold-bright);
}

.hud-nav-btn.active {
  background: var(--crimson-gradient);
  color: var(--gold-bright);
  border-color: var(--gold-bright);
  box-shadow: 0 0 14px rgba(168, 36, 49, 0.65);
}

.nav-icon-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.hud-audio-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  flex-shrink: 0;
}

.main-stage {
  flex: 1;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0.85rem 1rem 1.5rem;
  box-sizing: border-box;
}

.hero-split-grid {
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  gap: 1.25rem;
  align-items: stretch;
}

.two-col-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.three-col-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.four-houses-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
}

.house-hourglass-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
}

.prophet-newspaper-grid {
  display: grid;
  grid-template-columns: 0.75fr 1.5fr 0.75fr;
  gap: 1.15rem;
  align-items: stretch;
}

.prophet-col-left {
  border-right: 1.5px solid rgba(20, 16, 13, 0.22);
  padding-right: 0.9rem;
}

.prophet-col-right {
  border-left: 1.5px solid rgba(20, 16, 13, 0.22);
  padding-left: 0.9rem;
}

.house-mini-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
}

.decree-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
  align-items: stretch;
}

.map-mission-dock-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
}

.map-mission-cards-pair {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}

@media (min-width: 769px) {
  .map-mission-dock-inner > .btn-royal {
    width: auto !important;
    min-width: 210px;
    flex-shrink: 0;
  }
}

@media (max-width: 1180px) {
  .hud-brand-titles,
  .hud-timer-label {
    display: none;
  }
  .prophet-newspaper-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .prophet-col-center {
    order: -1;
  }
  .prophet-col-left,
  .prophet-col-right {
    border-right: none;
    border-left: none;
    padding-right: 0;
    padding-left: 0;
    border-top: 1.5px solid rgba(20, 16, 13, 0.2);
    padding-top: 0.85rem;
  }
  .four-houses-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ==========================================================================
 * MOBILE & TABLET NATIVE APP DOCK (< 980px)
 * ========================================================================== */
@media (max-width: 980px) {
  .hero-split-grid,
  .two-col-grid,
  .three-col-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .hud-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 160;
    background: linear-gradient(180deg, rgba(18, 13, 10, 0.98) 0%, rgba(10, 7, 5, 0.99) 100%);
    backdrop-filter: blur(18px);
    border-top: 2px solid var(--gold-imperial);
    padding: 0.32rem 0.2rem calc(0.35rem + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.18rem;
    box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.9);
  }

  .hud-nav-btn {
    flex-direction: column;
    gap: 0.14rem;
    padding: 0.34rem 0.08rem;
    font-size: 0.66rem;
    border-radius: 5px;
    border-width: 1px;
    text-align: center;
    white-space: nowrap;
    min-width: 0;
    overflow: hidden;
  }

  .nav-icon-slot svg {
    width: 18px;
    height: 18px;
  }

  .nav-label-slot {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .main-stage {
    padding: 0.6rem 0.55rem 5.1rem;
  }
}

@media (max-width: 768px) {
  .map-mission-dock-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 0.7rem;
  }
}

@media (max-width: 680px) {
  .hud-inner {
    padding: 0.4rem 0.5rem;
    gap: 0.35rem;
  }

  .hud-crest-seal {
    width: 32px;
    height: 32px;
  }

  .hud-status-bar {
    flex: 1 1 0%;
    min-width: 0;
    justify-content: space-between;
    gap: 0.3rem;
  }

  .hud-team-pill {
    flex: 1 1 0%;
    min-width: 0;
    padding: 0.25rem 0.45rem;
    gap: 0.28rem;
  }

  .hud-team-name {
    font-size: 0.78rem;
  }

  .hud-role-tag {
    font-size: 0.62rem;
    padding: 0.12rem 0.32rem;
  }

  .hud-house-tag {
    display: none;
  }

  .hud-timer-box {
    padding: 0.24rem 0.45rem;
    flex-shrink: 0;
  }

  .hud-timer-value {
    font-size: 0.96rem;
  }

  .hud-audio-btn {
    width: 32px;
    height: 32px;
  }

  .login-two-fields-row {
    grid-template-columns: 1fr !important;
    gap: 0.55rem !important;
  }

  .four-houses-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .house-hourglass-svg-slot {
    display: none;
  }

  .house-mini-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem;
  }

  .decree-cards-grid {
    grid-template-columns: 1fr !important;
    gap: 0.55rem;
  }

  .decree-cards-grid .object-card-btn {
    flex-direction: row !important;
    text-align: left !important;
    justify-content: flex-start !important;
    padding: 0.55rem 0.7rem !important;
    gap: 0.7rem !important;
  }

  .decree-cards-grid .object-card-btn .art-frame {
    width: 54px !important;
    max-width: 54px !important;
    margin: 0 !important;
    flex-shrink: 0;
  }
}
