:root {
  --purple: #6d3df2;
  --purple-700: #5428d6;
  --purple-50: #f1ecff;
  --ink: #17122b;
  --muted: #6a6483;
  --line: #e6e2f3;
  --bg: #f7f5fc;
  --card: #ffffff;
  --radius: 16px;
  --radius-lg: 24px;
  --shadow: 0 4px 12px rgba(23, 18, 43, 0.08), 0 12px 32px rgba(23, 18, 43, 0.08);
  --font-display: var(--font-display);
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
a { color: var(--purple-700); font-weight: 600; text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

.material-symbols-rounded {
  font-variation-settings: "FILL" 1, "wght" 500, "GRAD" 0, "opsz" 24;
  font-size: 22px;
  line-height: 1;
  user-select: none;
}

/* ---------- Header ---------- */

.topnav {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--rx-sm, 12px);
  background: var(--purple);
  color: #fff;
}

.hero {
  max-width: 1080px;
  margin: 0 auto;
  padding: 40px 20px 24px;
}
.hero h1 { font-size: clamp(34px, 6vw, 56px); font-weight: 800; max-width: 14ch; }
.hero p { color: var(--muted); font-size: 18px; max-width: 46ch; margin: 14px 0 0; }

/* ---------- Game grid ---------- */

main { max-width: 1080px; margin: 0 auto; padding: 8px 20px 48px; }
.section-title { font-size: 26px; font-weight: 700; margin: 24px 0 16px; }

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: 20px;
}

.game-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  color: inherit;
  font-weight: 400;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
a.game-card:hover { transform: translateY(-3px); text-decoration: none; }
.game-card-img { aspect-ratio: 16 / 10; width: 100%; object-fit: cover; display: block; background: var(--purple-50); }
.game-card-body { padding: 18px 20px 22px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.game-card h3 { font-size: 22px; font-weight: 700; }
.game-card p { margin: 0; color: var(--muted); font-size: 15px; }
.game-card-cta { margin-top: auto; padding-top: 12px; color: var(--purple-700); font-weight: 700; font-family: var(--font-display); }
.game-card.coming-soon { opacity: 0.7; }

/* ---------- Buttons / mode picker ---------- */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 22px;
  border: 1px solid var(--line);
  border-radius: var(--pill, 999px);
  background: var(--card);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.mode-hero {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 20px 8px;
  display: flex;
  gap: 20px;
  align-items: center;
}
.mode-hero img { width: 140px; height: 100px; object-fit: cover; border-radius: var(--radius); box-shadow: var(--shadow); }
.mode-hero h1 { font-size: clamp(28px, 5vw, 44px); font-weight: 800; }
.mode-hero p { margin: 6px 0 0; color: var(--muted); }
.back-link { display: inline-flex; align-items: center; gap: 4px; margin: 4px 0; }

.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
  gap: 20px;
}
.mode-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 24px;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  color: inherit;
  font-weight: 400;
}
a.mode-card:hover { text-decoration: none; transform: translateY(-3px); }
.mode-card .mode-icon {
  display: grid; place-items: center; width: 52px; height: 52px;
  border-radius: var(--rx-lg, 16px); background: var(--purple-50); color: var(--purple-700);
}
.mode-card .mode-icon .material-symbols-rounded { font-size: 28px; }
.mode-card h3 { font-size: 22px; }
.mode-card p { margin: 0; color: var(--muted); font-size: 15px; }
.mode-card.disabled { opacity: 0.6; cursor: not-allowed; }
.badge {
  align-self: flex-start;
  padding: 3px 10px;
  border-radius: var(--pill, 999px);
  background: var(--purple-50);
  color: var(--purple-700);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.site-footer { text-align: center; color: var(--muted); font-size: 14px; padding: 32px 20px 48px; }

/* ---------- Accounts ---------- */

.topnav { gap: 12px; }
.btn-small { min-height: 38px; padding: 8px 16px; font-size: 14px; text-decoration: none; }
.btn-primary { background: var(--purple); border-color: var(--purple); color: #fff; }
.btn-primary:hover { background: var(--purple-700); text-decoration: none; }
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.btn-block { display: flex; width: 100%; }
.muted { color: var(--muted); }

.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  overflow: hidden;
  border-radius: 50%;
  background: var(--purple);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-sm { width: 40px; height: 40px; font-size: 18px; }
.avatar-lg { width: 112px; height: 112px; font-size: 48px; }

.account-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 4px 14px;
  border-radius: var(--pill, 999px);
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 600;
}
.account-chip:hover { text-decoration: none; box-shadow: var(--shadow); }
.account-chip-text { display: grid; gap: 1px; min-width: 96px; }
.account-chip-level { font-family: var(--font-display); font-size: 14px; font-weight: 700; line-height: 1.1; }
.account-chip-xp { font-size: 11px; color: var(--muted); font-weight: 500; line-height: 1.1; }

.xp-bar { height: 10px; border-radius: var(--pill, 999px); background: var(--purple-50); overflow: hidden; }
.xp-bar > span { display: block; height: 100%; border-radius: inherit; background: var(--purple); transition: width 0.4s ease; }
.xp-bar-mini { height: 5px; margin-top: 2px; }

main.narrow { max-width: 640px; }
.panel {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.panel h1 { font-size: 30px; margin-bottom: 16px; }
.panel h2 { font-size: 20px; margin-bottom: 12px; }

form label { display: block; margin-bottom: 14px; font-weight: 600; font-size: 14px; }
form input[type=text], form input[type=email], form input[type=password] {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--rx-sm, 12px);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}
form textarea, form select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--rx-sm, 12px);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}
form textarea { resize: vertical; min-height: 140px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
form textarea:focus, form select:focus { outline: 2px solid var(--purple); outline-offset: 1px; border-color: transparent; }
form input:focus { outline: 2px solid var(--purple); outline-offset: 1px; border-color: transparent; }
.hint-text { display: block; margin-top: 4px; font-weight: 400; color: var(--muted); }
.hint-text.ok, .form-error.ok { color: #1b8a4b; }
.hint-text.bad { color: #d23a3a; }
.form-error { min-height: 1.4em; margin: 0 0 12px; color: #d23a3a; font-size: 14px; }
.form-links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 16px 0 0; font-size: 14px; }
.guest-note { text-align: center; color: var(--muted); font-size: 14px; margin: 20px 0 0; }
.notice { background: var(--purple-50); border-radius: var(--rx-sm, 12px); padding: 12px 14px; }

.profile-head { display: flex; gap: 24px; align-items: center; }
.avatar-edit { display: grid; gap: 12px; justify-items: center; }
.profile-id { flex: 1; min-width: 0; }
.profile-id h1 { font-size: 28px; margin: 0; overflow-wrap: anywhere; }
.profile-id p { margin: 2px 0 10px; overflow-wrap: anywhere; }
.level-row { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 8px; }
.level-badge { background: var(--purple); color: #fff; font-family: var(--font-display); font-weight: 700; padding: 2px 12px; border-radius: var(--pill, 999px); }
@media (max-width: 520px) { .profile-head { flex-direction: column; text-align: center; } .level-row { justify-content: center; } }

.table-wrap { overflow-x: auto; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-tile { display: grid; gap: 2px; padding: 14px 16px; border-radius: var(--radius); background: var(--bg); }
.stat-tile strong { font-size: 26px; line-height: 1.2; }
.stat-tile span { font-size: 13px; color: var(--muted); }
.stats-games { display: grid; gap: 8px; }
.stats-game { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.stats-game summary { display: flex; align-items: center; gap: 12px; padding: 12px 16px; cursor: pointer; list-style: none; font-weight: 600; }
.stats-game summary::-webkit-details-marker { display: none; }
.stats-game summary::before { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform 0.15s; flex: none; }
.stats-game[open] summary::before { transform: rotate(45deg); }
.stats-game-name { flex: 1; }
.stats-game-count { font-size: 13px; font-weight: 400; color: var(--muted); }
.stats-game .table-wrap { padding: 0 16px 8px; }
.stats-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.stats-table th, .stats-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.stats-table th { color: var(--muted); font-size: 13px; font-weight: 600; }

.achievements { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.achievement { display: grid; gap: 4px; justify-items: center; text-align: center; padding: 14px 10px; border-radius: var(--radius); background: var(--bg); color: var(--muted); }
.achievement.unlocked { background: var(--purple-50); color: var(--ink); }
.achievement .material-symbols-rounded { font-size: 32px; }
.achievement.unlocked .material-symbols-rounded { color: var(--purple); }
.achievement small { font-size: 12px; color: var(--muted); }

/* narrow screens: keep the brand on one line and the account chip inside the viewport */
.brand { white-space: nowrap; }
#account-widget { min-width: 0; }
@media (max-width: 560px) {
  .topnav { padding-left: 14px; padding-right: 14px; }
  .brand { font-size: 18px; gap: 8px; }
  .brand-mark { width: 32px; height: 32px; border-radius: var(--rx-sm, 10px); }
  .account-chip { gap: 8px; padding-left: 10px; }
  .account-chip-text { min-width: 72px; }
}
@media (max-width: 340px) {
  .brand-text { display: none; }
}

/* ---------- Friends ---------- */

.account-chip { position: relative; }
.chip-badge {
  position: absolute; top: -6px; right: -4px;
  min-width: 20px; height: 20px; padding: 0 5px;
  display: grid; place-items: center;
  border-radius: var(--pill, 999px); background: #e5484d; color: #fff;
  font-size: 12px; font-weight: 700; line-height: 1;
  border: 2px solid var(--bg);
}

#toasts { position: fixed; z-index: 3000; right: 16px; bottom: 16px; left: 16px; display: grid; gap: 8px; justify-items: end; pointer-events: none; }
.toast {
  pointer-events: auto; max-width: 360px; padding: 12px 16px;
  background: var(--ink); color: #fff; border-radius: var(--rx-sm, 14px);
  box-shadow: var(--shadow); font-size: 14px; font-weight: 500;
}
a.toast:hover { text-decoration: none; background: #2a2347; }

.friend-search { position: relative; display: flex; gap: 8px; margin-bottom: 16px; }
.friend-search input[type=search] {
  flex: 1;
  width: 100%;
  margin-top: 0 !important;
  padding: 16px 18px 16px 52px;
  min-height: 56px;
  border-radius: 999px;
  font-size: 17px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.friend-search input[type=search]:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 4px rgba(124, 92, 255, 0.18); }
.friend-search-icon { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); font-size: 24px; color: var(--muted); pointer-events: none; }
.people { list-style: none; margin: 0 0 12px; padding: 0; }
.people li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.people li:last-child { border-bottom: 0; }
.person-name { flex: 1; min-width: 0; display: grid; }
.person-name strong { overflow: hidden; text-overflow: ellipsis; }
.person-name small { color: var(--muted); }
.person-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.btn-ghost { background: transparent; }
.btn-danger { color: #d23a3a; border-color: #f0c9c9; }
.avatar-xs { width: 36px; height: 36px; font-size: 16px; }
.subhead { font-size: 14px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 18px 0 4px; }
.subhead:first-of-type { margin-top: 4px; }
.count-pill { display: inline-block; min-width: 22px; padding: 0 7px; margin-left: 6px; border-radius: var(--pill, 999px); background: var(--purple); color: #fff; font-size: 12px; text-align: center; vertical-align: middle; }
.invite-box { display: flex; gap: 8px; margin-top: 10px; }
.invite-box input { margin-top: 0 !important; font-size: 14px !important; }

.invite-panel #inviter-avatar { margin-bottom: 16px; }
.invite-panel .btn { margin-top: 8px; }

/* ---------- Battle options on game menus ---------- */

.mode-button { appearance: none; border: 0; font: inherit; text-align: left; cursor: pointer; width: 100%; }
.mode-button[aria-expanded="true"] { outline: 2px solid var(--purple); }
.battle-options { margin-top: 28px; }
.battle-options .notice { margin: 0 0 16px; }

/* ---------- Home page: category rows and favourites ---------- */

.category { margin: 8px 0 28px; }
.category-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.category-title { font-size: 24px; font-weight: 700; }
.category-blurb { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.row-nav { display: flex; gap: 8px; }
.row-nav[hidden] { display: none; }
.row-arrow {
  appearance: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer;
}
.row-arrow:hover:not(:disabled) { background: var(--purple-50); }
.row-arrow:disabled { opacity: 0.35; cursor: default; }
@media (hover: none) { .row-nav { display: none; } }

.row-scroller {
  display: flex; gap: 16px; overflow-x: auto; padding: 4px 4px 14px; margin: 0 -4px;
  scroll-snap-type: x proximity; scroll-padding: 0 4px; -webkit-overflow-scrolling: touch;
}
.row-scroller:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; border-radius: var(--rx-sm, 12px); }
.row-scroller .game-card { flex: 0 0 min(290px, 80vw); scroll-snap-align: start; }
.row-empty { margin: 0; padding: 20px 4px; color: var(--muted); }

.game-card { position: relative; }
.game-card-link { color: inherit; font: inherit; }
.game-card-link:hover { text-decoration: none; }
.game-card-link::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius-lg); }
.game-card-link:focus-visible { outline: none; }
.game-card-link:focus-visible::after { outline: 3px solid var(--purple); outline-offset: 2px; }
.game-card:hover { transform: translateY(-3px); }

.heart {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  appearance: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: rgba(255, 255, 255, 0.92); color: #e5484d; cursor: pointer;
  box-shadow: 0 2px 8px rgba(23, 18, 43, 0.25);
}
.heart:hover { background: #fff; transform: scale(1.06); }
.heart:disabled { opacity: 0.6; cursor: default; }
.heart .heart-off { font-variation-settings: "FILL" 0, "wght" 500, "GRAD" 0, "opsz" 24; color: var(--muted); }

/* GuesserGod logo in the header (it brings its own rounded background) */
.brand-mark-logo { background: none; border-radius: 0; overflow: visible; }
.brand-mark-logo img { width: 100%; height: 100%; display: block; }
