/* ==========================================================================
   /games — shared styles
   --------------------------------------------------------------------------
   Deliberately standalone: the games pages do NOT load css/style.css, which
   pulls in the Arter template's Bootstrap/Swiper/Fancybox chrome. They only
   borrow its theme custom properties, redeclared here, so dark/light stays
   consistent with the rest of the site without the weight.

   Mobile-first throughout — these pages are played on phones.
   ========================================================================== */

:root {
  --accent: #2dd4bf;
  --accent-dark: #0d9488;
  --bg-main: #20202a;
  --bg-card: #191923;
  --bg-darkest: #1e1e28;
  --text-primary: #fafafc;
  --text-secondary: #8c8c8e;
  --text-subtle: #646466;
  --text-on-accent: #1e1e28;
  --card-gradient-start: rgba(37, 37, 50, 0.98);
  --card-gradient-end: rgba(35, 35, 45, 0.98);
  --shadow-color: rgba(15, 15, 20, 0.2);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --danger: #f87171;

  --radius: 14px;
  --gap: 16px;
  --maxw: 1080px;
}

[data-theme="light"] {
  --accent: #0d9488;
  --accent-dark: #0f766e;
  --bg-main: #f5f5f7;
  --bg-card: #ffffff;
  --bg-darkest: #e8e8ec;
  --text-primary: #1e1e28;
  --text-secondary: #555560;
  --text-subtle: #8c8c8e;
  --text-on-accent: #ffffff;
  --card-gradient-start: rgba(255, 255, 255, 0.98);
  --card-gradient-end: rgba(248, 248, 252, 0.98);
  --shadow-color: rgba(0, 0, 0, 0.1);
  --border-subtle: rgba(0, 0, 0, 0.08);
  --danger: #dc2626;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  /* Column flex with a flexing .g-wrap is what pins the footer to the bottom
     of short pages — the landing page is barely a screen tall, and a footer
     floating mid-viewport looked like the page had failed to load. */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  color: var(--text-secondary);
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  /* Room codes and word cards must never be zoomed away on rotate */
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { color: var(--text-primary); margin: 0 0 0.4em; line-height: 1.25; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
a { color: var(--accent); }

.g-wrap {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px 16px 40px;
  flex: 1 0 auto;        /* absorbs the slack, pushing the footer down */
}

/* -- Header --------------------------------------------------------------
   Deliberately a simple bar rather than the main site's slide-out sidebar.
   That nav is built on the Arter template's ~98KB stylesheet plus jQuery,
   Swiper, Fancybox and smooth-scrollbar; its links are also same-page anchors
   (#projects, #contact) that would be dead here. This borrows the design
   language — same tokens, same circular blurred toggle — without the weight,
   and carries no name or avatar.                                            */

.g-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg-main) 88%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-subtle);
}
/* color-mix is well supported, but a hard fallback keeps the bar opaque
   rather than transparent on anything that misses it. */
@supports not (background: color-mix(in srgb, red 50%, transparent)) {
  .g-topbar { background: var(--bg-main); }
}

.g-topbar__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.g-back {
  appearance: none;
  background: rgba(0, 0, 0, 0.25);
  border: none;
  color: var(--text-primary);
  border-radius: 50%;
  width: 32px; height: 32px;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  transition: 0.2s ease-in-out;
}
[data-theme="light"] .g-back { background: rgba(0, 0, 0, 0.08); }
.g-back:hover { color: var(--accent); }
.g-back:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.g-crumbs {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.86rem;
  color: var(--text-subtle);
  min-width: 0;
}
.g-crumbs a { color: var(--text-secondary); text-decoration: none; }
.g-crumbs a:hover { color: var(--accent); }
.g-crumbs__sep { opacity: 0.5; }
.g-crumbs__current {
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.g-topbar__spacer { flex: 1; }

/* Matches .art-theme-toggle from the main site: circular, translucent,
   backdrop-blurred. */
.g-themetoggle {
  background: rgba(0, 0, 0, 0.25);
  border: none;
  color: var(--text-primary);
  border-radius: 50%;
  width: 36px; height: 36px;
  font-size: 15px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: 0.3s ease-in-out;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
[data-theme="light"] .g-themetoggle {
  background: rgba(0, 0, 0, 0.08);
  color: var(--text-primary);
}
.g-themetoggle:hover { color: var(--accent); }

/* -- Footer --------------------------------------------------------------
   Mirrors the main site's <footer> in css/style.css: one line, copyright at
   one end and attribution at the other, same gradient, 11px, same greys.    */

.g-footer {
  width: 100%;
  flex-shrink: 0;
  margin-top: auto;
  padding: 17px 30px 7px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(159deg, #2d2d3a 0%, #2b2b35 100%);
  box-shadow: 0 1px 4px 0 rgba(15, 15, 20, 0.1);
  font-size: 11px;
  color: #8c8c8e;
}
[data-theme="light"] .g-footer {
  background: linear-gradient(159deg, #ffffff 0%, #f5f5f7 100%);
  color: var(--text-subtle);
}
.g-footer div { margin-bottom: 10px; }
.g-footer a {
  color: inherit;
  text-decoration: none;
  transition: 0.2s ease-in-out;
}
.g-footer a:hover { color: var(--text-primary); }

/* Same breakpoint behaviour as the main site: stack and centre on mobile. */
@media (max-width: 767px) {
  .g-footer {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 15px 20px 10px;
  }
}

/* -- Hero --------------------------------------------------------------- */

.g-hero { padding: 0 0 28px; }
.g-hero p { margin: 0; max-width: 62ch; }
.g-hero__kicker {
  color: var(--accent);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: 0 0 6px;
  font-weight: 600;
}

/* -- Card grid ---------------------------------------------------------- */

.g-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
}
@media (min-width: 620px) {
  .g-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 900px) {
  .g-grid { grid-template-columns: repeat(3, 1fr); }
}

.g-card {
  background: linear-gradient(145deg, var(--card-gradient-start), var(--card-gradient-end));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 22px 20px;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 4px 18px var(--shadow-color);
  transition: transform 0.18s ease, border-color 0.18s ease;
}
a.g-card:hover, a.g-card:focus-visible {
  transform: translateY(-3px);
  border-color: var(--accent);
}
.g-card__icon { font-size: 2rem; line-height: 1; }
.g-card__name { color: var(--text-primary); font-weight: 600; font-size: 1.05rem; }
.g-card__blurb { font-size: 0.9rem; margin: 0; }
.g-card__meta {
  margin-top: auto;
  padding-top: 12px;
  font-size: 0.8rem;
  color: var(--text-subtle);
  display: flex; align-items: center; gap: 8px;
}
.g-card--soon { opacity: 0.62; }
.g-badge {
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}
.g-badge--soon { color: var(--text-subtle); }

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

.g-btn {
  appearance: none;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--text-on-accent);
  font: inherit;
  font-weight: 600;
  border-radius: 10px;
  padding: 12px 20px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  /* 44px minimum touch target */
  min-height: 44px;
}
.g-btn:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.g-btn--ghost {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-subtle);
}
.g-btn--ghost:hover { background: transparent; border-color: var(--accent); color: var(--accent); }
.g-btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.g-btn--block { width: 100%; }

/* -- Chips (multi-select filters) --------------------------------------- */

.g-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.g-chip {
  appearance: none;
  font: inherit;
  font-size: 0.85rem;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  min-height: 38px;
}
/* "All" reads as a control over the row rather than another category, so it
   keeps a visible outline even when off. */
.g-chip--all {
  font-weight: 600;
  border-color: var(--text-subtle);
}
.g-chip--all[aria-pressed="true"] { border-color: var(--accent); }

.g-chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-on-accent);
  font-weight: 600;
}
.g-chip:focus-visible, .g-btn:focus-visible, .g-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* -- Panels ------------------------------------------------------------- */

.g-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: var(--gap);
}
.g-panel__title {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.95rem;
  margin: 0 0 10px;
}
.g-field { margin-bottom: 16px; }
.g-field:last-child { margin-bottom: 0; }
.g-label {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  margin-bottom: 8px;
}

/* ==========================================================================
   Rooms — shared lobby chrome
   --------------------------------------------------------------------------
   Every game that uses rooms gets this: the code, the QR, the roster, the
   team columns and the avatar picker. Nothing here is Pictionary-specific.
   ========================================================================== */

/* -- The code ------------------------------------------------------------
   Read aloud across a room, so it is the largest thing on the lobby screen.
   Monospace with wide tracking: 8 and B are told apart by their shapes, and
   a proportional font at speed is where "did you say D or E" comes from. */

.g-code {
  font-family: 'Courier Prime', 'SF Mono', Menlo, monospace;
  font-size: clamp(2.4rem, 13vw, 4rem);
  font-weight: 700;
  letter-spacing: 0.16em;
  text-indent: 0.16em;            /* re-centres against the trailing space */
  color: var(--text-primary);
  text-align: center;
  margin: 0;
  line-height: 1.1;
}

.g-codebar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
  margin-top: 12px;
}

/* -- QR ------------------------------------------------------------------
   The one component that does NOT follow the theme. An inverted QR scans
   poorly on many phones and the quiet zone has to stay light, so the card is
   white in dark mode too. */

.g-qr {
  background: #ffffff;
  padding: 10px;
  border-radius: 10px;
  display: inline-block;
  line-height: 0;
  box-shadow: 0 2px 10px var(--shadow-color);
}
.g-qr canvas { display: block; width: 180px; height: 180px; image-rendering: pixelated; }

@media (max-width: 420px) {
  .g-qr canvas { width: 148px; height: 148px; }
}

/* -- Players ------------------------------------------------------------- */

.g-roster { display: flex; flex-wrap: wrap; gap: 8px; }

.g-player {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-darkest);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 5px 12px 5px 8px;
  font-size: 0.9rem;
  color: var(--text-primary);
}
.g-player__avatar { font-size: 1.15rem; line-height: 1; }
.g-player__name { font-weight: 500; }
.g-player__tag {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-on-accent);
  background: var(--accent);
  border-radius: 999px;
  padding: 1px 7px;
}
/* Dimmed, never removed: a player who has gone quiet is still in the game,
   and dropping them off the roster is how a room loses track of someone who
   is simply answering a text. */
.g-player.is-away { opacity: 0.45; }

/* -- Team columns -------------------------------------------------------- */

.g-teams {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.g-team {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.g-team__name {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-subtle);
  margin: 0;
}
/* Reserved height, so a column does not jump as people join and leave. */
.g-team__players {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 72px;
}
.g-team__players .g-player { align-self: flex-start; }
.g-team__join { width: 100%; margin-top: auto; }

/* -- Avatar picker ------------------------------------------------------- */

.g-avatars {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  max-width: 340px;
}
@media (max-width: 420px) {
  .g-avatars { grid-template-columns: repeat(4, 1fr); }
}

.g-avatar {
  font-size: 1.35rem;
  line-height: 1;
  aspect-ratio: 1;
  background: var(--bg-darkest);
  border: 2px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  padding: 0;
  transition: border-color 0.15s, opacity 0.15s;
}
.g-avatar:hover:not([disabled]) { border-color: var(--text-subtle); }
.g-avatar[aria-pressed="true"] { border-color: var(--accent); }
/* Taken, not broken: still visible so you can see it is spoken for. */
.g-avatar[disabled] { opacity: 0.2; cursor: not-allowed; }

/* -- Text inputs --------------------------------------------------------- */

.g-input {
  width: 100%;
  background: var(--bg-darkest);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  color: var(--text-primary);
  /* 16px minimum: anything smaller makes iOS Safari zoom the page on focus,
     and it never zooms back out. */
  font-size: 16px;
  font-family: inherit;
  padding: 12px 14px;
}
.g-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.g-input--code {
  font-family: 'Courier Prime', 'SF Mono', Menlo, monospace;
  font-size: 1.6rem;
  letter-spacing: 0.24em;
  text-align: center;
  text-transform: uppercase;
}

/* -- Connection banner ---------------------------------------------------
   Only ever shown when something is actually wrong. Reserved space would be
   a permanent scar on a screen that is fine 99% of the time. */

.g-banner {
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.85rem;
  margin-bottom: 14px;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid var(--danger);
  color: var(--danger);
}

/* -- Utility ------------------------------------------------------------ */

.g-muted { color: var(--text-subtle); font-size: 0.85rem; }
.g-danger { color: var(--danger); }
.g-hidden { display: none !important; }

/* Visible to screen readers only — used for live-region announcements that
   would be redundant on screen (turn changes, reveal state). */
.g-sr {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
