/* ==========================================================================
   我的游戏平台 — Premium Dark Glassmorphism Stylesheet
   100% Self-Contained / Offline / Zero External CDN Dependencies
   ========================================================================== */

:root {
  --bg-deep: #070b14;
  --bg-base: #0b1120;
  --bg-surface: rgba(17, 25, 44, 0.78);
  --bg-surface-solid: #11192c;
  --bg-surface-hover: rgba(24, 35, 60, 0.92);
  --bg-elevated: rgba(22, 32, 54, 0.92);
  --bg-input: rgba(8, 13, 25, 0.78);

  --border-subtle: rgba(148, 163, 184, 0.14);
  --border-medium: rgba(148, 163, 184, 0.24);
  --border-glow: rgba(16, 185, 129, 0.45);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-emerald: #10b981;
  --accent-cyan: #06b6d4;
  --accent-sky: #38bdf8;
  --accent-violet: #8b5cf6;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  --gradient-cta: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
  --gradient-cta-hover: linear-gradient(135deg, #059669 0%, #0891b2 100%);
  --gradient-play: linear-gradient(135deg, #10b981 0%, #0ea5e9 100%);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 28px rgba(0, 0, 0, 0.48);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.65);
  --shadow-cta: 0 6px 24px rgba(16, 185, 129, 0.34);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --font-sans: "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

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

html, body {
  min-height: 100%;
  background-color: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* Ambient Gaming Backdrop */
body.hub-body {
  background-image:
    radial-gradient(ellipse 80% 50% at 15% -10%, rgba(16, 185, 129, 0.13), transparent 60%),
    radial-gradient(ellipse 70% 45% at 88% 0%, rgba(6, 182, 212, 0.12), transparent 55%),
    radial-gradient(ellipse 60% 50% at 50% 100%, rgba(139, 92, 246, 0.09), transparent 65%);
  background-attachment: fixed;
  padding-bottom: calc(48px + var(--safe-bottom));
}

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

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

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.hidden {
  display: none !important;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: rgba(7, 11, 20, 0.5);
}
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.25);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.42);
}

/* ==========================================================================
   Top Header Bar
   ========================================================================== */
.hub-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(8, 13, 25, 0.82);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border-subtle);
  padding-top: var(--safe-top);
}

.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: var(--text-primary);
  user-select: none;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.22), rgba(6, 182, 212, 0.22));
  border: 1px solid rgba(16, 185, 129, 0.45);
  display: grid;
  place-items: center;
  box-shadow: 0 0 22px rgba(16, 185, 129, 0.25);
  flex-shrink: 0;
}

.brand-logo svg {
  width: 24px;
  height: 24px;
  filter: drop-shadow(0 0 6px rgba(16, 185, 129, 0.55));
}

.brand-title {
  font-size: 1.22rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  background: linear-gradient(90deg, #f8fafc 0%, #a7f3d0 60%, #67e8f9 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Server Status Pill */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-subtle);
  font-size: 0.82rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 10px var(--accent-emerald);
  animation: pulse-dot 2.2s infinite ease-in-out;
  flex-shrink: 0;
}

.status-pill.offline .status-dot {
  background: var(--accent-rose);
  box-shadow: 0 0 10px var(--accent-rose);
  animation: none;
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.28); opacity: 0.65; }
}

.status-pill strong {
  color: var(--text-primary);
  font-weight: 600;
}

.status-sep {
  opacity: 0.35;
}

/* Header Action Buttons */
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  transition: transform 0.16s ease, box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease;
  white-space: nowrap;
  user-select: none;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-primary-cta {
  background: var(--gradient-cta);
  color: #031511;
  font-weight: 800;
  box-shadow: var(--shadow-cta);
  padding: 0 18px;
}

.btn-primary-cta:hover:not(:disabled) {
  background: var(--gradient-cta-hover);
  color: #f0fdfa;
  box-shadow: 0 8px 28px rgba(6, 182, 212, 0.42);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(30, 41, 59, 0.72);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(41, 56, 80, 0.9);
  border-color: var(--border-medium);
}

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

.btn-ghost:hover:not(:disabled) {
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-primary);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.18);
  color: #fda4af;
  border: 1px solid rgba(244, 63, 94, 0.4);
}

.btn-danger:hover:not(:disabled) {
  background: #e11d48;
  color: #fff;
  border-color: #f43f5e;
}

.btn-sm {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.83rem;
  border-radius: 10px;
}

.btn-lg {
  min-height: 52px;
  padding: 0 28px;
  font-size: 1.05rem;
  border-radius: 16px;
}

.btn-icon {
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: 10px;
  background: rgba(30, 41, 59, 0.72);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.98rem;
}

.btn-icon:hover:not(:disabled) {
  background: rgba(51, 65, 85, 0.88);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

.btn-icon.pinned-active {
  background: rgba(245, 158, 11, 0.18);
  border-color: rgba(245, 158, 11, 0.5);
  color: #fbbf24;
}

.btn-icon.danger-icon:hover:not(:disabled) {
  background: rgba(244, 63, 94, 0.22);
  border-color: rgba(244, 63, 94, 0.5);
  color: #fda4af;
}

/* ==========================================================================
   Main Layout & Filter Toolbar
   ========================================================================== */
.hub-main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 24px 0;
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 22px;
}

.toolbar-top {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1 1 280px;
  min-width: 200px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 0.95rem;
}

.search-input {
  width: 100%;
  height: 42px;
  padding: 0 38px 0 40px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

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

.search-input:focus {
  border-color: var(--accent-cyan);
  background: rgba(15, 23, 42, 0.95);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.16);
}

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--text-muted);
  display: grid;
  place-items: center;
  font-size: 0.9rem;
}

.search-clear:hover {
  background: rgba(148, 163, 184, 0.16);
  color: var(--text-primary);
}

.sort-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.sort-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.select-control {
  height: 42px;
  padding: 0 32px 0 13px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%2394a3b8' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.select-control:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
}

.select-control option {
  background: #0f172a;
  color: #f1f5f9;
}

/* Category Chips */
.chips-row {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.chips-row::-webkit-scrollbar {
  display: none;
}

.chip {
  flex-shrink: 0;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-full);
  background: rgba(17, 25, 44, 0.72);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.86rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.16s ease;
}

.chip:hover {
  background: rgba(30, 41, 59, 0.9);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

.chip.active {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.24), rgba(6, 182, 212, 0.24));
  border-color: rgba(16, 185, 129, 0.65);
  color: #ecfdf5;
  font-weight: 700;
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.18);
}

.chip-count {
  font-size: 0.75rem;
  padding: 1px 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
}

/* ==========================================================================
   Empty State Hero (Platform Ships Empty!)
   ========================================================================== */
.empty-hero {
  max-width: 860px;
  margin: 28px auto 12px;
  padding: 44px 32px 36px;
  border-radius: 26px;
  background: linear-gradient(160deg, rgba(17, 26, 46, 0.88) 0%, rgba(10, 16, 31, 0.92) 100%);
  border: 1px solid rgba(16, 185, 129, 0.26);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.empty-hero::before {
  content: "";
  position: absolute;
  inset: -40% -20% auto -20%;
  height: 260px;
  background: radial-gradient(ellipse at center, rgba(16, 185, 129, 0.16), transparent 65%);
  pointer-events: none;
}

.empty-icon-wrap {
  width: 86px;
  height: 86px;
  margin: 0 auto 20px;
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(6, 182, 212, 0.2));
  border: 1px solid rgba(16, 185, 129, 0.42);
  display: grid;
  place-items: center;
  box-shadow: 0 10px 34px rgba(16, 185, 129, 0.22);
  animation: float-slow 3.8s ease-in-out infinite;
}

@keyframes float-slow {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-6px); }
}

.empty-hero h2 {
  font-size: 1.75rem;
  font-weight: 800;
  margin-bottom: 12px;
  letter-spacing: 0.02em;
}

.empty-subtitle {
  max-width: 580px;
  margin: 0 auto 28px;
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.65;
}

.empty-cta-wrap {
  margin-bottom: 36px;
}

.empty-cta-btn {
  min-height: 56px;
  padding: 0 34px;
  font-size: 1.1rem;
  border-radius: 16px;
  box-shadow: 0 10px 36px rgba(16, 185, 129, 0.42);
}

.guide-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  text-align: left;
}

.guide-step {
  padding: 16px 18px;
  border-radius: 16px;
  background: rgba(8, 13, 25, 0.65);
  border: 1px solid var(--border-subtle);
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.guide-step-num {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: rgba(16, 185, 129, 0.18);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
  font-weight: 800;
  font-size: 0.85rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.guide-step h4 {
  font-size: 0.94rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.guide-step p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* No Search Results */
.no-results {
  text-align: center;
  padding: 56px 20px;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  border: 1px dashed var(--border-medium);
  color: var(--text-secondary);
}

.no-results h3 {
  color: var(--text-primary);
  margin-bottom: 8px;
  font-size: 1.15rem;
}

.no-results p {
  margin-bottom: 18px;
  font-size: 0.9rem;
}

/* ==========================================================================
   Game Cards Grid
   ========================================================================== */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(295px, 1fr));
  gap: 20px;
}

.game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
}

.game-card:hover {
  transform: translateY(-4px);
  border-color: rgba(6, 182, 212, 0.48);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55), 0 0 24px rgba(6, 182, 212, 0.14);
}

.game-card.invalid-card {
  border-color: rgba(244, 63, 94, 0.38);
}

/* 16:9 Cover Banner */
.card-cover {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #0f172a;
  cursor: pointer;
}

.card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

.game-card:hover .card-cover img {
  transform: scale(1.05);
}

.cover-fallback {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
  overflow: hidden;
}

.cover-fallback::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: radial-gradient(circle at center, black 35%, transparent 90%);
  -webkit-mask-image: radial-gradient(circle at center, black 35%, transparent 90%);
  pointer-events: none;
}

.cover-fallback::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 55%;
  background: linear-gradient(to top, rgba(7, 11, 20, 0.72), transparent);
  pointer-events: none;
}

.cover-emblem-title {
  position: relative;
  z-index: 1;
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  color: #ffffff;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.55);
  max-width: 92%;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cover-emblem-sub {
  position: relative;
  z-index: 1;
  margin-top: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.76);
  padding: 2px 10px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

/* 8 Built-In Cover Gradient Themes (0..7) */
.cover-theme-0 { background: linear-gradient(135deg, #065f46 0%, #0e7490 55%, #1e1b4b 100%); }
.cover-theme-1 { background: linear-gradient(135deg, #1d4ed8 0%, #6d28d9 58%, #312e81 100%); }
.cover-theme-2 { background: linear-gradient(135deg, #b45309 0%, #dc2626 55%, #450a0a 100%); }
.cover-theme-3 { background: linear-gradient(135deg, #0f766e 0%, #0284c7 55%, #082f49 100%); }
.cover-theme-4 { background: linear-gradient(135deg, #7e22ce 0%, #db2777 55%, #3b0764 100%); }
.cover-theme-5 { background: linear-gradient(135deg, #15803d 0%, #4d7c0f 55%, #14532d 100%); }
.cover-theme-6 { background: linear-gradient(135deg, #c2410c 0%, #d97706 52%, #431407 100%); }
.cover-theme-7 { background: linear-gradient(135deg, #334155 0%, #0f172a 55%, #020617 100%); }

/* Badges on Cover */
.cover-badges {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  z-index: 3;
  pointer-events: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 0.74rem;
  font-weight: 700;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.badge-pin {
  background: rgba(245, 158, 11, 0.88);
  color: #1c1002;
}

.badge-mp {
  background: rgba(6, 182, 212, 0.86);
  color: #031921;
}

.badge-invalid {
  background: rgba(244, 63, 94, 0.92);
  color: #fff;
}

.badge-orient {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 3;
  background: rgba(7, 11, 20, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #cbd5e1;
  font-weight: 600;
  pointer-events: none;
}

/* Card Body */
.card-body {
  padding: 15px 16px 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 10px;
}

.card-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.card-title {
  font-size: 1.08rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-pill {
  flex-shrink: 0;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 0.74rem;
  font-weight: 600;
  background: rgba(56, 189, 248, 0.13);
  border: 1px solid rgba(56, 189, 248, 0.26);
  color: #7dd3fc;
}

.card-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.48;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.52em;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
  padding-top: 2px;
}

.card-actions {
  margin-top: auto;
  padding-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-play {
  flex: 1;
  min-height: 42px;
  background: var(--gradient-play);
  color: #031511;
  font-weight: 800;
  font-size: 0.94rem;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.25);
}

.btn-play:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow: 0 6px 22px rgba(6, 182, 212, 0.38);
  transform: translateY(-1px);
}

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(3, 6, 14, 0.76);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fade-in 0.16s ease;
}

.modal-backdrop.layer-top {
  z-index: 130;
}

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

.modal {
  width: 100%;
  max-width: 680px;
  max-height: 92vh;
  background: #0e1629;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modal-pop 0.2s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.modal-sm {
  max-width: 460px;
}

.modal-lg {
  max-width: 760px;
}

@keyframes modal-pop {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(15, 23, 42, 0.65);
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  background: rgba(148, 163, 184, 0.08);
}

.modal-close:hover {
  background: rgba(148, 163, 184, 0.2);
  color: var(--text-primary);
}

.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 15px 22px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.65);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* Step 1 Highlight Zone in Add/Edit Modal */
.picker-zone {
  padding: 16px;
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.11), rgba(6, 182, 212, 0.09));
  border: 1px solid rgba(16, 185, 129, 0.35);
  margin-bottom: 20px;
}

.picker-zone-title {
  font-size: 0.92rem;
  font-weight: 800;
  color: #a7f3d0;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.picker-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.picker-btn-main {
  min-height: 46px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--gradient-cta);
  color: #031511;
  font-weight: 800;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 18px rgba(16, 185, 129, 0.28);
}

.picker-btn-main:hover:not(:disabled) {
  filter: brightness(1.06);
}

.picker-btn-sub {
  min-height: 46px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid rgba(56, 189, 248, 0.38);
  color: #bae6fd;
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.picker-btn-sub:hover:not(:disabled) {
  background: rgba(30, 41, 59, 0.95);
  border-color: var(--accent-sky);
  color: #fff;
}

.picker-status {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 0.84rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.picker-status.loading {
  background: rgba(6, 182, 212, 0.14);
  border: 1px solid rgba(6, 182, 212, 0.32);
  color: #a5f3fc;
}

.picker-status.success {
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #a7f3d0;
}

.picker-status.error {
  background: rgba(244, 63, 94, 0.14);
  border: 1px solid rgba(244, 63, 94, 0.35);
  color: #fda4af;
}

.picker-status.warn {
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fde68a;
}

/* Form Elements */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

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

.form-group.full {
  grid-column: 1 / -1;
}

.form-label {
  font-size: 0.84rem;
  font-weight: 700;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.req {
  color: var(--accent-rose);
  margin-left: 3px;
}

.input-row {
  display: flex;
  gap: 8px;
}

.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 10px 13px;
  border-radius: 11px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.16);
}

.form-input.mono {
  font-family: var(--font-mono);
  font-size: 0.86rem;
}

.form-textarea {
  min-height: 74px;
  resize: vertical;
}

.form-select option {
  background: #0f172a;
  color: #f1f5f9;
}

.preset-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.preset-tag {
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.77rem;
  background: rgba(30, 41, 59, 0.78);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.preset-tag:hover, .preset-tag.active {
  background: rgba(6, 182, 212, 0.2);
  border-color: rgba(6, 182, 212, 0.55);
  color: #cffafe;
}

/* Switch Toggle */
.toggle-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
}

.toggle-info strong {
  display: block;
  font-size: 0.88rem;
  color: var(--text-primary);
}

.toggle-info span {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.switch {
  position: relative;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  inset: 0;
  border-radius: 99px;
  background: #334155;
  transition: background 0.2s ease;
}

.switch-slider::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
}

.switch input:checked + .switch-slider {
  background: var(--accent-emerald);
}

.switch input:checked + .switch-slider::before {
  transform: translateX(20px);
}

/* Cover Configurator */
.cover-editor {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 14px;
  align-items: start;
  padding: 12px;
  border-radius: 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
}

.cover-preview-box {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-medium);
  position: relative;
}

.cover-preview-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cover-preview-box .cover-emblem-title {
  font-size: 0.96rem;
}

.cover-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.theme-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.theme-swatch {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  border: 2px solid transparent;
  transition: transform 0.14s ease, border-color 0.14s ease;
}

.theme-swatch:hover {
  transform: scale(1.1);
}

.theme-swatch.active {
  border-color: #ffffff;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.75);
}

.cover-upload-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* ==========================================================================
   In-Page Folder Browser Modal
   ========================================================================== */
.fs-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.fs-breadcrumbs {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  padding: 7px 10px;
  border-radius: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  font-size: 0.85rem;
  white-space: nowrap;
}

.fs-crumb {
  padding: 2px 7px;
  border-radius: 6px;
  color: var(--text-secondary);
  font-weight: 600;
}

.fs-crumb:hover {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-primary);
}

.fs-crumb.current {
  color: #a7f3d0;
}

.fs-crumb-sep {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.fs-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 260px;
  max-height: 46vh;
  overflow-y: auto;
  padding-right: 4px;
}

.fs-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid var(--border-subtle);
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.fs-item:hover {
  background: rgba(30, 41, 59, 0.92);
  border-color: rgba(56, 189, 248, 0.4);
}

.fs-item.has-game {
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.08);
}

.fs-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.fs-item-name {
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fs-game-badge {
  flex-shrink: 0;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 0.74rem;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.22);
  border: 1px solid rgba(16, 185, 129, 0.55);
  color: #6ee7b7;
}

.fs-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.fs-footer-info {
  flex: 1;
  min-width: 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.fs-footer-path {
  display: block;
  font-family: var(--font-mono);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   Network / LAN Modal
   ========================================================================== */
.net-section {
  margin-bottom: 16px;
}

.net-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.net-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.net-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 13px;
  border-radius: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
}

.net-url {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  color: #67e8f9;
  word-break: break-all;
}

.net-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.frp-tip {
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.3);
  font-size: 0.84rem;
  color: #ddd6fe;
  line-height: 1.6;
}

.frp-tip strong {
  color: #fff;
}

.frp-tip code {
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.35);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 0.82rem;
}

/* Delete Confirm Note */
.safe-note {
  margin-top: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #a7f3d0;
  font-size: 0.86rem;
}

/* Spinner */
.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.22);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}

.spinner-lg {
  width: 44px;
  height: 44px;
  border-width: 3.5px;
  border-color: rgba(16, 185, 129, 0.2);
  border-top-color: var(--accent-emerald);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */
.toast-container {
  position: fixed;
  right: 20px;
  bottom: calc(20px + var(--safe-bottom));
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--border-medium);
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toast-in 0.22s ease;
}

.toast.success { border-color: rgba(16, 185, 129, 0.6); color: #d1fae5; }
.toast.error   { border-color: rgba(244, 63, 94, 0.6);  color: #ffe4e6; }
.toast.info    { border-color: rgba(6, 182, 212, 0.6);  color: #cffafe; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ==========================================================================
   Fullscreen Embedded Player (play.html)
   ========================================================================== */
html.player-html, body.player-body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #000;
  touch-action: none;
}

#gameFrame {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  border: none;
  margin: 0;
  padding: 0;
  background: #000;
  display: block;
}

/* Transparent Drag Shield (prevents iframe from eating pointer events while dragging pill) */
.drag-shield {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: transparent;
  cursor: grabbing;
}

/* Player Loading Overlay */
.player-loading {
  position: fixed;
  inset: 0;
  z-index: 800;
  background: radial-gradient(circle at center, #0f172a 0%, #050811 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
  transition: opacity 0.3s ease;
}

.player-loading.fade-out {
  opacity: 0;
  pointer-events: none;
}

.player-loading-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
}

.player-loading-sub {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Player Error Overlay */
.player-error {
  position: fixed;
  inset: 0;
  z-index: 850;
  background: radial-gradient(circle at center, #111827 0%, #050811 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.player-error-card {
  max-width: 440px;
  width: 100%;
  padding: 30px 26px;
  border-radius: 22px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(244, 63, 94, 0.38);
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.player-error-card h2 {
  font-size: 1.3rem;
  margin: 12px 0 8px;
}

.player-error-card p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 22px;
  line-height: 1.55;
}

.player-error-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Smart Floating Hub Pill */
.hub-floating-wrap {
  position: fixed;
  z-index: 950;
  top: calc(12px + var(--safe-top));
  left: calc(12px + var(--safe-left));
  user-select: none;
  touch-action: none;
}

.hub-floating-wrap.snapping {
  transition: left 0.24s cubic-bezier(0.2, 0.9, 0.3, 1), top 0.24s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.hub-pill {
  height: 36px;
  padding: 0 13px;
  border-radius: 999px;
  background: rgba(10, 16, 30, 0.62);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(148, 163, 184, 0.28);
  color: rgba(241, 245, 249, 0.92);
  font-size: 0.82rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  cursor: grab;
  transition: opacity 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  opacity: 0.72;
}

.hub-pill:hover, .hub-pill.active-touch {
  opacity: 1;
  background: rgba(15, 23, 42, 0.9);
  border-color: rgba(16, 185, 129, 0.6);
}

.hub-pill.dragging {
  cursor: grabbing;
  opacity: 1;
  transform: scale(1.04);
}

/* Expanded Floating Toolbar */
.hub-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  max-width: calc(100vw - 24px);
  padding: 6px 8px;
  border-radius: 16px;
  background: rgba(9, 14, 27, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(148, 163, 184, 0.28);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.65);
  animation: modal-pop 0.16s ease;
}

.hub-tool-btn {
  height: 34px;
  padding: 0 11px;
  border-radius: 10px;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.16);
  color: #f1f5f9;
  font-size: 0.82rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.hub-tool-btn:hover {
  background: rgba(51, 65, 85, 0.95);
}

.hub-tool-btn.back-btn {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.45);
  color: #a7f3d0;
}

.hub-tool-btn.back-btn.confirming {
  background: #e11d48;
  border-color: #fb7185;
  color: #fff;
}

.hub-tool-btn.close-btn {
  background: rgba(148, 163, 184, 0.12);
  color: #94a3b8;
}

/* Android Back Button Confirm Bar */
.back-confirm-bar {
  position: fixed;
  left: 50%;
  bottom: calc(20px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 980;
  width: min(440px, calc(100vw - 24px));
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(11, 17, 32, 0.95);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(16, 185, 129, 0.45);
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  animation: toast-in 0.18s ease;
}

.back-confirm-text {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
}

.back-confirm-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ==========================================================================
   Responsive Breakpoints (Mobile Portrait, Mobile Landscape, Tablet)
   ========================================================================== */
@media (max-width: 900px) {
  .guide-steps {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .header-inner {
    padding: 10px 14px;
    gap: 10px;
  }

  .brand-title {
    font-size: 1.08rem;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .header-actions .btn-primary-cta {
    flex: 1;
  }

  .hub-main {
    padding: 14px 14px 0;
  }

  .empty-hero {
    padding: 30px 18px 24px;
    margin-top: 12px;
  }

  .empty-hero h2 {
    font-size: 1.42rem;
  }

  .games-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 14px;
  }

  .picker-actions,
  .form-grid,
  .cover-editor {
    grid-template-columns: 1fr;
  }

  .modal {
    max-height: 94vh;
    border-radius: 18px;
  }

  .modal-header, .modal-body, .modal-footer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .toast-container {
    right: 12px;
    left: 12px;
    max-width: none;
  }
}

/* Mobile Landscape — 3 compact columns & compact header */
@media (max-height: 520px) and (orientation: landscape) {
  .header-inner {
    padding: 8px 16px;
  }

  .hub-main {
    padding: 12px 16px 0;
  }

  .games-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }

  .card-body {
    padding: 10px 12px 12px;
    gap: 6px;
  }

  .card-desc {
    display: none;
  }
}

@media (max-width: 480px) {
  .games-grid {
    grid-template-columns: 1fr;
  }

  .btn {
    min-height: 44px;
  }

  .btn-play {
    min-height: 44px;
  }

  .btn-icon {
    width: 42px;
    height: 42px;
  }
}
