/* Arcade Hub — premium dark neon launcher */

:root {
  --bg: #070b16;
  --bg-elev: rgba(14, 20, 38, 0.82);
  --panel: rgba(18, 26, 48, 0.92);
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #eef2ff;
  --muted: #94a0c2;
  --cyan: #3de7ff;
  --magenta: #ff4fd8;
  --gold: #ffd56a;
  --green: #58d68d;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Ubuntu, Cantarell, sans-serif;
}

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

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  overflow-x: hidden;
}

button, a { font-family: inherit; }

/* Faster taps on iOS; avoids 300ms double-tap-zoom wait on controls */
button, a, .game-card, .filter-chip, .recent-chip, .featured-cta, .play-btn, .ghost-btn {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.hidden { display: none !important; }

#versionTag {
  position: fixed;
  top: max(10px, env(safe-area-inset-top, 0px));
  right: max(12px, env(safe-area-inset-right, 0px));
  z-index: 20;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  opacity: 0.55;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
  pointer-events: none;
  letter-spacing: 0.5px;
}

.version-line {
  margin: 8px 0 0 !important;
  font-size: 0.78rem !important;
  letter-spacing: 0.3px;
  opacity: 0.75;
}

/* ---------- ambient background ---------- */
#bg {
  position: fixed;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(7, 11, 22, 0.55) 0%, rgba(7, 11, 22, 0.88) 55%, #070b16 100%),
    url("../art/bg.jpg") center / cover no-repeat;
  z-index: 0;
  pointer-events: none;
}

#bgGlow {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(61, 231, 255, 0.16), transparent 60%),
    radial-gradient(700px 480px at 95% 10%, rgba(255, 79, 216, 0.12), transparent 55%),
    radial-gradient(600px 400px at 50% 100%, rgba(88, 214, 141, 0.08), transparent 50%);
  z-index: 0;
  pointer-events: none;
  animation: glowPulse 8s ease-in-out infinite alternate;
}

@keyframes glowPulse {
  from { opacity: 0.75; }
  to { opacity: 1; }
}

#app {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  min-height: 100dvh;
  padding:
    calc(16px + var(--safe-top))
    calc(18px + var(--safe-right))
    calc(28px + var(--safe-bot))
    calc(18px + var(--safe-left));
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ---------- top bar ---------- */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  box-shadow:
    0 0 0 1px rgba(61, 231, 255, 0.35),
    0 8px 24px rgba(61, 231, 255, 0.2);
  flex-shrink: 0;
}

.brand-text h1 {
  margin: 0;
  font-size: clamp(1.25rem, 3.5vw, 1.55rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  background: linear-gradient(100deg, #fff 20%, var(--cyan) 70%, var(--magenta));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-text p {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ghost-btn {
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  white-space: nowrap;
}

.ghost-btn:hover {
  background: rgba(61, 231, 255, 0.12);
  border-color: rgba(61, 231, 255, 0.45);
}

.ghost-btn:active { transform: scale(0.97); }
.ghost-btn .ico { font-size: 0.95rem; }

/* ---------- sections ---------- */
#main {
  display: flex;
  flex-direction: column;
  gap: 28px;
  flex: 1;
}

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

.section-head h2 {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.muted { color: var(--muted); font-size: 0.85rem; font-weight: 600; }

/* ---------- featured ---------- */
#featured {
  position: relative;
  border-radius: calc(var(--radius) + 4px);
  overflow: hidden;
  min-height: 220px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  cursor: pointer;
  isolation: isolate;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

#featured:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 55px rgba(0, 0, 0, 0.5);
}

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

.featured-bg {
  position: absolute;
  inset: 0;
  background-color: #12182a;
  transform: scale(1.02);
  transition: transform 0.45s ease;
  z-index: 0;
  overflow: hidden;
}

.featured-bg-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
  display: block;
  border: 0;
  pointer-events: none;
  -webkit-user-drag: none;
}

#featured:hover .featured-bg { transform: scale(1.06); }

.featured-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(100deg, rgba(7, 11, 22, 0.92) 0%, rgba(7, 11, 22, 0.55) 48%, rgba(7, 11, 22, 0.2) 100%),
    linear-gradient(0deg, rgba(7, 11, 22, 0.75) 0%, transparent 50%);
  z-index: 1;
  pointer-events: none;
}

.featured-content {
  position: relative;
  z-index: 2;
  padding: clamp(18px, 4vw, 28px);
  min-height: 220px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  max-width: 520px;
}

.badge {
  display: inline-flex;
  align-self: flex-start;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(61, 231, 255, 0.16);
  border: 1px solid rgba(61, 231, 255, 0.35);
  color: var(--cyan);
}

/* Game version pill — detail sheet only (not library cards) */
.game-version {
  display: inline-flex;
  align-items: center;
  margin: 0;
  font-family: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(7, 11, 22, 0.78);
  border: 1px solid rgba(255, 213, 106, 0.45);
  color: var(--gold);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  line-height: 1.2;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.featured-content h3 {
  margin: 0;
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.05;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.5);
}

.featured-content p {
  margin: 0;
  color: #d5dcf5;
  font-size: 0.95rem;
  line-height: 1.4;
  opacity: 0.92;
  max-width: 38ch;
}

.featured-cta {
  margin-top: 6px;
  align-self: flex-start;
  border: none;
  border-radius: 999px;
  padding: 11px 22px;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  color: #061018;
  background: linear-gradient(180deg, #8af7ff, var(--cyan));
  box-shadow:
    0 4px 0 #1a8ea0,
    0 10px 24px rgba(61, 231, 255, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
  transition: transform 0.1s, filter 0.15s;
}

.featured-cta:hover { filter: brightness(1.06); }
.featured-cta:active {
  transform: translateY(2px);
  box-shadow:
    0 2px 0 #1a8ea0,
    0 6px 16px rgba(61, 231, 255, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

/* ---------- filters ---------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.filter-chip {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-chip:hover {
  color: var(--text);
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.08);
}

.filter-chip.active {
  color: #061018;
  background: linear-gradient(180deg, #b8f7ff, var(--cyan));
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(61, 231, 255, 0.25);
}

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

@media (min-width: 640px) {
  .game-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 18px;
  }
}

.game-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  padding: 0;
  color: inherit;
  /* CSS grid avoids WebKit flex+aspect-ratio collapse (0-height covers on iPad) */
  display: grid;
  grid-template-rows: auto auto;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  transition: transform 0.16s ease, border-color 0.16s, box-shadow 0.16s;
  animation: cardIn 0.45s ease both;
  -webkit-tap-highlight-color: transparent;
}

.game-card:hover {
  transform: translateY(-4px) scale(1.015);
  border-color: color-mix(in srgb, var(--card-accent, var(--cyan)) 55%, transparent);
  box-shadow:
    0 16px 36px rgba(0, 0, 0, 0.4),
    0 0 0 1px color-mix(in srgb, var(--card-accent, var(--cyan)) 35%, transparent);
}

.game-card:active { transform: translateY(-1px) scale(1.0); }

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

@keyframes cardIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.card-cover {
  position: relative;
  width: 100%;
  /* Padding-box ratio is bulletproof on iPad WebKit (aspect-ratio inside cards can collapse to 0) */
  height: 0;
  padding-bottom: 133.333%; /* 3:4 portrait */
  background-color: #12182a;
  overflow: hidden;
}

.card-cover-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  border: 0;
  pointer-events: none;
  -webkit-user-drag: none;
  z-index: 0;
}

.card-cover::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 45%;
  background: linear-gradient(to top, rgba(7, 11, 22, 0.85), transparent);
  pointer-events: none;
  z-index: 1;
}



.card-play {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: color-mix(in srgb, var(--card-accent, var(--cyan)) 90%, #fff);
  color: #061018;
  font-size: 0.85rem;
  font-weight: 900;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.15s, transform 0.15s;
  pointer-events: none;
  z-index: 2;
}

.game-card:hover .card-play,
.game-card:focus-visible .card-play {
  opacity: 1;
  transform: scale(1);
}

.card-meta {
  padding: 11px 12px 13px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.card-meta h3 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.card-meta p {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.tag {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: #c3cce8;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 28px 12px;
}

/* ---------- recently played ---------- */
.recent-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.recent-chip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: inherit;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.88rem;
  transition: background 0.15s, border-color 0.15s;
}

.recent-chip:hover {
  background: rgba(61, 231, 255, 0.1);
  border-color: rgba(61, 231, 255, 0.35);
}

.recent-thumb {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background-color: #1a2238;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  flex-shrink: 0;
}

/* ---------- footer ---------- */
#footer {
  margin-top: auto;
  padding-top: 8px;
  text-align: center;
}

#footer p {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  opacity: 0.85;
}

#footer code {
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 6px;
  color: #cfe8ff;
}

/* ---------- detail sheet ---------- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: end center;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  background: rgba(3, 6, 14, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: pointer;
  padding: 0;
}

.sheet-panel {
  position: relative;
  z-index: 1;
  width: min(480px, 100%);
  max-height: min(92dvh, 820px);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.5);
  overflow: auto;
  animation: sheetUp 0.28s cubic-bezier(0.2, 0.9, 0.2, 1);
  padding-bottom: var(--safe-bot);
}

@media (min-width: 560px) {
  .sheet { place-items: center; }
  .sheet-panel {
    border-radius: 22px;
    max-height: min(88dvh, 760px);
  }
}

@keyframes sheetUp {
  from { transform: translateY(28px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.sheet-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: rgba(7, 11, 22, 0.7);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.sheet-close:hover { background: rgba(255, 255, 255, 0.12); }

.sheet-cover {
  height: 220px;
  background-color: #10182c;
  position: relative;
  overflow: hidden;
}

.sheet-cover-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  border: 0;
  pointer-events: none;
  -webkit-user-drag: none;
  z-index: 0;
}

.sheet-cover::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 50%;
  background: linear-gradient(to top, var(--panel), transparent);
  pointer-events: none;
  z-index: 1;
}

/* Version sits at the top of the detail sheet cover (not on library cards) */
.sheet-version {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  max-width: calc(100% - 64px); /* leave room for close button */
  pointer-events: none;
}

.sheet-body {
  padding: 4px 22px 26px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sheet-body .tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sheet-body h2 {
  margin: 2px 0 0;
  font-size: 1.65rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.sheet-sub {
  margin: 0;
  color: var(--cyan);
  font-weight: 700;
  font-size: 0.95rem;
}

.sheet-desc {
  margin: 4px 0 8px;
  color: #c7d0ea;
  line-height: 1.5;
  font-size: 0.95rem;
}

.play-btn {
  border: none;
  border-radius: 999px;
  padding: 14px 20px;
  font-size: 1.1rem;
  font-weight: 900;
  cursor: pointer;
  color: #061018;
  background: linear-gradient(180deg, #9cf75a, #3fce4e);
  box-shadow:
    0 5px 0 #2b8f3a,
    0 12px 28px rgba(0, 0, 0, 0.35),
    inset 0 2px 0 rgba(255, 255, 255, 0.45);
  transition: transform 0.1s, filter 0.15s;
  margin-top: 4px;
}

.play-btn:hover { filter: brightness(1.05); }
.play-btn:active {
  transform: translateY(3px);
  box-shadow:
    0 2px 0 #2b8f3a,
    0 8px 18px rgba(0, 0, 0, 0.3),
    inset 0 2px 0 rgba(255, 255, 255, 0.45);
}

.text-link {
  align-self: center;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}

.text-link:hover { color: var(--cyan); }

/* accent override for play button when set from JS */
.play-btn[data-accent] {
  background: linear-gradient(180deg, color-mix(in srgb, var(--btn-accent) 55%, #fff), var(--btn-accent));
  box-shadow:
    0 5px 0 color-mix(in srgb, var(--btn-accent) 70%, #000),
    0 12px 28px rgba(0, 0, 0, 0.35),
    inset 0 2px 0 rgba(255, 255, 255, 0.45);
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bot));
  transform: translateX(-50%);
  z-index: 80;
  background: rgba(12, 18, 34, 0.94);
  border: 1px solid var(--line-strong);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  animation: toastIn 0.25s ease;
  max-width: min(90vw, 360px);
  text-align: center;
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
