/* ==========================================================================
   Lexic Quest design system
   One stylesheet for every page. Mobile first; desktop adds the side panels.
   ========================================================================== */

/* ---------- Tokens ---------- */

:root {
  color-scheme: dark;

  --bg: #0a0b26;
  --bg-elev: #0d0f2e;
  --surface: #15183f;
  --surface-2: #1c2050;
  --surface-3: #252a62;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #ffffff;
  --text-muted: #a8acd8;
  --text-faint: #6f74a8;

  --primary: #6c4df6;
  --primary-hover: #7b5ff8;
  --primary-soft: rgba(108, 77, 246, 0.18);
  --primary-text: #b9a8ff;
  --gradient: linear-gradient(100deg, #5a3ff0 0%, #7d55f5 100%);

  --orange: #f7931a;
  --green: #22c55e;
  --green-text: #34d873;
  --yellow: #f5c63c;
  --red: #ef4444;

  --tile: #2c3054;
  --tile-hover: #363b66;
  --tile-text: #ffffff;
  --tile-clue: #312a72;
  --tile-clue-text: #ffffff;

  --gold-bg: linear-gradient(100deg, #f7c843, #f2b92a);
  --gold-text: #2a1d00;
  --silver-bg: #262a52;
  --silver-ring: #9ea3c4;
  --bronze-bg: #5a3c2a;
  --bronze-ring: #d08c55;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-primary: 0 12px 32px rgba(92, 64, 240, 0.35);

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 26px;

  --font: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Outfit", "Nunito", system-ui, sans-serif;

  --left-w: 260px;
  --left-w-collapsed: 84px;
  --right-w: 400px;
  --tabbar-h: 64px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

:root[data-theme="light"] {
  color-scheme: light;

  --bg: #f3f3fb;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #eef0fa;
  --surface-3: #e2e5f6;
  --border: rgba(24, 26, 74, 0.09);
  --border-strong: rgba(24, 26, 74, 0.16);
  --text: #14163a;
  --text-muted: #555a86;
  --text-faint: #8a8fb5;

  --primary-soft: rgba(108, 77, 246, 0.12);
  --primary-text: #5b3fe0;

  --green-text: #15a34a;

  --tile: #e3e6f5;
  --tile-hover: #d6daf0;
  --tile-text: #14163a;
  --tile-clue: #dcd5ff;
  --tile-clue-text: #2a1d7a;

  --silver-bg: #eceef8;
  --silver-ring: #8d92b5;
  --bronze-bg: #f6e3d4;
  --bronze-ring: #c27a43;

  --shadow-sm: 0 1px 2px rgba(20, 22, 60, 0.08);
  --shadow: 0 10px 30px rgba(20, 22, 60, 0.12);
  --shadow-primary: 0 12px 28px rgba(92, 64, 240, 0.28);
}

/* ---------- Base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img,
video {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 0;
  background: none;
  padding: 0;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: var(--font-display);
  line-height: 1.15;
  letter-spacing: -0.01em;
}

p {
  margin: 0;
}

:focus-visible {
  outline: 2px solid var(--primary-text);
  outline-offset: 2px;
}

::selection {
  background: var(--primary);
  color: #fff;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.muted {
  color: var(--text-muted);
}

.tabular {
  font-variant-numeric: tabular-nums;
}

/* ---------- App shell ---------- */

.app {
  min-height: 100vh;
  min-height: 100svh;
  padding-bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom));
}

.main {
  min-width: 0;
  padding: 18px 16px 24px;
}

.main-inner {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
}

/* Mobile top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.topbar .logo img {
  width: auto;
  height: 22px;
}

/* Logo variants: white text on dark, dark text on light */
.logo-on-light,
:root[data-theme="light"] .logo-on-dark {
  display: none !important;
}

:root[data-theme="light"] .logo-on-light {
  display: block !important;
}

@media (min-width: 900px) {
  html.left-collapsed .sidebar .logo .logo-on-light,
  html.left-collapsed .sidebar .logo .logo-on-dark {
    display: none !important;
  }
}

.topbar-actions {
  display: flex;
  gap: 6px;
}

/* Mobile bottom tab bar */
.tabbar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg-elev);
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
}

.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-faint);
  transition: color 0.15s;
}

.tabbar a i {
  font-size: 19px;
}

.tabbar a[aria-current="page"] {
  color: var(--primary-text);
}

/* Desktop sidebar: hidden on mobile */
.sidebar {
  display: none;
}

/* Right panel: stacks under the content on mobile */
.aside {
  padding: 0 16px 24px;
}

.aside-inner {
  max-width: 820px;
  margin: 0 auto;
}

.panel-handle {
  display: none;
}

/* ---------- Desktop layout ---------- */

@media (min-width: 900px) {
  .topbar,
  .tabbar {
    display: none;
  }

  .app {
    display: grid;
    padding-bottom: 0;
    grid-template-columns: var(--left-w) minmax(0, 1fr) var(--right-w);
    transition: grid-template-columns 0.28s var(--ease);
  }

  .app.no-aside {
    grid-template-columns: var(--left-w) minmax(0, 1fr);
  }

  html.left-collapsed .app {
    grid-template-columns: var(--left-w-collapsed) minmax(0, 1fr) var(--right-w);
  }

  html.left-collapsed .app.no-aside {
    grid-template-columns: var(--left-w-collapsed) minmax(0, 1fr);
  }

  html.right-collapsed .app:not(.no-aside) {
    grid-template-columns: var(--left-w) minmax(0, 1fr) 0px;
  }

  html.left-collapsed.right-collapsed .app:not(.no-aside) {
    grid-template-columns: var(--left-w-collapsed) minmax(0, 1fr) 0px;
  }

  .main {
    padding: 36px clamp(20px, 4vw, 56px) 48px;
  }

  /* Sidebar */
  .sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100svh;
    display: flex;
    flex-direction: column;
    padding: 30px 18px 24px;
    border-right: 1px solid var(--border);
    background: var(--bg-elev);
    z-index: 20;
  }

  .sidebar .logo {
    display: block;
    padding: 6px 10px 34px;
  }

  .sidebar .logo img {
    width: 100%;
    max-width: 200px;
    height: auto;
  }

  .sidebar .logo .logo-mark {
    display: none;
    width: 44px;
    height: 44px;
    border-radius: 12px;
  }

  .nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .nav a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 16px;
    height: 54px;
    padding: 0 20px;
    border-radius: var(--radius);
    font-size: 17px;
    font-weight: 700;
    color: var(--text-muted);
    transition: background 0.15s, color 0.15s;
  }

  .nav a i {
    width: 24px;
    font-size: 20px;
    text-align: center;
  }

  .nav a:hover {
    background: var(--surface);
    color: var(--text);
  }

  .nav a[aria-current="page"] {
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-primary);
  }

  .sidebar-divider {
    height: 1px;
    margin: 22px 8px;
    background: var(--border);
  }

  /* Buy Me a Coffee button (an icon in the collapsed rail) */
  .coffee-link {
    position: relative;
    display: block;
    padding: 0 6px;
    border-radius: 12px;
    transition: transform 0.18s var(--ease), filter 0.18s;
  }

  .coffee-link img {
    display: block;
    width: 100%;
    max-width: 210px;
    height: auto;
  }

  .coffee-link i {
    display: none;
  }

  .coffee-link:hover {
    transform: translateY(-2px);
    filter: brightness(1.08);
  }

  html.left-collapsed .coffee-link {
    display: grid;
    place-items: center;
    height: 54px;
    padding: 0;
    border-radius: var(--radius);
    color: var(--yellow);
    font-size: 20px;
  }

  html.left-collapsed .coffee-link img {
    display: none;
  }

  html.left-collapsed .coffee-link i {
    display: block;
  }

  html.left-collapsed .coffee-link:hover {
    background: var(--surface);
    transform: none;
    filter: none;
  }

  .sidebar-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 6px;
  }

  /* Collapsed sidebar: an icon rail with hover labels */
  html.left-collapsed .sidebar {
    padding-left: 14px;
    padding-right: 14px;
  }

  html.left-collapsed .sidebar .logo {
    padding: 0 0 30px;
    display: flex;
    justify-content: center;
  }

  html.left-collapsed .sidebar .logo .logo-full {
    display: none;
  }

  html.left-collapsed .sidebar .logo .logo-mark {
    display: block;
  }

  html.left-collapsed .nav a {
    justify-content: center;
    padding: 0;
  }

  html.left-collapsed .nav a span {
    display: none;
  }

  html.left-collapsed .sidebar-footer {
    flex-direction: column;
    padding: 0;
  }

  html.left-collapsed [data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    padding: 6px 10px;
    border-radius: 8px;
    background: var(--surface-3);
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: var(--shadow);
    pointer-events: none;
    z-index: 50;
  }

  /* Right panel */
  .aside {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100svh;
    margin: 0;
    padding: 0;
    border-left: 1px solid var(--border);
    z-index: 15;
  }

  .aside-scroll {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    transition: opacity 0.2s;
  }

  .aside-inner {
    width: var(--right-w);
    max-width: none;
    padding: 36px 26px 32px;
  }

  html.right-collapsed .aside {
    border-left-color: transparent;
  }

  html.right-collapsed .aside-scroll {
    opacity: 0;
    visibility: hidden;
  }

  /* Edge handles that hide and show the panels */
  .panel-handle {
    position: absolute;
    top: 50%;
    z-index: 25;
    display: grid;
    place-items: center;
    width: 26px;
    height: 56px;
    margin-top: -28px;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text-muted);
    font-size: 12px;
    box-shadow: var(--shadow-sm);
    opacity: 0;
    transition: opacity 0.18s, background 0.15s, color 0.15s;
  }

  .panel-handle:hover,
  .panel-handle:focus-visible {
    background: var(--surface-3);
    color: var(--text);
  }

  .sidebar .panel-handle {
    display: grid;
    right: -13px;
  }

  .aside .panel-handle {
    display: grid;
    left: -13px;
  }

  .sidebar:hover .panel-handle,
  .aside:hover .panel-handle,
  .panel-handle:focus-visible,
  html.right-collapsed .aside .panel-handle {
    opacity: 1;
  }

  html.right-collapsed .aside .panel-handle {
    left: -40px;
  }

  .panel-handle i {
    transition: transform 0.25s var(--ease);
  }

  html.left-collapsed .sidebar .panel-handle i,
  html.right-collapsed .aside .panel-handle i {
    transform: rotate(180deg);
  }
}

@media (min-width: 900px) and (max-width: 1199px) {
  :root {
    --right-w: 340px;
  }

  .aside-inner {
    padding: 30px 20px;
  }
}

/* Avoid animating the layout while the page first renders */
html.no-transitions *,
html.no-transitions *::before,
html.no-transitions *::after {
  transition: none !important;
}

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

.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  color: var(--text-muted);
  font-size: 18px;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

.icon-btn:hover {
  background: var(--surface);
  color: var(--text);
}

.icon-btn:active {
  transform: scale(0.94);
}

.theme-toggle .fa-sun,
:root[data-theme="light"] .theme-toggle .fa-moon {
  display: none;
}

:root[data-theme="light"] .theme-toggle .fa-sun {
  display: inline-block;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 22px;
  border-radius: var(--radius);
  font-weight: 800;
  font-size: 16px;
  transition: transform 0.12s var(--ease), box-shadow 0.2s, background 0.15s, opacity 0.15s;
  user-select: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--gradient);
  color: #fff;
  box-shadow: var(--shadow-primary);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 16px 38px rgba(92, 64, 240, 0.45);
  filter: brightness(1.06);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-3);
}

.btn-ghost {
  color: var(--text-muted);
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--surface);
}

.btn-block {
  width: 100%;
}

.btn-lg {
  min-height: 60px;
  font-size: 19px;
  border-radius: var(--radius-lg);
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin: -8px -10px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-muted);
  transition: color 0.15s, background 0.15s;
}

.link-btn:hover {
  color: var(--text);
  background: var(--surface);
}

.link-btn i {
  transition: transform 0.2s var(--ease);
}

.link-btn:hover .fa-chevron-left {
  transform: translateX(-3px);
}

/* ---------- Cards and panels ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.panel-card {
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
}

@media (min-width: 900px) {
  .aside .panel-card {
    background: transparent;
    border: 0;
    padding: 0;
  }
}

.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 24px;
  font-weight: 800;
}

/* Banner rows (Legend Quests, Watch Tutorial, View Stats) */
.banner {
  display: flex;
  align-items: center;
  gap: 18px;
  width: 100%;
  padding: 18px 18px 18px 22px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: transform 0.18s var(--ease), border-color 0.18s, background 0.18s;
}

.banner:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
  transform: translateY(-2px);
}

.banner-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 56px;
  font-size: 30px;
  color: var(--primary-text);
}

.banner-coffee .banner-icon {
  color: var(--yellow);
}

:root[data-theme="light"] .banner-coffee .banner-icon,
:root[data-theme="light"] .coffee-link i {
  color: #d99a00;
}

.banner-divider {
  align-self: stretch;
  width: 1px;
  background: var(--border-strong);
}

.banner-text {
  flex: 1;
  min-width: 0;
}

.banner-text strong {
  display: block;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.25;
}

.banner-text span {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 15px;
}

.banner-arrow {
  flex: none;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  background: var(--surface-3);
  font-size: 18px;
  transition: background 0.18s, color 0.18s;
}

.banner-arrow i {
  transition: transform 0.2s var(--ease);
}

.banner:hover .banner-arrow {
  background: var(--primary);
  color: #fff;
}

.banner:hover .banner-arrow i {
  transform: translateX(3px);
}

@media (max-width: 520px) {
  .banner {
    gap: 14px;
    padding: 14px 14px 14px 16px;
  }

  .banner-icon {
    width: 36px;
    font-size: 24px;
  }

  .banner-divider {
    display: none;
  }

  .banner-text strong {
    font-size: 17px;
  }

  .banner-text span {
    font-size: 13.5px;
  }

  .banner-arrow {
    width: 40px;
    height: 40px;
    font-size: 15px;
  }
}

/* ---------- Activity feed ("Who's Playing") ---------- */

.feed-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.feed-header h2 {
  flex: 1;
  font-size: 22px;
  font-weight: 700;
}

.live-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
  animation: pulse 2s infinite;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 800;
}

.pill-live {
  color: var(--green-text);
  border: 1.5px solid color-mix(in srgb, var(--green) 60%, transparent);
  background: color-mix(in srgb, var(--green) 12%, transparent);
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55);
  }
  70% {
    box-shadow: 0 0 0 9px rgba(34, 197, 94, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

.feed-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  padding: 18px 16px;
}

@keyframes feed-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}

/* Live grid: one tile per open game */
.live-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.live-tile > a {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  height: 100%;
  min-height: 118px;
  padding: 9px 9px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  transition: transform 0.18s var(--ease), border-color 0.18s, background 0.18s, opacity 0.4s, box-shadow 0.18s;
}

.live-tile > a:hover,
.live-tile > a:focus-visible {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--primary) 55%, transparent);
  box-shadow: var(--shadow-sm);
}

.live-tile.is-new > a {
  animation: tile-in 0.5s var(--ease);
}

@keyframes tile-in {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
}

.live-tile.is-solving > a {
  border-color: color-mix(in srgb, var(--orange) 35%, transparent);
  background: color-mix(in srgb, var(--orange) 7%, var(--surface-2));
}

.live-tile.is-solved > a {
  border-color: color-mix(in srgb, var(--green) 35%, transparent);
  background: color-mix(in srgb, var(--green) 7%, var(--surface-2));
}

.live-tile.is-gaveup > a {
  opacity: 0.55;
}

.live-tile.is-gaveup .flag {
  filter: grayscale(1);
}

.live-status {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 3px;
  white-space: nowrap;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.is-solving .live-status {
  color: var(--orange);
}

.is-solved .live-status {
  color: var(--green-text);
}

.live-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--orange);
  animation: pulse-orange 1.6s infinite;
}

@keyframes pulse-orange {
  0% {
    box-shadow: 0 0 0 0 rgba(247, 147, 26, 0.6);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(247, 147, 26, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(247, 147, 26, 0);
  }
}

.live-name,
.live-place,
.live-quest {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.live-name {
  font-size: 14px;
  font-weight: 800;
  line-height: 1.25;
}

.live-name.is-anon {
  color: var(--text-muted);
  font-weight: 700;
}

.live-place {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
}

.live-place span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.live-place .flag {
  width: 16px;
  height: 12px;
  border-radius: 2px;
}

.live-quest {
  color: var(--primary-text);
  font-size: 11.5px;
  font-weight: 700;
}

.live-time {
  margin-top: auto;
  padding-top: 4px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.live-go {
  position: absolute;
  right: 9px;
  bottom: 10px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 0.18s, transform 0.18s var(--ease);
}

.live-tile > a:hover .live-go,
.live-tile > a:focus-visible .live-go {
  opacity: 1;
  transform: none;
}

.live-tile.is-loading {
  min-height: 118px;
}

.live-tile.is-loading .skeleton {
  display: block;
  height: 100%;
  min-height: 118px;
  border-radius: var(--radius);
}

.live-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 26px 12px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  font-size: 14px;
}

.live-empty i {
  margin-bottom: 6px;
  font-size: 22px;
  color: var(--text-faint);
}

.live-empty strong {
  color: var(--text);
  font-weight: 800;
}

.live-more {
  margin: 10px 0 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

@media (hover: none) {
  .live-go {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .live-pulse {
    animation: none;
  }
}

.flag {
  display: inline-block;
  width: 20px;
  height: 15px;
  border-radius: 3px;
  object-fit: cover;
  flex: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.feed-footer {
  margin-top: 14px;
}

.feed-empty {
  padding: 20px 8px;
  text-align: center;
  color: var(--text-muted);
}

/* ---------- Skeleton loaders ---------- */

.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: 8px;
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
  animation: shimmer 1.4s infinite;
}

:root[data-theme="light"] .skeleton::after {
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.7), transparent);
}

@keyframes shimmer {
  to {
    transform: translateX(100%);
  }
}

.skeleton-line {
  height: 12px;
  margin: 6px 0;
}

/* ---------- Forms ---------- */

.field {
  display: block;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 800;
  color: var(--text-muted);
}

.input {
  width: 100%;
  height: 50px;
  padding: 0 16px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border-strong);
  background: var(--surface-2);
  font-size: 16px;
  font-weight: 700;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.input::placeholder {
  color: var(--text-faint);
  font-weight: 600;
}

.input:hover {
  border-color: color-mix(in srgb, var(--primary) 40%, var(--border-strong));
}

.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.input.is-invalid {
  border-color: var(--red);
}

.form-message {
  min-height: 22px;
  margin-top: 8px;
  font-size: 14px;
  font-weight: 700;
}

.form-message.error {
  color: var(--red);
}

.form-message.success {
  color: var(--green-text);
}

/* Switch toggle */
.switch {
  position: relative;
  flex: none;
  width: 48px;
  height: 28px;
}

.switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--surface-3);
  transition: background 0.2s;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s var(--ease);
}

.switch input:checked + span {
  background: var(--primary);
}

.switch input:checked + span::after {
  transform: translateX(20px);
}

.switch input:focus-visible + span {
  outline: 2px solid var(--primary-text);
  outline-offset: 2px;
}

/* Segmented control */
.segmented {
  display: inline-flex;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.segmented button {
  padding: 7px 14px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 800;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}

.segmented button:hover {
  color: var(--text);
}

.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

:root:not([data-theme="light"]) .segmented button[aria-pressed="true"] {
  background: var(--surface-3);
}

/* ---------- Modal ---------- */

dialog.modal {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100svh - 32px);
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

dialog.modal.modal-wide {
  width: min(760px, calc(100vw - 24px));
}

dialog.modal[open] {
  animation: modal-in 0.24s var(--ease);
}

dialog.modal::backdrop {
  background: rgba(5, 6, 20, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

dialog.modal[open]::backdrop {
  animation: fade-in 0.24s ease;
}

dialog.modal.is-closing {
  animation: modal-out 0.16s ease forwards;
}

dialog.modal.is-closing::backdrop {
  animation: fade-out 0.16s ease forwards;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
}

@keyframes modal-out {
  to {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes fade-out {
  to {
    opacity: 0;
  }
}

.modal-body {
  max-height: calc(100svh - 34px);
  overflow-y: auto;
  padding: 26px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.modal-header h2 {
  font-size: 24px;
  font-weight: 800;
}

.modal-close {
  margin: -8px -8px -8px 0;
}

@media (max-width: 520px) {
  dialog.modal {
    width: 100vw;
    max-width: 100vw;
    max-height: 92svh;
    margin: auto 0 0;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    border-bottom: 0;
  }

  dialog.modal[open] {
    animation: sheet-in 0.3s var(--ease);
  }

  dialog.modal.is-closing {
    animation: sheet-out 0.2s ease forwards;
  }

  .modal-body {
    max-height: 92svh;
    padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  }

  @keyframes sheet-in {
    from {
      transform: translateY(100%);
    }
  }

  @keyframes sheet-out {
    to {
      transform: translateY(100%);
    }
  }
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  border-top: 1px solid var(--border);
}

.settings-row:first-of-type {
  border-top: 0;
}

.settings-row strong {
  display: block;
  font-size: 16px;
}

.settings-row span {
  display: block;
  font-size: 13.5px;
  color: var(--text-muted);
}

/* How-to-play content (modal and tutorial page) */
.video-frame {
  position: relative;
  overflow: hidden;
  width: min(100%, 48svh, 520px);
  margin: 0 auto;
  border-radius: var(--radius-lg);
  background: #0b0f5c;
  aspect-ratio: 1;
}

.video-frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.how-layout {
  display: grid;
  gap: 4px;
}

@media (min-width: 720px) {
  .how-layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    gap: 26px;
  }

  .how-layout .video-frame {
    width: 100%;
  }

  .how-layout .rules {
    margin-top: 0;
  }
}

.rules {
  list-style: none;
  margin: 20px 0 0;
  padding: 0;
  display: grid;
  gap: 14px;
}

.rules li {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  font-size: 15.5px;
  color: var(--text-muted);
}

.rules li b {
  color: var(--text);
}

.rule-swatch {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  font-weight: 900;
  font-size: 16px;
  background: var(--tile);
  color: var(--tile-text);
}

.rule-swatch.is-clue {
  background: var(--tile-clue);
  color: var(--tile-clue-text);
}

.rule-swatch.is-almost {
  background: var(--orange);
  color: #fff;
}

.rule-swatch.is-correct {
  background: var(--green);
  color: #fff;
}

/* ---------- Toast ---------- */

.toast-region {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 100;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

@media (min-width: 900px) {
  .toast-region {
    bottom: 28px;
  }
}

.toast {
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  font-weight: 800;
  font-size: 15px;
  box-shadow: var(--shadow);
  animation: toast-in 0.25s var(--ease);
}

.toast.is-leaving {
  animation: fade-out 0.2s ease forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* ---------- Footer ---------- */

.site-footer {
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: var(--text-faint);
  font-size: 14px;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
}

.site-footer a {
  font-weight: 700;
  transition: color 0.15s;
}

.site-footer a:hover {
  color: var(--text);
}

.socials {
  display: flex;
  gap: 4px;
}

.socials a {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 16px;
  transition: background 0.15s, color 0.15s;
}

.socials a:hover {
  background: var(--surface);
}

/* ---------- Page headers ---------- */

.page-header {
  margin-bottom: 26px;
}

.page-header h1 {
  font-size: clamp(30px, 6vw, 44px);
  font-weight: 800;
}

.page-header p {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 17px;
}

/* ---------- Motion preferences ---------- */

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

/* Stop the page behind an open pop-up from scrolling */
html:has(dialog[open]) {
  overflow: hidden;
}

/* ---------- Ad slots (Google AdSense) ---------- */

.ad-slot {
  margin-top: 28px;
  text-align: center;
}

.ad-label {
  display: none;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* Only show the label once Google has actually filled the slot */
.ad-slot:has(ins[data-ad-status="filled"]) .ad-label {
  display: block;
}

/* No ad available: collapse the slot so there's no empty gap */
ins.adsbygoogle[data-ad-status="unfilled"],
.ad-slot:has(ins[data-ad-status="unfilled"]) {
  display: none !important;
}

.results .ad-slot {
  margin-top: 18px;
}
