:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-2: #eef1f8;
  --text: #1c2333;
  --dim: #63708c;
  --accent: #16a06d;
  --accent-2: #d98a00;
  --bad: #e0453c;
  --line: #d9dfea;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #e4ecff 0, var(--bg) 60%), var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.topbar h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.3px;
}
.scene-meta {
  display: flex;
  gap: 12px;
  align-items: baseline;
  font-size: 14px;
}

/* Play header: humanized scene title + a counter pill */
.scene-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 20px 4px;
}
.scene-title {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0.2px;
}
.scene-counter {
  flex: none;
  font-size: 13px;
  color: var(--dim);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  font-variant-numeric: tabular-nums;
}
.scene-counter b { color: var(--text); }
.dim {
  color: var(--dim);
}

.hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
}
.stat {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 14px;
  min-width: 78px;
}
.stat .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--dim);
}
.stat span:last-child {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}
.controls {
  display: flex;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
}
.btn {
  background: var(--accent);
  color: #06251a;
  border: 0;
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.05s ease, filter 0.15s ease;
}
.btn:hover {
  filter: brightness(1.06);
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn.ghost {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
}

/* Mode tabs */
.modes {
  display: flex;
  gap: 6px;
}
.tab {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.tab.active {
  background: var(--accent);
  color: #06251a;
  border-color: transparent;
}

/* Credits (betting) bar */
.credit-bar {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 10px 20px;
  margin: 0 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}
body.mode-credits .credit-bar {
  display: flex;
}
body.mode-credits .casual-only {
  display: none;
}
.stake-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stakes {
  display: flex;
  gap: 6px;
}
.stake {
  min-width: 46px;
  padding: 7px 10px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}
.stake.selected {
  background: var(--accent-2);
  color: #3a2600;
  border-color: transparent;
}
.stake.unaffordable {
  opacity: 0.4;
}
.stake:disabled {
  cursor: not-allowed;
}
#net.ok {
  color: var(--accent);
}
#net.bad {
  color: var(--bad);
}
#timer.urgent {
  color: var(--bad);
  animation: pulse 0.8s ease-in-out infinite;
}

/* Result modal */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 26, 40, 0.55);
  z-index: 20;
}
.modal.hidden {
  display: none;
}
.modal-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px 30px;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}
.modal-card h2 {
  margin: 0 0 10px;
}
.modal-card h2.win {
  color: var(--accent);
}
.modal-card h2.bad {
  color: var(--bad);
}
.modal-card p {
  margin: 0 0 18px;
  color: var(--text);
  line-height: 1.5;
}

.message {
  margin: 4px 20px 10px;
  min-height: 22px;
  font-size: 15px;
  color: var(--dim);
}
.message.ok {
  color: var(--accent);
}
.message.bad {
  color: var(--bad);
}
.message.hint {
  color: var(--accent-2);
}
.message.win {
  color: var(--accent);
  font-weight: 700;
}

.stage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 0 20px 24px;
  max-width: 1600px;
  margin: 0 auto;
}
.pane {
  margin: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}
.pane figcaption {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--dim);
  margin-bottom: 8px;
}
.canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 720 / 520;
  border-radius: 10px;
  overflow: hidden;
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  background: var(--panel-2);
  touch-action: manipulation; /* fast taps, no double-tap zoom on tablets */
}
.markers {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Magnifier lens — round, follows the cursor/finger on both panes. */
.magnifier {
  position: absolute;
  display: none;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px rgba(20, 26, 40, 0.35), 0 8px 24px rgba(20, 26, 40, 0.3);
  background-repeat: no-repeat;
  pointer-events: none;
  z-index: 6;
}
/* On touch devices the lens is bigger so a finger can aim it comfortably. */
@media (pointer: coarse) {
  .magnifier { width: 200px; height: 200px; border-width: 4px; }
}
/* Active toggle state for a control (magnifier on). */
.controls .btn.active {
  background: var(--accent-2, #f39c12);
  color: #3a2600;
  box-shadow: inset 0 0 0 2px var(--text, #1c2333);
}

.marker {
  fill: none;
  stroke-width: 4;
}
.marker.found {
  stroke: var(--accent);
  animation: pop 0.35s ease-out;
}

/* Found difference: soft highlight of the object's mask shape + a check badge.
   (Legacy scenes without an outline fall back to the .marker.found ring.) */
.found-shape {
  fill: var(--accent);
  fill-opacity: 0.16;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linejoin: round;
  animation: found-in 0.3s ease-out;
}
.found-badge {
  transform-box: fill-box;
  transform-origin: center;
  animation: badge-pop 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.found-badge circle { fill: var(--accent); stroke: #fff; stroke-width: 2.5; }
.found-badge path { fill: none; stroke: #fff; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
@keyframes found-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes badge-pop {
  0% { transform: scale(0); opacity: 0; }
  70% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .found-shape, .found-badge { animation: none; }
}
/* Hint: a magnifying-glass icon that blinks over the target area, then vanishes. */
.hint-icon { animation: hint-blink 0.55s ease-in-out infinite; }
.hint-icon .hint-halo { fill: var(--accent-2); opacity: 0.18; }
.hint-icon .hint-lens-bg { fill: none; stroke: #fff; stroke-width: 8; }
.hint-icon .hint-handle-bg { stroke: #fff; stroke-width: 8; stroke-linecap: round; }
.hint-icon .hint-lens { fill: none; stroke: var(--accent-2); stroke-width: 4; }
.hint-icon .hint-handle { stroke: var(--accent-2); stroke-width: 4; stroke-linecap: round; }
@keyframes hint-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.15; } }
@media (prefers-reduced-motion: reduce) { .hint-icon { animation: none; } }
.marker.miss {
  stroke: var(--bad);
  stroke-width: 5;
  animation: fade 0.5s ease-out forwards;
}

@keyframes pop {
  from {
    stroke-width: 10;
    opacity: 0;
  }
  to {
    stroke-width: 4;
    opacity: 1;
  }
}
@keyframes pulse {
  0%, 100% {
    opacity: 0.4;
    stroke-width: 3;
  }
  50% {
    opacity: 1;
    stroke-width: 6;
  }
}
@keyframes fade {
  from {
    opacity: 1;
    stroke-width: 6;
  }
  to {
    opacity: 0;
    stroke-width: 1;
  }
}

/* How to play — lives inside the Play view, as a tidy card. */
.play-help {
  margin: 18px 20px 40px;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--dim);
  font-size: 14px;
}
.play-help summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 600;
  list-style: none;
}
.play-help summary::before { content: '💡 '; }
.play-help ul {
  margin: 10px 0 4px;
  padding-left: 20px;
  line-height: 1.6;
}
kbd {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 12px;
}

@media (max-width: 780px) {
  .stage {
    grid-template-columns: 1fr;
  }
  .controls {
    width: 100%;
  }
}

/* =========================================================================
   PLAY — full-screen, tablet-first, finger-friendly, no distractions.
   Activated by body.playing (set by the router while the Play view is open).
   ========================================================================= */

/* One compact bar: scene · live stats · tools. */
.play-bar {
  display: flex;
  align-items: center;
  gap: 12px 18px;
  flex-wrap: wrap;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}
.play-bar__scene {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}
.play-bar__scene .scene-title {
  font-size: 20px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.play-bar__stats {
  display: flex;
  gap: 10px;
  flex: none;
}
.play-bar__stats .stat {
  min-width: 66px;
  padding: 5px 12px;
}
.play-bar__tools {
  margin-left: 0;
  gap: 8px;
  flex: none;
}

/* Full-screen frame: the stage owns the viewport; distractions step aside. */
body.playing {
  overflow: hidden;
}
body.playing #view-play {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}
body.playing .topbar {
  display: none; /* the game takes the whole screen — brand/nav is a distraction here */
}
body.playing .stage {
  flex: 1 1 auto;
  min-height: 0;
  align-items: center;
  padding: 14px 20px;
  max-width: none;
}
body.playing .pane {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
body.playing .pane figcaption {
  flex: none;
}
/* Fit each picture to the available height, preserving its aspect ratio. */
body.playing .canvas-wrap {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  width: auto;
  max-width: 100%;
  margin: 0 auto;
}
/* Hide everything that isn't the puzzle while playing. */
body.playing .history,
body.playing .play-help {
  display: none;
}

/* Floating status line — a pill over the stage, never shifts the layout. */
body.playing .message {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  margin: 0;
  max-width: min(92vw, 640px);
  text-align: center;
  padding: 8px 18px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 6px 20px rgba(20, 26, 40, 0.14);
  z-index: 7;
  pointer-events: none;
}
body.playing .message:empty {
  display: none;
}

/* Finger-sized controls: every tool is at least a 48px touch target. */
body.playing .play-bar .btn {
  min-height: 48px;
  padding: 0 18px;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
body.playing .play-bar .btn[aria-label] {
  min-width: 48px;
  padding: 0 14px;
  font-size: 18px;
}

/* Tablet portrait / phones: stack the panes, wrap the tools full-width. */
@media (max-width: 900px) {
  body.playing .stage {
    grid-template-columns: 1fr;
    align-items: stretch;
    overflow-y: auto;
  }
  body.playing #view-play {
    height: 100dvh;
  }
  body.playing .canvas-wrap {
    width: 100%;
    height: auto;
    flex: none;
  }
  body.playing .pane {
    height: auto;
  }
  .play-bar__tools {
    width: 100%;
    justify-content: space-between;
  }
  body.playing .play-bar .btn {
    flex: 1 1 auto;
  }
}

/* ---- auth widget + modal (PocketBase) ---- */
.auth { display: flex; gap: 8px; align-items: center; }
.auth-btn { padding: 6px 12px; font-size: 13px; }
.auth-who { font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.auth-role { font-size: 10px; text-transform: uppercase; letter-spacing: .04em;
  background: var(--accent); color: #fff; border-radius: 20px; padding: 1px 7px; }
.auth-card { text-align: left; width: 340px; max-width: 92vw; }
.auth-tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.auth-tab { flex: 1; padding: 8px; border: 1px solid var(--line); border-radius: 8px;
  background: transparent; color: var(--text); cursor: pointer; font: inherit; }
.auth-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.auth-field { display: grid; gap: 4px; font-size: 13px; margin-bottom: 12px; color: var(--muted, #667085); }
.auth-field.hidden { display: none; }
.auth-field input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--text); font: inherit; }
.auth-msg { min-height: 18px; margin: 0 0 12px; font-size: 12px; color: var(--bad, #d3455b); }
.auth-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---- profile view + creator credits ---- */
.profile-view { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-start;
  justify-content: center; padding: 40px 16px; overflow-y: auto; background: rgba(20, 26, 40, 0.55); }
.profile-view.hidden { display: none; }
.profile-card { position: relative; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 26px 30px; width: 520px; max-width: 94vw;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); }
.profile-card h2 { margin: 0 0 4px; }
.profile-sub { margin: 0 0 18px; color: var(--muted, #667085); font-size: 13px; display: flex; gap: 8px; align-items: center; }
.profile-close { position: absolute; top: 14px; right: 16px; border: 0; background: transparent;
  font-size: 18px; cursor: pointer; color: var(--muted, #667085); }
.auth-role.player { background: #667085; }
.credit-panel { border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 18px; }
.credit-balance { display: flex; align-items: baseline; justify-content: space-between; }
.credit-label { color: var(--muted, #667085); font-size: 13px; }
.credit-value { font-size: 26px; }
.credit-note { margin: 8px 0 14px; font-size: 12px; color: var(--muted, #667085); line-height: 1.5; }
.buy-panel { border: 1px dashed var(--accent); border-radius: 12px; padding: 16px; margin-bottom: 18px; }
.buy-panel.hidden { display: none; }
.buy-panel h3 { margin: 0 0 10px; font-size: 14px; }
.packages { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.package { display: grid; gap: 4px; padding: 14px 8px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); cursor: pointer; font: inherit; text-align: center; }
.package:hover { border-color: var(--accent); }
.pkg-credits { font-size: 16px; font-weight: 700; }
.pkg-price { font-size: 12px; color: var(--muted, #667085); }
.pay-placeholder { margin: 12px 0 0; font-size: 12px; color: var(--muted, #667085); line-height: 1.5; }
.ledger-h { font-size: 13px; margin: 0 0 8px; }
.ledger { display: grid; gap: 4px; }
.ledger-row { display: grid; grid-template-columns: 60px 1fr auto; gap: 10px; font-size: 13px;
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; align-items: center; }
.ledger-delta.pos { color: var(--accent); font-weight: 700; }
.ledger-delta.neg { color: var(--bad, #d3455b); font-weight: 700; }
.ledger-date { font-size: 11px; }

/* ---- create-a-scene: one guided flow ---- */
.create-page { max-width: 720px; margin: 0 auto; padding: 26px 20px 48px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding-bottom: 18px; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
.page-title { margin: 0 0 6px; font-size: 26px; letter-spacing: 0.2px; }
.page-sub { margin: 0; color: var(--dim); font-size: 14px; line-height: 1.55; max-width: 560px; }
.panel-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 24px; box-shadow: 0 1px 2px rgba(20, 26, 40, 0.04); }

/* how it works — three steps: what happens + what's needed */
.how-strip { list-style: none; margin: 0 0 20px; padding: 0; display: grid;
  grid-template-columns: repeat(3, 1fr); gap: 14px; }
.how-strip li { display: flex; gap: 10px; align-items: flex-start; }
.how-n { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: #06251a; font-weight: 700; font-size: 13px; }
.how-strip li > div { display: grid; gap: 2px; }
.how-strip b { font-size: 13.5px; color: var(--text); }
.how-strip li span:not(.how-n) { font-size: 12.5px; color: var(--dim); line-height: 1.45; }

/* Surprise me — the hero (the one obvious action) */
.surprise-hero { text-align: center; padding: 30px 24px 22px; margin-bottom: 20px;
  background: linear-gradient(180deg, oklch(from var(--accent) l c h / 0.14) 0%, var(--panel) 62%); }
.surprise-hero .surprise-die { font-size: 46px; line-height: 1; }
.surprise-hero h3 { margin: 8px 0 4px; font-size: 22px; }
.surprise-hero p { margin: 0 auto 18px; color: var(--dim); font-size: 14px; line-height: 1.5; max-width: 360px; }
.btn-lg { font-size: 17px; padding: 14px 34px; white-space: nowrap; }
.make-cost { margin: 14px 0 0; color: var(--dim); font-size: 13px; }
.make-cost b { color: var(--accent-2); font-variant-numeric: tabular-nums; }

/* Difficulty — a segmented Easy/Normal/Hard control (maps to the diff count) */
.difficulty { display: inline-flex; margin: 6px 0 4px; border: 1px solid var(--line);
  border-radius: 999px; overflow: hidden; background: var(--panel); }
.diff-opt { border: 0; background: transparent; color: var(--dim); font: inherit; font-weight: 600;
  font-size: 13px; padding: 8px 18px; cursor: pointer; transition: background 140ms, color 140ms; }
.diff-opt + .diff-opt { border-left: 1px solid var(--line); }
.diff-opt.active { background: var(--accent); color: #06251a; }
.diff-opt:focus-visible { outline: 3px solid var(--color-focus, #2563eb); outline-offset: -3px; }
.diff-note { margin: 4px 0 14px; color: var(--dim); font-size: 12.5px; }

/* Describe-your-own — secondary, collapsed by default */
.write-own { margin-top: 16px; }
.write-own > summary { cursor: pointer; list-style: none; text-align: center; color: var(--dim);
  font-size: 13px; padding: 8px; text-decoration: underline; text-underline-offset: 3px; }
.write-own > summary::-webkit-details-marker { display: none; }
.write-own__body { display: grid; gap: 14px; margin-top: 12px; padding: 18px 20px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.write-own .auth-field { display: grid; gap: 6px; font-size: 13px; color: var(--dim); font-weight: 500; }
.write-own textarea, .write-own input[type=file] { width: 100%; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); font: inherit; }
.write-own textarea { resize: vertical; min-height: 74px; line-height: 1.5; }
.write-own textarea:focus-visible, .write-own input:focus-visible { outline: 3px solid var(--color-focus, #2563eb); outline-offset: 1px; border-color: transparent; }
.write-own .btn { justify-self: start; }
.req { color: var(--dim); font-weight: 400; }
.photo-preview img { max-width: 150px; border-radius: 8px; margin-top: 2px; border: 1px solid var(--line); }

/* Generating — full-screen focus, centred, no scrolling */
.gen-page { max-width: 520px; }
.gen-focus { text-align: center; padding: 24px 0; }
.gen-emoji { font-size: 48px; line-height: 1; margin-bottom: 8px; }
.gen-focus .page-sub { margin: 0 auto 18px; max-width: 420px; }
.gen-focus .gen-steps { display: inline-grid; text-align: left; margin: 0 auto 16px; }
.gen-focus .btn { margin-top: 14px; }

/* Result — full-screen focus */
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
#createResult:not(:empty) { margin-top: 22px; }
.ab { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0 0; }
.ab figure { margin: 0; }
.ab img { width: 100%; border-radius: 8px; display: block; border: 1px solid var(--line); }
.ab figcaption { font-size: 11px; color: var(--dim); margin-top: 5px; text-align: center; }

/* generating: skeleton cards + progress + step log */
.skeleton { width: 100%; aspect-ratio: 1 / 1; border-radius: 8px; border: 1px solid var(--line);
  background: linear-gradient(100deg, var(--panel-2) 30%, #f6f8fd 50%, var(--panel-2) 70%);
  background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
.skeleton.failed { animation: none; background: #fbeaea; border-color: var(--bad); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.gen-bar { height: 4px; border-radius: 999px; background: var(--panel-2); overflow: hidden; margin: 4px 0 12px; }
.gen-bar span { display: block; height: 100%; width: 40%; border-radius: 999px; background: var(--accent);
  animation: indet 1.4s ease-in-out infinite; }
@keyframes indet { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }
.gen-steps { list-style: none; margin: 0 0 4px; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.gen-steps li { color: var(--dim); padding-left: 22px; position: relative; }
.gen-steps li::before { content: '○'; position: absolute; left: 4px; color: var(--line); }
.gen-steps li.active { color: var(--text); font-weight: 500; }
.gen-steps li.active::before { content: '◐'; color: var(--accent); animation: spin 1s linear infinite; display: inline-block; }
.gen-steps li.done { color: var(--dim); }
.gen-steps li.done::before { content: '✓'; color: var(--accent); }
.gen-steps li.bad { color: var(--bad); }
.gen-steps li.bad::before { content: '✗'; color: var(--bad); }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 620px) {
  .create-page { padding: 18px 16px 40px; }
  .how-strip { grid-template-columns: 1fr; gap: 10px; }
  .surprise-hero { padding: 24px 18px 20px; }
  .surprise-hero .btn-lg { width: 100%; }
  .result-actions .btn { flex: 1 1 100%; }
}

/* ---- app shell: nav + views ---- */
.mainnav { display: flex; gap: 6px; }
.navbtn { padding: 7px 14px; border: 1px solid var(--line); border-radius: 8px; background: transparent;
  color: var(--text); cursor: pointer; font: inherit; font-size: 14px; }
.navbtn.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.view.hidden { display: none; }

/* ---- landing ---- */
.landing-page { display: grid; place-items: center; padding: 60px 20px; }
.hero { max-width: 680px; text-align: center; }
.hero h2 { font-size: 34px; line-height: 1.15; margin: 0 0 14px; }
.hero-sub { color: var(--muted, #667085); font-size: 16px; line-height: 1.6; margin: 0 0 26px; }
.hero-cta { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---- manage scenes ---- */
.manage-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 0; }
.manage-head h2 { margin: 0; }
.scene-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; padding: 16px 20px; }
.scene-card { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--panel);
  display: flex; flex-direction: column; }
.scene-card .thumb { aspect-ratio: 4/3; background: #eef1f6; display: grid; place-items: center; }
.scene-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.scene-card .scene-meta { padding: 10px 12px; display: grid; gap: 3px; }
.scene-card .scene-name { font-weight: 600; font-size: 14px; }
.scene-card .btn { margin: 0 12px 12px; }
.small { font-size: 12px; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--panel-2);
  color: var(--dim); border: 1px solid var(--line); }
.card-actions { display: flex; gap: 8px; align-items: center; margin: 0 12px 12px; flex-wrap: wrap; }
.card-actions .btn { margin: 0; }
.shared-badge { font-size: 12px; color: var(--accent); font-weight: 600; }

/* toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- play: history ---- */
.history { padding: 8px 20px 24px; }
.history h3 { margin: 0 0 8px; font-size: 14px; }
.past-list { display: grid; gap: 6px; }
.past-row { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: baseline;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.past-scene { font-weight: 600; }
@media (max-width: 640px) { .past-row { grid-template-columns: 1fr; gap: 2px; } }

/* ---- profile: change name ---- */
.name-panel { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 16px; flex-wrap: wrap; }
.name-panel .auth-field { flex: 1; min-width: 160px; margin: 0; }
.name-msg { font-size: 12px; color: var(--muted, #667085); }

/* ---- create options ---- */
.create-opts { display: flex; gap: 12px; }
.create-opts .auth-field { flex: 1; margin-bottom: 12px; }
.create-opts input, .create-opts select { padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--panel); color: var(--text); font: inherit; }
