/* AstroTown · Play Page */
@import url('../tokens.css');

/* Body override — play page is full-bleed, no scroll */
.play-page-body {
  overflow: hidden;
  height: 100vh;
}

/* ── Play layout: center player + right rail ────────────────────────────── */
.play-main {
  display: flex;
  height: 100vh;
  overflow: hidden;
  padding-top: 0 !important;
}

.play-layout {
  display: flex;
  flex: 1;
  height: 100%;
  overflow: hidden;
}

/* ── Center area ──────────────────────────────────────────────────────────── */
.play-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: var(--s4) var(--s4) 0;
  min-width: 0;
  position: relative;
  background: var(--bg-void);
  overflow: hidden;
}

/* ── Top meta bar ─────────────────────────────────────────────────────────── */
.play-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 520px;
  flex-shrink: 0;
  padding-bottom: var(--s3);
  gap: var(--s3);
}

.play-topbar-btn {
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background var(--t-fast) ease, color var(--t-fast) ease;
}
.play-topbar-btn:hover { background: var(--bg-raised); color: var(--text-primary); }

/* ── Player wrapper + shell ──────────────────────────────────────────────── */
.play-player-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 520px;
}

.play-player-shell {
  border-radius: var(--r-xl);
  overflow: hidden;
  box-shadow: 0 0 40px rgba(99,102,241,0.2), 0 24px 64px rgba(0,0,0,0.8);
  border: 1px solid var(--border-subtle);
  position: relative;
  background: #000;
  transition: width var(--t-base) var(--ease-out), height var(--t-base) var(--ease-out);
  /* Default size M: 360×640 */
  width: 360px;
  height: 640px;
  flex-shrink: 0;
}

/* Iframe fills the player shell exactly */
.play-player-shell iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: none;
}

/* ── Loading state ────────────────────────────────────────────────────────── */
.play-loading-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s4);
  background: var(--bg-deep);
  z-index: 10;
}

.play-loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--bg-raised);
  border-top-color: var(--accent-primary);
  border-radius: var(--r-full);
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.play-loading-text {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.play-loading-state.hidden { display: none; }

/* Error state */
.play-error-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s3);
  padding: var(--s6);
  background: var(--bg-deep);
  text-align: center;
  z-index: 10;
}
.play-error-icon { font-size: 40px; opacity: 0.4; }
.play-error-title { font-size: var(--text-md); font-weight: var(--weight-semibold); color: var(--text-secondary); }
.play-error-desc { font-size: var(--text-sm); color: var(--text-muted); }

/* Welcome / empty state */
.play-welcome-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s3);
  padding: var(--s8) var(--s6);
  background: var(--bg-deep);
  text-align: center;
  z-index: 10;
}
.play-welcome-icon { margin-bottom: var(--s2); opacity: 0.8; }
.play-welcome-title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.play-welcome-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  padding: 0;
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
  counter-reset: steps;
}
.play-welcome-steps li {
  display: flex;
  align-items: center;
  gap: var(--s2);
  counter-increment: steps;
}
.play-welcome-steps li::before {
  content: counter(steps);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(99,102,241,0.2);
  border: 1px solid rgba(99,102,241,0.4);
  font-size: 11px;
  font-weight: var(--weight-bold);
  color: var(--accent-glow);
  flex-shrink: 0;
}
.play-welcome-link { color: var(--accent-glow); text-decoration: none; }
.play-welcome-link:hover { color: var(--accent-pulse); }
.play-welcome-btn {
  margin-top: var(--s2);
  font-size: var(--text-sm);
  padding: var(--s2) var(--s5);
}
.play-welcome-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  opacity: 0.6;
  margin-top: var(--s1);
}

/* ── Compat badge ─────────────────────────────────────────────────────────── */
.play-compat-badge {
  margin-top: var(--s2);
  padding: var(--s1) var(--s3);
  border-radius: var(--r-full);
  background: rgba(251,191,36,0.12);
  border: 1px solid rgba(251,191,36,0.25);
  font-size: var(--text-2xs);
  color: var(--color-warning);
  white-space: nowrap;
}

/* ── Size selector ────────────────────────────────────────────────────────── */
.play-size-select {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: 3px;
}

.play-size-btn {
  padding: 3px 8px;
  border-radius: calc(var(--r-md) - 2px);
  font-size: 10px;
  font-weight: var(--weight-bold);
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background var(--t-fast) ease, color var(--t-fast) ease;
  white-space: nowrap;
  letter-spacing: 0.03em;
}
.play-size-btn:hover { color: var(--text-secondary); background: var(--bg-raised); }
.play-size-btn.active {
  background: var(--bg-overlay);
  color: var(--text-primary);
}

/* ── Bottom author strip ──────────────────────────────────────────────────── */
.play-bottom-strip {
  flex-shrink: 0;
  width: 100%;
  max-width: 520px;
  padding: var(--s3) 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
}

.play-author-info {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-width: 0;
  flex: 1;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.play-author-info:hover .play-author-name { color: var(--accent-glow); }

.play-author-avatar {
  width: 36px; height: 36px;
  border-radius: var(--r-full);
  background: var(--bg-overlay);
  border: 2px solid var(--border-accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  overflow: hidden;
}
.play-author-avatar img { width: 100%; height: 100%; object-fit: cover; }

.play-author-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--t-fast) ease;
}

.play-author-handle {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.play-follow-btn {
  padding: var(--s2) var(--s4);
  border-radius: var(--r-full);
  background: var(--accent-primary);
  color: #fff;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--t-fast) ease, color var(--t-fast) ease, border-color var(--t-fast) ease;
  flex-shrink: 0;
}
.play-follow-btn:hover { background: var(--accent-secondary); }
.play-follow-btn.following {
  background: transparent;
  border-color: var(--border-normal);
  color: var(--text-secondary);
}

/* ── Right action rail ────────────────────────────────────────────────────── */
.play-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: var(--s6) var(--s3);
  gap: var(--s4);
  border-left: 1px solid var(--border-subtle);
  background: rgba(7,8,16,0.7);
  min-width: 68px;
  max-width: 72px;
  height: 100%;
  flex-shrink: 0;
}

.play-rail-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s3);
}

.play-rail-btn {
  width: 44px; height: 48px;
  border-radius: var(--r-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  transition:
    background var(--t-fast) ease,
    color var(--t-fast) ease,
    border-color var(--t-fast) ease,
    transform var(--t-fast) ease;
}

.play-rail-btn:hover {
  background: var(--bg-raised);
  color: var(--text-primary);
  border-color: var(--border-accent);
  transform: scale(1.06);
}
.play-rail-btn:active { transform: scale(0.95); }

.play-rail-btn.liked { color: var(--accent-pulse); border-color: rgba(236,72,153,0.4); }
.play-rail-btn.rated { color: var(--color-warning); border-color: rgba(251,191,36,0.4); }
.play-rail-btn.danger { color: rgba(239,68,68,0.7); }
.play-rail-btn.danger:hover { color: var(--color-error); border-color: rgba(239,68,68,0.4); }

.play-rail-count {
  font-size: 9px;
  color: var(--text-muted);
  font-weight: var(--weight-semibold);
  line-height: 1;
  font-family: var(--font-mono);
}

.play-rail-nav-btn {
  width: 44px; height: 44px;
  border-radius: var(--r-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: background var(--t-fast) ease, color var(--t-fast) ease, transform var(--t-fast) ease;
}
.play-rail-nav-btn:hover { background: var(--bg-raised); color: var(--text-primary); transform: scale(1.05); }
.play-rail-nav-btn:disabled { opacity: 0.25; cursor: not-allowed; transform: none; }

/* ── Share modal ──────────────────────────────────────────────────────────── */
.share-modal-body { padding: var(--s4); }

.share-url-row {
  display: flex;
  gap: var(--s2);
  margin-bottom: var(--s4);
}

.share-url-input {
  flex: 1;
  padding: var(--s2) var(--s3);
  border-radius: var(--r-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-normal);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-actions { display: flex; gap: var(--s2); }

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s4);
  border-radius: var(--r-sm);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  text-decoration: none;
  border: 1px solid var(--border-normal);
  color: var(--text-secondary);
  transition: background var(--t-fast) ease;
}
.share-btn:hover { background: var(--bg-raised); }
.share-btn-twitter { border-color: rgba(29,161,242,0.4); color: rgba(29,161,242,0.9); }
.share-btn-twitter:hover { background: rgba(29,161,242,0.1); }

/* ── Rate modal ────────────────────────────────────────────────────────────── */
.rate-modal-body { padding: var(--s5); }

.star-rating {
  display: flex;
  justify-content: center;
  gap: var(--s2);
  font-size: 36px;
  margin-bottom: var(--s3);
}

.star-rating .star {
  color: var(--text-muted);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  transition: color var(--t-fast) ease, transform var(--t-fast) ease;
  line-height: 1;
}
.star-rating .star:hover,
.star-rating .star.active { color: var(--color-warning); transform: scale(1.15); }

/* ── Report modal ──────────────────────────────────────────────────────────── */
.report-modal-body { padding: var(--s4); }

.report-options {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  margin-bottom: var(--s4);
}

.report-options label {
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  padding: var(--s2) var(--s3);
  border-radius: var(--r-sm);
  transition: background var(--t-fast) ease;
}
.report-options label:hover { background: var(--bg-raised); }

.report-textarea {
  width: 100%;
  padding: var(--s3);
  border-radius: var(--r-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-normal);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  resize: none;
  box-sizing: border-box;
}
.report-textarea:focus { outline: none; border-color: var(--border-focus); }

/* ── Mobile responsive adjustments ─────────────────────────────────────────── */
@media (max-width: 959px) {
  .play-main {
    padding-top: var(--topbar-h) !important;
  }

  .play-rail {
    min-width: 52px;
    max-width: 52px;
    padding: var(--s4) var(--s2);
  }
  .play-rail-btn { width: 38px; height: 42px; font-size: 17px; }
  .play-rail-nav-btn { width: 38px; height: 38px; }

  /* On small screens, constrain player to viewport */
  .play-player-shell {
    max-width: calc(100vw - 80px);
    max-height: calc(100vh - var(--topbar-h) - 100px);
  }

  .play-center {
    padding: var(--s2);
  }

  .play-topbar {
    padding-bottom: var(--s2);
    flex-wrap: wrap;
  }

  /* Hide some size options on tiny screens */
  .play-size-btn[data-size="xl"] { display: none; }
}

@media (max-width: 479px) {
  .play-size-btn[data-size="lg"] { display: none; }
  .play-rail-count { display: none; }
}

/* ── ATGameOver retention panel ─────────────────────────────────────────────
   Mounts inside .play-player-shell and slides up over the player iframe.
   Visibility is toggled by adding/removing .visible via ATGameOver.show().
   ──────────────────────────────────────────────────────────────────────── */
.at-game-over-panel {
  position: absolute;
  inset: 0;
  z-index: 80;
  background: rgba(7, 8, 16, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: var(--s4);
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.at-game-over-panel.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

.at-go-inner {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: var(--s5);
}

/* Header */
.at-go-header {
  text-align: center;
}

.at-go-icon {
  font-size: 40px;
  margin-bottom: var(--s2);
}

.at-go-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary, #fff);
}

.at-go-score {
  margin-top: var(--s2);
  font-size: 14px;
  color: var(--text-muted, rgba(255,255,255,.55));
}

.at-go-score span {
  font-size: 28px;
  font-weight: 900;
  color: var(--accent-violet, #8b5cf6);
  letter-spacing: -0.03em;
}

/* Star rating */
.at-go-rate-section {
  text-align: center;
}

.at-go-rate-label {
  font-size: 13px;
  color: var(--text-muted, rgba(255,255,255,.5));
  margin-bottom: var(--s2);
}

.at-go-stars {
  display: flex;
  justify-content: center;
  gap: var(--s2);
}

.at-go-star {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: rgba(255,255,255,.18);
  transition: color 0.15s, transform 0.1s;
  padding: 4px;
  line-height: 1;
}

.at-go-star:hover,
.at-go-star.active {
  color: #f59e0b;
  transform: scale(1.15);
}

.at-go-star:disabled {
  cursor: default;
  transform: none;
}

.at-go-rate-msg {
  margin-top: var(--s2);
  font-size: 13px;
  min-height: 18px;
  color: var(--accent-violet, #8b5cf6);
}

/* Section title */
.at-go-section-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted, rgba(255,255,255,.4));
  margin-bottom: var(--s3);
}

/* Related games */
.at-go-related-list {
  display: flex;
  gap: var(--s3);
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.at-go-related-list::-webkit-scrollbar { display: none; }

.at-go-related-item {
  flex: 0 0 100px;
  text-decoration: none;
  color: var(--text-primary, #fff);
}

.at-go-related-cover {
  width: 100px;
  height: 70px;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: var(--s1);
  position: relative;
}

.at-go-related-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.at-go-related-title {
  font-size: 11px;
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  color: var(--text-secondary, rgba(255,255,255,.7));
}

/* Action buttons */
.at-go-actions {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.at-go-btn-again {
  width: 100%;
  font-size: 15px;
  font-weight: 700;
}

.at-go-actions .btn-ghost {
  width: 100%;
  text-align: center;
  font-size: 14px;
}

/* Mobile: tighten spacing */
@media (max-width: 479px) {
  .at-go-inner { gap: var(--s4); }
  .at-go-icon  { font-size: 32px; }
  .at-go-title { font-size: 18px; }
}
