/* CREATE — publishing: the check-and-publish dialog, the gallery strip, the public play page.
   Uses the tokens app.css puts on :root (--bg --card --card-2 --ink --soft --dim --line --hot --gold ...). */

/* ---------- the dialog: a bottom sheet on phones, a centred card on bigger screens ---------- */
.pub-overlay { position: fixed; inset: 0; z-index: 150; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(5,4,10,0); transition: background .18s ease; }
.pub-overlay.in { background: rgba(5,4,10,.66); }
.pub-overlay.out { background: rgba(5,4,10,0); }
.pub-dialog { position: relative; width: 100%; max-height: calc(100% - 24px - var(--sat, 0px)); overflow: auto; overscroll-behavior: contain;
  background: var(--card); color: var(--ink); border: 1px solid var(--line-2, rgba(255,255,255,.16)); border-bottom: 0;
  border-radius: 22px 22px 0 0; box-shadow: var(--shadow); padding: 0 18px calc(18px + var(--sab, 0px));
  transform: translateY(24px); opacity: 0; transition: transform .22s cubic-bezier(.2,.9,.3,1.1), opacity .18s ease; }
.pub-overlay.in .pub-dialog { transform: none; opacity: 1; }
.pub-overlay.out .pub-dialog { transform: translateY(24px); opacity: 0; }
.pub-grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line-2, rgba(255,255,255,.16)); margin: 9px auto 0; }
.pub-head { display: flex; align-items: center; gap: 8px; padding: 10px 0 12px; position: sticky; top: 0; background: var(--card); z-index: 1; }
.pub-head h2 { flex: 1; font: 800 21px/1.2 var(--font-head); }
.pub-x { width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; color: var(--soft); display: grid; place-items: center; flex: none; }
.pub-x:hover:not(:disabled) { background: rgba(255,255,255,.07); color: var(--ink); }
.pub-x:disabled { opacity: .3; }
.pub-ico { display: inline-grid; place-items: center; width: 22px; height: 22px; flex: none; }
.pub-ico svg, .pub-x svg { width: 22px; height: 22px; }

@media (min-width: 760px) {
  .pub-overlay { align-items: center; padding: 24px; }
  .pub-dialog { width: min(720px, 100%); border-radius: var(--r-lg, 18px); border-bottom: 1px solid var(--line-2, rgba(255,255,255,.16));
    padding: 4px 24px 24px; max-height: calc(100vh - 48px); transform: translateY(10px) scale(.98); }
  .pub-overlay.out .pub-dialog { transform: translateY(10px) scale(.98); }
  .pub-grab { display: none; }
  .pub-head { padding-top: 16px; }
}

/* ---------- the form ---------- */
.pub-formgrid { display: grid; gap: 16px; }
@media (min-width: 760px) { .pub-formgrid { grid-template-columns: 260px 1fr; align-items: start; } }
.pub-thumb { position: relative; aspect-ratio: 16 / 9; border-radius: var(--r, 14px); overflow: hidden; background: var(--bg-2, #110e19);
  border: 1px solid var(--line); display: grid; place-items: center; color: var(--dim); font-size: 14px; }
.pub-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; image-rendering: auto; }
.pub-thumb.loading::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,.06) 50%, transparent 80%); background-size: 200% 100%;
  animation: pub-shimmer 1.1s linear infinite; }
.pub-fields { display: grid; gap: 12px; }
.pub-field { display: grid; gap: 6px; }
.pub-label { font: 700 14px var(--font-body); color: var(--soft); letter-spacing: .01em; }
.pub-note { font-size: 14px; color: var(--dim); min-height: 1.2em; line-height: 1.35; }
.pub-note.warn { color: var(--gold); }
.pub-note.bad { color: #ff8a70; }
.pub-field .field[aria-invalid="true"] { border-color: rgba(255,91,61,.7); }
.pub-promise { display: flex; gap: 10px; align-items: flex-start; margin: 16px 0 0; padding: 12px 14px; border-radius: var(--r, 14px);
  background: rgba(46,196,182,.08); border: 1px solid rgba(46,196,182,.28); color: var(--soft); font-size: 15px; line-height: 1.4; }
.pub-promise .pub-ico { color: #2ec4b6; }
.pub-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }
.pub-actions .btn { min-height: 48px; }
.pub-actions .btn.primary { font-weight: 800; padding: 0 20px; }
.pub-actions a.btn { text-decoration: none; }
.pub-actions .ico svg { width: 18px; height: 18px; }
@media (max-width: 759px) { .pub-actions .btn { flex: 1 1 140px; } }

.pub-live { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; padding: 10px 10px 10px 14px; border-radius: var(--r, 14px);
  background: rgba(51,209,122,.08); border: 1px solid rgba(51,209,122,.32); }
.pub-dot { width: 10px; height: 10px; border-radius: 50%; background: #33d17a; box-shadow: 0 0 0 4px rgba(51,209,122,.2); flex: none; }
.pub-live-text { display: grid; min-width: 0; flex: 1; font-size: 15px; }
.pub-live-text strong { color: #7ee2a8; font-weight: 700; }
.pub-live-text a { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pub-copy.done { color: #33d17a; border-color: rgba(51,209,122,.5); }
.pub-copy svg { width: 20px; height: 20px; }

/* ---------- checking ---------- */
.pub-checking { display: grid; justify-items: center; gap: 10px; padding: 6px 0 10px; text-align: center; }
.pub-scan { position: relative; width: min(100%, 420px); aspect-ratio: 16 / 9; border-radius: var(--r, 14px); overflow: hidden;
  background: var(--bg-2, #110e19); border: 1px solid var(--line); }
.pub-scan img { width: 100%; height: 100%; object-fit: contain; display: block; filter: saturate(.8) brightness(.85); }
.pub-beam { position: absolute; left: 0; right: 0; top: 0; height: 28%;
  background: linear-gradient(180deg, transparent, rgba(46,196,182,.30) 70%, rgba(126,255,240,.85) 96%, transparent);
  animation: pub-scan 1.6s cubic-bezier(.45,0,.55,1) infinite alternate; }
.pub-step { font: 800 19px var(--font-head); margin: 8px 0 0; }
.pub-small { font-size: 14px; color: var(--dim); margin: 0; line-height: 1.4; }
.pub-small.warn { color: var(--gold); }

/* ---------- results ---------- */
.pub-result { display: grid; gap: 12px; padding: 4px 0; }
.pub-badge { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; margin: 4px auto 2px; }
.pub-badge svg { width: 32px; height: 32px; }
.pub-badge.ok { background: rgba(51,209,122,.16); color: #33d17a; animation: pub-pop .4s cubic-bezier(.2,1.4,.4,1) both; }
.pub-badge.no { background: rgba(255,91,61,.14); color: #ff7a5c; }
.pub-badge.held { background: rgba(255,181,61,.14); color: var(--gold); }
.pub-lead { margin: 0; font-size: 17px; line-height: 1.45; text-align: center; color: var(--ink); }
.pub-result .pub-small { text-align: center; }
.pub-linkrow { display: flex; gap: 8px; }
.pub-link { flex: 1; min-width: 0; font-size: 15px; color: var(--soft); }
.pub-reasons { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 10px; }
.pub-reasons li { padding: 12px 14px; border-radius: var(--r, 14px); background: var(--card-2); border: 1px solid var(--line);
  border-left: 4px solid #ff7a5c; display: grid; gap: 4px; }
.pub-where { font: 800 15px var(--font-head); color: #ffb4a3; }
.pub-problem { font-size: 16px; line-height: 1.4; }
.pub-fix { font-size: 15px; color: var(--soft); line-height: 1.4; }
.pub-fix b { color: var(--gold); }

.pub-badge.wait { background: rgba(255,181,61,.14); color: var(--gold); }
.pub-notice { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 14px; padding: 10px 14px; border-radius: var(--r, 14px);
  font-size: 15px; line-height: 1.4; color: var(--soft); }
.pub-notice.wait { background: rgba(255,181,61,.08); border: 1px solid rgba(255,181,61,.3); }
.pub-notice .pub-ico { color: var(--gold); }
.pub-result .pub-live { margin: 2px 0 0; }
.pub-spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line-2, rgba(255,255,255,.16)); border-top-color: var(--gold);
  animation: pub-turn .8s linear infinite; margin: 18px auto 4px; }
@keyframes pub-turn { to { transform: rotate(360deg); } }

/* ---------- the status badge on a My games card (home.js) ---------- */
.gbadge.wait { border-color: rgba(255,181,61,.6); color: #ffd28a; }
.gbadge.back { border-color: rgba(255,122,92,.65); color: #ffb4a3; }
.gbadge.live { border-color: rgba(51,209,122,.5); color: #7ef0ad; }

/* ---------- gallery strip ---------- */
.pub-gallery { display: grid; gap: 10px; min-width: 0; }
.pub-gal-h { font: 800 19px var(--font-head); }
.pub-gal-row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(200px, 240px); gap: 12px; overflow-x: auto;
  padding: 2px 2px 10px; scroll-snap-type: x proximity; scrollbar-width: thin; scrollbar-color: var(--card-3, #252034) transparent; }
.pub-card { scroll-snap-align: start; display: grid; gap: 4px; padding: 8px; border-radius: var(--r, 14px); background: var(--card);
  border: 1px solid var(--line); color: var(--ink); text-decoration: none; min-width: 0; transition: transform .15s, border-color .15s, background .15s; }
.pub-card:hover { transform: translateY(-2px); border-color: rgba(255,181,61,.45); background: var(--card-2); }
.pub-card-img { position: relative; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: var(--bg-2, #110e19); }
.pub-card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pub-card-play { position: absolute; right: 8px; bottom: 8px; width: 34px; height: 34px; border-radius: 50%; background: var(--hot); color: var(--hot-ink, #1a0d08);
  display: grid; place-items: center; box-shadow: 0 4px 12px rgba(0,0,0,.4); opacity: 0; transform: scale(.85); transition: opacity .15s, transform .15s; }
.pub-card-play svg { width: 18px; height: 18px; }
.pub-card:hover .pub-card-play, .pub-card:focus-visible .pub-card-play { opacity: 1; transform: none; }
@media (hover: none) { .pub-card-play { opacity: 1; transform: none; } }
.pub-card-t { font: 700 16px/1.25 var(--font-head); padding: 4px 2px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pub-card-s { font-size: 14px; color: var(--dim); padding: 0 2px 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pub-card.skel .pub-card-img, .pub-card.skel .pub-card-t, .pub-card.skel .pub-card-s { background: var(--card-2); border-radius: 8px; color: transparent;
  background-image: linear-gradient(100deg, transparent 20%, rgba(255,255,255,.05) 50%, transparent 80%); background-size: 200% 100%; animation: pub-shimmer 1.2s linear infinite; }
.pub-card.skel .pub-card-t { height: 18px; width: 70%; margin-top: 6px; }
.pub-card.skel .pub-card-s { height: 14px; width: 45%; }
.pub-gal-empty { margin: 0; padding: 18px 16px; border-radius: var(--r, 14px); border: 1px dashed var(--line-2, rgba(255,255,255,.16));
  color: var(--dim); font-size: 15px; grid-column: 1 / -1; }

/* ---------- the public play page (/create/play/?g=ID) ---------- */
body.pubplay { min-height: 100%; background: radial-gradient(1200px 600px at 50% -10%, #1d1530 0%, var(--bg) 60%) fixed, var(--bg); }
.pp { max-width: 980px; margin: 0 auto; padding: calc(16px + var(--sat, 0px)) calc(16px + var(--sar, 0px)) calc(28px + var(--sab, 0px)) calc(16px + var(--sal, 0px)); }
.pp-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; margin-bottom: 14px; }
.pp-brand { font: 400 20px var(--font-display); color: var(--ink); text-decoration: none; letter-spacing: .02em; }
.pp-brand span { color: var(--hot); }
.pp-make { text-decoration: none; }
.pp-card { display: grid; gap: 18px; padding: 16px; border-radius: 22px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); }
@media (min-width: 760px) { .pp-card { grid-template-columns: 1.35fr 1fr; align-items: center; padding: 20px; } }
.pp-shot { position: relative; aspect-ratio: 16 / 9; border-radius: 16px; overflow: hidden; background: var(--bg-2, #110e19); border: 0; padding: 0; display: block; width: 100%; }
.pp-shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pp-shot .pp-bigplay { position: absolute; inset: 0; margin: auto; width: 84px; height: 84px; border-radius: 50%; background: var(--hot); color: var(--hot-ink, #1a0d08);
  display: grid; place-items: center; box-shadow: 0 10px 30px rgba(0,0,0,.5); transition: transform .15s; }
.pp-shot:hover .pp-bigplay { transform: scale(1.06); }
.pp-bigplay svg { width: 40px; height: 40px; margin-left: 4px; }
.pp-info { display: grid; gap: 10px; min-width: 0; }
.pp-info h1 { font: 800 clamp(26px, 6vw, 36px)/1.1 var(--font-head); overflow-wrap: anywhere; }
.pp-by { color: var(--soft); font-size: 16px; }
.pp-by b { color: var(--ink); }
.pp-blurb { color: var(--ink); font-size: 17px; line-height: 1.45; margin: 0; overflow-wrap: anywhere; }
.pp-meta { color: var(--dim); font-size: 14px; }
.pp-buttons { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.pp-buttons .btn.play { min-height: 54px; font-size: 18px; padding: 0 26px 0 20px; flex: 1 1 180px; }
.pp-buttons .btn.play svg { width: 22px; height: 22px; }
.pp-report { color: var(--dim); }
.pp-report svg { width: 18px; height: 18px; }
.pp-msg { text-align: center; padding: 60px 20px; display: grid; gap: 14px; justify-items: center; color: var(--soft); font-size: 17px; }
.pp-msg h1 { font: 800 26px var(--font-head); color: var(--ink); }
.pp-msg .btn { text-decoration: none; }
.pp-gal { margin-top: 26px; }
.pp-choices { display: grid; gap: 8px; }
.pp-choice { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 14px; border-radius: 12px; background: var(--card-2);
  border: 1px solid var(--line); cursor: pointer; font-size: 16px; }
.pp-choice:has(input:checked) { border-color: rgba(255,181,61,.6); background: rgba(255,181,61,.08); }
.pp-choice input { width: 20px; height: 20px; accent-color: var(--gold); flex: none; }

@keyframes pub-shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }
@keyframes pub-scan { from { transform: translateY(-40%); } to { transform: translateY(300%); } }
@keyframes pub-pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .pub-overlay, .pub-dialog, .pub-card, .pub-card-play, .pp-shot .pp-bigplay { transition: none !important; }
  .pub-beam, .pub-thumb.loading::after, .pub-card.skel *, .pub-badge.ok, .pub-spin { animation: none !important; }
  .pub-beam { top: 36%; }
}
