/* ═══════════════════════════════════════════════════════
   Game Module — Shared Navigation + Light/Dark Theme
   /modules/game/css/game-nav.css
═══════════════════════════════════════════════════════ */

/* ── Light mode: override hardcoded dark :root vars ── */
html:not(.dark-mode) {
  --dark:   #f0f2f8;
  --card:   #ffffff;
  --border: rgba(168,85,247,.13);
  --t:      #1a1a2e;
  --tm:     #5e6a85;
}
html:not(.dark-mode) body {
  background: var(--dark);
  color: var(--t);
}

/* Fix hardcoded dark surfaces that don't use CSS vars */
html:not(.dark-mode) .play-bar {
  background: rgba(240,242,248,.94) !important;
  border-bottom-color: rgba(168,85,247,.14) !important;
}
html:not(.dark-mode) .hex-bg   { opacity: .022 !important; }
html:not(.dark-mode) input,
html:not(.dark-mode) select,
html:not(.dark-mode) textarea  {
  background: #fff !important;
  color: var(--t) !important;
  border-color: rgba(168,85,247,.18) !important;
}
html:not(.dark-mode) input::placeholder,
html:not(.dark-mode) textarea::placeholder { color: #9ba8c0 !important; }
html:not(.dark-mode) .gf-btn   { color: var(--tm) !important; }
html:not(.dark-mode) .gf-btn.active {
  background: rgba(168,85,247,.09) !important;
  color: #a855f7 !important;
}
html:not(.dark-mode) .lb-select,
html:not(.dark-mode) .flt-select,
html:not(.dark-mode) .stat-chip {
  background: #fff !important;
  color: var(--t) !important;
}
html:not(.dark-mode) #searchInput {
  background: #fff !important;
  color: var(--t) !important;
}

/* ═══════════════════════════════════════════════════════
   Game Subnav Bar
═══════════════════════════════════════════════════════ */
.game-nav {
  position: sticky;
  top: 0;
  z-index: 200;
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 max(16px, calc((100vw - 1240px) / 2 + 16px));
  background: rgba(10,10,15,.82);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  border-bottom: 1px solid rgba(168,85,247,.18);
  box-shadow: 0 1px 14px rgba(0,0,0,.22);
  transition: background .3s, border-color .3s, box-shadow .3s;
  gap: 0;
}
html:not(.dark-mode) .game-nav {
  background: rgba(255,255,255,.88);
  border-bottom-color: rgba(168,85,247,.13);
  box-shadow: 0 1px 8px rgba(0,0,0,.07);
}
.game-nav.gn-scrolled {
  background: rgba(10,10,15,.97);
}
html:not(.dark-mode) .game-nav.gn-scrolled {
  background: rgba(255,255,255,.99);
}

/* ── Back button ── */
.gn-back {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px 5px 8px;
  border-radius: 9px;
  border: 1.5px solid transparent;
  background: transparent;
  color: var(--tm, #7c7a99);
  font-size: .755rem;
  font-weight: 600;
  letter-spacing: .01em;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1;
  transition: border-color .18s, background .18s, color .18s;
}
.gn-back i {
  font-size: .62rem;
  transition: transform .22s cubic-bezier(.34,1.56,.64,1);
}
.gn-back:hover {
  border-color: rgba(168,85,247,.4);
  background: rgba(168,85,247,.09);
  color: #a855f7;
}
.gn-back:hover i { transform: translateX(-3px); }
.gn-back:active  { transform: scale(.97); }

/* ── Separator ── */
.gn-sep {
  width: 1px;
  height: 18px;
  background: var(--border, rgba(168,85,247,.18));
  margin: 0 10px;
  border-radius: 1px;
  flex-shrink: 0;
}

/* ── Nav links ── */
.gn-links {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.gn-links::-webkit-scrollbar { display: none; }

.gn-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 8px;
  font-size: .755rem;
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--tm, #7c7a99);
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  flex-shrink: 0;
  transition: background .18s, color .18s;
}
.gn-link:hover {
  background: rgba(168,85,247,.08);
  color: #a855f7;
}
.gn-link.active {
  background: rgba(168,85,247,.11);
  color: #a855f7;
}
.gn-link.active::after {
  content: '';
  position: absolute;
  bottom: -13.5px;
  left: 22%;
  right: 22%;
  height: 2px;
  background: linear-gradient(90deg, #a855f7 0%, #10b981 100%);
  border-radius: 2px;
}

/* Live dot (injected by JS when there are live comps) */
.gn-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 5px rgba(239,68,68,.65);
  flex-shrink: 0;
  animation: gnBlink 1.8s ease-in-out infinite;
}
@keyframes gnBlink {
  0%,100% { opacity:1; transform:scale(1);   }
  50%      { opacity:.4; transform:scale(.7); }
}

/* ── Right: theme toggle ── */
.gn-right {
  margin-left: auto;
  padding-left: 8px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.gn-theme {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 1.5px solid var(--border, rgba(168,85,247,.18));
  background: transparent;
  color: var(--tm, #7c7a99);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  line-height: 1;
  transition: border-color .18s, background .18s, color .18s, transform .22s cubic-bezier(.34,1.56,.64,1);
}
.gn-theme:hover {
  border-color: rgba(168,85,247,.5);
  background: rgba(168,85,247,.09);
  color: #a855f7;
  transform: rotate(20deg);
}
.gn-theme:active { transform: rotate(20deg) scale(.9); }

/* play.html: push sticky play-bar down so game-nav stays visible */
/* play-bar top reset */

/* ── Responsive ── */
@media (max-width: 600px) {
  .game-nav { padding: 0 12px; }
}
@media (max-width: 440px) {
  .gn-link .gn-lbl { display: none; }
  .gn-link          { padding: 5px 8px; gap: 0; font-size: .88rem; }
  .gn-back .gn-blbl { display: none; }
  .gn-back          { padding: 5px 8px; }
  .gn-sep           { margin: 0 6px; }
}


/* ═══════════════════════════════════════════════════════════════
   GAME MODULE — Comprehensive Mobile Responsive Styles
   Appended to game-nav.css  |  covers all 9 game pages
═══════════════════════════════════════════════════════════════ */

/* ── 0. Global safety ── */
html, body { max-width: 100vw; overflow-x: hidden; }

#gameCanvas, #compGameCanvas { max-width: 100% !important; height: auto !important; }

#toast {
  max-width: calc(100vw - 32px) !important;
  white-space: normal !important;
  text-align: center !important;
  word-break: break-word;
}

/* Minimum tap-target size */
@media (max-width: 600px) {
  .btn          { min-height: 38px; }
  .cat-pill,
  .gf-btn,
  .pf-btn       { min-height: 36px; }
}

/* ── Light-mode: bars that are hard-coded dark ── */
html:not(.dark-mode) .play-bar,
html:not(.dark-mode) .match-bar,
html:not(.dark-mode) .top-bar {
  background: rgba(240,242,248,.96) !important;
  border-bottom-color: rgba(168,85,247,.14) !important;
  box-shadow: 0 1px 8px rgba(0,0,0,.07) !important;
}
html:not(.dark-mode) .back-btn  { color: var(--t) !important; border-color: rgba(168,85,247,.18) !important; }
html:not(.dark-mode) .live-badge { background: rgba(239,68,68,.08) !important; }
html:not(.dark-mode) .scoreboard { background: #fff !important; }
html:not(.dark-mode) .chat-box,
html:not(.dark-mode) .info-card  { background: #fff !important; }
html:not(.dark-mode) .chat-input { background: #f0f2f8 !important; color: var(--t) !important; }
html:not(.dark-mode) .video-box  { background: #e8eaf0 !important; border-color: rgba(168,85,247,.14) !important; }
html:not(.dark-mode) .go-box,
html:not(.dark-mode) .ref-match-card,
html:not(.dark-mode) .comp-header,
html:not(.dark-mode) .page-hero  { background: #fff !important; border-color: rgba(168,85,247,.16) !important; }
html:not(.dark-mode) #countdownOverlay,
html:not(.dark-mode) #resultOverlay  { background: rgba(240,242,248,.92) !important; }
html:not(.dark-mode) #resultLabel    { color: var(--t) !important; }
html:not(.dark-mode) .countdown-sub  { color: var(--tm) !important; }

/* ══════════════════════════════════════════════════
   1.  index.html — Arcade Home
══════════════════════════════════════════════════ */

/* Hero: stack on narrow screens */
@media (max-width: 640px) {
  .hero-inner {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 14px;
  }
  .hero-inner > div:last-child {
    align-items: flex-start !important;
    flex-direction: row !important;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }
  .hero-left h1 { font-size: clamp(1.7rem,7vw,2.6rem) !important; }
}

/* Mode cards: compact on very small */
@media (max-width: 480px) {
  .mode-card  { padding: 18px 14px; gap: 10px; }
  .mode-icon  { width: 44px; height: 44px; font-size: 1.2rem; }
  .mode-card h3 { font-size: .9rem; }
  .mode-card p  { font-size: .75rem; }
  .mode-badge   { font-size: .65rem; padding: 2px 8px; }
}

/* Game filter: horizontal scroll — no wrapping */
.game-filter {
  flex-wrap: nowrap !important;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.game-filter::-webkit-scrollbar { display: none; }
.gf-btn { flex-shrink: 0; }

/* LB filters: stack on mobile */
@media (max-width: 640px) {
  .lb-filters {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .lb-select { min-width: unset !important; width: 100%; }
  .lb-filters .btn { width: 100%; justify-content: center; }
}

/* Leaderboard panels: allow horizontal scroll for tables */
.lb-panel { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.lb-table  { min-width: 460px; }

/* Public standings table */
.lb-panel table { min-width: 460px; }

/* Match result cards: better mobile layout */
@media (max-width: 500px) {
  .match-result-card {
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
  }
  .match-teams  { text-align: center; width: 100%; }
  .match-score-num { font-size: .95rem; }
}

/* Account panel */
@media (max-width: 480px) {
  .profile-card  { padding: 18px 14px; }
  .stat-item .val { font-size: 1.1rem; }
  .achievement-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
  }
}

/* ══════════════════════════════════════════════════
   2.  play.html — Single Player
══════════════════════════════════════════════════ */

/* Play bar: keep in one row, shrink gracefully */
@media (max-width: 520px) {
  .play-bar { padding: 8px 12px; gap: 7px; flex-wrap: nowrap !important; }
  .bar-left  { min-width: 0; flex: 1; overflow: hidden; }
  .back-btn  { padding: 6px 10px; font-size: .75rem; }
  #arenaTitle {
    font-size: .82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 110px;
  }
  .score-pill { padding: 5px 10px; }
  .score-lbl  { display: none; }
  #scoreVal   { font-size: 1rem; min-width: 22px; }
}

/* Picker: tighter on mobile */
@media (max-width: 480px) {
  .game-picker { padding: 20px 14px; gap: 16px; border-radius: 18px; }
  .picker-head h2 { font-size: 1.1rem; }
  .picker-head p  { font-size: .78rem; }
  .picker-card    { padding: 14px 10px; border-radius: 14px; }
  .p-icon  { font-size: 2rem; margin-bottom: 7px; }
  .p-name  { font-size: .82rem; }
  .p-desc  { font-size: .68rem; }
  .p-tag   { font-size: .63rem; padding: 2px 8px; }
}

/* Picker filters: horizontal scroll */
.picker-filters {
  flex-wrap: nowrap !important;
  overflow-x: auto;
  scrollbar-width: none;
  justify-content: flex-start !important;
  padding-bottom: 2px;
  width: 100%;
}
.picker-filters::-webkit-scrollbar { display: none; }
.pf-btn { flex-shrink: 0; }

/* Sidebar: single col on very small */
@media (max-width: 440px) {
  .sidebar { grid-template-columns: 1fr !important; }
  .side-card { padding: 14px; }
  .comp-cta  { padding: 16px; }
}

/* Game-over overlay */
@media (max-width: 440px) {
  .go-box     { padding: 22px 16px; border-radius: 22px; max-width: calc(100vw - 32px); }
  .go-em      { font-size: 3rem; }
  .go-heading { font-size: 1.4rem; }
  .go-sub     { font-size: .78rem; }
  .go-stats   { gap: 20px; padding: 14px 0; }
  .go-stat .val { font-size: 2rem; }
  .go-actions .btn { padding: 11px; font-size: .84rem; }
}

/* D-pad: bigger targets on very small phones */
@media (max-width: 380px) {
  .dpad {
    grid-template-columns: repeat(3, 44px) !important;
    grid-template-rows:    repeat(3, 44px) !important;
  }
  .dpad button, .dpad .db { width: 44px !important; height: 44px !important; }
}

/* ══════════════════════════════════════════════════
   3.  competition/index.html
══════════════════════════════════════════════════ */

/* Hero: stack on mobile */
@media (max-width: 620px) {
  .hero { padding: 24px 16px 20px; }
  .hero-row { flex-direction: column; gap: 14px; align-items: flex-start !important; }
  .hero-row h1 { font-size: clamp(1.5rem,6vw,2.2rem) !important; }
  .hero-actions { width: 100%; }
  .hero-actions .btn { flex: 1; justify-content: center; min-width: 0; }
  .stats-row { gap: 7px; }
  .stat-chip { font-size: .72rem; padding: 5px 11px; }
}

/* Filters: stack on mobile */
@media (max-width: 700px) {
  .filters-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 14px 16px;
  }
  .cat-pills {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .cat-pills::-webkit-scrollbar { display: none; }
  .cat-pill   { flex-shrink: 0; }
  .filter-sep { display: none; }
  .flt-select { width: 100%; }
  .search-wrap { width: 100%; }
  #searchInput { width: 100% !important; }
}

/* Competition card grid */
@media (max-width: 400px) {
  #compGrid { grid-template-columns: 1fr; gap: 12px; }
  .comp-card { padding: 16px; }
  .comp-card-head h3 { font-size: .88rem; padding-right: 48px; }
}

/* ══════════════════════════════════════════════════
   4.  competition/create.html
══════════════════════════════════════════════════ */

@media (max-width: 520px) {
  .main-wrap  { padding: 16px 12px 100px; }
  .page-hero  { padding: 18px 16px; border-radius: 18px; }
  .page-hero h1 { font-size: 1.3rem; }
  .page-hero p  { font-size: .8rem; }
  .step-indicator { padding: 4px; }
  .step { font-size: .62rem; padding: 7px 5px; border-radius: 9px; }
  .form-section { padding: 18px 14px; border-radius: 16px; }
  .section-head h3 { font-size: .88rem; }
  .submit-btn { font-size: .9rem; padding: 13px; }
}

/* Switch rows: stack on very small */
@media (max-width: 440px) {
  .switch-row { flex-direction: column; align-items: flex-start; gap: 10px; padding: 12px; }
  .switch-row label:first-child { font-size: .8rem; }
}

/* ══════════════════════════════════════════════════
   5.  competition/detail.html
══════════════════════════════════════════════════ */

/* Tab bar: horizontal scroll */
@media (max-width: 560px) {
  .tab-bar {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    scrollbar-width: none;
    gap: 3px;
    padding: 4px;
  }
  .tab-bar::-webkit-scrollbar { display: none; }
  .tab-btn { min-width: 76px; flex-shrink: 0; padding: 7px 10px; font-size: .71rem; }
}

/* Standings: horizontal scroll */
.standings-table {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 18px;
}
.standings-table table { min-width: 540px; }

/* Match sub-filter tabs: scroll */
@media (max-width: 520px) {
  #tab-matches > div:first-child {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 4px;
    gap: 4px;
  }
  #tab-matches > div:first-child::-webkit-scrollbar { display: none; }
  #tab-matches .tab-btn { flex-shrink: 0; white-space: nowrap; min-width: unset; }
}

/* Match cards */
@media (max-width: 480px) {
  .match-card { padding: 12px; gap: 8px; flex-wrap: wrap; }
  .match-player { font-size: .78rem; min-width: 70px; }
  .match-score  { font-size: 1.1rem; min-width: 48px; }
  .match-status-pill { font-size: .62rem; padding: 2px 7px; }
  .match-card > div:last-child { width: 100%; justify-content: flex-end; margin-top: 2px; }
}

/* Manage section */
@media (max-width: 480px) {
  .form-box { padding: 16px; border-radius: 16px; }
  .form-box h3 { font-size: .82rem; }
  .comp-header { padding: 16px; border-radius: 18px; }
}

/* ══════════════════════════════════════════════════
   6.  competition/match.html
══════════════════════════════════════════════════ */

/* Match bar: single row, no wrap */
@media (max-width: 560px) {
  .match-bar { padding: 8px 12px; gap: 8px; flex-wrap: nowrap !important; }
  .bar-left  { gap: 7px; min-width: 0; flex: 1; overflow: hidden; }
  .live-badge { padding: 4px 9px; font-size: .67rem; gap: 5px; }
  .live-dot   { width: 6px; height: 6px; }
  #myRoleLabel {
    font-size: .68rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80px;
  }
  .bar-right  { gap: 5px; flex-shrink: 0; }
  #gameTimer  { font-size: 1.15rem; min-width: 38px; }
  .bar-right .btn { padding: 6px 9px; font-size: .74rem; gap: 4px; }
}
/* Hide button labels on tiny screens, keep icons */
@media (max-width: 400px) {
  #btnReady span, #btnLeave span,
  #btnReady .btn-text, #btnLeave .btn-text { display: none; }
}

/* Scoreboard */
@media (max-width: 500px) {
  .scoreboard  { padding: 16px 12px; gap: 8px; }
  .sc-avatar   { width: 36px; height: 36px; font-size: .95rem; margin-bottom: 6px; }
  .sc-name     { font-size: .68rem; }
  .sc-score    { font-size: 1.9rem; }
  .vs-text     { font-size: .85rem; }
  .sc-details  { font-size: .6rem; }
}

/* Video boxes */
@media (max-width: 480px) {
  .video-box { aspect-ratio: 16/9; }
  .video-label { font-size: .65rem; padding: 3px 8px; }
}

/* Chat box */
@media (max-width: 480px) {
  .chat-input-row { padding: 8px 10px; gap: 6px; }
  .chat-input { font-size: .76rem; padding: 7px 10px; }
}

/* Countdown + result overlays */
@media (max-width: 480px) {
  .countdown-num  { font-size: 5rem; }
  .countdown-sub  { font-size: .95rem; }
  #resultLabel    { font-size: 1.7rem; }
  #resultScore    { font-size: 2.6rem; letter-spacing: 4px; }
  .result-actions { flex-direction: column; align-items: stretch; }
  .result-actions .btn { justify-content: center; }
}

/* ══════════════════════════════════════════════════
   7.  competition/referee.html
══════════════════════════════════════════════════ */

/* Breadcrumb top bar */
@media (max-width: 520px) {
  .top-bar { padding: 9px 12px; flex-wrap: nowrap; gap: 8px; }
  .breadcrumb { font-size: .68rem; gap: 4px; min-width: 0; overflow: hidden; }
  .breadcrumb a {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 56px;
  }
  .ref-badge { flex-shrink: 0; padding: 4px 10px; font-size: .68rem; }
}
@media (max-width: 420px) {
  .ref-badge { display: none; }
}

/* Page hero */
@media (max-width: 580px) {
  .page-hero { flex-direction: column; gap: 10px; padding: 18px 16px; }
  .hero-icon { display: none; }
}

/* Filter tabs: scroll */
@media (max-width: 560px) {
  .filter-tabs {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 4px;
    gap: 6px;
  }
  .filter-tabs::-webkit-scrollbar { display: none; }
  .cat-pill { flex-shrink: 0; font-size: .72rem; padding: 7px 13px; }
  .pill-count { padding: 1px 5px; font-size: .63rem; }
}

/* Ref players grid */
@media (max-width: 500px) {
  .ref-players { gap: 8px; padding-bottom: 14px; }
  .ref-player-icon { font-size: 1.6rem; margin-bottom: 4px; }
  .ref-player .name { font-size: .78rem; }
  .ref-player .role-lbl { font-size: .65rem; }
  .ref-score-big { font-size: 1.7rem; }
  .ref-score-note { font-size: .65rem; }
}

/* Ref match card */
@media (max-width: 480px) {
  .ref-match-card { padding: 16px 14px; border-radius: 18px; }
  .pts-section    { padding: 12px; }
  .pts-section-head { font-size: .72rem; margin-bottom: 10px; }
  .pts-btn        { padding: 7px 10px; font-size: .75rem; }
  .dec-submit-btn { font-size: .84rem; padding: 11px; border-radius: 12px; }
}

/* Watch live button */
@media (max-width: 480px) {
  .watch-btn { font-size: .72rem; padding: 5px 12px; }
}

/* ══════════════════════════════════════════════════
   8.  premium.html & upgrade.html
══════════════════════════════════════════════════ */

@media (max-width: 500px) {
  .game-header  { padding: 26px 16px 20px; border-radius: 18px; }
  .game-header h1 { font-size: 1.35rem; }
  .game-header p  { font-size: .85rem; }
}

/* ══════════════════════════════════════════════════
   9.  Very small phones (≤360px) — final safety net
══════════════════════════════════════════════════ */

@media (max-width: 360px) {
  .modes   { padding: 0 10px; gap: 10px; }
  .panels  { padding: 0 10px 80px; }
  .hero    { padding: 28px 10px 0; }
  .gn-link { padding: 5px 6px; font-size: .8rem; }
  .mode-card p   { display: none; }
  .hero-left p   { font-size: .82rem; }
  .online-pill   { font-size: .72rem; padding: 6px 11px; }
}
