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

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #21262d;
  --border: #30363d;
  --accent: #e8623a;
  --accent2: #1b8dff;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --success: #3fb950;
  --warning: #d29922;
  --danger: #f85149;
  --radius: 8px;
  --radius-lg: 12px;
}

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

/* ── Header ───────────────────────────────────────────────────────────────── */
header {
  background: linear-gradient(135deg, #0d1117 0%, #1a1f2e 100%);
  border-bottom: 1px solid var(--border);
  padding: 2rem 1rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}
header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 60% 80% at 50% -10%, rgba(232,98,58,0.15) 0%, transparent 70%);
  pointer-events: none;
}

.header-inner { position: relative; z-index: 1; }

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 0.75rem;
  text-decoration: none;
}
.logo:hover { opacity: 0.85; }
.logo svg { width: 20px; height: 20px; }

h1 {
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  font-weight: 800;
  background: linear-gradient(135deg, #ffffff 0%, #8b949e 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.tagline {
  color: var(--text-muted);
  margin-top: 0.5rem;
  font-size: 1rem;
}

/* ── Layout ───────────────────────────────────────────────────────────────── */
main {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

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

.hidden { display: none !important; }

/* ── Input section ────────────────────────────────────────────────────────── */
.input-section h2 { font-size: 1.1rem; margin-bottom: 0.5rem; }

.hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
.hint code {
  background: var(--surface2);
  padding: 0.1em 0.35em;
  border-radius: 4px;
  font-family: 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.8em;
}

textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  font-family: 'Fira Code', 'Cascadia Code', monospace;
  padding: 0.75rem;
  resize: vertical;
  transition: border-color 0.2s;
}
textarea:focus {
  outline: none;
  border-color: var(--accent2);
}
textarea::placeholder { color: var(--text-muted); }

.input-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

.btn-primary, .btn-secondary {
  padding: 0.6rem 1.4rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: transform 0.1s, opacity 0.2s;
}
.btn-primary:active, .btn-secondary:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary {
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-secondary:hover { color: var(--text); border-color: var(--text-muted); }

/* ── Status / progress ────────────────────────────────────────────────────── */
.status-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
}

.progress-bar-wrap {
  height: 4px;
  background: var(--surface2);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent2) 100%);
  border-radius: 99px;
  width: 0%;
  transition: width 0.4s ease;
}

.status-msg {
  font-size: 0.9rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.status-msg::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

/* ── Private account warnings ─────────────────────────────────────────────── */
.warning-banner {
  background: rgba(210, 153, 34, 0.1);
  border: 1px solid rgba(210, 153, 34, 0.4);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.warning-banner .warn-title {
  font-weight: 600;
  color: var(--warning);
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.warning-banner ul { list-style: none; padding-left: 1rem; color: var(--text-muted); }
.warning-banner ul li::before { content: '• '; color: var(--warning); }

.error-banner {
  background: rgba(248, 81, 73, 0.1);
  border: 1px solid rgba(248, 81, 73, 0.4);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--danger);
}

/* ── Accounts grid ────────────────────────────────────────────────────────── */
.accounts-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.account-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 0.35rem 0.85rem 0.35rem 0.35rem;
  font-size: 0.85rem;
}
.account-chip img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}
.account-chip .avatar-placeholder {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 700;
}

/* ── Results header ───────────────────────────────────────────────────────── */
.results-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.results-header h2 { font-size: 1.2rem; }

.results-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-left: auto;
}

.badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.2em 0.65em;
  border-radius: 99px;
  white-space: nowrap;
}

.sort-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
  cursor: pointer;
}
select:focus { outline: none; border-color: var(--accent2); }

.filter-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
  width: 160px;
}
.filter-input::placeholder { color: var(--text-muted); }
.filter-input:focus { outline: none; border-color: var(--accent2); }

/* ── Game grid ────────────────────────────────────────────────────────────── */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.game-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s, border-color 0.2s;
}
.game-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.game-card a { text-decoration: none; color: inherit; }

.game-img-wrap {
  position: relative;
  aspect-ratio: 460 / 215;
  overflow: hidden;
  background: var(--surface2);
}
.game-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.3s;
}
.game-img-wrap img.loading { opacity: 0; }

.game-body {
  padding: 0.85rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.game-name {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.3;
}

.game-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.cat-tag {
  font-size: 0.7rem;
  padding: 0.15em 0.5em;
  border-radius: 4px;
  background: rgba(27, 141, 255, 0.15);
  color: var(--accent2);
  border: 1px solid rgba(27, 141, 255, 0.3);
  white-space: nowrap;
}

.playtime-list {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.playtime-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.playtime-row img {
  width: 18px;
  height: 18px;
  border-radius: 50%;
}
.playtime-row .avatar-sm {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}
.playtime-hours {
  margin-left: auto;
  color: var(--text);
  font-weight: 600;
}
.playtime-hours.zero { color: var(--text-muted); font-weight: 400; }

.store-link {
  display: block;
  text-align: center;
  font-size: 0.78rem;
  color: var(--accent2);
  padding: 0.45rem;
  border-top: 1px solid var(--border);
  text-decoration: none;
  transition: background 0.15s;
}
.store-link:hover { background: rgba(27,141,255,0.08); }

/* ── Free tag (badge on card image) ──────────────────────────────────────── */
.free-tag {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  background: var(--success);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 0.15em 0.55em;
  border-radius: 4px;
  z-index: 1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ── Free games section ───────────────────────────────────────────────────── */
.free-games-section {
  border-top: 2px solid rgba(63, 185, 80, 0.2);
  padding-top: 1.5rem;
  margin-top: 0.5rem;
}

.section-desc {
  font-size: 0.83rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.free-badge-count { background: var(--success); }

.loading-msg {
  animation: pulse-text 1.5s ease-in-out infinite;
}

@keyframes pulse-text {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* ── No results ───────────────────────────────────────────────────────────── */
.no-results {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: 1rem;
}

/* ── Footer ───────────────────────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}
footer a { color: var(--accent); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ── Header auth ──────────────────────────────────────────────────────────── */
.header-auth {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 2;
}

.btn-steam {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: #1b2838;
  color: #c7d5e0;
  border: 1px solid #4c6b8a;
  border-radius: var(--radius);
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.btn-steam:hover {
  background: #2a475e;
  border-color: #66c0f4;
  color: #fff;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 0.3rem 0.75rem 0.3rem 0.3rem;
  font-size: 0.85rem;
}
.user-chip img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}
.logout-link {
  color: var(--text-muted);
  font-size: 0.78rem;
  text-decoration: none;
  margin-left: 0.25rem;
  padding-left: 0.5rem;
  border-left: 1px solid var(--border);
}
.logout-link:hover { color: var(--danger); }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h3 { font-size: 1rem; font-weight: 700; }

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}
.btn-icon:hover { background: var(--surface2); color: var(--text); }

.modal-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.friend-search-wrap {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.friend-search { width: 100%; }

.friend-list {
  flex: 1;
  overflow-y: auto;
}

.friend-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 1rem;
  cursor: pointer;
  transition: background 0.1s;
  user-select: none;
}
.friend-row:hover { background: var(--surface2); }
.friend-row input[type=checkbox] { flex-shrink: 0; accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

.friend-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface2);
}

.friend-name {
  font-size: 0.88rem;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.self-row {
  border-bottom: 1px solid var(--border);
  background: rgba(232,98,58,0.05);
}
.self-badge {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
  background: rgba(232,98,58,0.15);
  border: 1px solid rgba(232,98,58,0.3);
  border-radius: 4px;
  padding: 0.1em 0.4em;
  flex-shrink: 0;
}

.friend-list-msg {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.friend-list-msg.error { color: var(--danger); }

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  gap: 1rem;
}
.selected-count { font-size: 0.85rem; color: var(--text-muted); }

/* ── Create party button (in user chip) ───────────────────────────────────── */
.btn-create-party {
  background: rgba(232,98,58,0.15);
  color: var(--accent);
  border: 1px solid rgba(232,98,58,0.3);
  border-radius: var(--radius);
  padding: 0.25rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-create-party:hover { background: rgba(232,98,58,0.28); }
.btn-create-party:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Party page ───────────────────────────────────────────────────────────── */
.party-hero { display: flex; flex-direction: column; gap: 0.85rem; }

.party-hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.party-hero-top h2 { font-size: 1.2rem; }

.party-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.party-link-wrap {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.party-link-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-family: 'Fira Code', 'Cascadia Code', monospace;
  padding: 0.5rem 0.75rem;
  min-width: 0;
}
.party-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0;
}

.party-members { display: flex; flex-direction: column; gap: 0.85rem; }
.party-members-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.party-members-header h3 { font-size: 1rem; }

/* Danger variant for leave/delete */
.btn-danger {
  background: rgba(248,81,73,0.1);
  color: var(--danger);
  border: 1px solid rgba(248,81,73,0.3);
}
.btn-danger:hover { background: rgba(248,81,73,0.2); }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .results-header { flex-direction: column; align-items: flex-start; }
  .results-meta { margin-left: 0; }
  .game-grid { grid-template-columns: 1fr; }
  .filter-input { width: 100%; }
  .header-auth { top: 0.5rem; right: 0.5rem; }
  .btn-steam span { display: none; }
  .party-link-wrap { flex-direction: column; align-items: stretch; }
}
