:root {
  --bg: #07070c;
  --panel: rgba(16, 16, 26, 0.92);
  --line: #262636;
  --text: #e6e6f0;
  --dim: #8b8ba3;
  --accent: #00e5ff;
  --rec: #ff2f5e;
  /* Self-hosted from /fonts, which is served publicly, so the gated studio and
     the marketing site share one copy of each file. */
  --font: "Google Sans", ui-sans-serif, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@font-face {
  font-family: 'Google Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/google-sans-400-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Google Sans';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/google-sans-500-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Google Sans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/google-sans-700-latin.woff2') format('woff2');
}

* { box-sizing: border-box; }

/* The UA stylesheet's `[hidden] { display: none }` loses to any author rule
   that sets `display`, so `el.hidden = true` silently does nothing on things
   like .preview-note (display:flex) or .card (display:block). Make it stick. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

/* ------------------------------------------------------------ preview mode */

.preview-bar {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100vw - 120px);
  padding: 9px 10px 9px 16px;
  border-radius: 99px;
  background: rgba(16, 16, 26, 0.94);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
  font-size: 13px;
  color: var(--dim);
}
.preview-bar b { color: var(--text); font-weight: 600; }
.preview-cta {
  flex: none;
  background: var(--accent);
  color: #04121a;
  font-weight: 620;
  font-size: 12.5px;
  text-decoration: none;
  padding: 6px 13px;
  border-radius: 99px;
}
.preview-cta:hover { filter: brightness(1.08); }

.preview-note {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  background: rgba(0, 229, 255, 0.06);
  border: 1px solid rgba(0, 229, 255, 0.28);
  border-radius: 12px;
  padding: 14px 16px;
  margin: 0 0 26px;
  font-size: 14px;
  color: var(--dim);
  line-height: 1.55;
}
.preview-note b { color: var(--text); font-weight: 620; }

.btn.locked {
  border-color: rgba(0, 229, 255, 0.45);
  color: var(--accent);
  background: rgba(0, 229, 255, 0.08);
}

@media (max-width: 760px) {
  .preview-bar {
    max-width: calc(100vw - 24px);
    font-size: 12px;
    gap: 10px;
    padding: 8px 8px 8px 13px;
  }
}

/* ------------------------------------------------------------ studio header */

.site-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
}
.site-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-size: 15px;
}
.site-brand .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 14px var(--accent);
}
.site-nav { display: flex; gap: 18px; font-size: 13.5px; }
.site-nav a { color: var(--dim); text-decoration: none; }
.site-nav a:hover { color: var(--text); }

/* ---------------------------------------------------------------- gallery */

.gallery-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 44px 24px 80px;
}

.gallery-wrap h1 {
  margin: 0 0 6px;
  font-size: 30px;
  letter-spacing: -0.02em;
}

.gallery-wrap .lede {
  margin: 0 0 40px;
  color: var(--dim);
  font-size: 15px;
  line-height: 1.6;
  max-width: 62ch;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

.card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: #0e0e18;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s;
}

.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.card .thumb {
  aspect-ratio: 9 / 16;
  max-height: 300px;
  width: 100%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 45%, #16162a 0%, #08080f 70%);
}

.card .thumb svg { width: 72%; height: auto; }

.card .meta { padding: 14px 16px 18px; }
.card .meta h3 { margin: 0 0 6px; font-size: 16px; }
.card .meta p { margin: 0; font-size: 13px; color: var(--dim); line-height: 1.5; }

.gallery-wrap footer {
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-size: 13px;
  line-height: 1.7;
}
.gallery-wrap footer code {
  background: #14141f;
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text);
}

/* ------------------------------------------------------------- game stage */

.stage {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

#stage-canvas {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 0 60px rgba(0, 229, 255, 0.07);
}

.back {
  position: fixed;
  top: 14px;
  left: 16px;
  z-index: 20;
  color: var(--dim);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(10, 10, 18, 0.7);
}
.back:hover { color: var(--text); }

/* ----------------------------------------------------------- control panel */

.gear {
  position: fixed;
  top: 12px;
  z-index: 20;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(16, 16, 26, 0.9);
  color: var(--text);
  font-size: 17px;
  cursor: pointer;
}
.gear-right { right: 14px; }
.gear-left { left: 14px; top: 52px; }
.gear-left-lower { left: 14px; top: 100px; }
.gear-left-third { left: 14px; top: 148px; font-weight: 700; font-family: var(--font); }
.gear:hover { border-color: var(--accent); }
.gear.hidden { display: none; }

.panel {
  position: fixed;
  top: 0;
  z-index: 30;
  width: 320px;
  height: 100vh;
  overflow-y: auto;
  padding: 14px 16px 22px;
  background: var(--panel);
  backdrop-filter: blur(8px);
  display: none;
  font-size: 13px;
}
.panel-right { right: 0; border-left: 1px solid var(--line); }
.panel-left { left: 0; border-right: 1px solid var(--line); }
.panel.open { display: block; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.panel-title { margin: 0; font-size: 15px; font-weight: 600; }

.icon-btn {
  background: none;
  border: none;
  color: var(--dim);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.icon-btn:hover { color: var(--text); }

.group {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-bottom: 14px;
}
.group-title {
  margin: 0 0 10px;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 600;
}

.row {
  display: grid;
  grid-template-columns: 108px 1fr 44px;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
}
.row.two { grid-template-columns: 1fr 1fr; }
.row.two .btn { grid-column: auto; }
.row > .btn:only-child { grid-column: 1 / -1; }
.row > .btn:first-child:not(:only-child) { grid-column: 1 / 3; }
.row.two > .btn:first-child { grid-column: 1; }

.row-label { color: var(--dim); }
.val {
  text-align: right;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}
.sub {
  margin: -4px 0 10px;
  color: #62627a;
  font-size: 11px;
  line-height: 1.4;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  height: 18px;
}
input[type="color"] {
  width: 100%;
  height: 26px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: none;
  cursor: pointer;
}
input.num, select {
  width: 100%;
  background: #14141f;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 6px;
  font-family: inherit;
  font-size: 12px;
}

.btn {
  background: #191926;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn.rec.on {
  background: var(--rec);
  border-color: var(--rec);
  color: #fff;
}

/* Paused state on the play/pause button */
.btn.on:not(.rec) {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(0, 229, 255, 0.1);
}

.timer {
  text-align: right;
  color: var(--rec);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.seg { display: flex; gap: 6px; grid-column: 2 / 4; }
.seg-btn {
  flex: 1;
  background: #14141f;
  border: 1px solid var(--line);
  color: var(--dim);
  border-radius: 7px;
  padding: 6px 4px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}
.seg-btn.on { border-color: var(--accent); color: var(--accent); }
.seg-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.switch { position: relative; display: inline-block; width: 36px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute;
  inset: 0;
  background: #2a2a3c;
  border-radius: 20px;
  transition: 0.15s;
}
.switch .slider::before {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  left: 3px;
  top: 3px;
  background: #8b8ba3;
  border-radius: 50%;
  transition: 0.15s;
}
.switch input:checked + .slider { background: rgba(0, 229, 255, 0.28); }
.switch input:checked + .slider::before { transform: translateX(16px); background: var(--accent); }

.needs-restart .row-label::after {
  content: "↻";
  color: #4a4a60;
  margin-left: 5px;
  font-size: 11px;
}

.hint {
  margin: 16px 0 0;
  color: #52526a;
  font-size: 11px;
  line-height: 1.6;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.hint b { color: var(--dim); font-weight: 600; }

/* ------------------------------------------------------------------ mobile */

@media (max-width: 760px) {
  .panel { width: min(320px, 88vw); }
  .stage { padding: 0; }
  #stage-canvas { border-radius: 0; }

  /* Bigger tap targets than a mouse needs. */
  .gear { width: 44px; height: 44px; }
  .btn { padding: 11px 10px; }
  .swatches .swatch { height: 38px; }
  input[type="range"] { height: 30px; }

  /* Labels get cramped at phone widths; give the control the room. */
  .row { grid-template-columns: 92px 1fr 40px; gap: 6px; }

  .hint { display: none; } /* no hardware keyboard to shortcut with */

  .site-head { padding: 13px 16px; }
  .site-nav { gap: 13px; font-size: 13px; }
  .gallery-wrap { padding: 28px 16px 60px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
  .card .thumb { max-height: 210px; }
}

/* --------------------------------------------------------- color panel bits */

.btn.wide { width: 100%; margin-top: 4px; }

.presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.preset-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: #14141f;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
  font-family: inherit;
}
.preset-btn:hover { border-color: var(--accent); }
.preset-name { color: var(--dim); font-size: 11.5px; }
.chips { display: flex; }
.chips i {
  width: 8px;
  height: 14px;
  display: block;
  border-radius: 1px;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  margin-bottom: 10px;
}
.swatches .swatch {
  width: 100%;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: none;
  cursor: pointer;
}

.palette-preview {
  display: flex;
  height: 16px;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}
.palette-preview i { flex: 1; display: block; }

/* --------------------------------------------------------------- text panel */

.layerlist { display: flex; flex-direction: column; gap: 5px; margin-bottom: 8px; }

.layerrow {
  display: flex;
  align-items: center;
  gap: 3px;
  background: #14141f;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 5px;
  cursor: pointer;
}
.layerrow:hover { border-color: #2e2e42; }
.layerrow.on { border-color: var(--accent); background: rgba(0, 229, 255, 0.07); }

.lname {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--text);
  font-size: 11.5px;
}
.lname.off { color: #52526a; text-decoration: line-through; }

.lbtn {
  flex: none;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 4px;
  color: var(--dim);
  font-family: inherit;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}
.lbtn:hover { background: #232334; color: var(--text); }
.lbtn.danger:hover { background: rgba(255, 61, 87, 0.16); color: var(--rec); }

.textbox {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  background: #14141f;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 8px;
  margin-bottom: 10px;
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1.35;
}
.textbox:focus { outline: none; border-color: var(--accent); }

.swatch-btn {
  width: 100%;
  height: 22px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  cursor: pointer;
}
.swatch-btn:hover { border-color: var(--accent); }

/* A 3x3 grid that mirrors the nine preset positions on the canvas. */
.anchors {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}
.anchor-btn {
  height: 26px;
  background: #14141f;
  border: 1px solid var(--line);
  border-radius: 5px;
  cursor: pointer;
  position: relative;
}
.anchor-btn::after {
  content: '';
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 2px;
  border-radius: 1px;
  background: #52526a;
}
.anchor-btn:hover { border-color: #2e2e42; }
.anchor-btn:hover::after { background: var(--dim); }
.anchor-btn.on { border-color: var(--accent); background: rgba(0, 229, 255, 0.1); }
.anchor-btn.on::after { background: var(--accent); }
