:root {
  --bg: #0b1030;
  --panel: #151c4a;
  --line: #2e3a82;
  --text: #f2f5ff;
  --muted: #aab4e8;
  --green: #3dd65c;
  --blue: #2f9bf0;
  --red: #e8495f;
  --gold: #ffd829;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body, #app { height: 100%; margin: 0; }
body { background: radial-gradient(circle at 50% 0, #24338a, var(--bg) 60%) fixed; color: var(--text); font: 15px/1.45 "Segoe UI", system-ui, sans-serif; }
h1, h2 { margin: 0.2em 0; }

.btn { font: inherit; font-weight: 700; color: #fff; background: #3a478f; border: 2px solid #000; border-radius: 9px; padding: 7px 14px; cursor: pointer; box-shadow: inset 0 2px 0 #ffffff40, inset 0 -3px 0 #00000040; }
.btn:hover:not(:disabled) { filter: brightness(1.15); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.btn.green { background: var(--green); color: #05290f; }
.btn.blue { background: var(--blue); }
.btn.red { background: var(--red); }
.btn.small { padding: 4px 11px; font-size: 13px; }
.btn.huge { font-size: 22px; padding: 14px 34px; }
.btn.on { background: var(--green); color: #05290f; }

.page { max-width: 880px; margin: 0 auto; padding: 28px 20px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.home header { text-align: center; }
.home header p { color: var(--muted); margin: 0; }
.logo { font-size: clamp(48px, 10vw, 84px); font-weight: 900; letter-spacing: -2px; color: var(--green); -webkit-text-stroke: 2px #000; text-shadow: 0 6px 0 #00000080; line-height: 1.1; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; width: 100%; }
.card { font: inherit; color: inherit; text-align: left; display: flex; flex-direction: column; gap: 6px; background: var(--panel); border: 2px solid var(--line); border-radius: 12px; padding: 14px; cursor: pointer; }
.card:hover { border-color: var(--green); }
.card strong { font-size: 17px; }
.card small, .tag { color: var(--muted); }
.tag { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--gold); }
.drop { width: 100%; border: 2px dashed var(--line); border-radius: 12px; padding: 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.drop.over { border-color: var(--green); background: #3dd65c18; }
.drop span, footer { color: var(--muted); font-size: 13px; }
.status { min-height: 1.4em; margin: 0; text-align: center; }
.picker { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-height: 240px; overflow: auto; padding-bottom: 2px; }
.warning { background: #ffd82922; border: 1px solid var(--gold); border-radius: 8px; padding: 8px 12px; margin: 0; }

.setup > .btn:first-child { align-self: flex-start; }
.field { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.field label { color: var(--muted); }
.segmented { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.minimap { width: 100%; height: 110px; border: 2px solid var(--line); border-radius: 8px; cursor: pointer; touch-action: none; }
.setup input[type=range] { width: 100%; }

.screen { height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--panel); border-bottom: 2px solid #000; flex-wrap: wrap; }
.bar strong { margin-right: auto; }
.stage { position: relative; flex: 1; min-height: 160px; min-width: 0; overflow: hidden; touch-action: none; cursor: grab; user-select: none; }
.fill { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hint { padding: 6px 12px; color: var(--muted); font-size: 12px; text-align: center; background: var(--panel); }
.clock { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 18px; min-width: 3.2em; text-align: center; }
.clock.low { color: var(--red); }
.check { display: flex; gap: 6px; align-items: center; font-size: 13px; cursor: pointer; }

/* editor: laid out like the in-game one */
.gded { height: 100%; display: flex; flex-direction: column; overflow: hidden; background: #000; user-select: none; }
.gded-view { position: relative; flex: 1; min-height: 0; display: flex; }
.editor-stage { cursor: crosshair; outline: none; }
.hud { position: absolute; display: flex; gap: 8px; align-items: center; pointer-events: none; }
.hud > *, .layers > * { pointer-events: auto; }
.hud-tl { top: 8px; left: 10px; }
.hud-left { top: 66px; left: 10px; flex-direction: column; }
.hud-top { top: 14px; left: 50%; transform: translateX(-50%); width: min(380px, 34%); }
.hud-top input { width: 100%; }
.hud-tr { top: 8px; right: 10px; flex-direction: column; align-items: flex-end; }
.hud-info { top: 68px; left: 62px; flex-direction: column; align-items: flex-start; gap: 0; font-size: 12px; color: #fff; text-shadow: 0 1px 2px #000, 0 0 3px #000; }
.hud-info > * { pointer-events: none; }
.hud-right { right: 8px; bottom: 8px; flex-direction: column; align-items: flex-end; }
.hud-right > .side-grid { pointer-events: none; }
.side-grid { display: grid; grid-template-columns: repeat(2, 72px); gap: 4px; }
.side-grid > * { pointer-events: auto; }
.side-btn { width: 72px; height: 46px; }
.layers { display: flex; align-items: center; gap: 4px; }
.layer { min-width: 34px; display: flex; justify-content: center; font-weight: 800; }
.submit { height: 38px; padding: 0 6px; }
.clock { font-variant-numeric: tabular-nums; }

/* game-style buttons (nine-slice textures once loaded) */
.gdb { display: inline-flex; align-items: center; justify-content: center; font: 800 12px/1.1 "Segoe UI", system-ui, sans-serif; color: #fff; background: #5fbf2a; border: 2px solid #000; border-radius: 8px; padding: 3px 6px; cursor: pointer; white-space: pre-line; text-shadow: 0 1px 2px #000; }
.gdb-light { background: #999; }
.gdb-dark { background: #737d99; }
.gdb-blue { background: #25e0e0; }
.gdb-red { background: #dd2d33; }
.gd-textures .gdb { background: transparent; border: 8px solid transparent; border-image: var(--gd-btn-green) 48 fill / 10px; border-radius: 0; padding: 0; }
.gd-textures .gdb-light { border-image-source: var(--gd-btn-light); }
.gd-textures .gdb-dark { border-image-source: var(--gd-btn-dark); }
.gd-textures .gdb-blue { border-image-source: var(--gd-btn-blue); }
.gd-textures .gdb-red { border-image-source: var(--gd-btn-red); }
.gdi { background: none; border: 0; padding: 0; cursor: pointer; line-height: 0; }
.gdb:active:not(:disabled), .gdi:active:not(:disabled) { transform: scale(1.12); }
.gdb:disabled, .gdi:disabled { opacity: 0.45; cursor: default; }
.sprite, .gd-text { display: block; flex-shrink: 0; pointer-events: none; }
.gdb > .sprite, .gdb > .gd-text { max-width: calc(100% + 8px); max-height: calc(100% + 8px); object-fit: contain; }

/* toolbar */
.gded-bar { display: flex; align-items: center; gap: 10px; padding: 6px 10px; height: 172px; flex-shrink: 0; background: linear-gradient(#0c0a0a, #211f20); }
.gd-textures .gded-bar { background: var(--gd-bar) center / 100% 100%; }
.vline { width: 2px; align-self: stretch; margin: 6px 0; background: linear-gradient(transparent, #fff9, transparent); }
.modes { display: grid; grid-template-columns: repeat(2, clamp(56px, 8vw, 76px)); gap: 4px; }
.mode { width: 100%; height: 76px; }
.toggles { display: grid; grid-template-columns: repeat(2, clamp(56px, 8vw, 76px)); gap: 4px; }
.toggle { width: 100%; height: 76px; }
.dock-center { container-type: inline-size; flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.tabs { display: flex; justify-content: safe center; gap: 2px; flex-shrink: 0; overflow-x: auto; }
.tab { position: relative; width: 46px; height: 30px; padding: 0; border: 0; background: #555; border-radius: 6px 6px 0 0; cursor: pointer; flex-shrink: 0; }
.tab.on { background: #aaa; }
.gd-textures .tab { background: none; }
.tab .tab-back { position: absolute; inset: 0; width: 46px !important; height: 30px !important; }
.tab canvas { position: absolute; left: 10px; top: 2px; width: 26px; height: 26px; }
.palette { display: flex; align-items: center; justify-content: center; gap: 10px; min-width: 0; }
.slots { display: grid; grid-auto-rows: 50px; gap: 4px; height: 104px; align-content: start; }
.slot { width: 50px; height: 50px; overflow: hidden; }
.slot.on { filter: brightness(0.75); }
.slot canvas { width: 40px; height: 40px; flex-shrink: 0; margin: -4px; }
.dots { display: flex; justify-content: center; align-items: center; gap: 5px; height: 14px; }
.dots button { width: 8px; height: 8px; padding: 0; border: 0; border-radius: 50%; background: #666; cursor: pointer; }
.dots button.on { background: #fff; }
.edit-panel { --u: min(1px, 0.145cqw); display: flex; justify-content: center; align-items: center; gap: calc(var(--u) * 14); height: 100%; }
.edit-panel[hidden], .mode-panel[hidden] { display: none; }
.pad { display: grid; grid-template-columns: repeat(3, calc(var(--u) * 58)); grid-template-rows: repeat(3, calc(var(--u) * 52)); place-items: center; }
.pad .sprite { height: calc(var(--u) * 62) !important; width: auto !important; }
.pad-up { grid-area: 1 / 2; }
.pad-left { grid-area: 2 / 1; }
.pad-right { grid-area: 2 / 3; }
.pad-down { grid-area: 3 / 2; }
.pad-up .sprite { transform: rotate(90deg); }
.pad-right .sprite { transform: rotate(180deg); }
.pad-down .sprite { transform: rotate(270deg); }
.pad-step { grid-area: 2 / 2; display: grid; place-items: center; min-width: 0; font-weight: 800; }
.pad-step .gd-text { max-width: calc(var(--u) * 56); object-fit: contain; }
.steps, .actions { display: grid; gap: calc(var(--u) * 7); grid-auto-rows: calc(var(--u) * 46); }
.steps { grid-template-columns: repeat(3, calc(var(--u) * 62)); }
.actions { grid-template-columns: repeat(4, calc(var(--u) * 62)); }
.key { width: 100%; height: 100%; min-width: 0; min-height: 0; }
.key > .sprite { height: calc(var(--u) * 34) !important; width: auto !important; max-width: 100%; }
.step > .sprite { height: calc(var(--u) * 30 * var(--s)) !important; }
.gdb.key.dim { filter: brightness(0.62); }
.mode-panel { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; align-items: center; text-align: center; }
.scale-pop { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 4px; padding: 6px 14px; background: #000b; border-radius: 10px; width: min(360px, 70%); }
.scale-pop[hidden] { display: none; }
.scale { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.scale b { min-width: 4.5em; }
.scale input { flex: 1; min-width: 0; }
select { font: inherit; font-size: 13px; background: #2a3470; color: #fff; border: 2px solid #000; border-radius: 7px; padding: 3px; }
.gd-textures .gd-slider { -webkit-appearance: none; appearance: none; background: var(--gd-groove) center / 100% 16px no-repeat; height: 30px; }
.gd-textures .gd-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 30px; height: 30px; background: var(--gd-thumb) center / contain no-repeat; cursor: pointer; }
.gd-textures .gd-slider::-moz-range-thumb { width: 30px; height: 30px; border: 0; background: var(--gd-thumb) center / contain no-repeat; }
.pause { background: var(--panel); color: var(--text); border: 3px solid #000; border-radius: 14px; max-width: 440px; text-align: center; }
.gd-textures .pause { background: transparent; border: 20px solid transparent; border-image: var(--gd-panel) 90 fill / 28px; border-radius: 0; }
.pause[open] { display: flex; flex-direction: column; gap: 10px; }
.pause::backdrop { background: #000a; }
.pause h2 { display: flex; justify-content: center; }
.pause .gdb { min-height: 46px; }

/* results */
.scores { display: grid; grid-template-columns: auto repeat(3, 1fr); gap: 10px; padding: 10px 12px; align-items: stretch; }
.overall { display: flex; align-items: center; gap: 12px; padding: 0 8px; }
.overall b { font-size: 30px; display: block; line-height: 1; }
.overall small { color: var(--muted); }
.grade { font-size: 58px; font-weight: 900; color: var(--gold); -webkit-text-stroke: 2px #000; line-height: 1; }
.score { background: var(--panel); border: 2px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.score > div:first-child { display: flex; justify-content: space-between; font-size: 17px; }
.score small { color: var(--muted); font-size: 12px; display: block; }
.meter { height: 8px; background: #000; border-radius: 4px; overflow: hidden; margin: 5px 0; }
.meter i { display: block; height: 100%; background: var(--green); }
.compare-layers { position: absolute; inset: 0; }
.layer-original { position: absolute; inset: 0; pointer-events: none; }
.official { text-align: center; }
.official h2 { font-size: 18px; }
/* These lists never scroll: a pressed button moves a pixel, which would flash up a
   scroll bar and reshuffle the buttons under the pointer. */
.official .picker { max-height: none; overflow: visible; }
.handle { position: absolute; top: 0; bottom: 0; width: 30px; margin-left: -15px; cursor: ew-resize; touch-action: none; }
.handle::before { content: ""; position: absolute; left: 13px; top: 0; bottom: 0; width: 4px; background: #fff; box-shadow: 0 0 6px #000; }
.handle span { position: absolute; top: 50%; left: -3px; width: 36px; height: 36px; margin-top: -18px; border-radius: 50%; background: #fff; color: #000; display: grid; place-items: center; font-weight: 900; }
.badge { position: absolute; top: 8px; padding: 2px 10px; background: #000b; border-radius: 6px; font-size: 12px; font-weight: 700; pointer-events: none; }
.badge.left { left: 8px; }
.badge.right { right: 8px; }
.compare-controls { display: flex; gap: 14px; align-items: center; padding: 6px 12px; background: var(--panel); flex-wrap: wrap; }
.split { flex: 1; min-width: 160px; }

.tab-label { position: relative; font: 800 13px/30px "Segoe UI", system-ui, sans-serif; color: #fff; text-shadow: 0 1px 2px #000, 0 0 3px #000; }
.scrub { width: 100%; flex-shrink: 0; margin: 0; padding: 0 12px; background-color: var(--panel); }
.range-inputs { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: center; }
.range-inputs input { width: 6.5em; font: inherit; background: #2a3470; color: #fff; border: 2px solid #000; border-radius: 7px; padding: 3px 6px; }

/* playtest overlay */
.playtest { position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; background: #000; user-select: none; }
.play-progress { display: flex; align-items: center; gap: 10px; padding: 4px 12px; background: var(--panel); }
.play-progress .meter { flex: 1; margin: 0; height: 10px; }
.play-progress b { min-width: 3em; text-align: right; font-variant-numeric: tabular-nums; }
.play-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; touch-action: none; cursor: pointer; }
.play-pick { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 5px 12px; background: var(--panel); font-size: 13px; }
.play-pick[hidden] { display: none; }
.play-pick .gd-slider { flex: 1; min-width: 140px; }
.play-message { position: absolute; left: 0; right: 0; top: 22%; display: flex; justify-content: center; pointer-events: none; text-align: center; padding: 0 12px; }
.play-message > div { background: #000c; border: 2px solid var(--line); border-radius: 14px; padding: 14px 24px; max-width: 460px; pointer-events: auto; }
.play-message p { margin: 6px 0; color: var(--muted); font-size: 13px; }

@media (max-width: 760px) {
  .scores { grid-template-columns: 1fr; gap: 5px; }
  .score small { display: none; }
  .gded-bar { flex-wrap: wrap; height: auto; justify-content: space-between; }
  .dock-center { order: -1; flex-basis: 100%; height: 160px; }
  .vline { display: none; }
  .modes { grid-template-columns: repeat(4, 50px); gap: 3px; }
  .mode { height: 46px; }
  .toggles { grid-template-columns: repeat(4, 50px); gap: 3px; }
  .toggle { height: 46px; }
  .hud-top { top: 62px; width: 40%; }
  .side-grid { grid-template-columns: repeat(2, 48px); }
  .side-btn { width: 48px; height: 32px; }
}

/* Edit Object popup, kept to one side so the object stays visible */
.object-dialog { margin: auto 12px auto auto; width: 340px; max-height: calc(100% - 20px); overflow: auto; }
.object-dialog::backdrop { background: #0004; }
.object-fields { display: flex; flex-direction: column; gap: 10px; }
.object-fields p { margin: 0; font-size: 13px; }
.object-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.object-fields label { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 12px; }
.object-fields input[type=number] { width: 100%; font: inherit; font-size: 13px; background: #2a3470; color: #fff; border: 2px solid #000; border-radius: 7px; padding: 3px 6px; }
.object-fields input[type=checkbox] { width: 20px; height: 20px; }
.object-buttons { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.object-fields .checks { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.object-fields label.check { flex-direction: row; font-size: 13px; }
.object-buttons input[type=number] { width: 6em !important; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; align-items: center; font-size: 13px; }
.group-list { display: flex; flex-direction: column; gap: 4px; max-height: 150px; overflow: auto; font-size: 13px; }
.group-list > div { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* daily level, level IDs, admin */
.daily { width: 100%; background: var(--panel); border: 2px solid var(--gold); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.daily p { margin: 0; }
.daily-count { color: var(--gold); font-size: 13px; }
.daily-banner { padding: 5px 12px; background: #ffd82922; border-bottom: 2px solid var(--gold); text-align: center; font-size: 13px; }
.id-form { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.id-form input, .sign-in input { font: inherit; background: #2a3470; color: #fff; border: 2px solid #000; border-radius: 9px; padding: 6px 10px; width: 12em; }
footer a { color: var(--muted); }
.picker-block { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.admin-top { display: flex; gap: 14px; align-items: center; align-self: stretch; }
.admin-body, .calendar-wrap, .day-panel, .chosen { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.month-bar { display: flex; gap: 14px; align-items: center; font-size: 18px; }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; width: 100%; }
.calendar > i { text-align: center; color: var(--muted); font-style: normal; font-size: 12px; }
.day { font: inherit; color: var(--text); background: var(--panel); border: 2px solid var(--line); border-radius: 8px; min-height: 78px; padding: 4px; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; cursor: pointer; overflow: hidden; text-align: left; min-width: 0; }
.day span { font-size: 12px; font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day small { color: var(--muted); font-size: 11px; }
.day.set { background: #1f3d4a; }
.day.today { border-color: var(--gold); }
.day.selected { border-color: var(--green); box-shadow: 0 0 0 2px var(--green); }
.sources { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; }
.stage.preview { width: 100%; height: 300px; flex: none; border: 2px solid var(--line); border-radius: 8px; }
.admin .scrub { border-radius: 8px; }

/* share */
.share-dialog { max-width: min(760px, 96vw); width: 760px; }
.share-preview { max-width: 100%; max-height: 52vh; align-self: center; border: 2px solid #000; border-radius: 8px; object-fit: contain; }
.day:disabled { cursor: default; opacity: .45; }
.day.done { box-shadow: inset 0 -4px 0 var(--green); }
.day small.mine { color: var(--gold); font-weight: 700; }

/* featured categories */
.featured { width: 100%; display: flex; flex-direction: column; gap: 16px; }
.featured:empty { display: none; }
.feature-list { width: 100%; display: flex; flex-direction: column; gap: 14px; }
.feature-category { background: var(--panel); border: 2px solid var(--line); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.feature-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.feature-row.item { border-top: 1px solid var(--line); padding-top: 8px; }
.feature-row small { color: var(--muted); flex: 1; min-width: 10em; }
.feature-row input, .sources input[type=text], .feature-row select, .sources select { font: inherit; background: #2a3470; color: #fff; border: 2px solid #000; border-radius: 9px; padding: 4px 8px; max-width: 100%; }
[hidden] { display: none !important; }

/* level packs: search and bulk upload */
.packs { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.packs:empty { display: none; }
.search { width: 100%; display: flex; justify-content: center; }
.search input { font: inherit; width: min(420px, 100%); background: #2a3470; color: #fff; border: 2px solid #000; border-radius: 9px; padding: 8px 12px; }
.pack summary { cursor: pointer; display: flex; gap: 10px; justify-content: center; align-items: baseline; }
.pack summary h2 { margin: 6px 0; }
.pack summary small { color: var(--muted); }
.pack summary::before { content: '▸'; color: var(--muted); }
.pack[open] summary::before { content: '▾'; }
.upload-list { width: 100%; max-height: 280px; overflow: auto; display: flex; flex-direction: column; gap: 4px; text-align: left; }
.upload-list label { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.upload-list small { color: var(--muted); }
.upload-problems { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.upload-problems:empty { display: none; }

/* random official level */
.random { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.random .segmented { align-items: center; }
.random input[type=number] { width: 5.5em; font: inherit; font-size: 13px; background: #2a3470; color: #fff; border: 2px solid #000; border-radius: 7px; padding: 3px 6px; }

/* moving the share camera */
.framer { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.framer canvas { width: 100%; max-height: 52vh; aspect-ratio: 1140 / 560; border: 2px solid #000; border-radius: 8px; cursor: grab; touch-action: none; }
