/* ============ Dever — swipe. play. create. ============ */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #060609;
  --card: #101018;
  --card2: #16161f;
  --text: #f4f4f8;
  --muted: #9a9aad;
  --accent: #a855f7;
  --accent2: #22d3ee;
  --gold: #fbbf24;
  --danger: #f43f5e;
  --rail-w: 64px;
}

html, body { height: 100%; }
body {
  background: #000;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
}

/* Phone frame: full-screen on mobile, centered column on desktop */
#phone {
  position: relative;
  height: 100dvh;
  width: 100vw;
  margin: 0 auto;
  background: var(--bg);
  overflow: hidden;
}
@media (min-width: 520px) {
  body { background: radial-gradient(1200px 800px at 50% -10%, #1b1030, #000 70%); }
  #phone {
    width: 430px;
    height: min(100dvh, 940px);
    margin-top: calc((100dvh - min(100dvh, 940px)) / 2);
    border-radius: 24px;
    box-shadow: 0 0 0 1px #ffffff18, 0 30px 80px #000;
  }
}

/* ============ Top bar ============ */
#topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 30;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px 6px;
  background: linear-gradient(#000c, #0000);
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }
.brand { font-weight: 800; font-size: 18px; letter-spacing: .3px; text-shadow: 0 1px 8px #000; }
.brand span { background: linear-gradient(90deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.coin-chip {
  border: 1px solid #ffffff2a; background: #00000080; color: var(--gold);
  border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 700; cursor: pointer;
  backdrop-filter: blur(6px);
}
.coin-chip b { color: #fff; }
.icon-btn {
  border: 1px solid #ffffff2a; background: #00000080; color: #fff;
  border-radius: 999px; width: 34px; height: 34px; font-size: 15px; cursor: pointer;
  backdrop-filter: blur(6px);
}

/* ============ Pills ============ */
.pills {
  position: absolute; top: 52px; left: 0; right: 0; z-index: 30;
  display: flex; gap: 8px; padding: 6px 14px 10px;
  overflow-x: auto; scrollbar-width: none;
}
.pills::-webkit-scrollbar { display: none; }
.pill {
  flex: 0 0 auto; border-radius: 999px; padding: 7px 14px;
  border: 1px solid #ffffff26; background: #00000075; color: #ddd;
  font-size: 13px; font-weight: 600; cursor: pointer; backdrop-filter: blur(6px);
  transition: all .15s;
}
.pill.active { background: #fff; color: #000; border-color: #fff; }

/* ============ Feed ============ */
#feed {
  height: 100%;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
}
#feed::-webkit-scrollbar { display: none; }

.game-card {
  position: relative;
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  background: var(--card);
  overflow: hidden;
}
.game-stage { position: absolute; inset: 0; }
.game-stage canvas { display: block; width: 100%; height: 100%; }

/* boot cover = the "thumbnail is the main menu" */
.boot-cover {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 14px;
  background: radial-gradient(600px 500px at 50% 30%, #ffffff0d, transparent), var(--cover-bg, var(--card));
  cursor: pointer; transition: opacity .3s;
}
.boot-cover.gone { opacity: 0; pointer-events: none; }
.boot-emoji { font-size: 72px; filter: drop-shadow(0 6px 20px #0009); }
.boot-title { font-size: 26px; font-weight: 800; }
.boot-play {
  border: none; border-radius: 999px; padding: 12px 34px;
  background: #fff; color: #000; font-size: 16px; font-weight: 800; cursor: pointer;
}
.boot-stats { color: #cfcfe0; font-size: 13px; text-shadow: 0 1px 4px #000; }
.boot-badge {
  position: absolute; top: 108px; left: 14px; z-index: 8;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  color: #fff; font-size: 12px; font-weight: 800; border-radius: 8px; padding: 5px 10px;
}

/* ============ Right action rail ============ */
.rail {
  position: absolute; right: 8px; bottom: 110px; z-index: 20;
  display: flex; flex-direction: column; gap: 16px; align-items: center;
  width: var(--rail-w);
}
.rail-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; background: none; border: none; color: #fff; cursor: pointer; }
.rail-ico {
  width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
  background: #00000070; border: 1px solid #ffffff22; backdrop-filter: blur(6px);
  transition: transform .12s;
}
.rail-btn:active .rail-ico { transform: scale(1.25); }
.rail-btn.liked .rail-ico { background: var(--danger); border-color: var(--danger); }
.rail-label { font-size: 11px; font-weight: 700; text-shadow: 0 1px 4px #000; }
.rail-avatar {
  width: 46px; height: 46px; border-radius: 50%; font-size: 24px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: 2px solid #fff; position: relative;
}
.rail-avatar .plus {
  position: absolute; bottom: -7px; left: 50%; transform: translateX(-50%);
  width: 18px; height: 18px; border-radius: 50%; background: var(--danger);
  color: #fff; font-size: 13px; line-height: 17px; text-align: center; font-weight: 800;
}
.rail-avatar.subbed .plus { background: #22c55e; content: "✓"; }

/* ============ Bottom meta ============ */
.meta {
  position: absolute; left: 14px; right: calc(var(--rail-w) + 12px); bottom: 18px; z-index: 20;
  display: flex; flex-direction: column; gap: 7px;
  text-shadow: 0 1px 6px #000;
  pointer-events: none;
}
.meta > * { pointer-events: auto; }
.meta .dev-line { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.sub-btn {
  border: 1px solid #ffffff55; background: #ffffff1c; color: #fff;
  border-radius: 6px; padding: 3px 10px; font-size: 12px; font-weight: 800; cursor: pointer;
}
.sub-btn.subbed { background: #22c55e33; border-color: #22c55e; color: #86efac; }
.meta .g-title { font-size: 17px; font-weight: 800; }
.meta .g-desc { font-size: 13px; color: #e6e6f2; }
.meta .g-stats { font-size: 12px; color: #cfcfe0; }
.tag-row { display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  font-size: 12px; font-weight: 700; color: var(--accent2);
  background: #22d3ee1a; border: 1px solid #22d3ee40; border-radius: 999px;
  padding: 2px 9px; cursor: pointer;
}

/* ============ Play mode: chrome fades, feed locks ============ */
#topbar, #pills, .rail, .meta { transition: opacity .25s; }
.playing-mode #feed { overflow: hidden; }
.playing-mode #topbar { opacity: .15; pointer-events: none; }
.playing-mode #pills { opacity: 0; pointer-events: none; }
.playing-mode #swipeHint { opacity: 0; }
.game-card.playing .rail,
.game-card.playing .meta { opacity: .13; pointer-events: none; }
.boot-badge { transition: opacity .25s; }
.game-card.playing .boot-badge { opacity: 0; }

.exit-play {
  position: absolute; top: 14px; right: 12px; z-index: 28;
  width: 42px; height: 42px; border-radius: 50%;
  background: #000000a0; border: 1px solid #ffffff44; color: #fff;
  font-size: 16px; cursor: pointer; display: none; backdrop-filter: blur(6px);
}
.game-card.playing .exit-play { display: block; }

/* always-clickable game controls: works over iframe games that eat touches */
.play-nav {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%); z-index: 28;
  display: none; flex-direction: column; gap: 12px; align-items: center;
}
.game-card.playing .play-nav { display: flex; }
.play-nav button {
  width: 46px; height: 46px; border-radius: 50%;
  background: #000000a0; border: 1px solid #ffffff44; color: #fff; font-size: 19px;
  cursor: pointer; backdrop-filter: blur(6px); transition: transform .1s;
}
.play-nav button:active { transform: scale(1.18); }

/* in-game HUD line from the game (score etc.) */
.hud {
  position: absolute; top: 96px; left: 0; right: 0; z-index: 15;
  text-align: center; font-size: 30px; font-weight: 900; color: #ffffffd9;
  text-shadow: 0 2px 10px #000a; pointer-events: none;
}

/* ============ Dev CTA card ============ */
.dev-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; text-align: center; padding: 30px;
  background:
    radial-gradient(500px 400px at 30% 20%, #a855f733, transparent),
    radial-gradient(500px 400px at 80% 90%, #22d3ee2e, transparent),
    var(--card);
}
.dev-card h2 { font-size: 30px; line-height: 1.2; }
.dev-card p { color: var(--muted); max-width: 300px; }
.dev-card .earn { color: var(--gold); font-weight: 800; }

/* ============ Modals ============ */
.modal-backdrop {
  position: absolute; inset: 0; z-index: 60;
  background: #000000c4; backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  position: relative; width: 100%; max-width: 360px; max-height: 86%;
  overflow-y: auto; scrollbar-width: none;
  background: var(--card2); border: 1px solid #ffffff1c; border-radius: 20px;
  padding: 24px 20px; display: flex; flex-direction: column; gap: 12px;
  text-align: center;
}
.modal::-webkit-scrollbar { display: none; }
.hidden { display: none !important; }
.close-x {
  position: absolute; top: 10px; right: 12px; background: none; border: none;
  color: var(--muted); font-size: 16px; cursor: pointer;
}
.primary-btn {
  border: none; border-radius: 12px; padding: 13px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  color: #fff; font-size: 15px; font-weight: 800; cursor: pointer;
}
.primary-btn:disabled { opacity: .4; cursor: default; }
.ghost-btn {
  border: 1px solid #ffffff30; border-radius: 12px; padding: 12px;
  background: none; color: #fff; font-size: 14px; font-weight: 700; cursor: pointer;
}
.text-btn { background: none; border: none; color: var(--muted); font-size: 13px; cursor: pointer; }
.muted { color: var(--muted); font-size: 13px; }
.fineprint { color: #6b6b80; font-size: 11px; }
.divider { color: #55556a; font-size: 12px; }

/* onboarding */
.onboard-logo { font-size: 56px; }
.onboard h1 { font-size: 34px; background: linear-gradient(90deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tagline { color: var(--muted); font-size: 14px; }
.interest-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.interest {
  border: 1px solid #ffffff26; border-radius: 12px; padding: 12px 8px;
  background: #ffffff08; color: #fff; font-size: 14px; font-weight: 700; cursor: pointer;
}
.interest.on { background: #a855f733; border-color: var(--accent); }

/* wallet / ads */
.wallet-balance { font-size: 34px; font-weight: 900; color: var(--gold); }
.ad-modal { align-items: center; }
.ad-screen {
  width: 100%; aspect-ratio: 9/14; border-radius: 14px; position: relative;
  background: linear-gradient(160deg, #1e293b, #0f172a);
  display: flex; align-items: center; justify-content: center;
}
.ad-body { text-align: center; font-size: 26px; color: #cbd5e1; line-height: 1.5; }
.ad-body small { font-size: 12px; color: #64748b; }
.ad-label { position: absolute; top: 10px; left: 10px; background: #fbbf24; color: #000; font-size: 11px; font-weight: 900; padding: 2px 7px; border-radius: 5px; }
.ad-timer {
  position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; border-radius: 50%;
  background: #000a; color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.go-score { font-size: 16px; color: var(--muted); }
.go-score b { color: #fff; font-size: 20px; }

/* profile */
.profile { text-align: center; }
.profile-avatar { font-size: 54px; }
.profile h2 { font-size: 22px; }
.profile .handle { color: var(--accent2); font-weight: 700; font-size: 14px; }
.profile-stats { display: flex; justify-content: center; gap: 22px; margin: 6px 0; }
.profile-stats div { font-size: 12px; color: var(--muted); }
.profile-stats b { display: block; font-size: 17px; color: #fff; }
.profile-games { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.profile-game {
  display: flex; align-items: center; gap: 10px; padding: 10px;
  background: #ffffff0a; border-radius: 12px; cursor: pointer;
}
.profile-game .pg-emoji { font-size: 26px; }
.profile-game .pg-name { font-weight: 800; font-size: 14px; }
.profile-game .pg-sub { font-size: 12px; color: var(--muted); }
.story-note { font-size: 12px; color: var(--muted); background: #a855f71a; border: 1px dashed #a855f755; border-radius: 10px; padding: 8px; }

/* search + top */
.search input {
  width: 100%; border-radius: 12px; border: 1px solid #ffffff26; background: #00000060;
  color: #fff; padding: 12px 14px; font-size: 15px; outline: none;
}
.search-results, .top-list { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.result-row, .top-row {
  display: flex; align-items: center; gap: 10px; padding: 10px;
  background: #ffffff0a; border-radius: 12px; cursor: pointer;
}
.result-row .r-emoji, .top-row .r-emoji { font-size: 24px; }
.r-name { font-weight: 800; font-size: 14px; }
.r-sub { font-size: 12px; color: var(--muted); }
.top-rank { font-weight: 900; font-size: 16px; width: 24px; color: var(--gold); }

/* create */
.create textarea {
  width: 100%; border-radius: 12px; border: 1px solid #ffffff26; background: #00000060;
  color: #fff; padding: 12px; font-size: 14px; font-family: inherit; resize: none; outline: none;
}
.gen-log {
  text-align: left; font-family: ui-monospace, monospace; font-size: 12px; color: #86efac;
  background: #000c; border-radius: 10px; padding: 12px; min-height: 90px; white-space: pre-wrap;
  max-height: 220px; overflow-y: auto; flex: none;
}

/* generated game preview */
.preview { max-width: 380px; }
.preview-frame-wrap {
  width: 100%; aspect-ratio: 9/15; border-radius: 14px; overflow: hidden;
  border: 1px solid #ffffff22; background: #05010d; flex: none;
}
.preview-frame-wrap iframe { width: 100%; height: 100%; border: 0; display: block; }

/* subscribe nudge */
.sub-nudge {
  position: absolute; left: 14px; right: 14px; bottom: 96px; z-index: 40;
  display: flex; align-items: center; gap: 10px;
  background: #16161fee; border: 1px solid #ffffff22; border-radius: 14px;
  padding: 12px 14px; font-size: 13px; font-weight: 600;
  animation: rise .3s ease;
}
.sub-nudge button#subNudgeBtn {
  margin-left: auto; border: none; border-radius: 8px; padding: 7px 14px;
  background: linear-gradient(90deg, var(--accent), var(--accent2)); color: #fff; font-weight: 800; cursor: pointer;
}
@keyframes rise { from { transform: translateY(16px); opacity: 0; } }

/* toasts */
#toasts { position: absolute; top: 100px; left: 0; right: 0; z-index: 90; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: #ffffffee; color: #000; font-size: 13px; font-weight: 700;
  border-radius: 999px; padding: 9px 18px; animation: rise .25s ease;
  box-shadow: 0 6px 24px #0008;
}

/* swipe hint */
.swipe-hint {
  position: absolute; bottom: 4px; left: 0; right: 0; z-index: 25;
  text-align: center; font-size: 11px; color: #ffffff88;
  animation: bob 1.6s ease-in-out infinite; pointer-events: none;
}
@keyframes bob { 50% { transform: translateY(-5px); } }

/* like burst */
.heart-burst {
  position: absolute; z-index: 50; font-size: 70px; pointer-events: none;
  animation: burst .7s ease forwards;
}
@keyframes burst {
  0% { transform: scale(.4); opacity: 0; }
  30% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1) translateY(-50px); opacity: 0; }
}
