/* JFun Gaming UI v1
   Loaded AFTER jfun-brand.css. Dark-first "gaming" look on the same brand colours
   (magenta #F20289 -> coral #FB2B52). New classes start with jg-.
   Page files: assets/brand/game/<name>.css, overrides written as html body.jg-<page> .class */

/* ---------- A. Tokens ---------- */
html:root {
  --jg-surface-2: #FFFFFF;
  --jg-ok: #2FBF8B;
  --jg-warn: #FF9A55;
  --jg-bad: #FF4D6D;
}
/* dark = everything except an explicit light theme (light keeps the brand pastel tokens) */
html:root:not([data-theme="light"]) {
  --bg-color: #0E0714;
  --card-bg: rgba(30, 14, 38, 0.78);
  --text-color: #FDEFF7;
  --text-secondary: #C9A7BD;
  --border-color: rgba(255, 255, 255, 0.09);
  --shadow-color: rgba(0, 0, 0, 0.55);
  --jf-glass: rgba(34, 16, 42, 0.66);
  --jf-glass-strong: rgba(40, 19, 50, 0.88);
  --jf-glass-border: rgba(255, 255, 255, 0.10);
  --jf-glass-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  --jf-nav-bg: rgba(24, 11, 31, 0.92);
  --jf-nav-border: rgba(255, 255, 255, 0.10);
  --jf-nav-shadow: 0 -8px 30px rgba(0, 0, 0, 0.55);
  --jf-toast-bg: #2E1630;
  --jg-surface-2: #2A1434;
}

/* ---------- B. Base (kept minimal so games are not affected) ---------- */
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; }
html body { -webkit-tap-highlight-color: transparent; }

/* ---------- C. Components ---------- */
.jg-display { font-family: var(--jg-font-display); font-weight: 700; letter-spacing: 0.02em; }
.jg-title {
  display: flex; align-items: center; gap: 10px; margin: 18px 0 10px;
}
.jg-title::before { content: ''; width: 4px; height: 1.1em; flex: 0 0 auto; }
.jg-card {
  background: var(--card-bg); border: 1px solid var(--border-color);
  border-radius: var(--jg-radius); padding: 16px; box-shadow: var(--jf-glass-shadow);
}
.jg-card--glow {
  background: linear-gradient(var(--jf-solid), var(--jf-solid)) padding-box, var(--jf-grad) border-box;
  border: 1.5px solid transparent;
}

.jg-btn--block { width: 100%; }
.jg-chip {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px;
  border-radius: var(--ui-r-pill); background: var(--jf-grad-soft); font: 600 12px var(--jg-font-body);
}
.jg-badge {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: var(--ui-r-pill);
  font: 700 12px var(--jg-font-body); background: rgba(242, 2, 137, 0.16); color: var(--jf-pink);
}
.jg-badge--ok { background: rgba(47, 191, 139, 0.16); color: var(--jg-ok); }
.jg-badge--warn { background: rgba(255, 154, 85, 0.16); color: var(--jg-warn); }
.jg-badge--bad { background: rgba(255, 77, 109, 0.16); color: var(--jg-bad); }
.jg-list-row {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 0;
  border-bottom: 1px solid var(--border-color);
}
.jg-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.jg-skel { position: relative; overflow: hidden; border-radius: var(--ui-r-sm); background: var(--jf-skel-a); }
.jg-skel::after {
  content: ''; position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  background: linear-gradient(90deg, transparent, var(--jf-skel-b), transparent);
  transform: translateX(-100%);
}
.jg-glow-text { text-shadow: 0 0 14px rgba(242, 2, 137, 0.55); }

/* animations: opacity/transform only, none for reduced-motion users */
@keyframes jg-fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes jg-pulse { 0%, 100% { opacity: 0.25; transform: scale(1); } 50% { opacity: 1; transform: scale(1.03); } }
@keyframes jg-shimmer { to { transform: translateX(100%); } }
@media (prefers-reduced-motion: no-preference) {
  .jg-anim { animation: jg-fade-up 0.35s ease-out both; }
  .jg-pulse { position: relative; }
  .jg-pulse::after {
    content: ''; position: absolute; top: 0; right: 0; bottom: 0; left: 0; border-radius: inherit;
    box-shadow: 0 0 18px 2px rgba(242, 2, 137, 0.55); pointer-events: none;
    animation: jg-pulse 2.4s ease-in-out infinite;
  }
  .jg-skel::after { animation: jg-shimmer 1.3s ease infinite; }
}

/* ---------- D. Restyle of existing shared classes ---------- */
html body input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="range"]),
html body select,
html body textarea {
  min-height: 48px; font-size: var(--ui-fs-md); border-radius: var(--jg-radius-sm);
}
html body input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="range"]):focus,
html body select:focus,
html body textarea:focus {
  box-shadow: 0 0 0 3px rgba(242, 2, 137, 0.30); border-color: var(--jf-pink);
}
/* dropdowns / modals / toasts stay solid */
html body .modal-content,
html body .modal-box,
html body .rules-content,
html body .toast {
  background: var(--jf-solid); color: var(--text-color); border: 1px solid var(--border-color);
}
/* dark mode: big stat numbers use the text colour */

/* ---------- NAVIGATION: bottom nav pill, top bar ---------- */
html body .jf-nav {
  left: 10px; right: 10px; bottom: calc(var(--jf-nav-gap) + env(safe-area-inset-bottom, 0px));
  width: auto; min-width: 0; max-width: 520px; margin-left: auto; margin-right: auto;
  height: var(--jf-nav-h); padding: 0 6px; transform: none;
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
/* base layout of the nav on pages that do not load jfun-pwa.css (game pages) - same values as there, tokens only */
html body .jf-nav { position: fixed; z-index: 1000; }
html body .jf-nav-inner { display: flex; }
html body .jf-nav-item { display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; text-decoration: none; }
html body .jf-nav-icon { display: flex; align-items: center; justify-content: center; }
html body .jf-nav-item::before { content: ''; position: absolute; transform: translateX(-50%); }
html body.modal-open .jf-nav { transform: translateY(150%); }
html body .jf-nav-inner { height: 100%; max-width: none; margin: 0; gap: 2px; align-items: stretch; justify-content: space-around; }
html body .jf-nav-item {
  min-height: 56px; flex: 1 1 0; max-width: none; min-width: 0; padding: 4px 2px; margin: auto 0; overflow: visible; gap: 3px;
}
html body .jf-nav-icon { height: 24px; }
html body .jf-nav-item::before {
  top: 2px; left: 50%; width: 0; height: 3px;
}
html body .jf-nav-item:hover::before { width: 0; }
html body .jf-nav-item.active { background: transparent; }
html body .jf-nav-item.active::before { width: 22px; height: 3px; }
html body .jf-nav-item.active .jf-nav-icon { animation: none; }

/* centre "play" item (Games) */
html body .jf-nav-item.jf-nav-play::before { display: none; }
html body .jf-nav-item.jf-nav-play .jf-nav-icon {
  width: 56px; height: 56px; margin-top: -26px; border-radius: 50%; font-size: var(--ui-fs-lg);
  background: var(--jf-grad); color: var(--ui-on-accent); text-shadow: none; transform: none;
  box-shadow: 0 0 0 5px var(--jf-nav-bg), 0 8px 22px rgba(242, 2, 137, 0.55);
}
html body .jf-nav-item.jf-nav-play.active .jf-nav-icon {
  color: var(--ui-on-accent); transform: none;
  box-shadow: 0 0 0 5px var(--jf-nav-bg), 0 8px 28px rgba(242, 2, 137, 0.85);
}
html body .jf-nav-item.jf-nav-play:active .jf-nav-icon { transform: scale(0.94); }

/* Room badge */
html body .jf-nav-item.jf-nav-play .jf-nav-icon { position: relative; }
html body .jf-nav-badge {
  position: absolute; top: -4px; right: -4px; box-sizing: border-box; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: var(--ui-r-pill); border: 2px solid var(--jf-nav-bg); background: var(--jg-bad); color: var(--ui-on-accent);
  font: 700 11px/16px var(--jg-font-display); text-align: center; pointer-events: none; text-shadow: none;
}
html body .jf-nav-badge[hidden] { display: none; }

/* spacing so content and floating buttons clear the pill */
html body.jf-has-nav { padding-bottom: calc(var(--jf-nav-clear) + env(safe-area-inset-bottom, 0px)) !important; }
html body .jf-theme-btn { width: 44px; height: 44px; bottom: calc(var(--jf-nav-clear) + env(safe-area-inset-bottom, 0px)); }
html body .jf-install.jf-has-bar { bottom: calc(var(--jf-nav-clear) + env(safe-area-inset-bottom, 0px)); }
/* light theme: no neon glow on the home cards (moved from game/home.css) */
html body.jg-home .jg-card--glow { box-shadow: var(--jf-glass-shadow); }
