/* Country Games Hub — shared styles.
 * Dark hub shell, flat matte colours (no gradients), mobile-first.
 * Bright, saturated and high-contrast throughout: the audience is
 * mostly children, so everything must read clearly at phone size.
 * Games reuse the .topbar / .game-shell / .stage-wrap / .feed /
 * .board / .banner / .overlay / .hud / .fairness-line classes here.
 */

:root {
  --bg: #0b0b12;
  --bg-soft: #161624;
  --bg-card: #1e1e30;
  --bg-panel: #262640;
  --line: #3d3d5c;
  --text: #ffffff;
  --text-dim: #cfcfe2;
  --accent: #ffd23f;
  --accent-red: #ff5030;
  --accent-cyan: #2ee6ff;
  --accent-pink: #ff7ac2;
  --accent-gold: #ffc61a;
  --accent-green: #45e07a;
  --radius: 18px;
  --radius-sm: 12px;
  --topbar-h: 58px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; }
img, svg { max-width: 100%; }
button { font: inherit; color: inherit; }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: var(--bg-soft);
  border-bottom: 3px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  text-decoration: none;
}

.brand-mark {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent-red);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  border: 2px solid #1a1a24;
}

.live-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  flex: 0 0 auto;
}

.live-badge.pulse,
.live-badge .dot {
  animation: live-pulse 1.6s ease-in-out infinite;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* ---------- Game switcher rail (fast switching for streamers) ---------- */

.switcher {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 12px;
  background: var(--bg-soft);
  border-bottom: 3px solid var(--line);
  scrollbar-width: none;
}
.switcher::-webkit-scrollbar { display: none; }

.switcher a {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 48px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 3px solid var(--line);
  background: var(--bg-panel);
  color: var(--text);
  font-weight: 800;
  font-size: 0.92rem;
  text-decoration: none;
  white-space: nowrap;
}
.switcher a:active { transform: translateY(1px); }
.switcher a[aria-current="page"] {
  background: var(--accent);
  border-color: #1a1a24;
  color: #1a1a24;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border: 3px solid var(--line);
  border-radius: 999px;
  background: var(--bg-panel);
  color: var(--text);
  font-weight: 800;
  font-size: 1rem;
  text-decoration: none;
  cursor: pointer;
  min-height: 46px;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  border-color: #1a1a24;
  color: #1a1a24;
}

.btn-danger {
  background: var(--accent-red);
  border-color: #1a1a24;
  color: #fff;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 3px solid var(--line);
  border-radius: 14px;
  background: var(--bg-panel);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
}

.icon-btn.is-muted { opacity: 0.75; }
.icon-btn:active { transform: translateY(1px); }

/* ---------- Game shell / stage ---------- */

.game-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.layout {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stage-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: #05050a;
  border: 3px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.stage-wrap.tall { aspect-ratio: 9 / 13; }
.stage-wrap.square { aspect-ratio: 1 / 1; }

canvas.game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  background: #05050a;
}

.side-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

@media (min-width: 820px) {
  .layout { flex-direction: row; align-items: flex-start; }
  .layout .stage-wrap { flex: 1 1 auto; min-width: 0; }
  .layout .side-col { flex: 0 0 300px; }
  .game-shell { padding: 16px 16px 24px; }
}

/* ---------- Feed / board ---------- */

.feed {
  background: var(--bg-card);
  border: 3px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  max-height: 240px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.feed-title,
.board-title {
  margin: 0 0 8px;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.feed-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  line-height: 1.35;
  font-weight: 600;
}

.feed-item:nth-child(even) { background: var(--bg-panel); }

.feed-item .feed-dot {
  flex: 0 0 auto;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #1a1a24;
}

.board {
  background: var(--bg-card);
  border: 3px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-bottom: 2px solid var(--line);
  font-size: 1rem;
  font-weight: 600;
}

.score-row:last-child { border-bottom: 0; }

.score-row .rank {
  flex: 0 0 26px;
  font-weight: 800;
  color: var(--accent);
  text-align: center;
}

.score-row .who {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-row .score { font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- Banner / overlay / HUD ---------- */

.banner {
  display: none;
  position: absolute;
  left: 50%;
  top: 14px;
  transform: translateX(-50%);
  z-index: 20;
  max-width: calc(100% - 24px);
  padding: 9px 18px;
  border-radius: 999px;
  background: var(--accent);
  color: #1a1a24;
  font-weight: 800;
  font-size: 1rem;
  text-align: center;
  border: 3px solid #1a1a24;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: clamp(0.8rem, 3.6vw, 1rem);
}

.banner.show { display: block; }

/* ---------- Game-page topbars: never overlap, never wrap ---------- */

.topbar.game-topbar .brand {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar.game-topbar .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

.topbar.game-topbar .live-badge,
.topbar.game-topbar .icon-btn {
  flex: 0 0 auto;
}

@media (max-width: 560px) {
  .topbar.game-topbar { gap: 8px; padding: 8px 10px; }
  /* The switcher rail directly below already names the current game. */
  .topbar.game-topbar .brand { display: none; }
  .topbar.game-topbar .live-badge { padding: 5px 9px; font-size: 0.7rem; }
  .topbar.game-topbar .icon-btn { width: 42px; height: 42px; }
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  background: rgba(5, 5, 10, 0.84);
  text-align: center;
}

.overlay[hidden] { display: none; }

.overlay-title {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.2;
}

.overlay-text {
  margin: 0;
  color: var(--text-dim);
  font-size: 1rem;
  max-width: 34em;
}

.hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--bg-panel);
  border: 3px solid var(--line);
  font-size: 0.92rem;
  font-weight: 800;
  white-space: nowrap;
}

.pill strong { font-variant-numeric: tabular-nums; }

/* ---------- Fairness line ---------- */

.fairness-line {
  display: inline-block;
  margin: 0;
  padding: 8px 16px;
  border-radius: 999px;
  background: #2b2b44;
  color: #ffffff;
  border: 3px solid #56567e;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
}

/* ---------- Forced fullscreen fallback ---------- */

.force-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  z-index: 9999 !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  margin: 0 !important;
  padding: 0 !important;
  border-radius: 0 !important;
  border: 0 !important;
  background: #05050a;
}

.force-fullscreen .stage-wrap {
  height: 100%;
  border: 0;
  border-radius: 0;
}

body.is-force-fullscreen { overflow: hidden; }

#btn-exit-fullscreen {
  position: fixed;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 10000;
  min-height: 48px;
  padding: 10px 18px;
  border: 3px solid #1a1a24;
  border-radius: 999px;
  background: var(--accent);
  color: #1a1a24;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
}

#btn-exit-fullscreen[hidden] { display: none !important; }

/* ---------- Hub homepage ---------- */

.hub-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 14px 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.hero { text-align: center; padding: 6px 4px 0; }

.hero-logo {
  width: 172px;
  height: 172px;
  margin: 0 auto 4px;
}

.hero-tagline {
  margin: 8px auto 0;
  max-width: 34em;
  color: var(--text-dim);
  font-size: 1.05rem;
  font-weight: 600;
}

.hero-title {
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: 0.01em;
}

.section-title {
  margin: 0 0 4px;
  font-size: 1.3rem;
  font-weight: 800;
}

.section-sub {
  margin: 0 0 14px;
  color: var(--text-dim);
  font-size: 0.95rem;
  font-weight: 600;
}

.game-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 560px) {
  .game-grid { grid-template-columns: 1fr 1fr; }
}

.game-card {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 16px;
  background: var(--bg-card);
  border: 3px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 5px 5px 0 #000000;
  text-decoration: none;
  min-height: 116px;
}

.game-card:active { transform: translate(2px, 2px); box-shadow: 3px 3px 0 #000000; }
.game-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.card-battle { border-color: var(--accent-red); }
.card-maze { border-color: var(--accent-cyan); }
.card-plinko { border-color: var(--accent-pink); }
.card-puzzle { border-color: var(--accent-gold); }

.game-card-icon {
  flex: 0 0 88px;
  width: 88px;
  height: 88px;
}

.game-card-body { min-width: 0; flex: 1 1 auto; }

.game-card-name {
  display: block;
  margin: 0 0 3px;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.2;
}

.game-card-desc {
  display: block;
  margin: 0 0 9px;
  color: #dcdcec;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
}

.badge {
  display: inline-block;
  padding: 5px 13px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  border: 2px solid #1a1a24;
}

.badge-auto { background: var(--accent-red); color: #fff; }
.badge-play { background: var(--accent-green); color: #0b0b12; }

.hub-footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 14px 30px;
  color: var(--text-dim);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.hub-footer p { margin: 0; }

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .live-badge.pulse,
  .live-badge .dot { animation: none; }
}
