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

:root {
  --bg: #0c0d12;
  --bg-elevated: #14151d;
  --bg-card: #191a24;
  --bg-input: #222333;
  --text: #f4f4f8;
  --muted: #9a9aaf;
  --faint: #6f6f84;
  --line: rgba(255, 255, 255, 0.08);
  --accent: #6d74ff;
  --accent-2: #9b6dff;
  --accent-game: #ff8a4c;
  --accent-game-2: #ff6b8a;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --radius: 18px;
}

html, body {
  min-height: 100%;
  background:
    radial-gradient(circle at 8% 0%, rgba(109, 116, 255, 0.2), transparent 28%),
    radial-gradient(circle at 100% 100%, rgba(155, 109, 255, 0.14), transparent 26%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
}

body {
  min-height: 100vh;
}

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

button {
  cursor: pointer;
}

code {
  font-family: Consolas, "Courier New", monospace;
  color: #c7c9ff;
}

.hidden { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.app-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 24px auto 40px;
}

.topbar, .stat-card, .app-card, .log-panel, .empty-state {
  border: 1px solid var(--line);
  background: rgba(20, 21, 29, 0.88);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 22px 24px;
  border-radius: 24px;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-size: 1.3rem;
}

.brand h1 {
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}

.brand p, .muted, .stat-label, .meta-row, .log-item time {
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-wrap input {
  width: min(280px, 70vw);
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-input);
  outline: none;
}

.search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(109, 116, 255, 0.18);
}

.ghost-button, .primary-button, .danger-button, .text-button {
  border: 0;
  border-radius: 12px;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

.ghost-button, .primary-button, .danger-button {
  padding: 10px 14px;
}

.ghost-button {
  background: #2a2b3a;
}

.primary-button {
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.ai-team-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.ai-team-link:hover { filter: brightness(1.12); transform: translateY(-1px); }
.ai-team-link:focus-visible { outline: 2px solid #c4b5fd; outline-offset: 3px; }

.danger-button {
  color: white;
  background: #7f1d1d;
}

.text-button {
  background: transparent;
  color: var(--muted);
  padding: 4px 8px;
}

button:hover:not(:disabled) { transform: translateY(-1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.status-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #222333;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--faint);
}

.status-dot[data-state="connected"] { background: var(--good); }
.status-dot[data-state="connecting"],
.status-dot[data-state="reconnecting"] {
  background: var(--warn);
  animation: pulse 1s infinite;
}
.status-dot[data-state="disconnected"] { background: var(--bad); }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 16px 0;
}

.stat-card, .empty-state, .log-panel {
  border-radius: var(--radius);
}

.stat-card {
  padding: 16px 18px;
}

.stat-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat-card strong {
  font-size: 1.4rem;
}

.catalog-tabs {
  display: flex;
  gap: 8px;
  padding: 6px;
  margin: 0 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(20, 21, 29, 0.88);
  box-shadow: var(--shadow);
}

.catalog-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 18px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 650;
  letter-spacing: -0.01em;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.catalog-tab:hover:not(.is-active) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.catalog-tab.is-active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 24px rgba(109, 116, 255, 0.28);
}

.catalog-tab[data-tab="games"].is-active {
  background: linear-gradient(135deg, var(--accent-game), var(--accent-game-2));
  box-shadow: 0 10px 24px rgba(255, 138, 76, 0.24);
}

.tab-count {
  min-width: 1.6em;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.4;
}

.catalog-tab.is-active .tab-count {
  background: rgba(0, 0, 0, 0.22);
  color: #fff;
}

.content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  margin-bottom: 12px;
}

.section-head h2 {
  font-size: 1rem;
}

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

.app-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: 20px;
}

.card-top {
  display: flex;
  gap: 12px;
}

.app-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: #24253a;
  font-size: 1.4rem;
}

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

.card-copy h3 {
  font-size: 1.02rem;
}

.card-copy p {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
  margin-top: 4px;
}

.badge {
  flex-shrink: 0;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}

.badge-live { background: rgba(52, 211, 153, 0.16); color: var(--good); }
.badge-idle { background: rgba(255, 255, 255, 0.06); color: var(--muted); }
.badge-game { background: rgba(255, 138, 76, 0.18); color: #ffb088; }
.badge-app { background: rgba(109, 116, 255, 0.16); color: #c7c9ff; }

.app-card-game {
  border-color: rgba(255, 138, 76, 0.22);
}
.app-card-game .app-icon {
  background: linear-gradient(160deg, #3a2418, #2a1c28);
}

.meta-row, .tag-row, .card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.meta-row {
  font-size: 0.75rem;
}

.tag {
  padding: 3px 8px;
  border-radius: 999px;
  background: #26273a;
  color: #c9cbe8;
  font-size: 0.72rem;
}

.card-actions {
  margin-top: auto;
}

.card-actions button, .card-actions .launch-link {
  flex: 1;
}

.launch-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.empty-state {
  padding: 36px 20px;
  text-align: center;
}

.empty-icon { font-size: 2rem; margin-bottom: 8px; }
.empty-state h3 { margin-bottom: 6px; }
.empty-state p { color: var(--muted); }

.log-panel {
  padding: 16px;
  max-height: calc(100vh - 250px);
  position: sticky;
  top: 16px;
}

.log-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100vh - 320px);
  overflow: auto;
}

.log-item {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 8px;
  font-size: 0.8rem;
  line-height: 1.4;
}

.log-error span { color: var(--bad); }
.log-warn span { color: var(--warn); }

@keyframes pulse {
  50% { opacity: 0.45; }
}

@media (max-width: 960px) {
  .content, .stats { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: stretch; }
  .log-panel { position: static; max-height: none; }
  .catalog-tabs {
    width: 100%;
    border-radius: 20px;
  }
  .catalog-tab {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .catalog-tabs {
    flex-direction: column;
    border-radius: 22px;
    padding: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}


/* Flipper of Things public experience catalog */
:root {
  --bg: #09100f;
  --bg-elevated: #111a17;
  --bg-card: #14201c;
  --bg-input: #1a2924;
  --text: #f5f6eb;
  --muted: #aab6a8;
  --faint: #708174;
  --line: rgba(213, 230, 202, 0.12);
  --accent: #c7ef72;
  --accent-2: #71d8b5;
  --accent-game: #f3b86d;
  --accent-game-2: #e98c75;
  --shadow: 0 24px 60px rgba(0, 0, 0, .24);
}

html, body {
  background:
    radial-gradient(ellipse at 82% 8%, rgba(90, 159, 120, .15), transparent 35%),
    radial-gradient(ellipse at 8% 28%, rgba(186, 217, 106, .09), transparent 30%),
    var(--bg);
}
.app-shell { width: min(1240px, calc(100% - 40px)); margin-top: 22px; }
.topbar, .stat-card, .app-card, .log-panel, .empty-state, .catalog-tabs {
  background: rgba(17, 26, 23, .91);
  border-color: var(--line);
}
.topbar { border-radius: 20px; }
.brand-mark { color: #132018; background: linear-gradient(135deg, #c7ef72, #71d8b5); }
.brand h1 { font-size: clamp(1.15rem, 2.5vw, 1.55rem); }
.brand p { margin-top: 4px; max-width: 470px; font-size: .9rem; }
.welcome-panel {
  min-height: 228px;
  margin: 18px 0 14px;
  padding: clamp(24px, 5vw, 48px);
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid rgba(199, 239, 114, .2);
  border-radius: 24px;
  background: linear-gradient(110deg, rgba(23, 39, 31, .97), rgba(21, 39, 33, .78) 65%, rgba(52, 87, 65, .55));
  box-shadow: var(--shadow);
}
.welcome-panel > div:first-child { position: relative; z-index: 1; max-width: 650px; }
.eyebrow { color: var(--accent); font-size: .72rem; font-weight: 800; letter-spacing: .18em; }
.welcome-panel h2 { margin: 9px 0; font-size: clamp(1.8rem, 5vw, 3.15rem); line-height: 1.04; letter-spacing: -.055em; }
.welcome-panel h2 span { color: var(--accent); }
.welcome-panel p:last-child { max-width: 500px; color: var(--muted); line-height: 1.55; }
.welcome-orbit { width: 180px; height: 180px; position: relative; flex: 0 0 auto; margin-right: 3%; border: 1px solid rgba(199, 239, 114, .26); border-radius: 50%; box-shadow: inset 0 0 44px rgba(199, 239, 114, .06), 0 0 70px rgba(113, 216, 181, .1); }
.welcome-orbit::before, .welcome-orbit::after { content: ""; position: absolute; inset: 15%; border: 1px solid rgba(199, 239, 114, .22); border-radius: 50%; transform: rotate(35deg) scaleX(.55); }
.welcome-orbit::after { transform: rotate(-35deg) scaleX(.55); }
.welcome-orbit span { position: absolute; top: 34%; left: 45%; color: var(--accent); font-size: 2rem; }
.welcome-orbit i { position: absolute; right: 25%; bottom: 27%; color: #fff; font-size: 1.3rem; font-style: normal; }
.stats { margin: 14px 0 18px; gap: 10px; }
.stat-card { padding: 13px 16px; border-radius: 15px; box-shadow: none; }
.stat-label { font-size: .68rem; letter-spacing: .1em; }
.stat-card strong { color: var(--accent); }
.catalog-tabs { padding: 6px; border-radius: 16px; }
.catalog-tab { border-radius: 12px; min-height: 44px; }
.catalog-tab.is-active { color: #132018; background: linear-gradient(135deg, #c7ef72, #8ddc98); box-shadow: 0 8px 24px rgba(139, 192, 102, .18); }
.catalog-tab[data-tab="games"].is-active { color: #231912; background: linear-gradient(135deg, #f3b86d, #e98c75); box-shadow: 0 8px 24px rgba(233, 140, 117, .16); }
.catalog-tab[data-tab="ar"].is-active { color: #10221e; background: linear-gradient(135deg, #71d8b5, #96d7dc); }
.app-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); }
.app-card { min-height: 195px; border-radius: 18px; box-shadow: 0 12px 30px rgba(0,0,0,.17); transition: transform .18s ease, border-color .18s ease, background .18s ease; }
.app-card:hover { transform: translateY(-3px); border-color: rgba(199, 239, 114, .3); background: #17251f; }
.app-card-game { border-color: rgba(243, 184, 109, .24); }
.app-card-ar { border-color: rgba(113, 216, 181, .3); }
.app-icon { background: linear-gradient(145deg, #263d31, #202b25); }
.app-card-ar .app-icon { color: var(--accent-2); background: linear-gradient(145deg, #153c35, #1c302b); }
.badge-ar { color: #91e5cb; background: rgba(113, 216, 181, .14); }
.tag { background: rgba(199, 239, 114, .09); color: #d2e1c9; }
.primary-button { color: #142018; font-weight: 750; background: linear-gradient(135deg, #c7ef72, #8ddc98); }
.app-card-game .primary-button { background: linear-gradient(135deg, #f3b86d, #e98c75); }
.app-card-ar .primary-button { background: linear-gradient(135deg, #71d8b5, #96d7dc); }
.search-wrap input, .sort-wrap select { border-color: var(--line); background: var(--bg-input); border-radius: 12px; }
.empty-state { border-style: dashed; box-shadow: none; }
.public-mode #refresh-btn { display: none; }
[hidden] { display: none !important; }

@media (max-width: 760px) {
  .app-shell { width: min(100% - 24px, 600px); margin: 12px auto 26px; }
  .topbar { gap: 14px; padding: 16px; border-radius: 18px; }
  .topbar-actions { width: 100%; gap: 8px; }
  .search-wrap { flex: 1 1 100%; }
  .search-wrap input { width: 100%; min-height: 44px; }
  .sort-wrap { flex: 1; }
  .sort-wrap select { width: 100%; min-height: 42px; color: var(--text); padding: 0 10px; }
  .status-chip { min-height: 40px; }
  .welcome-panel { min-height: 190px; padding: 24px 20px; border-radius: 19px; }
  .welcome-orbit { width: 105px; height: 105px; margin: 0 0 0 10px; opacity: .75; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .content { grid-template-columns: 1fr; }
  .section-head { align-items: start; flex-direction: column; }
  .app-grid { grid-template-columns: 1fr; }
  .app-card { min-height: 0; padding: 16px; }
  .catalog-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
  .catalog-tab { gap: 5px; padding: 10px 5px; font-size: .82rem; }
}
@media (max-width: 420px) {
  .brand { align-items: flex-start; }
  .brand-mark { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 13px; }
  .brand p { font-size: .82rem; }
  .welcome-panel { min-height: 175px; }
  .welcome-panel h2 { font-size: 1.75rem; }
  .welcome-panel p:last-child { max-width: 250px; font-size: .87rem; }
  .welcome-orbit { width: 66px; height: 66px; margin-right: 0; }
  .welcome-orbit span { top: 29%; left: 41%; font-size: 1.3rem; }
  .welcome-orbit i { font-size: 1rem; }
  .catalog-tab { flex-direction: column; min-height: 55px; font-size: .74rem; }
  .tab-count { font-size: .68rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
