/* ==========================================================================
   NOLA Games — global stylesheet
   Theme: antique parchment / gold / black. Tokens mirror the Figma theme.css
   so the whole site can be re-themed from the :root block alone.
   ========================================================================== */

/* ---- Design tokens ------------------------------------------------------- */
:root {
  --background: #f0deb8;
  --foreground: #1c1008;
  --card: #faf3df;
  --card-foreground: #1c1008;
  --primary: #9a7209;
  --primary-foreground: #faf3df;
  --secondary: #e4d09e;
  --muted: #ddc890;
  --muted-foreground: #7a6035;
  --accent: #6b500a;
  --destructive: #8b1a1a;
  --border: rgba(120, 88, 20, 0.22);
  --input-background: rgba(250, 243, 220, 0.85);

  /* Nav / footer use the dark "sidebar" tokens for black-and-gold contrast */
  --sidebar: #1c1008;
  --sidebar-foreground: #f0deb8;
  --sidebar-primary: #c8a840;        /* bright antique gold */
  --gold-bright: #c8a840;
  --gold-deep: #6b500a;

  /* Puzzle group difficulty colours (1=easiest .. 4=trickiest), muted to
     sit on the parchment theme. */
  --diff-1: #c9a227;
  --diff-2: #5c7a3f;
  --diff-3: #4a6d8c;
  --diff-4: #7a5a86;

  --radius: 0.625rem;
  --radius-sm: 0.4rem;
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;

  --font-heading: 'Playfair Display', Georgia, serif;
  --font-body: 'Lato', system-ui, sans-serif;
  --font-mono: 'DM Mono', ui-monospace, monospace;

  --maxw: 72rem;       /* 1152px content width */
}

/* ---- Reset --------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--foreground);
  line-height: 1.5;
  /* Fixed parchment texture — cross-hatch threads over a warm radial wash */
  background-color: var(--background);
  background-attachment: fixed;
  background-image:
    repeating-linear-gradient(-45deg,
      transparent 0px, transparent 3px,
      rgba(140, 100, 20, 0.04) 3px, rgba(140, 100, 20, 0.04) 4px),
    repeating-linear-gradient(45deg,
      transparent 0px, transparent 3px,
      rgba(140, 100, 20, 0.025) 3px, rgba(140, 100, 20, 0.025) 4px),
    radial-gradient(ellipse at 50% 40%,
      #f7e8c4 0%, #f0deb8 45%, #e6d0a0 100%);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  line-height: 1.2;
  font-weight: 800;
}

a { color: inherit; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--secondary); }
::-webkit-scrollbar-thumb {
  background: rgba(154, 114, 9, 0.35);
  border-radius: 3px;
}

/* ---- Layout shell -------------------------------------------------------- */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Subtle vignette across the whole viewport */
.page::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(ellipse at center,
    transparent 60%, rgba(100, 70, 10, 0.08) 100%);
}

.site-main {
  position: relative;
  z-index: 1;
  flex: 1;
}

.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: 1rem;
}

/* ---- Header / nav -------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--sidebar);
  border-bottom: 1px solid rgba(200, 168, 64, 0.25);
}

/* Gold hairline accents above and below the nav bar */
.site-header__top-rule {
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-bright), transparent);
}
.site-header__bottom-rule {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(200, 168, 64, 0.4), transparent);
}

.nav {
  height: 4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  text-decoration: none;
}
.brand__mark {
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--gold-bright), var(--primary));
  box-shadow: 0 2px 12px rgba(200, 168, 64, 0.35);
}
.brand__mark svg { width: 1.05rem; height: 1.05rem; }
.brand__name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: 0.04em;
  color: var(--sidebar-foreground);
}

.nav__links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav__link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  color: rgba(240, 222, 184, 0.7);
  transition: color .2s, background-color .2s;
}
.nav__link:hover {
  color: var(--sidebar-foreground);
  background: rgba(255, 255, 255, 0.05);
}
.nav__link.is-active {
  color: var(--sidebar-primary);
  background: rgba(200, 168, 64, 0.12);
}
.nav__link svg { width: 1rem; height: 1rem; }

/* Solid-gold "Sign In" call to action */
.nav__cta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--sidebar);
  background: linear-gradient(135deg, var(--gold-bright), var(--primary));
  box-shadow: 0 2px 10px rgba(200, 168, 64, 0.3);
  transition: filter .2s;
}
.nav__cta:hover { filter: brightness(1.07); }
.nav__cta svg { width: 1rem; height: 1rem; }

.nav__signout {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  color: rgba(240, 222, 184, 0.6);
  background: transparent;
  border: 0;
  transition: color .2s, background-color .2s;
}
.nav__signout:hover {
  color: var(--sidebar-foreground);
  background: rgba(255, 255, 255, 0.05);
}
.nav__signout svg { width: 1rem; height: 1rem; }

/* Mobile menu toggle */
.nav__toggle {
  display: none;
  padding: 0.5rem;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: rgba(240, 222, 184, 0.7);
}
.nav__toggle:hover { background: rgba(255, 255, 255, 0.05); }
.nav__toggle svg { width: 1.25rem; height: 1.25rem; display: block; }

.nav__mobile {
  display: none;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid rgba(200, 168, 64, 0.2);
  background: var(--sidebar);
}
.nav__mobile.is-open { display: flex; }

@media (max-width: 768px) {
  .nav__links { display: none; }
  .nav__toggle { display: block; }
}

/* ---- Footer -------------------------------------------------------------- */
.site-footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid rgba(120, 88, 20, 0.2);
  padding: 1.5rem 0;
  text-align: center;
}
.site-footer span {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  letter-spacing: 0.06em;
  color: #9a7835;
}

/* ---- Buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: 0;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  transition: filter .2s, opacity .2s;
}
.btn svg { width: 1rem; height: 1rem; }
.btn--primary {
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: 0 6px 18px rgba(154, 114, 9, 0.3);
}
.btn--primary:hover { filter: brightness(1.08); }
.btn--block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ---- Generic card -------------------------------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
}

/* ==========================================================================
   HOME — game grid
   ========================================================================== */
.home {
  max-width: var(--maxw);
  margin-inline: auto;
  padding: 3rem 1rem;
}
.home__head {
  text-align: center;
  margin-bottom: 3.5rem;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 1rem;
  margin-bottom: 1.5rem;
  border-radius: 999px;
  border: 1px solid rgba(154, 114, 9, 0.35);
  background: rgba(154, 114, 9, 0.08);
  color: var(--primary);
  font-size: 0.875rem;
  font-weight: 600;
}
.pill svg { width: 0.875rem; height: 0.875rem; }
.home__title {
  font-size: clamp(2.5rem, 6vw, 3.75rem);
  font-weight: 900;
  letter-spacing: -0.01em;
  margin-bottom: 1rem;
}
.home__title .accent {
  background: linear-gradient(135deg, var(--gold-bright), var(--gold-deep));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.home__sub {
  color: var(--muted-foreground);
  font-size: 1.125rem;
  max-width: 32rem;
  margin-inline: auto;
}

/* Tiles wrap and every row stays centred — up to 4 per row. A partial last
   row (or a grid of just 1-3 tiles) centres instead of left-aligning. */
.game-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.25rem;
}
.game-grid > * {
  flex: 0 0 calc(50% - 0.625rem);                  /* 2 per row (small screens) */
}
@media (min-width: 640px) {
  .game-grid > * { flex-basis: calc((100% - 2 * 1.25rem) / 3); }  /* 3 per row */
}
@media (min-width: 768px) {
  .game-grid > * { flex-basis: calc((100% - 3 * 1.25rem) / 4); }  /* 4 per row */
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}
/* Per-game colour values (8-digit hex incl. alpha) are set inline by home.js
   as the custom properties --c-border, --c-bg, --c-border-h, --c-bg-h,
   --c-glow and --c-ring. */
.tile__circle {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid var(--c-border, var(--border));
  background-color: var(--c-bg, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  transition: transform .3s, box-shadow .3s, border-color .3s, background-color .3s;
}
.tile:hover .tile__circle {
  transform: scale(1.05);
  border-color: var(--c-border-h, var(--primary));
  background-color: var(--c-bg-h, transparent);
  box-shadow: 0 4px 24px var(--c-glow, rgba(154, 114, 9, 0.3)),
              0 1px 8px rgba(0, 0, 0, 0.12);
}
.tile__icon { transition: transform .3s; }
.tile:hover .tile__icon { transform: scale(1.1); }
.tile__icon svg { display: block; }

/* Thin accent ring that fades in on hover */
.tile__ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid var(--c-ring, var(--primary));
  opacity: 0;
  transition: opacity .3s;
}
.tile:hover .tile__ring { opacity: 0.3; }

/* "Coming soon" lock overlay, revealed on hover */
.tile__lock {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(240, 222, 184, 0.6);
  backdrop-filter: blur(1px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity .2s;
  color: var(--c-ring, var(--primary));
}
.tile:hover .tile__lock { opacity: 1; }
.tile__lock svg { width: 1.25rem; height: 1.25rem; }
.tile__lock span {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
}
.tile__label { text-align: center; }
.tile__name {
  font-family: var(--font-heading);
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.2;
}
.tile__desc {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  margin-top: 0.125rem;
  line-height: 1.35;
}

/* ==========================================================================
   AUTH — login / register cards
   ========================================================================== */
.auth {
  min-height: calc(100vh - 8rem);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
}
.auth__box { width: 100%; max-width: 28rem; }
.auth__card { padding: 2rem; }
.auth__head {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 2rem;
  text-align: center;
}
.auth__badge {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}
.auth__badge svg { width: 1.75rem; height: 1.75rem; }
.auth__badge--primary {
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: 0 8px 20px rgba(154, 114, 9, 0.4);
}
.auth__badge--accent {
  background: var(--accent);
  color: var(--primary-foreground);
  box-shadow: 0 8px 20px rgba(107, 80, 10, 0.3);
}
.auth__title { font-size: 1.5rem; font-weight: 900; }
.auth__subtitle {
  color: var(--muted-foreground);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}
.auth__hint {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted-foreground);
  margin-top: 1rem;
}

/* ---- Forms --------------------------------------------------------------- */
.form { display: flex; flex-direction: column; gap: 1.25rem; }
.form--tight { gap: 1rem; }
.field { display: flex; flex-direction: column; gap: 0.375rem; }
.field__label {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--foreground);
}
.input {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--input-background);
  color: var(--foreground);
  font-size: 0.95rem;
  transition: border-color .2s, box-shadow .2s;
}
.input::placeholder { color: var(--muted-foreground); }
.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(154, 114, 9, 0.18);
}
.input:disabled { opacity: 0.5; cursor: not-allowed; }
select.input { cursor: pointer; }

/* Compact variant — inline table controls */
.input--sm { padding: 0.35rem 0.5rem; font-size: 0.82rem; width: auto; }

.field__pw { position: relative; }
.field__pw .input { padding-right: 3rem; }
.field__pw-toggle {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--muted-foreground);
  display: flex;
}
.field__pw-toggle:hover { color: var(--foreground); }
.field__pw-toggle svg { width: 1rem; height: 1rem; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
}
.alert--error {
  background: rgba(139, 26, 26, 0.1);
  border: 1px solid rgba(139, 26, 26, 0.25);
  color: var(--destructive);
}

.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.5rem 0;
}
.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.divider span {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

.auth__switch {
  text-align: center;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}
.link {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}
.link:hover { text-decoration: underline; }

.spinner {
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid rgba(250, 243, 220, 0.3);
  border-top-color: var(--primary-foreground);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Avatar -------------------------------------------------------------- */
.avatar {
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
  overflow: hidden;
}

/* ==========================================================================
   HIGH SCORES
   ========================================================================== */
.scores { max-width: 64rem; margin-inline: auto; padding: 3rem 1rem; }
.scores__head {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2.5rem;
}
.scores__icon {
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(200, 168, 64, 0.12);
  border: 1px solid rgba(200, 168, 64, 0.3);
  color: var(--primary);
}
.scores__icon svg { width: 1.5rem; height: 1.5rem; }
.scores__title { font-size: 1.875rem; font-weight: 900; }
.scores__caption { color: var(--muted-foreground); font-size: 0.875rem; }

.scores__layout {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
}
@media (min-width: 768px) {
  .scores__layout { grid-template-columns: 220px 1fr; }
}

.game-picker { padding: 0.75rem; height: fit-content; }
.game-picker__label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted-foreground);
  padding: 0 0.5rem;
  margin-bottom: 0.5rem;
}
.game-picker__list { display: flex; flex-direction: column; gap: 0.125rem; }
.game-picker__item {
  text-align: left;
  padding: 0.625rem 0.75rem;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted-foreground);
  transition: color .15s, background-color .15s;
}
.game-picker__item:hover {
  color: var(--foreground);
  background: rgba(120, 88, 20, 0.07);
}
.game-picker__item.is-active {
  background: rgba(154, 114, 9, 0.15);
  color: var(--primary);
}

.scores__panel { display: flex; flex-direction: column; gap: 1rem; }

.tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.375rem;
  width: fit-content;
}
.tab {
  padding: 0.5rem 1.25rem;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--muted-foreground);
  transition: color .2s, background-color .2s;
}
.tab:hover { color: var(--foreground); }
.tab.is-active {
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: 0 4px 12px rgba(154, 114, 9, 0.3);
}

.board { overflow: hidden; padding: 0; }
.board__row {
  display: grid;
  grid-template-columns: 40px 1fr auto auto;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.5rem;
}
.board__row--head {
  padding-block: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.board__row + .board__row { border-top: 1px solid rgba(120, 88, 20, 0.12); }
.board__row--top { background: rgba(200, 168, 64, 0.07); }
.board__th {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted-foreground);
}
.board__th--right, .board__loc, .board__score { text-align: right; }
.board__rank {
  display: flex;
  align-items: center;
  justify-content: center;
}
.board__rank svg { width: 1.25rem; height: 1.25rem; }
.board__rank-num {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}
.board__player {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}
.board__names { display: flex; flex-direction: column; min-width: 0; }
.board__name {
  font-weight: 700;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.board__handle {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted-foreground);
}
.board__loc {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted-foreground);
}
.board__score {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}
.scores__note {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted-foreground);
  text-align: center;
}
@media (max-width: 640px) {
  .board__row { grid-template-columns: 32px 1fr auto; }
  .board__loc { display: none; }
}

/* ==========================================================================
   PROFILE
   ========================================================================== */
.profile { max-width: 48rem; margin-inline: auto; padding: 3rem 1rem; }

.profile__header {
  position: relative;
  overflow: hidden;
  padding: 2rem;
  margin-bottom: 1.5rem;
}
.profile__banner {
  position: absolute;
  inset: 0 0 auto 0;
  height: 6rem;
  opacity: 0.2;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold-deep));
}
.profile__header-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.5rem;
}
@media (min-width: 640px) {
  .profile__header-inner { flex-direction: row; align-items: center; }
}

.avatar-btn {
  position: relative;
  border: 0;
  padding: 0;
  background: transparent;
  border-radius: 50%;
  flex-shrink: 0;
}
.avatar-btn__overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .2s;
}
.avatar-btn:hover .avatar-btn__overlay { opacity: 1; }
.avatar-btn__overlay svg { width: 1.5rem; height: 1.5rem; color: #fff; }
.avatar-remove {
  position: absolute;
  bottom: -0.25rem;
  right: -0.25rem;
  width: 1.5rem;
  height: 1.5rem;
  border: 0;
  border-radius: 50%;
  background: var(--destructive);
  color: #fff;
  font-weight: 700;
  font-size: 0.875rem;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.profile__info { flex: 1; min-width: 0; }
.profile__name { font-size: 1.5rem; font-weight: 900; }
.profile__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.375rem;
}
.profile__meta span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}
.profile__meta svg { width: 0.875rem; height: 0.875rem; }
.profile__meta .mono { font-family: var(--font-mono); }
.profile__photo-link {
  margin-top: 0.5rem;
  border: 0;
  background: transparent;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
}
.profile__photo-link:hover { text-decoration: underline; }

.profile__edit-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 700;
  border: 1px solid rgba(154, 114, 9, 0.2);
  background: rgba(154, 114, 9, 0.1);
  color: var(--primary);
  flex-shrink: 0;
}
.profile__edit-btn svg { width: 1rem; height: 1rem; }
.profile__edit-btn.is-editing {
  background: var(--muted);
  color: var(--muted-foreground);
  border-color: transparent;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
@media (min-width: 768px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { padding: 1.25rem; text-align: center; }
.stat__value { font-size: 1.5rem; font-weight: 900; }
.stat__value.mono { font-family: var(--font-mono); }
.stat__label {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  margin-top: 0.25rem;
}

.panel { padding: 2rem; }
.panel__title { font-size: 1.125rem; font-weight: 800; }
.panel__caption {
  color: var(--muted-foreground);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.activity { display: flex; flex-direction: column; margin-top: 1.5rem; }
.activity__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
}
.activity__row + .activity__row {
  border-top: 1px solid rgba(120, 88, 20, 0.12);
}
.activity__game { font-size: 0.875rem; font-weight: 700; }
.activity__date { font-size: 0.75rem; color: var(--muted-foreground); }
.activity__score {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.875rem;
  text-align: right;
}
.activity__rank {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted-foreground);
  text-align: right;
}

.profile__empty {
  min-height: calc(100vh - 8rem);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  text-align: center;
}
.profile__empty-inner { max-width: 24rem; }
.profile__empty h2 {
  font-size: 1.5rem;
  font-weight: 900;
  margin: 1.5rem 0 0.75rem;
}
.profile__empty p {
  color: var(--muted-foreground);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

.saved-msg {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1c3a20;
}

.is-hidden { display: none !important; }
.mt-1 { margin-top: 0.5rem; }

/* ---- Flash messages ------------------------------------------------------ */
.flash {
  margin: 1rem 0 0;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid;
}
.flash--info {
  background: rgba(154, 114, 9, 0.1);
  border-color: rgba(154, 114, 9, 0.3);
  color: var(--accent);
}
.flash--success {
  background: rgba(28, 58, 32, 0.1);
  border-color: rgba(28, 58, 32, 0.3);
  color: #1c3a20;
}
.flash--error {
  background: rgba(139, 26, 26, 0.1);
  border-color: rgba(139, 26, 26, 0.25);
  color: var(--destructive);
}

/* File input styled to match other form controls */
input[type="file"].input { padding: 0.55rem 0.75rem; cursor: pointer; }

/* ==========================================================================
   ADMIN
   ========================================================================== */
.admin { max-width: 64rem; margin-inline: auto; padding: 3rem 1rem; }

.admin__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.admin__title { font-size: 1.875rem; font-weight: 900; }
.admin-muted { color: var(--muted-foreground); font-size: 0.85rem; }

/* Dashboard stat cards double as links */
a.stat { text-decoration: none; transition: border-color .15s, transform .15s; }
a.stat:hover { border-color: rgba(154, 114, 9, 0.45); transform: translateY(-2px); }

/* ---- Button variants ----------------------------------------------------- */
.btn--ghost {
  background: transparent;
  color: var(--foreground);
  border: 1px solid var(--border);
}
.btn--ghost:hover { background: rgba(120, 88, 20, 0.07); }
.btn--danger {
  background: transparent;
  color: var(--destructive);
  border: 1px solid rgba(139, 26, 26, 0.35);
}
.btn--danger:hover { background: rgba(139, 26, 26, 0.1); }
.btn--sm {
  padding: 0.45rem 0.85rem;
  font-size: 0.82rem;
}

/* ---- Tables -------------------------------------------------------------- */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.admin-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted-foreground);
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.admin-table td {
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid rgba(120, 88, 20, 0.12);
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table .mono { font-family: var(--font-mono); }

/* ---- Chips --------------------------------------------------------------- */
.chip {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: var(--font-mono);
  background: var(--secondary);
  color: var(--accent);
}
.chip--twist {
  background: rgba(122, 90, 134, 0.18);
  color: #6a4a76;
  margin-left: 0.35rem;
}

/* ---- Category checkbox grid ---------------------------------------------- */
.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 0.4rem 1rem;
  max-height: 16rem;
  overflow-y: auto;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--input-background);
}
.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
}
.check input { width: 1rem; height: 1rem; accent-color: var(--primary); }

/* ---- Puzzle builder ------------------------------------------------------ */
.builder__group {
  border-left: 5px solid var(--diff-1);
}
.builder__group--1 { border-left-color: var(--diff-1); }
.builder__group--2 { border-left-color: var(--diff-2); }
.builder__group--3 { border-left-color: var(--diff-3); }
.builder__group--4 { border-left-color: var(--diff-4); }

.builder__clues {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
@media (max-width: 560px) {
  .builder__clues { grid-template-columns: 1fr; }
}

.diff-dot {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  margin-right: 0.4rem;
  vertical-align: middle;
}
.diff-dot--1 { background: var(--diff-1); }
.diff-dot--2 { background: var(--diff-2); }
.diff-dot--3 { background: var(--diff-3); }
.diff-dot--4 { background: var(--diff-4); }

/* Stack admin form rows that were laid out inline on small screens */
@media (max-width: 560px) {
  .admin__bar { flex-direction: column; align-items: flex-start; }
}

/* ---- Games hub ----------------------------------------------------------- */
.game-hub-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.game-hub-card__info { flex: 1; min-width: 14rem; }
.game-hub-card__info .panel__title { margin-bottom: 0.15rem; }
.game-hub-card__info .panel__caption { margin-bottom: 0.5rem; }
.game-hub-card__actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ==========================================================================
   CONNECTIONS GAME
   ========================================================================== */
.cx {
  max-width: 34rem;
  margin-inline: auto;
  padding: 2.5rem 1rem 3.5rem;
}
.cx__head { text-align: center; margin-bottom: 1.5rem; }
.cx__title { font-size: 2.25rem; font-weight: 900; }
.cx__sub { color: var(--muted-foreground); margin-top: 0.35rem; }

.cx__test-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  background: var(--sidebar);
  color: var(--sidebar-primary);
  font-family: var(--font-mono);
  font-size: 0.82rem;
}
.cx__test-banner a { color: var(--sidebar-foreground); font-weight: 700; }

.cx__notice { padding: 2rem; text-align: center; }

.cx__board { display: flex; flex-direction: column; gap: 1rem; }

/* ---- Solved / revealed group rows --------------------------------------- */
.cx__solved { display: flex; flex-direction: column; gap: 0.6rem; }
.cx-group {
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  text-align: center;
  color: #fff;
  animation: cx-pop 0.3s ease;
}
.cx-group--1 { background: var(--diff-1); color: #2a1e06; }
.cx-group--2 { background: var(--diff-2); }
.cx-group--3 { background: var(--diff-3); }
.cx-group--4 { background: var(--diff-4); }
.cx-group__cat {
  font-family: var(--font-heading);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 0.95rem;
}
.cx-group__clues { font-size: 0.85rem; margin-top: 0.15rem; opacity: 0.95; }
@keyframes cx-pop {
  from { transform: scale(0.96); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ---- The 4x4 tile grid -------------------------------------------------- */
.cx__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
}
.cx-tile {
  min-height: 4.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.4rem 0.3rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--foreground);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.8rem;
  line-height: 1.2;
  cursor: pointer;
  transition: transform .1s, background-color .15s, color .15s;
}
.cx-tile:hover { border-color: rgba(154, 114, 9, 0.5); }
.cx-tile.is-selected {
  background: var(--foreground);
  color: var(--card);
  border-color: var(--foreground);
  transform: scale(0.97);
}
.cx-tile.cx-shake { animation: cx-shake 0.45s ease; }
@keyframes cx-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* ---- Mistakes, message, controls ---------------------------------------- */
.cx__mistakes {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  color: var(--muted-foreground);
  font-size: 0.9rem;
}
.cx__dots { display: inline-flex; gap: 0.4rem; }
.cx-dot {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  background: var(--foreground);
  transition: background-color .2s, transform .2s;
}
.cx-dot--used { background: var(--border); transform: scale(0.8); }

.cx__msg {
  align-self: center;
  padding: 0.5rem 1.25rem;
  border-radius: 999px;
  background: var(--foreground);
  color: var(--card);
  font-weight: 700;
  font-size: 0.9rem;
}

.cx__controls {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.cx__end { text-align: center; padding-top: 0.5rem; }
.cx__end-title { font-size: 1.75rem; font-weight: 900; }
.cx__end-sub {
  color: var(--muted-foreground);
  margin: 0.4rem 0 1.25rem;
}
