/*
  TV-mode overrides — everything in this file is scoped under html.tv-mode
  so it has zero effect on the normal site. Loaded unconditionally (see
  index.html boot script); inert unless window.TV_MODE is true.
*/

/* ---- Containment overrides ---------------------------------------- */
/* A Fire TV WebView renders at TV resolution (>=1920px wide), which never
   matches the site's existing max-width:768px "mobile" media queries. Left
   alone that means TV would silently get the desktop header (instant
   leave/end, no confirmation) and a visible account/admin menu. Force the
   mobile-style header-actions path and hide account/admin regardless of
   actual viewport width. .header-left itself stays visible — it's also
   home to the persistent music-mute button below. */
html.tv-mode #header-game-action-btn,
html.tv-mode .account-menu,
html.tv-mode .mobile-menu-toggle {
  display: none !important;
}

html.tv-mode .mobile-game-actions {
  display: flex !important;
}

/* ---- Background music mute toggle -------------------------------------
   Always present (not screen-specific like the leave/cancel/end icons).
   tv-nav.js moves it into .header-right (music on the right, back/cancel/
   end on the left — swapped from the non-TV layout) and moves
   .mobile-game-actions into .header-left to match. Sized and bordered the
   same as .mobile-action-btn (style.css) for visual consistency. */
html.tv-mode .tv-music-toggle {
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: none;
  border: 1px solid #ffffff;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  padding: 0;
}

#tv-music-mute-slash {
  stroke: #ff4d4d;
}

/* ---- Back button label -------------------------------------------------
   Icon-only elsewhere on the site; TV adds a visible "BACK" label since a
   bare arrow is more ambiguous at a distance / without a mouse cursor for
   context. Cancel/End keep their icon-only look — their meaning is
   already unambiguous. */
.tv-back-label {
  display: none;
}

html.tv-mode #mobile-action-back-btn {
  width: auto;
  padding: 0 0.75rem;
  gap: 0.4rem;
}

html.tv-mode .tv-back-label {
  display: inline;
  font-family: 'Opsilon', sans-serif;
  font-size: 0.9rem;
  letter-spacing: 0.5px;
}

/* ---- Layout: unchanged from the main site ----------------------------
   Design/UI intentionally stays as close to identical as possible — this
   file only adds what's functionally required for D-pad use (focus
   highlighting below) and containment (above). No font-size, spacing, or
   layout redesign here. */
html.tv-mode body {
  overflow: hidden; /* avoid stray scrollbars drifting on a fixed TV viewport */
}

/* ---- Focus indicator -------------------------------------------------
   The one visual affordance a D-pad user has instead of a mouse cursor —
   keep it unmissable. No outline/border, no color — scale + plain black
   drop shadow only, per feedback. !important needed since some cards
   already set box-shadow:none !important themselves (see
   .home-banners .banner). */
html.tv-mode .tv-focused {
  transform: scale(1.15);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.8) !important;
  transition: transform 150ms ease, box-shadow 150ms ease;
  z-index: 5;
  position: relative;
}

/* .tv-focused above is the only focus indicator TV should ever show —
   suppress the browser's own default focus outline (visible whenever
   setFocus() calls .focus(), and on a stray mouse click during testing)
   so nothing border-like can appear alongside it. */
html.tv-mode button:focus,
html.tv-mode a:focus,
html.tv-mode input:focus,
html.tv-mode [tabindex]:focus {
  outline: none !important;
}

/* Small icon-only header buttons (music mute, back/cancel/end) barely
   read with just scale+shadow — at ~40px, a shadow is nearly invisible
   against the black header. Swap to a solid white fill + black icon
   instead: a full-colour fill for the ones with no background (music
   toggle), and an unmistakable colour change for the ones that already
   have one (back/cancel's black, end's red). */
html.tv-mode .tv-music-toggle.tv-focused,
html.tv-mode .mobile-action-btn.tv-focused {
  background: #ffffff !important;
  border-color: #ffffff !important;
  color: #111111 !important;
}

/* Card flip is restored for TV (tv-nav.js flips on Enter, same .flipped
   class and CSS the non-TV site uses) — no override needed here. */

/* ---- Rules & FAQ modal -------------------------------------------------
   Opened from the flipped card's "Full rules & FAQ" link (app.js) instead
   of the real navigation that link does on the non-TV site — same visual
   language as the site's existing confirm-popup/game-ended-popup overlays
   (style.css), just sized for more content and independently scrollable. */
html.tv-mode .tv-rules-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  padding: 2rem;
}

html.tv-mode .tv-rules-popup {
  width: 100%;
  max-width: 640px;
  max-height: 80vh;
  border-radius: 16px;
  padding: 2rem;
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

html.tv-mode .tv-rules-title {
  font-family: 'Opsilon', sans-serif;
  font-size: 1.8rem;
  color: #ffffff;
  text-transform: uppercase;
  text-align: center;
}

html.tv-mode .tv-rules-body {
  overflow-y: auto;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.5;
}

html.tv-mode .tv-rules-body h3 {
  font-family: 'Opsilon', sans-serif;
  font-size: 1.1rem;
  color: #22d3ee;
  margin: 1rem 0 0.5rem;
  text-transform: uppercase;
}

html.tv-mode .tv-rules-body h3:first-child {
  margin-top: 0;
}

html.tv-mode .tv-rules-steps {
  padding-left: 1.25rem;
}

html.tv-mode .tv-rules-steps li {
  margin-bottom: 0.5rem;
}

html.tv-mode .tv-rules-faq-item {
  margin-bottom: 1rem;
}

html.tv-mode .tv-rules-faq-q {
  font-weight: bold;
  color: #ffffff;
  margin-bottom: 0.25rem;
}

html.tv-mode .tv-rules-faq-a {
  color: rgba(255, 255, 255, 0.75);
}

html.tv-mode .tv-rules-close-btn {
  align-self: center;
  background: #ffffff;
  color: #111;
  border: none;
  border-radius: 8px;
  padding: 0.75rem 2.5rem;
  font-family: 'Opsilon', sans-serif;
  font-size: 1.1rem;
  cursor: pointer;
  text-transform: uppercase;
}
