/* ===========================
   Base / Reset
   =========================== */
:root {
  --brand-red: #b22222;
  --brand-blue: #253397;
  --brand-gold: #f7c641;
  --ink: #232946;
  --bg: #f6f8fb;

  /* iOS safe areas */
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

html, body {
  margin: 0;
  padding: 0;
  color: var(--ink);
  background: var(--bg);
  min-height: 100%;
  width: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden; /* Prevent accidental horizontal scroll or right-side gaps */
  font-family: 'Segoe UI', 'Roboto', Arial, sans-serif;
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

a {
  text-decoration: none;
  color: inherit;
}

/* ===========================
   Desktop/Laptop (default)
   =========================== */

/* Header */
.main-header-bg {
  background: #fff;
  border-bottom: 1px solid #eee;
  box-shadow: 0 4px 16px 0 #0057ff06;
  position: relative;
  z-index: 110;
  width: 100%;
}

.main-header {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  height: 80px;
  padding: 0 0.8rem;
  gap: 1.1rem;
  width: 100%;
}

.logo-block {
  flex-shrink: 0;
  width: 110px;
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.logo-img {
  width: 130px;
  height: 130px;
  object-fit: contain;
  margin-left: -40px;
}

.header-titles {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-left: 0.2rem;
}

.header-titles h1 {
  margin: 0 0 2px 0;
  color: var(--brand-red);
  font-size: 1.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: center;
  line-height: 1.28;
}

.header-titles h2 {
  margin: 0;
  color: var(--brand-red);
  font-size: 1.6rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-align: center;
  line-height: 1.25;
}

.new-badge {
  display: inline-block;
  background: var(--brand-red);
  color: #fff;
  font-size: 0.93em;
  font-weight: 700;
  border-radius: 4px;
  padding: 1px 7px;
  margin-left: 7px;
  line-height: 1.1;
  vertical-align: middle;
  letter-spacing: 0.01em;
  position: relative;
  top: -1px;
  box-shadow: 0 2px 6px #0001;
  text-transform: uppercase;
  font-family: inherit;
}

/* Marquee */
.marquee-wrap {
  width: 100%;
  background: #f7c641cf;
  border-bottom: 1px solid #e7ab37;
  position: relative;
  font-size: 1rem;
  font-weight: 500;
  color: var(--brand-red);
  overflow: hidden;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: max(0.75rem, var(--safe-left));
  padding-right: max(0.75rem, var(--safe-right));
}

.flash-text {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  font-size: 1.14rem;
  font-weight: 600;
  color: blue;
  letter-spacing: 0.01em;
  animation: fadeInFlash 0.8s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.7s;
}

@keyframes fadeInFlash {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Navigation */
nav {
  width: 100%;
  background: #ae2424d9;
  border-bottom: 2.5px solid var(--brand-gold);
  box-shadow: 0 6px 28px 0 #00000008;
  z-index: 100;
  font-size: 1rem;
  position: sticky;
  top: 0;
}

.navbar {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding-left: max(1rem, var(--safe-left));
  padding-right: max(1rem, var(--safe-right));
}

.menu {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 1.5rem;
  margin: 0;
  padding: 0 1.5rem 0 0;
  width: 100%;
  height: 45px;
  list-style: none;
}

.menu > li {
  position: relative;
  user-select: none;
}

.menu > li > button,
.menu > li > a {
  background: none;
  border: none;
  cursor: pointer;
  color: #fff;
  font-size: 1rem;
  font-weight: 500;
  padding: 1.1rem 0.4rem;
  border-radius: 3.5px;
  letter-spacing: 0.04em;
  transition: background 0.16s, color 0.16s;
  outline: none;
  display: flex;
  align-items: center;
  gap: 0.4em;
}

.menu > li > button:hover,
.menu > li > button.active,
.menu > li > a:hover,
.menu > li > a.active {
  background: var(--brand-gold);
  color: var(--brand-red);
}

.arrow-down {
  display: inline-block;
  margin-left: 0.18em;
  font-size: 0.9em;
  pointer-events: none;
  vertical-align: middle;
  transition: transform 0.18s;
}

.submenu .arrow-down,
.subsubmenu .arrow-down {
  margin-left: 2.5em !important;
}

.menu > li > button.active .arrow-down,
.menu > li:focus-within > button .arrow-down,
.menu > li:hover > button .arrow-down {
  transform: rotate(180deg);
}

/* Submenus */
.submenu,
.subsubmenu {
  display: none;
  position: absolute;
  left: 0;
  min-width: 190px;
  background: #f7f8ef;
  border-radius: 0 0 7px 7px;
  box-shadow: 0 8px 32px 0 #b222221a;
  z-index: 20;
  padding: 0.5rem 0;
  margin-top: 0;
  animation: fadeIn 0.18s;
  list-style: none;
}

.submenu a,
.submenu > li > button,
.subsubmenu a {
  text-decoration: none !important;
}

.submenu > li { margin-bottom: 0.10rem; }
.submenu > li:last-child { margin-bottom: 0; }

.subsubmenu > li { margin-bottom: 0.46rem; }
.subsubmenu > li:last-child { margin-bottom: 0; }

.menu > li > button.active + .submenu,
.submenu.open {
  display: block;
}

.submenu > li > button,
.submenu > li > a {
  width: 250px;
  background: none;
  border: none;
  color: #253397;
  font-size: 1.1rem;
  padding: 0.77rem 1.1rem;
  text-align: left;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.14s, color 0.14s;
  outline: none;
  display: flex;
  align-items: center;
  gap: 0.33em;
}

.submenu > li > button:hover,
.submenu > li > button.active,
.submenu > li > a:hover,
.submenu > li > a.active {
  background: #c9c9e8;
  color: var(--brand-red);
  font-weight: 600;
}

.subsubmenu {
  position: absolute;
  left: 100%;
  top: 0;
  min-width: 300px;
  border-radius: 0 7px 7px 7px;
  margin-left: 0;
  animation: fadeInRight 0.18s;
  box-shadow: 0 8px 32px 0 #b2222212;
  background: #f7f8ef;
  padding: 0.4rem 0;
  z-index: 100;
}

.submenu > li { position: relative; }

.submenu > li:hover > .subsubmenu,
.submenu > li:focus-within > .subsubmenu,
.submenu > li > button.active + .subsubmenu,
.subsubmenu.open {
  display: block;
}

.subsubmenu li a {
  display: block;
  padding: 0.54rem 1.1rem;
  color: #862d66;
  text-decoration: none !important;
  border-radius: 4px;
  font-size: 0.99rem;
  font-weight: 600;
  transition: background 0.13s, color 0.13s;
  outline: none;
}

.subsubmenu li a:hover,
.subsubmenu li a.active {
  background: var(--brand-gold);
  color: var(--brand-red);
}

/* Hamburger */
.hamburger {
  display: none;
  width: 39px;
  height: 39px;
  background: transparent;
  border: none;
  cursor: pointer;
  margin-right: 0.7rem;
  position: relative;
  z-index: 210;
}

.hamburger span,
.hamburger span:before,
.hamburger span:after {
  content: '';
  display: block;
  height: 4px;
  width: 26px;
  background: var(--brand-red);
  border-radius: 2px;
  margin: 0 auto;
  transition: 0.3s;
  position: absolute;
  left: 6px;
}

.hamburger span { top: 18px; }
.hamburger span:before { top: -8px; position: absolute; }
.hamburger span:after { top: 8px; position: absolute; }
.hamburger.active span { background: transparent; }
.hamburger.active span:before { transform: rotate(45deg) translate(5px,5px); }
.hamburger.active span:after { transform: rotate(-45deg) translate(6px,-7px); }

/* Main */
main {
  flex: 1;
  padding: 2.3rem 1.5rem 2.5rem 1.5rem;
  background: var(--bg);
  min-height: 320px;
  animation: fadeIn 0.5s;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}

#main-flash-h2 {
  color: #0014a8;
  font-size: 1.8rem;
  font-weight: 700;
  margin-top: -80px;
  margin-bottom: -30px;
  letter-spacing: 0.03em;
  transition: opacity 0.7s;
  min-height: 2.7em;
  animation: fadeInFlash 0.7s;
  line-height: 1.2;
}

#main-flash-p {
  color: #454d5e;
  font-size: 1.11rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0 auto 0.5em auto;
  line-height: 1.6;
  transition: opacity 0.7s;
  animation: fadeInFlash 0.7s;
  text-align: center;
  font-style: italic;
}

/* Footer */
.footer {
  background: var(--brand-blue);
  color: #fff;
  text-align: center;
  padding: 0;
  height: 35px;
  line-height: 35px;
  font-size: 1rem;
  letter-spacing: 0.5px;
  box-shadow: 0 -3px 16px #0057ff0b;
  margin-top: auto;
  min-height: 35px;
  max-height: 35px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: max(0.75rem, var(--safe-left));
  padding-right: max(0.75rem, var(--safe-right));
}

/* View count section (centered) */
.view-count-div {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 40px auto 0 auto;
  width: 100%;
}

.view-count {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.view-count h7 {
  font-size: 1rem;
  font-weight: bold;
  letter-spacing: 1px;
  text-align: center;
  margin-bottom: 5px;
  display: block;
}

.view-count table {
  margin: 0 auto;
  font-size: 1.2rem;
  text-align: center;
}

.view-count td {
  min-width: 22px;
  height: 22px;
  font-size: 1rem;
  text-align: center;
  font-weight: 700;
  border-radius: 4px;
  background: #17a2b8;
  color: #fff;
  border: 1px solid yellow;
}

/* Online users and district popup */
.online-users {
  font-size: 1rem;
  font-weight: bold;
  color: #fff;
  border-radius: 8px;
  padding: 6px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 40px;
  margin-bottom: -40px;
}

.online-users span {
  color: #198754;
}

.district-popup {
  position: absolute;
  top: 110%;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border: 1.5px solid var(--brand-red);
  border-radius: 8px;
  box-shadow: 0 6px 18px #0002;
  min-width: 240px;
  z-index: 40000;
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  margin-top: 8px;
}

.district-popup-content { position: relative; }

.close-btn {
  position: absolute;
  top: 1px;
  right: 3px;
  font-size: 1.5em;
  color: var(--brand-red);
  cursor: pointer;
}

.centered-heading { text-align: center; }

.district-popup ul {
  margin: 0;
  padding-left: 0.8em;
}

.district-popup li {
  list-style: disc;
  margin-bottom: 0.18em;
}

/* Form footer button (centered) */
.form-group.mb-3 {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: 1200px;
  margin: 32px auto;
  padding-left: max(0.75rem, var(--safe-left));
  padding-right: max(0.75rem, var(--safe-right));
}

.btnBottom {
  margin: 0 auto;
  text-align: center;
  font-size: 0.85rem;
  background: #eaf7dc;
  color: #227317;
  border: none;
  border-radius: 8px;
  padding: 10px 5px;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(52,117,196,0.08);
  cursor: pointer;
  max-width: 98vw;
  width: 98%;
  display: block;
  white-space: normal;
  word-break: break-word;
}

/* Slideshow frames */
.slideshow-frame-container {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: flex-start;
  gap: 3vw;
  margin: 2.2rem 0 2.3rem 0;
  width: 100%;
  flex-wrap: wrap;
}

.slideshow-frame {
  background: #fff;
  border: 1px solid #B22222;
  border-radius: 1.4rem;
  box-shadow: 0 4px 24px #0002;
  width: 330px;
  height: 220px;
  min-width: 0;
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  position: relative;
  transition: box-shadow 0.18s;
}

.crossfade-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 1.2rem;
  box-shadow: 0 2px 13px #0001;
  opacity: 0;
  position: absolute;
  left: 0;
  top: 0;
  transition: opacity 0.8s;
  background: #f8fff8;
  min-width: 0;
  min-height: 0;
  display: block;
}

.crossfade-img:first-child { z-index: 1; }
.crossfade-img:last-child { z-index: 2; }

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInRight {
  from { opacity: 0; transform: translateX(-14px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ===========================
   Tablet (<= 991px)
   =========================== */
@media (max-width: 991px) {
  .main-header { max-width: 100%; }

  .navbar {
    max-width: 100%;
    padding-left: max(0.75rem, var(--safe-left));
    padding-right: max(0.75rem, var(--safe-right));
  }

  /* Off-canvas menu for tablet: keep fixed width drawer */
  .menu {
    flex-direction: column;
    position: fixed;
    left: -300px;
    top: 148px;
    width: 245px;
    min-width: 245px;
    max-width: 245px;
    height: calc(100vh - 148px);
    background: #fff;
    overflow-y: auto;
    box-shadow: 5px 0 18px #2329460d;
    z-index: 180;
    transition: left 0.28s;
    gap: 0.1rem;
    padding: 0.5rem 0.1rem 0 0.1rem;
    border-radius: 0 13px 13px 0;
    align-items: flex-start;
  }
  .menu.open { left: 0; }

  .menu > li,
  .menu > li > button,
  .menu > li > a {
    width: 100%;
    min-width: 245px;
    max-width: 245px;
  }

  .menu > li > button,
  .menu > li > a {
    padding: 0.9rem 1.2rem;
    margin-bottom: 0.1rem;
    text-align: left;
    color: var(--brand-red); /* ensure readability on white bg */
  }

  .submenu,
  .subsubmenu {
    position: static;
    left: 0;
    min-width: 0;
    width: 100%;
    max-width: none;
    box-shadow: none;
    border-radius: 0 0 7px 7px;
    background: #f9faff;
    padding: 0.3rem 0.1rem 0.3rem 1.1rem;
  }

  .submenu > li > button,
  .submenu > li > a {
    padding: 0.7rem 1.3rem;
    border-radius: 0 7px 7px 0;
    width: 100%;
  }

  .subsubmenu {
    background: #f7fafc;
    padding: 0.2rem 0.1rem 0.2rem 1.3rem;
  }

  .subsubmenu li a { padding: 0.47rem 1.2rem; }

  .hamburger { display: block; }
  nav { position: static; }

  main {
    padding: 1.15rem 0.7rem 1.5rem 0.7rem;
    max-width: 100%;
  }

  #main-flash-h2 { font-size: 1.4rem; min-height: 2.4em; }
  #main-flash-p { font-size: 1rem; max-width: 95vw; padding: 0 8vw; }

  .slideshow-frame-container { gap: 1vw; }
  .slideshow-frame {
    width: 28vw;
    min-width: 180px;
    height: 18vw;
    min-height: 120px;
  }
}

/* ===========================
   Mobile (<= 600px)
   =========================== */
@media (max-width: 600px) {
  /* Header sizing */
  .main-header {
    height: 66px;
    padding: 0.22rem 0.18rem 0.14rem 0.16rem;
    width: 100%;
  }
  .logo-block { width: 90px; height: 90px; }
  .logo-img {
    width: 100px;
    height: 100px;
    margin-left: 5px;
  }
  .flash-text { font-size: 0.9rem; }
  .header-titles h1 { font-size: 1.1rem; margin-left: -20px; }
  .header-titles h2 { font-size: 1.1rem; margin-left: -10px; }

  /* Ensure full-width backgrounds extend to safe areas */
  .navbar, nav {
    width: 100%;
    max-width: 100%;
    background: #ae2424d9;
  }

  /* Mobile menu: full-width drawer */
  .menu,
  .menu > li,
  .menu > li > button,
  .menu > li > a {
    min-width: 100%;
    max-width: 100%;
    width: 100%;
    font-size: 1.1rem;
    color: var(--brand-red);
  }

  .menu {
    position: fixed;
    left: -100%;
    top: 50px; /* below header+marquee */
    height: calc(100vh - 50px);
    background: #fff;
    box-shadow: 5px 0 18px #2329460d;
    z-index: 180;
    transition: left 0.28s;
    gap: 0.1rem;
    padding: 0.5rem 0.1rem 1rem 0.1rem;
    border-radius: 0 13px 13px 0;
    align-items: flex-start;
    overflow-y: auto;
  }
  .menu.open { left: 0; }

  #main-flash-h2 {
    font-size: 1.2rem;
    min-height: 2.1em;
    margin-bottom: 20px;
    padding: 0 0.3em;
  }
  #main-flash-p {
    font-size: 0.96rem;
    padding: 0 0.4em;
    max-width: 100%;
    text-align: justify;
    font-family: Arial, sans-serif;
    line-height: 1.5;
  }

  .district-popup {
    min-width: 160px;
    font-size: 1em;
    padding: 8px 4px 8px 8px;
    left: 50%;
    transform: translateX(-50%);
  }

  /* Slideshow: stacked and full width */
  .slideshow-frame-container {
    flex-direction: column;
    align-items: center;
    gap: 2.3rem;
    width: 100%;
  }
  .slideshow-frame {
    width: 100%;
    max-width: 100%;
    height: 54vw; /* responsive height */
    min-width: 0;
    min-height: 60px;
    border-radius: 1rem;
  }
  .slideshow-frame img.crossfade-img {
    border-radius: 1rem;
    height: 100%;
    width: 100%;
    object-fit: cover;
    max-width: 100%;
    max-height: 100%;
    min-width: 0;
    min-height: 0;
  }
}

/* ===========================
   Small Phones (<= 480px)
   =========================== */
@media (max-width: 480px) {
  .slideshow-frame-container { gap: 1.2rem; }
  .slideshow-frame {
    width: 100%;
    max-width: 100%;
    height: 54vw;
  }
}