/* Tom Games sponsored placements (js/tg-ads.js).
 * Cards take the font and colours of the screen they sit on (everything is drawn from currentColor),
 * so one look fits every game. A game tunes them with --tga-* on the slot or any parent:
 *   --tga-radius  --tga-bg  --tga-line  --tga-accent  --tga-width  --tga-margin
 * The slot measures itself: 3 cards when there is room, 2 in a narrow panel, 1 in a very narrow one.
 * Never animated, never louder than the screen around it. */
.tga {
  container-type: inline-size;
  display: flex; justify-content: center; gap: 8px;
  width: 100%; max-width: var(--tga-width, 660px); margin: var(--tga-margin, 14px auto 0);
  font: inherit; text-align: left; line-height: 1.2;
}
.tga--empty, .tga--nofit { display: none !important; }

.tga-card {
  flex: 1 1 0; min-width: 0; max-width: 300px;
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px 6px 6px;
  border-radius: var(--tga-radius, 10px);
  border: 1px solid rgba(128, 128, 128, .35);
  border-color: var(--tga-line, color-mix(in srgb, currentColor 22%, transparent));
  background: rgba(128, 128, 128, .1);
  background: var(--tga-bg, color-mix(in srgb, currentColor 7%, transparent));
  color: inherit; text-decoration: none;
  transition: background-color .15s, border-color .15s;
}
.tga-card:hover { background: color-mix(in srgb, currentColor 13%, transparent); border-color: color-mix(in srgb, currentColor 40%, transparent); }
.tga-card:focus-visible { outline: 2px solid var(--tga-accent, currentColor); outline-offset: 2px; }
.tga-card--text { padding-left: 12px; }

.tga-img {
  flex: none; width: 44px; height: 44px; object-fit: cover;
  border-radius: max(2px, calc(var(--tga-radius, 10px) - 4px));
  background: color-mix(in srgb, currentColor 10%, transparent);
}
.tga-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tga-label, .tga-title, .tga-line { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tga-label { font-size: 9.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; opacity: .62; }
.tga-title { font-size: 13px; font-weight: 700; letter-spacing: 0; text-transform: none; }
.tga-line { font-size: 12px; opacity: .74; }

.tga--menu .tga-card, .tga--load .tga-card { max-width: 280px; }

@container (max-width: 560px) { .tga-card:nth-child(n+3) { display: none; } }
@container (max-width: 420px) { .tga-line { display: none; } .tga-img { width: 36px; height: 36px; } }
@container (max-width: 300px) { .tga-card:nth-child(n+2) { display: none; } }

/* Short screens (phones held sideways): one card, and no menu cards at all — the buttons need the room. */
@media (max-height: 520px) {
  .tga { margin-top: 10px; }
  .tga-card:nth-child(n+2) { display: none; }
  .tga-card { flex: 0 1 280px; }
  .tga--menu { display: none !important; }
}
@media (prefers-reduced-motion: reduce) { .tga-card { transition: none; } }
@media (forced-colors: active) { .tga-card { border-color: CanvasText; } }

/* ── where each game puts them ─────────────────────────────────────────── */

/* A free corner of a wide menu (TomPearl.IO): bottom left, clear of the menu and the F2 tip; desktop only. */
.tga-corner {
  position: absolute; z-index: 2; width: 280px; margin: 0;
  left: max(18px, env(safe-area-inset-left)); bottom: max(16px, env(safe-area-inset-bottom));
}
@media (max-width: 1000px) { .tga-corner { display: none !important; } }

/* Pearl-Man results: a strip across the foot of the panel, under the score and the high scores. */
.game-result__panel > .tga {
  grid-column: 1 / -1; max-width: none; margin: 0; padding: 12px 18px 16px;
  border-top: 1px solid var(--pm-line, rgba(255, 255, 255, .12));
}

/* TomPearl.IO: under the white death card and the white menu, as white cards of their own. */
#death-screen > .tga, #start-screen > .tga {
  --tga-bg: #fff; --tga-line: rgba(0, 0, 0, .06); --tga-radius: 12px;
  color: var(--ink, #1d2433); margin-top: 12px;
}
#death-screen > .tga .tga-card, #start-screen > .tga .tga-card { box-shadow: 0 8px 22px rgba(0, 0, 0, .18); }
#death-screen > .tga .tga-card:hover, #start-screen > .tga .tga-card:hover { background: #f4f6fa; }

/* Toilet Jerk loading: at the foot of the screen, so the loading line never moves. */
.loading > .tga { position: absolute; left: 0; right: 0; bottom: max(22px, env(safe-area-inset-bottom)); margin: 0 auto; padding: 0 16px; font-weight: 400; }

/* Tom Pearl Clicker: under the Stats sheet only, never under the shop, trophies, flush or casino. */
.pc-sheet:not(:has(.pc-stats)) > .tga { display: none !important; }

/* Shit Seas: the title card wears the dark chip look of Leaderboard / Sound; results sit on the paper panel. */
.ss-title-menu > .tga { --tga-bg: #1d140bb3; --tga-line: #fbefd266; --tga-radius: 14px; color: var(--paper, #fbefd2); }
.ss-panel > .tga { --tga-line: color-mix(in srgb, var(--ink, #2b1a0c) 28%, transparent); --tga-radius: 12px; }

/* Pearl Pong: square PPN lower-thirds with the gold rule of the Club ladder chips. */
.pp-screen .tga { --tga-radius: 0; }
.pp-screen .tga-card { border-width: 0 0 0 3px; border-color: var(--gold, #ffc72c); }
.pp-title-menu > .tga { --tga-bg: #0b1d42d9; color: var(--white, #f4f6fb); justify-content: flex-start; }

/* Tom Birds: dark rounded notes, like the guest-save note, so they read on sky and on wood. */
.tb-title-box > .tga, .tb-result-panel > .tga { --tga-bg: rgba(42, 20, 10, .62); --tga-line: transparent; --tga-radius: 12px; color: #fff; font-family: system-ui, sans-serif; }
.tb-title-box > .tga { max-width: 300px; }

/* Toilet Jerk: paper cards with the ink outline of the menu cards; in the "caught" card, a row of its own. */
.menu > .tga, .modal--after .card > .tga { --tga-bg: var(--paper, #fffaf0); --tga-line: var(--ink, #1d1a16); --tga-radius: 14px; color: var(--ink, #1d1a16); }
.menu > .tga .tga-card { border-width: 2px; box-shadow: 3px 3px 0 var(--ink, #1d1a16); }
.menu > .tga .tga-card:hover { background: #fff; }
.modal--after .card:has(> .tga:not(.tga--empty)) { flex-wrap: wrap; }
.modal--after .card > .tga { flex: 1 0 100%; margin-top: 2px; }
