:root {
  --bg: #12151c;
  --ink: #f2f4f8;
  --muted: #8b93a7;
  --candy-a: #ff5a6a;
  --candy-b: #ffc14d;
  --candy-c: #3ecf8e;
  --candy-d: #4ab0ff;
  --panel: #1a1e28;
  --font: "Outfit", "ZCOOL KuaiLe", system-ui, sans-serif;
  --display: "ZCOOL KuaiLe", "Outfit", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  overflow-x: hidden;
  padding:
    env(safe-area-inset-top, 0)
    env(safe-area-inset-right, 0)
    env(safe-area-inset-bottom, 0)
    env(safe-area-inset-left, 0);
}

/* ===== Scrollbar ===== */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 193, 77, 0.55) rgba(255, 255, 255, 0.06);
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 999px;
  margin: 4px;
}

*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #ffc14d, #ff5a6a);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #ffd76a, #ff7a86);
  background-clip: padding-box;
}

*::-webkit-scrollbar-corner {
  background: transparent;
}

.shop-list::-webkit-scrollbar,
.palette::-webkit-scrollbar,
.moods::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ===== Hero ===== */
.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(900px 500px at 20% 10%, rgba(255, 90, 106, 0.16), transparent 55%),
    radial-gradient(700px 480px at 90% 80%, rgba(62, 207, 142, 0.12), transparent 50%),
    var(--bg);
}

/* display:grid 会覆盖原生 [hidden]，必须显式隐藏 */
.hero[hidden] {
  display: none !important;
}

.wall {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.55;
}

.hero-inner {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 2rem 1.25rem 3rem;
  max-width: 40rem;
  animation: rise 0.9s cubic-bezier(.22,1,.36,1) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: none; }
}

.brand {
  font-family: var(--font);
  font-weight: 800;
  letter-spacing: 0.42em;
  font-size: 0.85rem;
  color: var(--candy-b);
  margin-bottom: 1rem;
  text-indent: 0.42em;
}

.slogan {
  font-family: var(--display);
  font-size: clamp(2.4rem, 8vw, 4.2rem);
  font-weight: 400;
  line-height: 1.15;
  margin-bottom: 0.85rem;
  background: linear-gradient(180deg, #fff 30%, #c5cce0);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lead {
  color: var(--muted);
  font-size: 1.05rem;
  margin-bottom: 2rem;
}

.drop-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.6rem;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--candy-a), #ff8a4a);
  color: #1a0808;
  font-family: var(--font);
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  box-shadow: 0 12px 40px rgba(255, 90, 106, 0.35);
  transition: transform 0.2s, box-shadow 0.2s;
  animation: pulse 2.4s ease-out infinite;
}

.drop-btn:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 16px 48px rgba(255, 90, 106, 0.45);
}

@media (hover: none) {
  .drop-btn:hover { transform: none; }
  .drop-btn:active {
    transform: scale(0.98);
  }
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 90, 106, 0.45); }
  70% { box-shadow: 0 0 0 22px rgba(255, 90, 106, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 90, 106, 0); }
}

.dot-stack {
  display: flex;
  gap: 3px;
}
.dot-stack i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #1a0808;
  opacity: 0.75;
}
.dot-stack i:nth-child(2) { background: #fff; opacity: 0.9; }
.dot-stack i:nth-child(3) { background: var(--candy-b); opacity: 1; }

.hint {
  margin-top: 1.1rem;
  font-size: 0.78rem;
  color: rgba(139, 147, 167, 0.75);
  letter-spacing: 0.04em;
}

.hero.dragover .drop-btn {
  transform: scale(1.06);
  background: linear-gradient(135deg, var(--candy-c), var(--candy-d));
}

/* ===== Studio ===== */
.studio {
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0.75rem 0.5rem 1.5rem;
  background:
    radial-gradient(600px 300px at 100% 0%, rgba(74, 176, 255, 0.1), transparent 50%),
    var(--bg);
}

.studio[hidden] { display: none !important; }

.studio-bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.85rem 1rem;
  margin-bottom: 0.75rem;
  max-width: none;
  width: 100%;
}

.text-btn, .swap {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--candy-b);
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  font-size: 0.9rem;
}

.moods {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.4rem;
  max-width: 560px;
  width: 100%;
  justify-self: center;
}

.mood {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.5rem 0.4rem;
  border-radius: 999px;
  cursor: pointer;
  transition: 0.2s;
  text-align: center;
  white-space: nowrap;
}

.mood.on {
  color: #12080a;
  border-color: transparent;
  background: linear-gradient(135deg, var(--candy-b), #ffe08a);
}

.stage {
  max-width: none;
  width: 100%;
  margin: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 50%);
  gap: 0.75rem;
  align-items: start;
}

.stage-main {
  width: 100%;
  min-width: 0;
}

.compare {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 0.55rem;
}

.pane {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.08);
  aspect-ratio: 1;
}

.pane.main {
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.pane canvas {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.pane-tag {
  position: absolute;
  top: 0.7rem;
  left: 0.7rem;
  z-index: 2;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: var(--ink);
  backdrop-filter: blur(6px);
}

.ingest {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 193, 77, 0.35), transparent 45%);
  animation: ingest 0.85s ease-out both;
}

@keyframes ingest {
  from { opacity: 1; transform: scale(0.4); filter: blur(12px); }
  to { opacity: 0; transform: scale(1.4); filter: blur(0); }
}

.controls {
  display: grid;
  gap: 0.85rem;
  padding: 1rem 1.1rem;
  border-radius: 20px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.08);
  position: sticky;
  top: 0.75rem;
  max-height: calc(100dvh - 1.5rem);
  overflow: auto;
  width: 100%;
  min-width: 0;
}

.ctrl-block {
  display: grid;
  gap: 0.75rem;
}

.ctrl-block.selectors {
  gap: 0.7rem;
  padding-bottom: 0.15rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.slider {
  display: grid;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.slider b { color: var(--candy-b); }

.slider input[type="range"] {
  width: 100%;
  accent-color: var(--candy-a);
}

.shape-row {
  display: grid;
  gap: 0.35rem;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.shapes,
.seg {
  display: grid;
  gap: 0.4rem;
}

.shapes.cols-2,
.seg.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.shapes.cols-3,
.seg.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.shape {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.55rem 0.35rem;
  border-radius: 10px;
  cursor: pointer;
  transition: 0.2s;
  min-height: 40px;
}

.shape.on {
  color: #12080a;
  border-color: transparent;
  background: linear-gradient(135deg, var(--candy-c), var(--candy-d));
}

.play-groups {
  display: grid;
  gap: 0.7rem;
}

.play-group {
  display: grid;
  gap: 0.3rem;
}

.play-label {
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: rgba(139, 147, 167, 0.9);
}

.mini-wide {
  grid-column: 1 / -1;
}

.tools-grid {
  width: 100%;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem;
  align-items: stretch;
}

.ghost-btn.compact {
  min-width: 64px;
  padding: 0.55rem 0.7rem;
  font-size: 0.78rem;
}

.inspire {
  gap: 0.7rem;
}

.palette {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 140px;
  overflow: auto;
}

.palette i {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.15);
}

.count {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
}

.shop-block {
  display: grid;
  gap: 0.55rem;
  padding-top: 0.35rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.shop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.shop-head h3 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
}

.link-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--candy-b);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.shop-list {
  max-height: 220px;
  overflow: auto;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.72rem;
}

.shop-empty {
  padding: 0.75rem;
  color: var(--muted);
}

.shop-table {
  width: 100%;
  border-collapse: collapse;
}

.shop-table th,
.shop-table td {
  padding: 0.4rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.shop-table th {
  position: sticky;
  top: 0;
  background: #1a1e28;
  color: var(--muted);
  font-weight: 600;
  z-index: 1;
}

.shop-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--candy-b);
  font-weight: 700;
}

.shop-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 0.35rem;
  vertical-align: middle;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.shop-total {
  padding: 0.45rem 0.5rem;
  color: var(--muted);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.poster-btn, .ghost-btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 0.85rem 1rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.poster-btn {
  background: linear-gradient(135deg, var(--candy-a), #ff8a4a);
  color: #1a0808;
}

.ghost-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--ink);
}

/* Poster */
.poster-layer {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  padding: 1rem;
  animation: fadeIn 0.35s ease;
}

.poster-layer[hidden] { display: none !important; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.poster-card {
  width: min(380px, 100%);
  animation: pop 0.45s cubic-bezier(.22,1,.36,1);
}

@keyframes pop {
  from { opacity: 0; transform: translateY(28px) scale(0.94); }
  to { opacity: 1; transform: none; }
}

.poster-card canvas {
  width: 100%;
  height: auto;
  border-radius: 18px;
  display: block;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}

.poster-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.9rem;
  justify-content: center;
  flex-wrap: wrap;
}

.poster-actions .poster-btn,
.poster-actions .ghost-btn {
  min-height: 44px;
  min-width: 120px;
}

/* ===== Tablet / Mobile ===== */
@media (max-width: 900px) {
  .studio {
    padding: 0.5rem 0.4rem calc(1rem + env(safe-area-inset-bottom, 0));
  }

  .studio-bar {
    grid-template-columns: 1fr auto;
    gap: 0.5rem 0.65rem;
    margin-bottom: 0.75rem;
  }

  .studio-bar .text-btn {
    justify-self: start;
  }

  .studio-bar .bar-right {
    justify-self: end;
  }

  .studio-bar .text-btn,
  .studio-bar .swap {
    font-size: 0.82rem;
    padding: 0.45rem 0.15rem;
    min-height: 40px;
  }

  .moods {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: none;
    gap: 0.4rem;
  }

  .mood {
    padding: 0.55rem 0.5rem;
    min-height: 42px;
    font-size: 0.76rem;
    border-radius: 12px;
  }

  .stage {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .stage-main {
    max-width: none;
    margin-inline: 0;
  }

  .compare {
    grid-template-columns: 1fr;
  }

  .pane:not(.main) {
    display: none;
  }

  .pane.main {
    border-radius: 16px;
    max-width: none;
    margin: 0;
    width: 100%;
  }

  .controls {
    position: static;
    max-height: none;
    overflow: visible;
    gap: 0.85rem;
    padding: 0.95rem;
    border-radius: 16px;
  }

  .ctrl-block.selectors {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 0.65rem;
    align-items: start;
  }

  .ctrl-block.selectors .shape {
    font-size: 0.72rem;
    padding: 0.5rem 0.25rem;
  }

  .shop-list {
    max-height: min(280px, 42vh);
  }

  .palette {
    max-height: 88px;
  }

  .poster-btn,
  .ghost-btn,
  .shape {
    min-height: 44px;
  }

  .poster-layer {
    padding: 0.75rem;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0));
    align-items: end;
  }

  .poster-card {
    width: min(100%, 420px);
    max-height: calc(100dvh - 1.5rem - env(safe-area-inset-bottom, 0));
    overflow: auto;
  }

  .poster-card canvas {
    max-height: calc(100dvh - 7rem);
    width: auto;
    max-width: 100%;
    margin: 0 auto;
  }
}

@media (max-width: 560px) {
  .hero-inner {
    padding: 1.5rem 1rem 2.5rem;
    width: 100%;
  }

  .brand {
    letter-spacing: 0.28em;
    font-size: 0.78rem;
  }

  .slogan {
    font-size: clamp(2rem, 9vw, 2.8rem);
  }

  .lead {
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    padding: 0 0.25rem;
  }

  .drop-btn {
    width: min(100%, 320px);
    justify-content: center;
    padding: 1.05rem 1.25rem;
    font-size: 1rem;
    animation: none; /* 移动端减少持续动画耗电 */
  }

  .hint {
    font-size: 0.72rem;
    padding: 0 0.5rem;
  }

  .shop-table th,
  .shop-table td {
    padding: 0.45rem 0.4rem;
    font-size: 0.7rem;
  }

  .poster-actions {
    position: sticky;
    bottom: 0;
    padding: 0.5rem 0 0.15rem;
    background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.55) 30%);
  }
}

@media (max-width: 900px) and (orientation: landscape) {
  .pane.main {
    max-width: min(56vh, 420px);
  }

  .shop-list {
    max-height: 160px;
  }
}

/* ===== Play / social / extras ===== */
.hero-quick {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1.1rem;
}

.chip {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font: 600 0.82rem var(--font);
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.chip:hover {
  background: rgba(255, 193, 77, 0.16);
  transform: translateY(-1px);
}

.bar-right {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.icon-tog {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font: 600 0.72rem var(--font);
  padding: 0.4rem 0.65rem;
  border-radius: 999px;
  cursor: pointer;
}

.icon-tog.on {
  color: #12151c;
  background: var(--candy-b);
  border-color: transparent;
}

.fold {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.18);
  margin: 0.55rem 0;
}

.fold summary {
  cursor: pointer;
  list-style: none;
  padding: 0.7rem 0.85rem;
  font: 700 0.85rem var(--font);
  color: var(--candy-b);
}

.fold summary::-webkit-details-marker { display: none; }

.fold-body {
  padding: 0 0.75rem 0.85rem;
  display: grid;
  gap: 0.55rem;
}

.btn-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

.mini {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font: 600 0.72rem var(--font);
  padding: 0.55rem 0.4rem;
  border-radius: 10px;
  cursor: pointer;
  min-height: 40px;
}

.mini.on,
.mini:hover {
  border-color: rgba(255, 193, 77, 0.55);
  background: rgba(255, 193, 77, 0.12);
}

.tiny {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.4;
}

.field {
  display: grid;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.field input {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.25);
  color: var(--ink);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  font: 500 0.9rem var(--font);
}

.check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.35rem;
}

.shop-tip {
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: var(--candy-b);
}

.shop-table .suggest {
  color: var(--candy-b);
}

.boards,
.duel {
  display: grid;
  gap: 0.85rem;
  width: min(100%, 920px);
  margin: 0 auto;
}

.boards {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.duel {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.board-card,
.duel-card {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 0.75rem;
}

.board-card h4,
.duel-card h4 {
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
  color: var(--candy-b);
}

.board-card canvas,
.duel-card canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 10px;
}

.board-list {
  list-style: none;
  margin: 0.55rem 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.board-list li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.2rem 0;
}

.board-list i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.duel-card pre {
  margin: 0.55rem 0;
  font: 500 0.7rem/1.45 var(--font);
  color: var(--muted);
  white-space: pre-wrap;
  max-height: 140px;
  overflow: auto;
}

.duel-card.a { border-color: rgba(255, 90, 106, 0.35); }
.duel-card.b { border-color: rgba(74, 176, 255, 0.35); }

.fall {
  pointer-events: none;
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 4;
}

.fall i {
  position: absolute;
  top: -12px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  animation: bead-fall 1s ease-in forwards;
  box-shadow: 0 0 8px currentColor;
}

@keyframes bead-fall {
  0% { transform: translateY(0) scale(0.6); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translateY(110%) scale(1); opacity: 0.15; }
}

.pane.main {
  position: relative;
}

.src-under {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.night {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(74, 176, 255, 0.08), transparent 45%),
    rgba(0, 0, 0, 0.72);
  mix-blend-mode: multiply;
}

body.night-mode .studio {
  filter: saturate(1.15) brightness(1.05);
}

body.night-mode .pane.main canvas {
  filter: drop-shadow(0 0 18px rgba(255, 193, 77, 0.25));
}

.gallery-card {
  width: min(960px, 100%);
  max-height: min(90dvh, 900px);
  overflow: auto;
  background: #151922;
  border-radius: 22px;
  padding: 1rem 1.1rem 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.gallery-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}

.gallery-head h2 {
  font: 800 1.25rem var(--display);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.gallery-grid figure {
  margin: 0;
  border-radius: 12px;
  overflow: hidden;
  background: #0e1016;
}

.gallery-grid img {
  width: 100%;
  display: block;
  aspect-ratio: 3/4;
  object-fit: cover;
}

.gallery-grid figcaption {
  font-size: 0.68rem;
  color: var(--muted);
  padding: 0.4rem 0.5rem 0.55rem;
}

.studio[hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  .boards,
  .duel {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .ctrl-block.selectors {
    grid-template-columns: 1fr;
  }

  .mood {
    font-size: 0.74rem;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .ghost-btn.compact {
    width: 100%;
  }
}

/* ===== City modal ===== */
.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 1rem;
  padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0));
  background: rgba(8, 10, 14, 0.72);
  backdrop-filter: blur(10px);
}

.modal-layer[hidden] {
  display: none !important;
}

.city-modal {
  width: min(100%, 420px);
  border-radius: 24px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(26, 34, 52, 0.95), #12151c 55%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
  padding: 0 1.25rem 1.25rem;
  animation: city-in 0.32s ease both;
}

@keyframes city-in {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.city-sky {
  position: relative;
  height: 108px;
  margin: 0 -1.25rem 1rem;
  background: linear-gradient(180deg, #1a2a4a 0%, #243868 45%, #0e121a 100%);
  overflow: hidden;
}

.city-moon {
  position: absolute;
  top: 18px;
  right: 28px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #f5e8a0;
  box-shadow: 0 0 18px rgba(245, 232, 160, 0.55);
}

.city-sky i {
  position: absolute;
  bottom: 0;
  width: 12%;
  height: var(--h);
  background: linear-gradient(180deg, #2a3a58, #141820);
  border-radius: 2px 2px 0 0;
}

.city-sky i:nth-child(2) { left: 4%; }
.city-sky i:nth-child(3) { left: 17%; width: 10%; }
.city-sky i:nth-child(4) { left: 29%; width: 14%; }
.city-sky i:nth-child(5) { left: 45%; width: 11%; }
.city-sky i:nth-child(6) { left: 58%; width: 13%; }
.city-sky i:nth-child(7) { left: 73%; width: 9%; }
.city-sky i:nth-child(8) { left: 84%; width: 12%; }

.city-sky i::after {
  content: "";
  position: absolute;
  inset: 8px 3px auto;
  height: 40%;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(255, 193, 77, 0.55) 0 3px,
      transparent 3px 9px
    );
  opacity: 0.55;
  mask-image: repeating-linear-gradient(90deg, #000 0 4px, transparent 4px 10px);
}

.city-eyebrow {
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  color: var(--candy-b);
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.city-modal h2 {
  font-family: var(--display);
  font-size: 1.65rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 0.35rem;
}

.city-sub {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.city-field {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.city-field span {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.city-field input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.35);
  color: var(--ink);
  border-radius: 14px;
  padding: 0.85rem 1rem;
  font: 600 1.05rem var(--font);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.city-field input:focus {
  border-color: rgba(255, 193, 77, 0.65);
  box-shadow: 0 0 0 3px rgba(255, 193, 77, 0.15);
}

.city-presets {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
  margin-bottom: 1.1rem;
}

.city-presets button {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  font: 600 0.8rem var(--font);
  padding: 0.55rem 0.3rem;
  border-radius: 999px;
  cursor: pointer;
  min-height: 40px;
}

.city-presets button.on,
.city-presets button:hover {
  border-color: transparent;
  background: linear-gradient(135deg, rgba(74, 176, 255, 0.35), rgba(255, 193, 77, 0.35));
}

.city-actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 0.55rem;
}

.city-actions .poster-btn,
.city-actions .ghost-btn {
  width: 100%;
  min-height: 46px;
}

@media (max-width: 560px) {
  .city-modal {
    width: 100%;
    border-radius: 22px 22px 18px 18px;
    align-self: end;
    animation: city-up 0.3s ease both;
  }

  @keyframes city-up {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: none; }
  }

  .modal-layer {
    place-items: end center;
  }
}
