.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.top-actions .account-link {
  max-width: none;
  font-family: inherit;
  cursor: pointer;
}

[hidden] { display: none !important; }

.tv-mode .intro { padding: 28px 0 32px; }
.tv-mode .intro h1,
.tv-mode .intro .lede,
.tv-mode .steps { display: none; }
.tv-mode .wall { animation: none; }
.tv-help { margin-top: 24px; color: var(--dim); }
.tv-mode body { width: var(--tv-viewport-width, 100%); max-width: 100%; }
.tv-mode .imp-overlay { right: auto; width: var(--tv-viewport-width, 100%); }

/* Keep every card inside the viewport, including older TV WebViews whose
   flex items otherwise retain the intrinsic width of images or long titles. */
.tv-mode .wrap { width: 100%; min-width: 0; }
.tv-mode main { min-width: 0; }
.tv-mode .top { flex-wrap: wrap; }
.tv-mode .top-actions { min-width: 0; max-width: 100%; }
.tv-mode .top-actions .account-link { max-width: 100%; }
.tv-mode .games {
  display: flex; /* Fallback for TV browsers without CSS Grid. */
  display: grid;
  grid-template-columns: repeat(var(--tv-columns, 3), minmax(0, 1fr));
  flex-wrap: wrap;
  width: 100%;
  min-width: 0;
  gap: 40px 24px;
}
.tv-mode .game {
  flex: 0 1 calc(100% / var(--tv-columns, 3) - 24px);
  min-width: 0;
  max-width: 100%;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.tv-mode .shot,
.tv-mode .shot img { max-width: 100%; }
.tv-mode .game a { min-width: 0; height: 100%; border-radius: 14px; scroll-margin: 32px; }

@media (min-width: 1181px) {
  .tv-mode .games { grid-template-columns: repeat(var(--tv-columns, 4), minmax(0, 1fr)); }
  .tv-mode .game { flex-basis: calc(100% / var(--tv-columns, 4) - 24px); }
}
@media (max-width: 860px) {
  .tv-mode .games { grid-template-columns: repeat(var(--tv-columns, 2), minmax(0, 1fr)); }
  .tv-mode .game { flex-basis: calc(100% / var(--tv-columns, 2) - 24px); }
}
@media (max-width: 560px) {
  .tv-mode .games { grid-template-columns: repeat(var(--tv-columns, 1), minmax(0, 1fr)); }
  .tv-mode .game { flex-basis: calc(100% / var(--tv-columns, 1) - 24px); }
}

.tv-mode .game a:hover { outline: 4px solid var(--pop); outline-offset: 6px; }
.remote-navigation a:focus,
.remote-navigation button:focus {
  outline: 4px solid var(--pop);
  outline-offset: 6px;
}
.remote-navigation .game a:focus .shot {
  box-shadow: 0 0 0 3px var(--accent), 0 18px 40px -14px var(--accent);
}
.remote-navigation .game a:focus h2 { color: var(--accent); }

.tv-diagnostic {
  position: fixed;
  bottom: 16px;
  left: 16px;
  z-index: 200;
  max-width: calc(100vw - 32px);
  padding: 16px;
  background: #1b1430;
  color: #fff3e2;
  border: 2px solid #ffd23f;
  font: 16px/1.5 monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  pointer-events: none;
}

@media (max-width: 560px) {
  .top { align-items: flex-start; }
  .top-actions { gap: 6px; }
  .top-actions .account-link { padding: 7px 10px; font-size: .8rem; }
}
