/* PurpleLite base styles — default purple/black appearance.
   Colors are tokens so the Phase 7 theme engine can replace them. */
:root {
  --bg: #0b0710;
  --surface: #171021;
  --surface-2: #221733;
  --text: #f3eefb;
  --text-muted: #b9aecb;
  --accent: #9b5cf6;
  --accent-strong: #7c3aed;
  --accent-text: #ffffff;
  --border: #33244a;
  --radius: 16px;
  --focus: #c4a1ff;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--focus); }

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

main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 32px 16px; }

.hero { text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 60vh; }
.hero h1 { font-size: clamp(2.5rem, 8vw, 4rem); margin: 0 0 8px; letter-spacing: -0.02em; }
.hero h1 span { color: var(--accent); }
.subtitle { font-size: 1.25rem; color: var(--text-muted); min-height: 1.9em; }

.btn {
  display: inline-block;
  background: var(--accent-strong);
  color: var(--accent-text);
  border: none;
  border-radius: 999px;
  padding: 14px 32px;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  margin: 8px;
}
.btn:hover { background: var(--accent); }
.btn.secondary { background: var(--surface-2); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--border); }

h1.page-title { text-align: center; font-size: 2.5rem; margin: 0 0 24px; }

.search {
  display: block;
  width: 100%;
  max-width: 600px;
  margin: 0 auto 24px;
  padding: 12px 20px;
  font-size: 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}
.game-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.1s ease, border-color 0.1s ease;
}
.game-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.game-card img { width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--surface-2); }
.game-card span { padding: 10px 12px; font-weight: 600; text-align: center; }

.status { text-align: center; color: var(--text-muted); }
.search-label { display: block; margin-bottom: 8px; }
.page-actions { text-align: center; margin-top: 32px; }

.prose { max-width: 680px; margin: 0 auto; }
.prose h1 { font-size: 2.25rem; }

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  text-align: center;
  padding: 20px 16px;
  font-size: 0.9rem;
}

#back-to-top { position: fixed; bottom: 20px; right: 20px; display: none; }

@media (prefers-reduced-motion: reduce) {
  .game-card { transition: none; }
}

/* --- Header / nav --------------------------------------------------------------------- */
.site-header { border-bottom: 1px solid var(--border); background: var(--surface); }
#site-nav { max-width: 1200px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; min-height: 56px; }
#site-nav a { color: var(--text); text-decoration: none; }
#site-nav a:hover { color: var(--focus); }
.brand { font-weight: 800; font-size: 1.2rem; }
.brand span { color: var(--accent); }
.nav-links, .nav-account { display: flex; align-items: center; gap: 14px; }
.nav-account { margin-left: auto; }
.nav-user { display: inline-flex; align-items: center; gap: 8px; }
.btn.small { padding: 8px 16px; font-size: 0.9rem; margin: 0; }
.linklike { background: none; border: none; color: var(--text); cursor: pointer; font: inherit; padding: 0; }
.linklike:hover { color: var(--focus); }

/* --- Cards and forms ------------------------------------------------------------------ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin: 16px 0; }
.card h2 { margin-top: 0; }
.notice { border-color: var(--accent); }
.form .field { margin-bottom: 16px; border: none; padding: 0; }
.form label, .form legend { display: block; font-weight: 600; margin-bottom: 6px; }
.form input[type="text"], .form input[type="password"], .form input:not([type]), .form select, .form textarea {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
}
.form input[aria-invalid="true"], .form textarea[aria-invalid="true"] { border-color: #f87171; }
.hint, .muted { color: var(--text-muted); font-size: 0.9rem; margin: 4px 0 0; }
.field-error, .form-error { color: #fca5a5; font-size: 0.9rem; margin: 4px 0 0; min-height: 0; }
.form-error:empty, .field-error:empty { display: none; }
.form-status { color: #86efac; margin: 8px 0 0; }
.form-status:empty { display: none; }
.form .btn { margin: 8px 0 0; }
.turnstile { margin: 8px 0; min-height: 65px; }
.check { display: flex; gap: 8px; align-items: center; }
.actions { display: flex; gap: 8px; }
.codes { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1.05rem; columns: 2; background: var(--surface-2); border-radius: 10px; padding: 12px 12px 12px 36px; }

.avatar-grid, .color-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.avatar-choice, .color-choice { position: relative; cursor: pointer; }
.avatar-choice input, .color-choice input { position: absolute; opacity: 0; inset: 0; }
.avatar-choice img, .swatch { display: block; border-radius: 12px; border: 3px solid transparent; }
.swatch { width: 36px; height: 36px; border-radius: 50%; }
.avatar-choice input:checked + img, .color-choice input:checked + .swatch { border-color: var(--text); }
.avatar-choice input:focus-visible + img, .color-choice input:focus-visible + .swatch { outline: 3px solid var(--focus); outline-offset: 2px; }

/* --- Identity ------------------------------------------------------------------------- */
.avatar { border-radius: 12px; flex-shrink: 0; }
.user-name { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; }
/* The shield sits LEFT of the name and its color is fixed here, not by any user setting. */
.admin-shield { width: 1.05em; height: 1.05em; fill: #facc15; flex-shrink: 0; }
.mod-tag { font-size: 0.7em; font-weight: 700; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 0 6px; margin-left: 4px; }
.account-head, .profile-head { display: flex; gap: 16px; align-items: center; }
.account-name { font-size: 1.3rem; }
.profile-card h1 { margin: 0; font-size: 1.8rem; }
.bio { white-space: pre-wrap; overflow-wrap: anywhere; }
.standing { margin-top: 4px; font-size: 0.9rem; }
.standing-good { color: #86efac; }
.standing-limited { color: #fde68a; }
.standing-suspended { color: #fca5a5; }
.sessions { list-style: none; padding: 0; }
.session { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 560px) {
  .codes { columns: 1; }
  .nav-account { margin-left: 0; width: 100%; }
}

/* --- Library and player ------------------------------------------------------------- */
.library-controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: center; max-width: 900px; margin: 0 auto 8px; }
.library-controls .search { margin: 0; flex: 1 1 280px; }
.select { padding: 12px 16px; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; }
.game-card-wrap { position: relative; }
.game-card-wrap .game-card { height: 100%; }
.fav-btn { position: absolute; top: 8px; right: 8px; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border); background: rgb(11 7 16 / 0.8); color: var(--text); font-size: 1.3rem; cursor: pointer; }
.fav-btn.on { color: #fde68a; }
.recent { margin-bottom: 24px; }
.recent-row { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.player-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 12px; }
.player-head h1 { margin: 0; }
.player-head p { margin: 4px 0 0; }
.player-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.stage { position: relative; width: 100%; aspect-ratio: 16 / 10; max-height: 80vh; background: #000; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.stage:fullscreen { max-height: none; border-radius: 0; border: none; }
.stage iframe { width: 100%; height: 100%; border: 0; display: block; }
.stage-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: var(--bg); text-align: center; padding: 16px; }
.stage-overlay[hidden] { display: none; }
.spinner { width: 48px; height: 48px; border: 5px solid var(--surface-2); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.small-print { font-size: 0.85rem; margin-top: 8px; }

/* --- Requests ----------------------------------------------------------------------- */
.requests { list-style: none; padding: 0; }
.request { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.admin-request { display: block; }
.pill { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 0.85rem; background: var(--surface-2); border: 1px solid var(--border); }
.pill-approved, .pill-added { color: #86efac; }
.pill-rejected { color: #fca5a5; }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.tabs button[aria-pressed="true"] { background: var(--accent-strong); }
.decision { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.decision input { flex: 1 1 220px; padding: 8px 12px; font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.form input[type="url"], .form input[type="search"] { width: 100%; padding: 10px 12px; font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
code { overflow-wrap: anywhere; }

/* `hidden` must always win over component display rules (e.g. .check is flex). */
[hidden] { display: none !important; }

@media (max-width: 560px) {
  .game-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .game-card span { padding: 8px; font-size: 0.9rem; }
  .fav-btn { width: 34px; height: 34px; font-size: 1.1rem; top: 6px; right: 6px; }
  .stage { aspect-ratio: 3 / 4; }
}

/* --- Friends and presence ----------------------------------------------------------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.live-status { font-size: 0.85rem; color: var(--text-muted); }
.live-status[data-state="connected"] { color: #86efac; }
.nav-friends { position: relative; }
.badge { display: inline-block; min-width: 1.4em; margin-left: 4px; padding: 0 5px; border-radius: 999px; background: #f472b6; color: #1a0612; font-size: 0.75rem; font-weight: 800; text-align: center; line-height: 1.4em; }
.people, .notifications { list-style: none; padding: 0; margin: 0; }
.person { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--border); }
.person:last-child, .notification:last-child { border-bottom: none; }
.person-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.person-link { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.presence { display: inline-flex; align-items: center; gap: 6px; font-size: 0.9rem; color: var(--text-muted); flex-wrap: wrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: #6b6380; }
.dot-online { background: #4ade80; }
.dot-away { background: #fbbf24; }
.notification { padding: 8px 0; border-bottom: 1px solid var(--border); }
.notification.unread { font-weight: 600; }
.inline-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { flex: 1 1 220px; margin-bottom: 0; }
.profile-card .actions { margin-top: 16px; flex-wrap: wrap; align-items: center; }
