:root {
  --ink: #14213d; --muted: #52617c; --sky: #4fb3ff; --sky-pale: #d8efff; --sun: #ffc933; --coral: #ff5d5d; --mint: #3ddc97; --paper: #f4faff; --white: #fff;
  --border: 3px solid var(--ink);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 700 16px/1.45 Nunito, system-ui, sans-serif; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; font-family: 'Lilita One', Nunito, sans-serif; font-weight: 400; line-height: 1.1; }
p { margin: 0; }
a { color: inherit; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--coral); outline-offset: 2px; }

#nav { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 22px; padding: 10px clamp(16px, 4vw, 40px); background: var(--white); border-bottom: var(--border); }
.logo { display: flex; align-items: center; gap: 8px; font: 400 25px 'Lilita One', sans-serif; text-decoration: none; }
.links { display: flex; gap: 4px; }
.links a { padding: 6px 13px; border-radius: 11px; text-decoration: none; }
.links a:hover { background: var(--sky-pale); }
.links a.on { background: var(--ink); color: var(--white); }
.navright { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.user { text-decoration: none; }
.user:hover { text-decoration: underline; }

.btn { display: inline-block; padding: 9px 18px; border: var(--border); border-radius: 13px; background: var(--white); color: var(--ink); text-align: center; text-decoration: none; cursor: pointer; box-shadow: 0 4px 0 var(--ink); transition: transform .06s, box-shadow .06s; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 5px 0 var(--ink); }
.btn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--ink); }
.btn.sun { background: var(--sun); }
.btn.danger { background: #ffd9d9; }
.btn.small { padding: 5px 12px; font-size: 14px; border-radius: 10px; box-shadow: 0 3px 0 var(--ink); }
.btn.big { padding: 13px 28px; font-size: 19px; }
.btn.huge { display: block; padding: 17px; font: 400 30px 'Lilita One', sans-serif; }
.btn.off { background: #dfe6ef; color: var(--muted); box-shadow: none; cursor: default; transform: none; }
.btn.on { background: var(--mint); }
.btn:disabled { opacity: .6; }

.hero { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 16px; min-height: 480px; padding: 34px clamp(16px, 6vw, 80px) 90px; overflow: hidden; background: linear-gradient(180deg, #2f8ff0, #6fc3ff 60%, #bfe6ff); color: var(--white); }
.pitch { position: relative; z-index: 2; }
.hero h1 { font-size: clamp(42px, 6.2vw, 78px); text-shadow: 0 5px 0 var(--ink); }
.hero p { max-width: 30em; margin-top: 16px; font-size: 18px; color: #fff; }
.cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.live-count { min-height: 1.4em; font-size: 15px !important; }
#heroCanvas { position: relative; z-index: 1; width: 100%; height: 430px; }
.cloudline { position: absolute; left: 0; right: 0; bottom: -1px; height: 72px; z-index: 2; background:
  radial-gradient(circle at 6% 100%, var(--paper) 58px, transparent 59px),
  radial-gradient(circle at 19% 100%, var(--paper) 44px, transparent 45px),
  radial-gradient(circle at 32% 100%, var(--paper) 66px, transparent 67px),
  radial-gradient(circle at 47% 100%, var(--paper) 46px, transparent 47px),
  radial-gradient(circle at 60% 100%, var(--paper) 62px, transparent 63px),
  radial-gradient(circle at 75% 100%, var(--paper) 48px, transparent 49px),
  radial-gradient(circle at 89% 100%, var(--paper) 64px, transparent 65px),
  linear-gradient(transparent 62%, var(--paper) 62%); }

.browse { max-width: 1320px; margin: 0 auto; padding: 18px clamp(16px, 4vw, 40px) 60px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-bottom: 11px; }
.toolbar h2 { font-size: 34px; }
.toolbar input { flex: 1 1 220px; max-width: 340px; margin-left: auto; padding: 8px 14px; border: var(--border); border-radius: 12px; background: var(--white); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { padding: 4px 13px; border: var(--border); border-radius: 99px; background: var(--white); cursor: pointer; font-size: 14px; }
.pill:hover { background: var(--sky-pale); }
.pill.on { background: var(--ink); color: var(--white); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; margin-top: 18px; }
.card { display: block; overflow: hidden; border: var(--border); border-radius: 18px; background: var(--white); text-decoration: none; box-shadow: 0 5px 0 var(--ink); transition: transform .1s, box-shadow .1s; }
.card:hover { transform: translateY(-4px); box-shadow: 0 9px 0 var(--ink); }
.thumb { position: relative; aspect-ratio: 16/9; background: var(--sky-pale); border-bottom: var(--border); }
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.thumb img:not([src]) { visibility: hidden; }
.thumb .live { position: absolute; left: 8px; top: 8px; padding: 1px 9px; border: 2px solid var(--ink); border-radius: 9px; background: var(--mint); font-size: 13px; }
.meta { padding: 10px 13px 12px; }
.meta h3 { font-size: 21px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.by { color: var(--muted); font-size: 14px; }
.stats { display: flex; justify-content: space-between; margin-top: 4px; font-size: 13px; color: var(--muted); }
.none { color: var(--muted); padding: 12px 0; }

.narrow { max-width: 1040px; margin: 0 auto; padding: 26px clamp(16px, 4vw, 40px) 60px; }
.gamehead { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 24px; }
.coverwrap { aspect-ratio: 16/9; overflow: hidden; border: var(--border); border-radius: 20px; background: var(--sky-pale); box-shadow: 0 6px 0 var(--ink); }
.coverwrap img { display: block; width: 100%; height: 100%; object-fit: cover; }
.coverwrap img:not([src]) { visibility: hidden; }
.details h1 { margin: 8px 0 2px; font-size: clamp(30px, 4vw, 42px); overflow-wrap: anywhere; }
.details .btn.huge { margin: 14px 0; }
.notice { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 12px; padding: 10px 12px; border: var(--border); border-radius: 13px; background: #fff3cc; }
.notice p { flex: 1 1 200px; font-size: 15px; }
.badge { display: inline-block; padding: 1px 10px; border: 2px solid var(--ink); border-radius: 9px; background: var(--sky-pale); font-size: 13px; }
.badge.live { background: var(--mint); }
.votes { display: flex; flex-wrap: wrap; gap: 7px; }
.facts { display: flex; gap: 26px; margin: 16px 0 0; }
.facts dt { color: var(--muted); font-size: 13px; }
.facts dd { margin: 0; font: 400 20px 'Lilita One', sans-serif; }
.panel { margin-top: 22px; padding: 18px 20px; border: var(--border); border-radius: 18px; background: var(--white); }
.panel h2 { margin-bottom: 8px; font-size: 25px; }
.panel #desc { white-space: pre-wrap; overflow-wrap: anywhere; }
.panelhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.panelhead h2 { margin: 0; }
.server { display: grid; grid-template-columns: 170px minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 10px 0; border-top: 2px solid var(--sky-pale); }
.server:first-child { border-top: 0; }
.fill small { color: var(--muted); }
.bar { height: 9px; margin: 3px 0; border: 2px solid var(--ink); border-radius: 6px; overflow: hidden; background: var(--paper); }
.bar i { display: block; height: 100%; background: var(--mint); }
.names { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 14px; }
.notfound { text-align: center; padding: 70px 0; }
.notfound h1 { font-size: 38px; margin-bottom: 12px; }
.notfound p { margin-bottom: 18px; }

.pagetitle { font-size: 42px; }
.lead { margin: 6px 0 16px; color: var(--muted); max-width: 44em; }
.templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.template { padding: 14px 16px; border: var(--border); border-radius: 15px; background: var(--white); text-align: left; cursor: pointer; box-shadow: 0 4px 0 var(--ink); }
.template:hover { background: var(--sun); }
.template:disabled { opacity: .6; }
.template h3 { font-size: 21px; margin-bottom: 3px; }
.template p { font-size: 14px; color: var(--ink); }
.mygame { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 0; border-top: 2px solid var(--sky-pale); }
.mygame:first-child { border-top: 0; }
.mygame h3 { font-size: 21px; overflow-wrap: anywhere; }
.mygame p { font-size: 14px; color: var(--muted); margin-top: 2px; }
.actions { display: flex; flex-wrap: wrap; gap: 7px; }

.avatarlayout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; margin-top: 12px; align-items: start; }
.stage { position: sticky; top: 84px; padding: 12px; border: var(--border); border-radius: 20px; background: linear-gradient(180deg, #6fc3ff, #d8efff); text-align: center; }
#preview { display: block; width: 100%; height: 400px; touch-action: none; cursor: grab; }
.saved { min-height: 1.4em; margin-top: 8px; font-size: 14px; }
.avatarlayout .panel { margin-top: 0; }
#options h3 { margin: 13px 0 6px; font-size: 18px; }
#options h3:first-child { margin-top: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.colors { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { width: 30px; height: 30px; border: 2px solid var(--ink); border-radius: 8px; cursor: pointer; }
.swatch.on { box-shadow: 0 0 0 3px var(--white), 0 0 0 6px var(--ink); }

.authwrap { display: grid; place-items: center; padding: 50px 16px; }
.auth { width: min(400px, 100%); margin: 0; display: flex; flex-direction: column; gap: 12px; }
.auth label { display: block; font-size: 15px; }
.banform { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-bottom: 8px; }
.banform label { display: flex; flex: 1 1 170px; flex-direction: column; gap: 3px; font-size: 14px; }
.banform input, .banform select { padding: 9px 11px; border: var(--border); border-radius: 12px; background: var(--white); font: inherit; color: inherit; }
.banform .err { flex: 1 0 100%; color: #c32f2f; }
.auth input { display: block; width: 100%; margin-top: 3px; padding: 10px 12px; border: var(--border); border-radius: 12px; background: var(--paper); }
.err { color: #c52a2a; font-size: 15px; }
.fine { color: var(--muted); font-size: 13px; }

@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; padding-bottom: 76px; }
  #heroCanvas { height: 300px; }
  .gamehead, .avatarlayout { grid-template-columns: 1fr; }
  .stage { position: static; }
  #preview { height: 300px; }
  .server { grid-template-columns: 1fr auto; }
  .names { grid-column: 1 / -1; grid-row: 2; }
  #nav { flex-wrap: wrap; gap: 8px 14px; }
  .links { order: 3; width: 100%; }
  .toolbar input { max-width: none; margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn, .card { transition: none; }
}

/* Friends */
.links a .count { display: inline-block; min-width: 20px; margin-left: 6px; padding: 0 6px; border-radius: 99px; background: #ff5d5d; color: #fff; font-size: 13px; line-height: 20px; text-align: center; }
.pill.locked { background: #eef2f7; color: var(--muted); cursor: not-allowed; }
.note { color: #1d7a4f; font-size: 15px; }
.banform .note { flex: 1 0 100%; }
.friend { justify-content: flex-start; flex-wrap: nowrap; }
.friend .info { flex: 1; min-width: 0; }
.friend .actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.face { flex: none; display: grid; place-items: center; width: 46px; height: 46px; border: var(--border); border-radius: 13px; }
.face i { position: relative; width: 30px; height: 20px; border-radius: 6px; }
.face i::before, .face i::after { content: ''; position: absolute; top: 6px; width: 6px; height: 8px; border-radius: 3px; background: currentColor; }
.face i::before { left: 6px; }
.face i::after { right: 6px; }
@media (max-width: 560px) { .friend { flex-wrap: wrap; } .friend .actions { flex: 1 0 100%; justify-content: flex-start; } }

/* Profiles */
.profilehead { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 24px; align-items: center; }
.profilehead .stage { position: static; }
.profilehead #preview { height: 320px; }
.profilehead .actions { margin-top: 14px; }
.profilehead #playing { margin-top: 8px; }
.badge.admin { background: var(--sun); }
.sectiontitle { margin-top: 26px; font-size: 30px; }
.biotext { white-space: pre-wrap; overflow-wrap: anywhere; }
#bioForm textarea { display: block; width: 100%; padding: 10px 12px; border: var(--border); border-radius: 12px; background: var(--paper); resize: vertical; }
#bioForm .by { margin: 6px 0; }
#bioForm .actions { align-items: center; }
.friend h3 a, .by a { color: inherit; }
@media (max-width: 760px) { .profilehead { grid-template-columns: 1fr; } .profilehead #preview { height: 260px; } }

/* The owner */
.badge.owner { background: linear-gradient(180deg, #ffe27a, #ffb52e); font-weight: 800; }

.panel h2.sub { margin-top: 20px; font-size: 21px; }

/* AI helper */
#askText { display: block; width: 100%; margin-bottom: 10px; padding: 10px 12px; border: var(--border); border-radius: 12px; background: var(--paper); resize: vertical; }
#askForm .actions, #jobActions { align-items: center; }
.joblog { margin: 6px 0 10px 20px; color: var(--muted); font-size: 14px; }
.joblog li { margin: 2px 0; }
.change { margin: 10px 0; border: 2px solid #dbe4f0; border-radius: 12px; overflow: hidden; }
.change summary { padding: 8px 12px; background: #eef3fa; cursor: pointer; font-size: 14px; }
.diff { margin: 0; padding: 8px 0; max-height: 420px; overflow: auto; background: #0f1a33; color: #cdd8ea; font: 12px/1.5 ui-monospace, Menlo, monospace; white-space: pre; }
.diff span { display: block; padding: 0 10px; }
.diff .add { background: rgba(61, 220, 151, .2); color: #c9ffe6; }
.diff .del { background: rgba(255, 93, 93, .22); color: #ffd3d3; }
.diff .fold { color: #7f8fb0; font-style: italic; }
.joblog { max-height: 320px; overflow-y: auto; }
.runon { display: flex; flex-wrap: wrap; gap: 10px 18px; margin: 10px 0 4px; font-size: 14px; font-weight: 700; }
.runon label { display: flex; align-items: center; gap: 8px; }
.runon select { max-width: 100%; }
.loadbar { height: 10px; margin: 8px 0; border-radius: 6px; background: #dbe4f0; overflow: hidden; }
.loadbar div { height: 100%; width: 0; background: var(--sun, #ffc93c); transition: width .3s; }
.joblog li.step { margin-top: 8px; color: var(--ink); font-weight: 800; }
