/* ============================================================
   Game Hub — standardized theme
   Cozy, dark, arcade-lounge aesthetic. Fully responsive.
   ============================================================ */

:root {
  --bg: #0d1117;
  --bg-elevated: #161b22;
  --bg-card: #1a2130;
  --bg-card-hover: #212a3b;
  --border: #2a3444;
  --border-strong: #3a4658;

  --text: #e8edf4;
  --text-dim: #9aa7b8;
  --text-faint: #6b7787;

  --accent: #4f8cff;
  --accent-2: #b45cff;
  --accent-glow: rgba(79, 140, 255, 0.35);

  --ok: #34d399;
  --warn: #fbbf24;

  --radius: 14px;
  --radius-sm: 9px;
  --gap: 18px;
  --header-h: 68px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(79, 140, 255, 0.10), transparent 60%),
    radial-gradient(1000px 500px at 100% 0%, rgba(180, 92, 255, 0.10), transparent 55%),
    var(--bg);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

.view[hidden] { display: none !important; }

/* ---------------------- Lobby header ---------------------- */
.hub-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px clamp(16px, 4vw, 40px);
  max-width: 1280px;
  margin: 0 auto;
}

.hub-header__brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.hub-header__logo {
  filter: drop-shadow(0 3px 10px var(--accent-glow));
  flex: none;
}

.hub-header__title {
  margin: 0;
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 800;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hub-header__subtitle {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.hub-header__device {
  font-size: 0.78rem;
  color: var(--text-dim);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  padding: 7px 12px;
  border-radius: 999px;
  white-space: nowrap;
  flex: none;
}

/* ---------------------- Filters ---------------------- */
.filters {
  display: flex;
  gap: 10px;
  padding: 4px clamp(16px, 4vw, 40px) 8px;
  max-width: 1280px;
  margin: 0 auto;
  flex-wrap: wrap;
}

.chip {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-dim);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.chip:hover { color: var(--text); border-color: var(--border-strong); }

.chip.is-active {
  color: #fff;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-color: transparent;
}

/* ---------------------- Lobby grid ---------------------- */
.lobby {
  padding: 14px clamp(16px, 4vw, 40px) 40px;
  max-width: 1280px;
  margin: 0 auto;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--gap);
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  color: inherit;
  font: inherit;
  padding: 0;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.card:hover,
.card:focus-visible {
  transform: translateY(-4px);
  border-color: var(--border-strong);
  background: var(--bg-card-hover);
  box-shadow: var(--shadow);
  outline: none;
}

.card.is-unsupported { opacity: 0.62; }

.card__thumb {
  aspect-ratio: 16 / 10;
  width: 100%;
  object-fit: cover;
  background: linear-gradient(135deg, #1b2436, #232f47);
  display: block;
}

.card__body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.card__title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
}

.card__tagline {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.4;
  flex: 1;
}

.card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}

.card__devices { display: flex; gap: 6px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-faint);
}

.badge.is-current {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(90deg, rgba(79,140,255,0.9), rgba(180,92,255,0.9));
}

.card__tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag {
  font-size: 0.7rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card__hint {
  position: absolute;
  top: 10px;
  left: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--border-strong);
  padding: 4px 8px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
}

/* ---------------------- Empty state ---------------------- */
.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
  color: var(--text-dim);
}
.empty h2 { color: var(--text); margin: 0 0 8px; }

/* ---------------------- Footer ---------------------- */
.hub-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px clamp(16px, 4vw, 40px) 30px;
  color: var(--text-faint);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}

/* ============================================================
   Play view — the standardized game chrome
   ============================================================ */
.play-view {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #05070c;
}

.play-bar {
  height: var(--header-h);
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  padding-top: env(safe-area-inset-top, 0);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
  z-index: 2;
}

.play-bar__back {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, border-color 0.15s;
  flex: none;
}
.play-bar__back:hover { background: var(--bg-card-hover); border-color: var(--accent); }

.play-bar__title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.play-bar__actions { display: flex; align-items: center; gap: 10px; flex: none; }

.play-bar__device {
  font-size: 0.72rem;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.play-bar__fs {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.play-bar__fs:hover { background: var(--bg-card-hover); border-color: var(--accent); }

.play-stage {
  position: relative;
  flex: 1;
  min-height: 0;
}

.game-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #000;
}

/* ---------------------- Unsupported-device notice ---------------------- */
.device-notice {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(3, 5, 10, 0.82);
  backdrop-filter: blur(6px);
  z-index: 3;
}
.device-notice[hidden] { display: none; }

.device-notice__card {
  max-width: 420px;
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 26px 24px;
  box-shadow: var(--shadow);
}

.device-notice__text {
  margin: 0 0 18px;
  color: var(--text);
  line-height: 1.5;
}

.device-notice__dismiss {
  appearance: none;
  border: none;
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 11px 22px;
  border-radius: 999px;
  cursor: pointer;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

/* ---------------------- Toast ---------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(12px);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 0.88rem;
  box-shadow: var(--shadow);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------------- Responsive tweaks ---------------------- */
@media (max-width: 560px) {
  .hub-header { flex-wrap: wrap; }
  .hub-header__subtitle { display: none; }
  .game-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .card__tagline { display: none; }
  .card__body { padding: 10px 12px 12px; gap: 6px; }
  .card__title { font-size: 0.95rem; }
  .play-bar__device { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .card:hover { transform: none; }
}
