/* =============== Base & Theme (matte black with Glassmorphism) =============== */

:root {
  --panel: rgba(10, 10, 13, 0.4);
  --panel-2: rgba(5, 5, 8, 0.4);
  --glass-bg: rgba(255, 255, 255, 0.08);
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.6);
  --accent: #ffffff;
  --primary: #ffffff;
  --danger: #ef4444;
}

html,
body {
  height: 100%;
}

body {
  font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
  margin: 0;
  background: #000;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  padding: 16px;
  min-height: 100vh;
  box-sizing: border-box;
}

/* New wrapper for content to help with sticky footer */
.content-wrapper {
  flex: 1 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}


.glass {
  background: rgb(17, 17, 23);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: none;
  border-radius: 16px;
  box-shadow: none;
}

.glassish {
  background: #111117;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 16px;
  border: none;
  box-shadow: none;
}

/* =============== Topbar =============== */
.topbar {
  width: min(1100px, 100%);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar__left,
.topbar__center,
.topbar__right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar__center {
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.season {
  font-weight: 600;
  opacity: .9;
  color: var(--text);
}

.season.short {
  display: none;
}

.online {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.online .dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #4ade80;
  box-shadow: 0 0 10px #4ade80aa;
}

.stat {
  color: var(--muted);
  font-size: 14px;
}

.stat strong {
  color: var(--text);
  margin-left: 6px;
}

/* =============== Buttons =============== */
.btn {
  padding: 8px 12px !important;
  min-height: 32px !important;
  border-radius: 8px !important;
  font-size: 14px !important;
  font-weight: 600;
  border: none;
  color: var(--text);
  background: #111117;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease;
  will-change: transform;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn:hover {
  transform: translateY(-2px);
  background: rgb(0, 0, 0);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  filter: grayscale(0.3);
}

.btn.primary {
  background: #0b0b0f;
  border-color: 1px #fff solid;
  animation: none;
  color: #fff;
}

.btn.primary:hover {
  background: rgba(255, 255, 255, 0.3);
  box-shadow: none;
}

.btn.alt {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn.sm {
  padding: 6px 10px !important;
  min-height: 28px !important;
  font-size: 13px !important;
}

.sound-toggle .icon-off {
  display: none;
}

.sound-toggle.muted .icon-on {
  display: none;
}

.sound-toggle.muted .icon-off {
  display: inline-block;
}


/* =============== Frame (responsive) =============== */
.frame {
  width: min(1000px, 100%);
  max-width: 1000px;
  aspect-ratio: 2 / 1;
  height: auto !important;
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  border: none;
  background: #000;
  box-shadow: none;
  touch-action: none;
  flex: none;
  isolation: isolate;
  margin-left: auto;
  margin-right: auto;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

/* HUD moved to top right */
.game-stats-container {

  position: absolute;
  right: 10px;
  top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.hud {

  color: #e5e7eb;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  padding: 6px 10px;
  border-radius: 999px;
}

/* =============== Modals =============== */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 10px;
}

.modal.show {
  display: flex;
}

.modal__content {
  width: min(780px, 94vw);
  max-height: 85vh;
  padding: 24px;
  border-radius: 16px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

.modal__content.center {
  text-align: center;
}

.modal__content h2 {
  margin: 0 0 8px;
  color: var(--text);
}

.modal__content .sub {
  margin: 0 0 12px;
  color: var(--muted);
}

.note {
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
}

.actions {
  margin-top: 14px;
  display: flex;
  justify-content: center;
}

.actions--row {
  gap: 10px;
  display: flex;
  flex-wrap: wrap;
}

.actions--row .btn {
  flex: 1 1 220px;
}

/* =============== Hero cards (responsive & compact) =============== */
.heroes {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 10px;
}

.hero-row {
  display: contents;
}

.hero-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px;
  border-radius: 14px;
  background: #0b0b0f;
  border: #fff 1px solid;
  border: none;
  cursor: pointer;
  text-align: center;
  transition: transform .2s ease, background .2s ease;
  position: relative;
  flex: 1;
  min-width: 180px;
  max-width: 220px;
}

.hero-card .sticker {
  font-size: 36px;
}

.hero-card h3 {
  margin: 4px 0 0 0;
  color: var(--text);
}

.hero-card .desc {
  margin: 0;
  color: var(--muted);
}

.hero-card:hover {
  transform: translateY(-4px) scale(1.02);
  background: rgba(255, 255, 255, 0.1);
}

.hero-card.selected {
  outline: 1px solid var(--accent);
  box-shadow: none;
}

/* =============== Loading Screen =============== */
.loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #000;
  z-index: 100;
  color: var(--text);
  pointer-events: none;
  opacity: 0;
  transition: opacity 1s ease, visibility 1s ease;
  visibility: hidden;
}

.loading-overlay.visible {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

.loading-text {
  font-size: 20px;
  font-weight: 500;
  opacity: 0.8;
}

/* =============== Touch controls & Rotate notice =============== */
.rotate-notice {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  z-index: 50;
  background: rgba(0, 0, 0, 0.75);
}

.rotate-notice__content h3 {
  margin: 0 0 6px;
}

.rotate-notice__content p {
  margin: 0;
  color: var(--muted);
}

.touch-controls {
  position: absolute;
  inset: 0;
  display: none;
  z-index: 15;
  pointer-events: none;
}

.ctrl {
  position: absolute;
  min-width: 44px;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .1);
  background: rgba(20, 22, 28, .45);
  color: rgba(255, 255, 255, 0.8);
  font-size: 16px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .4);
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ctrl:active {
  background: rgba(40, 42, 48, .6);
}

#ctrlLeft {
  left: 10px;
  bottom: 10px;
}

#ctrlRight {
  left: 64px;
  bottom: 10px;
}

#ctrlJump {
  right: 10px;
  bottom: 64px;
}

#ctrlAbility {
  right: 10px;
  bottom: 10px;
}

/* =============== Tabs below game =============== */
.tabs {
  width: min(1100px, 100%);
  padding: 12px;
  border-radius: 16px;
}

.tabs__list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.tab {
  appearance: none;
  background: #0b0b0f;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  color: var(--text);
  padding: 10px 18px !important;
  border-radius: 10px !important;
  cursor: pointer;
  box-shadow: none !important;
  font-weight: 500;
  transition: background 0.2s ease, border-color 0.2s ease;
  width: 100%;
}

.tab:hover {
  background: rgba(255, 255, 255, 0.05) !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
  transform: none !important;
}

.tab[aria-selected="true"] {
  background: rgba(255, 255, 255, 0.1) !important;
  border-color: rgba(255, 255, 255, 0.3) !important;
  color: #fff;
}


.tab-panel {
  display: block;
  min-height: 300px;
}

.is-hidden {
  display: none !important;
}

.leaderboard-controls {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 16px;
  padding: 0 12px;
}

#chainFilter {
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 8px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 14px;
}

.lb-table table,
.tab-panel table {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  border-collapse: collapse;
  font-size: 14px;
}

.tab-panel table th,
.tab-panel table td {
  padding: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  text-align: left;
}

.tab-panel table th {
  color: var(--muted);
  font-weight: 600;
}

.guide-list,
.rewards {
  max-width: 960px;
  margin: 16px auto;
  padding-left: 20px;
}

.guide-list h3,
.rewards h3 {
  margin-top: 24px;
}

.muted {
  color: var(--muted);
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
}

.pagination button {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pagination button.active {
  background: rgba(255, 255, 255, 0.2);
  font-weight: bold;
}


/* =============== Site Footer =============== */
.site-footer {
  width: min(1100px, 100%);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  flex-shrink: 0;
}

.site-footer__left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.site-footer__center {
  text-align: center;
  color: var(--muted);
}

.site-footer__right {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.dropdown {
  position: relative;
}

.dropdown>summary {
  list-style: none;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, .09);
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  text-decoration: none;
}

.dropdown[open]>summary {
  background: rgba(167, 139, 250, .12);
  border-color: rgba(167, 139, 250, .35);
}

.dropdown>ul {
  position: absolute;
  right: 0;
  margin: 6px 0 0 0;
  padding: 8px 0;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 12px;
  min-width: 200px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  z-index: 10;
  bottom: calc(100% + 8px);
  top: auto !important;
}

.dropdown>ul li {
  list-style: none;
}

.dropdown>ul a {
  display: block;
  padding: 8px 12px;
  color: var(--text);
  text-decoration: none;
}

.dropdown>ul a:hover {
  background: rgba(255, 255, 255, .06);
}


/* =============== Responsive Adjustments =============== */

@media (max-width: 640px) {
  body {
    padding: 8px;
    gap: 8px;
  }

  .topbar__center {
    gap: 8px;
  }

  .stat {
    font-size: 12px;
  }

  .btn .text,
  .season.long {
    display: none;
  }

  .season.short {
    display: inline-block;
  }
}

@media (max-width: 900px) {
  .hero-row {
    flex-direction: column;
    display: flex;
  }
}

@media (min-width: 901px) {
  .heroes {
    flex-direction: row;
  }
}


@media (orientation: portrait) {
  body.is-mobile .frame .rotate-notice {
    display: flex;
  }

  body.is-mobile #heroModal.modal.show {
    display: none;
  }
}

/* --- Mobile Devices (Landscape) --- */
@media (orientation: landscape) {
  body.is-mobile {
    padding: 5vh 5vw; /* MODIFIED: Set padding to 5% of viewport */
    box-sizing: border-box; /* MODIFIED: Include padding in total size */
    gap: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  body.is-mobile .topbar,
  body.is-mobile .site-footer,
  body.is-mobile .tabs {
    display: none;
  }

  body.is-mobile .content-wrapper {
    width: 100%;
    height: 100%;
    padding: 0;
    gap: 0;
    justify-content: center;
    align-items: center;
  }

  body.is-mobile .frame {
    width: 100%; /* MODIFIED: Fill the new padded area */
    height: 100%; /* MODIFIED: Fill the new padded area */
    max-width: none;
    max-height: none;
    aspect-ratio: unset;
    border-radius: 14px;
    padding: 0;
    flex: none;
  }

  body.is-mobile .touch-controls {
    display: block;
  }

  body.is-mobile #heroModal .modal__content {
    max-width: 480px;
    width: 90vw;
    padding: 16px;
    max-height: 90vh;
  }

  body.is-mobile .hero-card {
    min-width: 140px;
    padding: 10px;
    gap: 4px;
    flex-basis: 140px;
  }

  body.is-mobile .hero-card .sticker {
    font-size: 24px;
  }

  body.is-mobile .hero-card h3 {
    font-size: 14px;
    margin: 0;
  }

  body.is-mobile .hero-card .desc {
    font-size: 11px;
  }

  body.is-mobile #heroModal.modal.show {
    display: flex;
  }
}
