:root {
  --bg: #0b0b0c; --panel: #151517; --line: #2a2a2e; --text: #f4f4f5; --dim: #a1a1aa;
  --y: #FFD60A; --y-ink: #111; --red: #ff4d4f; --ok: #3ddc84;
  --r: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
body { overflow-x: hidden; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: #1d1d20; font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none; white-space: nowrap; user-select: none; }
.btn:hover { border-color: #3a3a40; }
.btn.primary { background: var(--y); color: var(--y-ink); border-color: var(--y); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); }
.btn.big { min-height: 56px; font-size: 18px; padding: 0 28px; }
.spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #333; border-top-color: var(--y); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- home */
.home { max-width: 620px; margin: 0 auto; padding: 28px 16px 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing: -.01em; }
.home h1 { font-size: clamp(34px, 9vw, 54px); line-height: 1.02; letter-spacing: -.03em; margin: 48px 0 14px; }
.home h1 em { font-style: normal; color: var(--y); }
.home .sub { color: var(--dim); font-size: 18px; margin: 0 0 28px; max-width: 30em; }
.pick { width: 100%; max-width: 360px; }
.draft, .mine-row { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.draft { margin-top: 20px; }
.draft img, .mine-row img { width: 64px; height: 48px; object-fit: cover; border-radius: 8px; background: #222; flex: none; }
.grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.grow b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grow span { color: var(--dim); font-size: 13px; }
.mine h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); margin: 40px 0 10px; }
.mine #mineList { display: grid; gap: 8px; }
.mine-row .btn { min-height: 36px; padding: 0 12px; font-size: 14px; }
@media (max-width: 520px) {
  .mine-row { flex-wrap: wrap; }
  .mine-row .grow { flex-basis: calc(100% - 80px); }
  .mine-row .btn { flex: 1; }
}

/* ---------- editor */
.editor { position: fixed; inset: 0; display: flex; flex-direction: column; background: #000; }
.ed-top { display: flex; align-items: center; gap: 8px; padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); background: var(--bg); border-bottom: 1px solid var(--line); }
.ed-top .btn { min-height: 38px; padding: 0 14px; }
.ed-count { flex: 1; text-align: center; color: var(--dim); font-size: 13px; }
.ed-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
#edCanvas { touch-action: none; display: block; cursor: grab; }
.ed-panel { background: var(--bg); border-top: 1px solid var(--line); padding: 12px 14px; max-height: 44vh; overflow-y: auto; }
.ed-panel .empty { margin: 4px 0; color: var(--dim); text-align: center; }
.p-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.p-head .btn { min-height: 34px; }
.p-sub { color: var(--dim); font-size: 13px; font-weight: 600; margin: 12px 0 6px; text-transform: uppercase; letter-spacing: .06em; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #1a1a1d; border-radius: 999px; padding: 7px 12px; font-size: 14px; cursor: pointer; }
.chip.on { background: var(--y); color: var(--y-ink); border-color: var(--y); font-weight: 700; }
.sliders { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
@media (max-width: 520px) { .sliders { grid-template-columns: 1fr; gap: 4px; } }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--dim); }
.field i { font-style: normal; opacity: .7; }
input[type=range] { width: 100%; accent-color: var(--y); height: 28px; }
input[type=text], input[type=url], textarea, select { width: 100%; background: #111113; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 16px; }
textarea { min-height: 72px; resize: vertical; }
.a-fields { display: grid; gap: 8px; margin-top: 10px; }
.a-fields .btn { justify-self: start; }
.hint { color: var(--dim); font-size: 14px; margin: 4px 0; }
.or { color: var(--dim); font-size: 13px; }
.ed-bar { display: flex; background: var(--bg); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.bar-btn { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px; background: none; border: 0; font-size: 13px; font-weight: 600; cursor: pointer; }
.bar-btn b { font-size: 20px; line-height: 1; color: var(--y); }

/* ---------- sheets, busy, toast */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; z-index: 30; }
.sheet-card { width: 100%; max-width: 560px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); display: grid; gap: 10px; max-height: 88vh; overflow-y: auto; }
.sheet-card h2 { margin: 0 0 4px; font-size: 24px; letter-spacing: -.02em; }
.kicker, .pl-kicker { color: var(--y); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.busy { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.7); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--text); text-align: center; padding: 16px; }
.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; background: #222226; border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; max-width: calc(100% - 32px); text-align: center; font-size: 15px; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.test-layer { position: fixed; inset: 0; z-index: 40; background: var(--bg); }

/* ---------- player */
body.play { overflow: hidden; }
.play-root { position: fixed; inset: 0; }
.play-msg { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 16px; text-align: center; }
.play-msg h1 { margin: 0; font-size: 28px; }
.play-msg p { margin: 0 0 8px; color: var(--dim); }
.pl { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--bg); }
.pl-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); }
.pl-brand { display: flex; align-items: center; gap: 8px; font-weight: 800; text-decoration: none; }
.pl-brand img { width: 26px; height: 26px; }
.pl-stats { display: flex; gap: 12px; align-items: center; font-variant-numeric: tabular-nums; font-size: 14px; color: var(--dim); }
.pl-tries { color: var(--y); letter-spacing: 2px; font-size: 13px; }
.pl-time { color: var(--text); font-weight: 700; min-width: 3.5em; text-align: right; }
.pl-cap { margin: 0; padding: 0 16px 10px; font-size: clamp(22px, 6vw, 34px); line-height: 1.1; letter-spacing: -.02em; text-align: center; }
.pl-stage { flex: 1; min-height: 0; position: relative; overflow: hidden; touch-action: none; background: #000; cursor: crosshair; }
.pl-zoom { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.pl-img { width: 100%; height: 100%; display: block; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.pl-marks { position: absolute; inset: 0; pointer-events: none; }
.pl-ring { position: absolute; border: 3px solid var(--y); border-radius: 10px; box-shadow: 0 0 0 3px rgba(0,0,0,.45), 0 0 24px var(--y); animation: pop .45s cubic-bezier(.2,1.6,.4,1); }
@keyframes pop { from { opacity: 0; scale: 1.8; } }
.pl-reveal { position: absolute; border: 3px dashed var(--y); border-radius: 10px; box-shadow: 0 0 0 3px rgba(0,0,0,.45); animation: blink 1s ease-in-out infinite alternate; }
@keyframes blink { to { opacity: .35; } }
.pl-x { position: absolute; transform: translate(-50%,-50%) scale(var(--s,1)); color: var(--red); font-weight: 900; font-size: 34px; text-shadow: 0 0 6px #000, 0 0 2px #000; animation: xfade .9s ease-out forwards; }
@keyframes xfade { 0% { opacity: 0; } 15% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; } }
.pl.shake .pl-stage { animation: shake .35s; }
@keyframes shake { 20% { translate: -10px 0; } 40% { translate: 9px 0; } 60% { translate: -6px 0; } 80% { translate: 4px 0; } }
.pl-hint { text-align: center; color: var(--dim); font-size: 13px; padding: 8px 16px calc(10px + env(safe-area-inset-bottom)); transition: opacity .4s; }
.pl-hint.gone { opacity: 0; }
.pl-toast { position: absolute; left: 50%; top: 40%; transform: translateX(-50%); background: rgba(20,20,22,.94); border: 1px solid var(--line); padding: 12px 20px; border-radius: 14px; font-size: 18px; font-weight: 700; z-index: 5; max-width: calc(100% - 32px); text-align: center; }
.pl-sheet { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; z-index: 10; pointer-events: none; }
.pl-card { pointer-events: auto; width: 100%; max-width: 560px; background: var(--panel); border: 1px solid var(--line); border-bottom: 0; border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); display: grid; gap: 10px; box-shadow: 0 -12px 40px rgba(0,0,0,.6); animation: up .28s ease-out; max-height: 80%; overflow-y: auto; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.pl-title { margin: 0; font-size: 30px; letter-spacing: -.02em; line-height: 1.1; }
.pl-title.msg { font-size: 24px; white-space: pre-wrap; }
.pl-text { margin: 0; color: var(--dim); white-space: pre-wrap; }
.pl-sub { color: var(--dim); font-size: 14px; }
.pl-row { display: flex; gap: 8px; flex-wrap: wrap; }
.pl-row .btn { flex: 1; }
.pl-media { width: 100%; border: 0; border-radius: 12px; background: #000; max-height: 50vh; }
.pl-media.yt { aspect-ratio: 16/9; height: auto; }
audio.pl-media { background: transparent; }
.pl.won .pl-time { color: var(--y); }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- show mode + shop */
.pl-dot { position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; background: #fff; border: 3px solid rgba(0,0,0,.55); box-shadow: 0 0 0 0 rgba(255,255,255,.7); transform: scale(var(--s,1)); animation: dot 1.8s ease-out infinite; }
@keyframes dot { 0% { box-shadow: 0 0 0 0 rgba(255,255,255,.75); } 70%, 100% { box-shadow: 0 0 0 14px rgba(255,255,255,0); } }
.pl-shop { display: flex; gap: 12px; align-items: center; }
.pl-shop img { width: 84px; height: 104px; object-fit: cover; border-radius: 10px; background: #222; flex: none; }
.pl-shop-t { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pl-shop-t b { font-size: 20px; line-height: 1.15; }
.pl-price { color: var(--y); font-weight: 800; font-size: 18px; }
.pl-fine { margin: 0; color: var(--dim); font-size: 12px; }
.fl-results { display: grid; gap: 6px; font-size: 14px; color: var(--dim); }
.fl-item { display: flex; gap: 10px; align-items: center; text-align: left; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: #141416; cursor: pointer; }
.fl-item img, .fl-picked img { width: 40px; height: 50px; object-fit: cover; border-radius: 6px; background: #222; flex: none; }
.fl-item div { display: flex; flex-direction: column; min-width: 0; }
.fl-item b { color: var(--text); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fl-item span { font-size: 12px; }
.fl-picked { display: flex; gap: 10px; align-items: center; color: var(--dim); font-size: 13px; }
.fl-picked .btn { min-height: 32px; margin-left: auto; }
input[type=search] { width: 100%; background: #111113; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 16px; }

/* ---------- pieces: the thing itself glows along its outline */
.pl-glow { position: absolute; pointer-events: none; }
.pl-glow.found { animation: pop .45s cubic-bezier(.2,1.6,.4,1); }
.pl-glow.tap { animation: glowin .25s ease-out; }
.pl-glow.reveal { animation: blink 1s ease-in-out infinite alternate; }
@keyframes glowin { from { opacity: 0; } }
.row .btn:disabled { opacity: .4; cursor: default; }

/* ---------- outlining a piece: a focused screen (Cancel / Done on top, tools in one strip) */
.editor.picking .ed-bar { display: none; }
.editor.picking .ed-count { color: var(--y); font-weight: 700; font-size: 15px; }
.pk-hint { text-align: center; margin: 0 0 10px; }
.pk-strip { display: flex; align-items: stretch; gap: 6px; }
.pk-tool { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border: 1px solid var(--line); border-radius: 12px; background: #161618; font-size: 12px; font-weight: 600; cursor: pointer; min-width: 0; }
.pk-tool b { font-size: 20px; line-height: 1.1; }
.pk-tool.on { background: var(--y); color: var(--y-ink); border-color: var(--y); }
.pk-tool:disabled { opacity: .35; cursor: default; }
.pk-size { flex: 1.6; display: flex; flex-direction: column; justify-content: center; gap: 0; font-size: 12px; color: var(--dim); padding: 0 4px; }
.pk-size.off { opacity: .35; pointer-events: none; }
.pk-square { display: block; margin: 8px auto 0; min-height: 32px; font-size: 13px; color: var(--dim); }
.editor:not(.picking) #edCanvas { cursor: default; }

/* came from a FitLink look (2026-10-19) */
.fl-row { margin: 0 0 16px; border-color: var(--y); }
.fl-item.on { outline: 2px solid var(--y); }
