/* ============================
   CloudPlay — Unique Theme
   Cool purple/cyan, glassmorphism
   ============================ */

:root {
  --bg-deep: #0a0a12;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(139, 92, 246, 0.5);
  --accent: #8b5cf6;
  --accent-light: #a78bfa;
  --cyan: #22d3ee;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --text-muted: #64748b;
  --radius: 16px;
  --radius-sm: 10px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---- Animated mesh background ---- */
.bg-mesh {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 80% 60% at 10% 20%, rgba(139,92,246,.15), transparent),
    radial-gradient(ellipse 60% 50% at 90% 80%, rgba(34,211,238,.10), transparent),
    radial-gradient(ellipse 50% 40% at 50% 50%, rgba(139,92,246,.05), transparent);
  animation: meshShift 20s ease-in-out infinite alternate;
}
@keyframes meshShift {
  0%   { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(20deg); }
}

/* ---- Screens ---- */
.screen { display: none; position: relative; z-index: 1; min-height: 100vh; }
.screen.active { display: flex; }

/* =========== SELECT SCREEN =========== */
#screen-select { flex-direction: column; }

/* Top bar */
.top-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 32px;
  backdrop-filter: blur(12px);
  background: rgba(10,10,18,.6);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}

.logo {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 1.15rem; color: #fff;
  letter-spacing: -0.02em;
}
.logo-icon { width: 22px; height: 22px; color: var(--accent-light); }

.server-pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card); border: 1px solid var(--border);
  padding: 6px 14px; border-radius: 100px;
  font-size: 0.8rem; color: var(--text-dim);
}

.pulse-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 6px #22c55e;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .5; transform: scale(.8); }
}

/* Hero */
.select-main { max-width: 1000px; margin: 0 auto; padding: 48px 28px 60px; width: 100%; }

.hero-section { text-align: center; margin-bottom: 56px; }
.hero-section h1 {
  font-size: 2.6rem; font-weight: 800; line-height: 1.15;
  letter-spacing: -0.03em; color: #fff;
}
.gradient-text {
  background: linear-gradient(135deg, var(--accent-light), var(--cyan));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-sub { color: var(--text-dim); font-size: 1.05rem; margin-top: 14px; }

/* Section header */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.section-header h2 { font-size: 1.15rem; font-weight: 700; color: #fff; }

.slot-badge {
  font-size: 0.78rem; font-weight: 600;
  background: var(--bg-card); border: 1px solid var(--border);
  padding: 5px 12px; border-radius: 100px; color: var(--text-dim);
}

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

.game-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 22px 22px;
  cursor: pointer;
  transition: transform .2s, border-color .25s, box-shadow .25s, background .25s;
  overflow: hidden;
}
.game-card::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  opacity: 0; transition: opacity .25s;
}
.game-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
  box-shadow: 0 8px 32px rgba(139,92,246,.12), 0 2px 8px rgba(0,0,0,.3);
}
.game-card:hover::before { opacity: 1; }

.game-card .card-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, rgba(139,92,246,.2), rgba(34,211,238,.15));
  margin-bottom: 16px; font-size: 1.3rem;
}

.game-card h3 {
  font-size: 1rem; font-weight: 700; color: #fff;
  margin-bottom: 4px;
}
.game-card .pkg-name {
  font-size: 0.72rem; color: var(--text-muted);
  font-family: "SF Mono", "Fira Code", monospace;
  word-break: break-all;
}

.game-card .play-tag {
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 16px; font-size: 0.78rem; font-weight: 600;
  color: var(--accent-light); opacity: 0; transition: opacity .2s;
}
.game-card:hover .play-tag { opacity: 1; }

/* Empty state */
.empty-state {
  text-align: center; padding: 64px 20px; color: var(--text-muted);
}
.empty-icon { width: 48px; height: 48px; margin-bottom: 16px; color: var(--text-muted); }
.empty-state code {
  background: rgba(139,92,246,.15); color: var(--accent-light);
  padding: 2px 7px; border-radius: 4px; font-size: 0.85rem;
}

/* =========== QUEUE SCREEN =========== */
#screen-queue {
  align-items: center; justify-content: center;
  background: var(--bg-deep);
}

.queue-card {
  text-align: center; padding: 48px 40px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 24px; backdrop-filter: blur(16px);
  width: 360px; max-width: 90vw;
}

.spinner-ring {
  width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-light);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.queue-card h2 { font-size: 1.2rem; font-weight: 700; color: #fff; margin-bottom: 20px; }

.queue-num-wrap {
  display: flex; align-items: baseline; justify-content: center; gap: 2px;
}
.queue-hash { font-size: 2rem; font-weight: 700; color: var(--text-muted); }
.queue-num  { font-size: 4.5rem; font-weight: 800; color: var(--accent-light); line-height: 1; }

.queue-sub { font-size: 0.9rem; color: var(--text-dim); margin: 16px 0 24px; }

.queue-bar-wrap {
  height: 4px; border-radius: 4px; background: var(--border);
  overflow: hidden; margin-bottom: 28px;
}
.queue-bar {
  height: 100%; width: 30%; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  animation: barPulse 2s ease-in-out infinite;
}
@keyframes barPulse {
  0%, 100% { width: 25%; margin-left: 0; }
  50%      { width: 40%; margin-left: 30%; }
}

.btn-ghost {
  background: none; border: 1px solid var(--border);
  color: var(--text-dim); font-family: var(--font);
  padding: 10px 28px; border-radius: 100px;
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  transition: border-color .2s, color .2s;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-light); }

/* =========== GAME SCREEN =========== */
#screen-game {
  background: #000; align-items: center; justify-content: center;
  position: relative;
}

.game-viewport {
  width: 100%; height: 100vh;
  display: flex; align-items: center; justify-content: center;
}

#game-canvas {
  width: 100%; height: 100vh;
  object-fit: contain; touch-action: none;
}

.game-overlay {
  position: absolute; inset: 0; z-index: 10;
  display: flex; flex-direction: column; gap: 16px;
  align-items: center; justify-content: center;
  background: rgba(0,0,0,.85); color: #fff;
  font-size: 0.95rem; transition: opacity .4s;
}
.game-overlay.hidden { opacity: 0; pointer-events: none; }

/* Unblock button — bottom-right of game screen */
.btn-unblock {
  position: absolute; bottom: 20px; right: 20px; z-index: 20;
  display: none; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
  color: #fff; font-family: var(--font);
  padding: 10px 18px; border-radius: 100px;
  font-size: 0.8rem; font-weight: 600; cursor: pointer;
  backdrop-filter: blur(8px);
  transition: background .2s, border-color .2s, transform .15s;
  opacity: 0.7;
}
.btn-unblock:hover { background: rgba(139,92,246,0.35); border-color: var(--accent); opacity: 1; transform: scale(1.05); }
.btn-unblock:active { transform: scale(0.97); }
.btn-unblock.visible { display: flex; }
.btn-unblock:disabled { cursor: not-allowed; opacity: 0.4; }
.btn-unblock:disabled:hover { transform: none; background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.2); }

/* Bouncing dots loader */
.loader-dots { display: flex; gap: 6px; }
.loader-dots span {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent-light);
  animation: bounce .6s ease-in-out infinite alternate;
}
.loader-dots span:nth-child(2) { animation-delay: .15s; }
.loader-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce {
  to { transform: translateY(-10px); opacity: .4; }
}

/* =========== RESPONSIVE =========== */
@media (max-width: 640px) {
  .top-bar { padding: 16px 18px; }
  .select-main { padding: 32px 18px 48px; }
  .hero-section h1 { font-size: 1.8rem; }
  .hero-sub { font-size: 0.92rem; }
  .game-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .game-card { padding: 20px 16px 16px; }
  .game-card .card-icon { width: 36px; height: 36px; font-size: 1.1rem; }
  .game-card h3 { font-size: 0.9rem; }
  .section-header { flex-direction: column; gap: 8px; align-items: flex-start; }
  .queue-num { font-size: 3.5rem; }
}

@media (max-width: 380px) {
  .game-grid { grid-template-columns: 1fr; }
}
