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

:root {
  --vh: 1dvh;
}

html, body {
  width: 100%;
  height: 100%;
  background: #000;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  overflow: hidden;
}

/* ── Header ── */
#header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: flex-end;
  padding: calc(8px + env(safe-area-inset-top)) 16px 10px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.5) 70%, transparent 100%);
  pointer-events: none;
}

#logo {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.5px;
  white-space: nowrap;
}

#logo span {
  color: #fe2c55;
}

/* ── Feed tabs ── */
#feed-tabs {
  display: flex;
  align-items: center;
  gap: 20px;
  pointer-events: auto;
}

.feed-tab {
  background: none;
  border: none;
  color: rgba(255,255,255,0.55);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  padding: 4px 2px 8px;
  letter-spacing: 0.1px;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

.feed-tab.active {
  color: #fff;
  font-weight: 700;
}

.feed-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 22px;
  height: 2.5px;
  background: #fff;
  border-radius: 2px;
}

.feed-tab:hover {
  color: rgba(255,255,255,0.85);
}

/* ── Header right ── */
#header-right {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  pointer-events: auto;
}


/* ── Feed ── */
#feed {
  width: 100%;
  height: 100dvh;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

#feed::-webkit-scrollbar {
  display: none;
}

/* ── Slide ── */
.game-slide {
  position: relative;
  width: 100%;
  height: 100dvh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  background: #111;
  overflow: hidden;
}

/* ── iframe ── */
.game-slide iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  z-index: 0;
}

/* ── Embed error fallback ── */
.embed-error {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: #0a0a0a;
  text-align: center;
  padding: 32px;
}

.embed-error[hidden] {
  display: none;
}

.embed-error .game-icon {
  font-size: 72px;
  line-height: 1;
}

.embed-error h2 {
  font-size: 22px;
  font-weight: 700;
}

.embed-error p {
  font-size: 14px;
  color: rgba(255,255,255,0.5);
  max-width: 280px;
  line-height: 1.5;
}

.embed-error .open-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fe2c55;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 14px 28px;
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.15s;
}

.embed-error .open-btn:hover {
  opacity: 0.85;
}

.embed-error--no-embed {
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.embed-error--no-embed .open-btn {
  background: #88a8c5;
  color: #fff;
}

.embed-error--no-embed p {
  color: rgba(255, 255, 255, 0.8);
}

/* ── Overlay ── */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  display: flex;
  align-items: flex-end;
  background: linear-gradient(
    to top,
    rgba(0,0,0,0.8) 0%,
    rgba(0,0,0,0.25) 35%,
    transparent 60%
  );
}

.overlay-inner {
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 12px 32px 16px;
  padding-bottom: max(52px, calc(52px + env(safe-area-inset-bottom)));
  gap: 12px;
}

/* ── Left info panel ── */
.game-info {
  flex: 1;
  min-width: 0;
}

/* ── Builder X profile link ── */
.builder-x {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
  transition: opacity 0.15s;
  pointer-events: auto;
}

.builder-x:hover {
  opacity: 0.85;
}

.builder-avatar {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  overflow: hidden;
}

.game-info .game-title {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 6px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

.game-info .game-desc {
  font-size: 13px;
  color: rgba(255,255,255,0.8);
  line-height: 1.4;
  margin-bottom: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

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

.tag {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  pointer-events: auto;
}

/* ── Right action column ── */
.game-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  pointer-events: auto;
  flex-shrink: 0;
}

/* ── Sidebar stats ── */
.action-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

/* ── Creator avatar ── */
.creator-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  line-height: 1;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(4px);
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
  transition: transform 0.15s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
}

.action-btn:hover {
  transform: scale(1.1);
}

.action-btn:active {
  transform: scale(0.92);
}

.action-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  line-height: 1;
}

.action-icon .x-icon {
  width: 22px;
  height: 22px;
}

.action-btn.liked .action-icon {
  background: rgba(254,44,85,0.25);
}

.action-btn.liked {
  color: #fe2c55;
}

/* ── Swipe hint ── */
#swipe-hint {
  position: fixed;
  bottom: max(80px, calc(80px + env(safe-area-inset-bottom)));
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  animation: hint-bounce 1.5s ease-in-out infinite;
  transition: opacity 0.5s;
}

#swipe-hint.hidden {
  opacity: 0;
}

#swipe-hint .hint-arrow {
  font-size: 20px;
}

#swipe-hint .hint-text {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

@keyframes hint-bounce {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-6px); }
}

/* ── Nav arrows (desktop) ── */
#nav-up, #nav-down {
  position: fixed;
  right: 24px;
  z-index: 100;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(8px);
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s, background 0.2s;
}

#nav-up {
  top: calc(50% - 52px);
}

#nav-down {
  top: calc(50% + 12px);
}

#nav-up:hover, #nav-down:hover {
  background: rgba(255,255,255,0.3);
}

#nav-up.disabled, #nav-down.disabled {
  opacity: 0.2;
  cursor: default;
}

@media (max-width: 600px) {
  #nav-up, #nav-down {
    display: none;
  }
}

/* ── Loading spinner inside iframe area ── */
.slide-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0a0a;
  transition: opacity 0.3s;
}

.slide-loading.gone {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: #fe2c55;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

