:root {
  --bg: #07070f;
  --stage: #05050c;
  --panel: #0e0e1a;
  --panel-2: #12121e;
  --line: #1e1e30;
  --line-2: #2a2a42;
  --fg: #d6d6f0;
  --muted: #8888b0;
  --dim: #5c5c84;
  --accent: #a78bfa;
  --accent-deep: #7c3aed;
  --accent-bg: #180d38;
  --rec: #ff5a5a;
  --ok: #5fd08a;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --chip: 52px;
  color-scheme: dark;
}
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; background: var(--bg); color: var(--fg); overflow: hidden; overscroll-behavior: none; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, 'Segoe UI', sans-serif;
  font-size: 14px;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  touch-action: manipulation;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { display: block; }

#app { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* ── Sahne ─────────────────────────── */
#stage {
  position: relative; flex: 1; min-height: 0; overflow: hidden; background: var(--stage);
  touch-action: none;
}
#zoomer { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
#cv { display: block; image-rendering: pixelated; image-rendering: crisp-edges; }
#overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* ── Üst çubuk ─────────────────────── */
#topbar {
  position: absolute; left: 0; right: 0; top: 0; z-index: 5;
  padding: calc(var(--sat) + 8px) calc(var(--sar) + 10px) 0 calc(var(--sal) + 10px);
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
  pointer-events: none;
}
#topbar .grp { display: flex; gap: 6px; pointer-events: auto; }
#topbar .mid { flex: 1; justify-content: center; flex-wrap: wrap; pointer-events: auto; }
.pill {
  height: 40px; min-width: 40px; padding: 0 11px; border-radius: 20px;
  background: rgba(16,16,28,.78); border: 1px solid var(--line-2);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  color: #cfcff0; font-size: 12.5px; font-weight: 650;
}
.pill svg { width: 18px; height: 18px; }
.pill:active { transform: scale(.94); }
.pill:disabled { opacity: .4; }
.pill.rec .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--rec); }
.pill.rec.on { border-color: var(--rec); color: #fff; background: rgba(90,16,24,.85); }
.pill.rec.on .dot { animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .2; } }
.badge {
  height: 26px; padding: 0 10px; border-radius: 13px; font-size: 11.5px; font-weight: 650;
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(24,13,56,.85); border: 1px solid #3b2a78; color: #cbb8ff;
  margin-top: 7px;
}
.badge.tap { cursor: pointer; }

/* ── Fırça kaydırıcısı ─────────────── */
#brush {
  position: absolute; z-index: 5; right: calc(var(--sar) + 10px); top: calc(var(--sat) + 62px);
  width: 40px; padding: 12px 0 8px; border-radius: 20px;
  background: rgba(16,16,28,.78); border: 1px solid var(--line-2);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  display: flex; flex-direction: column; align-items: center; gap: 8px; touch-action: none;
}
#brush .track { position: relative; width: 6px; height: 120px; border-radius: 3px; background: var(--line-2); }
#brush .fill { position: absolute; left: 0; right: 0; bottom: 0; border-radius: 3px; background: var(--accent-deep); }
#brush .knob { position: absolute; left: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.5); }
#brush .val { font-size: 11px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }

/* ── Fotoğraf eylemleri ────────────── */
#photo-bar {
  position: absolute; z-index: 6; left: 50%; bottom: 12px; transform: translateX(-50%);
  width: min(560px, calc(100% - 24px));
  background: rgba(14,14,26,.94); border: 1px solid #3b2a78; border-radius: 18px;
  padding: 10px; display: grid; gap: 8px;
  box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
.ph-msg { font-size: 12.5px; color: var(--muted); text-align: center; }
.ph-btns { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.ph-btn {
  display: grid; justify-items: center; gap: 4px; padding: 8px 2px; border-radius: 12px;
  background: var(--panel-2); border: 1px solid var(--line); font-size: 11.5px; font-weight: 650; color: #d0d0f0;
}
.ph-btn i { width: 26px; height: 18px; border-radius: 5px; display: block; }
.ph-btn.go { background: var(--accent-bg); border-color: var(--accent-deep); color: #e2d6ff; }

/* ── Bildirim ──────────────────────── */
#toast {
  position: absolute; z-index: 7; left: 50%; top: calc(var(--sat) + 60px); transform: translate(-50%, -8px);
  max-width: calc(100% - 120px); padding: 8px 14px; border-radius: 14px;
  background: rgba(20,20,34,.95); border: 1px solid var(--line-2); color: #e6e6ff;
  font-size: 13px; font-weight: 600; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#debug {
  position: absolute; z-index: 7; left: calc(var(--sal) + 10px); bottom: 10px;
  font: 11px ui-monospace, Menlo, monospace; color: #9f9; background: rgba(0,0,0,.6); padding: 4px 6px; border-radius: 6px;
}

/* ── Alt panel ─────────────────────── */
#dock {
  flex: none; background: rgba(14,14,26,.97); border-top: 1px solid var(--line);
  padding: 7px calc(var(--sar) + 8px) calc(var(--sab) + 8px) calc(var(--sal) + 8px);
  display: grid; gap: 7px;
}
#tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
#tabs::-webkit-scrollbar, #chips::-webkit-scrollbar { display: none; }
.tab {
  flex: none; padding: 5px 11px; border-radius: 10px; font-size: 12px; font-weight: 650; color: #6c6c98;
}
.tab.on { background: var(--accent-bg); color: #c9b2ff; }
#chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 1px; scroll-snap-type: x proximity; }
.chip {
  flex: none; width: var(--chip); display: grid; justify-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 600; color: var(--muted); position: relative; scroll-snap-align: start;
}
.chip .sw {
  width: calc(var(--chip) - 4px); height: 34px; border-radius: 10px; border: 2px solid var(--line);
  display: grid; place-items: center; color: #cfcff0; position: relative; overflow: hidden;
}
.chip .sw::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(255,255,255,.18), rgba(255,255,255,0) 45%, rgba(0,0,0,.18)); pointer-events: none; }
.chip .sw svg { width: 20px; height: 20px; position: relative; z-index: 1; }
.chip .nm { max-width: calc(var(--chip) + 8px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip.on .sw { border-color: var(--accent-deep); box-shadow: 0 0 10px rgba(124,58,237,.55); }
.chip.on .nm { color: #d2bcff; }
.chip .lock {
  position: absolute; top: -3px; right: -2px; z-index: 2; width: 18px; height: 18px; border-radius: 50%;
  background: #241a48; border: 1px solid #5b44b0; display: grid; place-items: center; color: #d8c8ff;
}
.chip .lock svg { width: 10px; height: 10px; }
.chip.toggle.on .sw { background: var(--accent-bg); }
.chip .sep { }
.chip-sep { flex: none; width: 1px; background: var(--line); margin: 4px 2px 18px; }

/* ── Alt sayfa (sheet) ─────────────── */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet-back { position: absolute; inset: 0; background: rgba(0,0,0,.55); animation: fade .2s; }
.sheet {
  position: relative; width: min(520px, 100%); max-height: calc(100% - var(--sat) - 20px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-bottom: 0; border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(var(--sab) + 18px); animation: up .25s cubic-bezier(.2,.8,.2,1);
  overscroll-behavior: contain;
}
@media (min-width: 700px) and (min-height: 600px) {
  .sheet-wrap { align-items: center; }
  .sheet { border-radius: 22px; border-bottom: 1px solid var(--line); padding-bottom: 20px; }
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.grabber { width: 38px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 0 auto 12px; }
.sheet h2 { font-size: 20px; font-weight: 800; color: #fff; margin-bottom: 4px; }
.sheet .sub { color: var(--muted); font-size: 13.5px; margin-bottom: 14px; }
.list { display: grid; gap: 2px; border-radius: 14px; overflow: hidden; background: var(--line); border: 1px solid var(--line); margin-bottom: 12px; }
.row {
  display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 0 14px; background: var(--panel-2);
  font-size: 15px; text-align: left; width: 100%;
}
.row svg { width: 20px; height: 20px; color: var(--accent); flex: none; }
.row .grow { flex: 1; min-width: 0; }
.row .hint { font-size: 12.5px; color: var(--dim); margin-top: 2px; line-height: 1.35; }
.row.danger { color: #ff8a8a; }
.row.danger svg { color: #ff8a8a; }
.row.pro { color: #e0d0ff; }
.row:active { background: #1a1a2c; }
.switch { width: 46px; height: 28px; border-radius: 14px; background: var(--line-2); position: relative; flex: none; transition: background .2s; }
.switch::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch.on { background: var(--accent-deep); }
.switch.on::after { transform: translateX(18px); }
.seg { display: flex; gap: 4px; background: var(--bg); padding: 3px; border-radius: 10px; }
.seg button { padding: 5px 12px; border-radius: 8px; font-size: 13px; font-weight: 650; color: var(--muted); }
.seg button.on { background: var(--accent-bg); color: #d2bcff; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 12px; }
.card { border-radius: 14px; overflow: hidden; background: var(--panel-2); border: 1px solid var(--line); display: grid; text-align: left; }
.card .th { aspect-ratio: 4 / 3; background: var(--stage) center / cover no-repeat; image-rendering: pixelated; }
.card .cap { padding: 8px 10px; font-size: 13.5px; font-weight: 650; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.card .cap small { color: var(--dim); font-weight: 500; font-size: 11.5px; }
.card .x { color: #ff8a8a; font-size: 12px; font-weight: 700; padding: 2px 4px; }
.btn {
  width: 100%; min-height: 50px; border-radius: 14px; font-size: 16px; font-weight: 750;
  background: var(--accent-deep); color: #fff; margin-bottom: 8px;
}
.btn.ghost { background: var(--panel-2); color: #d6d6f0; border: 1px solid var(--line); font-weight: 650; }
.btn.link { background: none; min-height: 40px; color: var(--muted); font-size: 14px; font-weight: 600; }
.btn:disabled { opacity: .5; }
.pro-hero {
  border-radius: 18px; padding: 18px; margin-bottom: 14px;
  background: radial-gradient(120% 120% at 0% 0%, #2a1660 0%, #120a2a 55%, #0b0b18 100%); border: 1px solid #3b2a78;
}
.pro-hero h2 { font-size: 26px; background: linear-gradient(135deg, #c4b5fd, #60a5fa, #34d399); -webkit-background-clip: text; background-clip: text; color: transparent; }
.pro-list { display: grid; gap: 10px; margin: 14px 0 4px; }
.pro-list div { display: grid; grid-template-columns: 22px 1fr; gap: 10px; font-size: 14.5px; line-height: 1.4; color: #dcd3ff; }
.pro-list svg { width: 20px; height: 20px; color: var(--ok); margin-top: 1px; }
.pro-els { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.pro-els span { width: 26px; height: 18px; border-radius: 5px; }
.brand { display: grid; justify-items: center; gap: 6px; padding-top: 6px; }
.brand img { width: 84px; filter: invert(1) hue-rotate(180deg); opacity: .8; }
.brand small { font-size: 11px; color: var(--dim); letter-spacing: .5px; }

#sim-ad { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: #000; color: #fff; font: 700 16px system-ui; letter-spacing: 1px; }

@media (min-width: 700px) {
  :root { --chip: 60px; }
  .pill { height: 44px; min-width: 44px; }
  #brush .track { height: 160px; }
}

/* ── Yan sütun (hız, geri sar, yavaş çekim) ── */
#side { position: absolute; z-index: 5; left: calc(var(--sal) + 10px); top: calc(var(--sat) + 62px); display: grid; gap: 8px; }
.pill.side { width: 40px; padding: 0; position: relative; }
.pill.side b { font-size: 13px; font-variant-numeric: tabular-nums; }
.pill.side.locked { color: #7d7da8; }
.pill.side.locked::after { content: ""; position: absolute; top: -2px; right: -2px; width: 9px; height: 9px; border-radius: 50%; background: var(--paid, #f5b942); }
.pill .lock { position: absolute; top: -5px; right: -5px; width: 16px; height: 16px; border-radius: 50%; background: #241a48; border: 1px solid #5b44b0; display: grid; place-items: center; }
.pill .lock svg { width: 9px; height: 9px; }
.badge.danger { background: rgba(120,20,20,.9); border-color: #ff6a6a; color: #fff; }
.badge svg { width: 14px; height: 14px; }

/* ── Günün görevi ── */
#challenge {
  position: absolute; z-index: 6; left: 50%; transform: translateX(-50%); top: calc(var(--sat) + 56px);
  width: min(460px, calc(100% - 120px)); background: rgba(14,14,26,.94); border: 1px solid #3b2a78; border-radius: 16px;
  padding: 10px 12px; display: grid; gap: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.45);
}
.ch-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ch-top b { font-size: 14px; color: #fff; }
.ch-x { width: 28px; height: 28px; border-radius: 14px; display: grid; place-items: center; color: var(--muted); flex: none; }
.ch-x svg { width: 16px; height: 16px; }
.ch-goal { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.ch-row { display: flex; align-items: center; gap: 8px; }
.ch-moves { font-size: 12px; font-weight: 700; color: #d2bcff; white-space: nowrap; }
.ch-moves.out { color: #ff8a8a; }
.ch-bar { flex: 1; height: 6px; border-radius: 3px; background: #22223a; overflow: hidden; }
.ch-bar i { display: block; height: 100%; background: linear-gradient(90deg, #7c3aed, #34d399); border-radius: 3px; transition: width .3s; }
.ch-pct { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--muted); min-width: 34px; text-align: right; }
.ch-state { font-size: 12.5px; padding: 6px 8px; border-radius: 8px; line-height: 1.35; }
.ch-state.info { background: #161230; color: #c9b8ff; }
.ch-state.hint { background: #22200e; color: #f3dfa2; }
.ch-state.good { background: #0f2a1b; color: #7fe0a8; font-weight: 700; }
.ch-state.bad { background: #2a1010; color: #ff9a9a; }
.ch-btns { display: flex; gap: 6px; }
.btn.sm { min-height: 32px; width: auto; padding: 0 10px; font-size: 12.5px; margin: 0; display: inline-flex; align-items: center; gap: 5px; border-radius: 10px; }
.btn.sm svg { width: 15px; height: 15px; }

/* ── Geri sar / yavaş çekim ── */
#rewind {
  position: absolute; z-index: 7; left: 50%; bottom: 12px; transform: translateX(-50%);
  width: min(520px, calc(100% - 24px)); background: rgba(14,14,26,.96); border: 1px solid #3b2a78; border-radius: 16px; padding: 12px; display: grid; gap: 10px;
}
.rw-top { display: flex; align-items: center; gap: 10px; }
.rw-top b { color: #fff; font-size: 14px; flex: 1; }
.rw-top span { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
#rw-r { width: 100%; accent-color: #7c3aed; }
#rewind .btn { margin: 0; min-height: 44px; }
#replay {
  position: absolute; z-index: 6; left: 50%; transform: translateX(-50%); top: calc(var(--sat) + 58px);
  display: flex; align-items: center; gap: 10px; width: min(320px, calc(100% - 120px));
  background: rgba(14,14,26,.9); border: 1px solid #3b2a78; border-radius: 14px; padding: 8px 12px; font-size: 12.5px; font-weight: 700; color: #d2bcff;
}

/* ── Zen modu ── */
#zen-exit { position: absolute; z-index: 8; right: calc(var(--sar) + 12px); top: calc(var(--sat) + 10px); display: none; }
body.zen #zen-exit { display: inline-flex; }
body.zen #topbar, body.zen #side, body.zen #brush, body.zen #dock, body.zen #challenge { display: none !important; }

/* ── Ödüllü geçiş reklamı tanıtımı ── */
.offer { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(0,0,0,.55); padding: 16px; }
.offer-box { width: min(360px, 100%); background: var(--panel); border: 1px solid #3b2a78; border-radius: 18px; padding: 18px; display: grid; gap: 10px; }
.offer-box h3 { color: #fff; font-size: 18px; margin: 0; }
.offer-box p { color: var(--muted); font-size: 14px; margin: 0; }
.offer-bar { height: 6px; border-radius: 3px; background: #22223a; overflow: hidden; }
.offer-bar i { display: block; width: 0; height: 100%; background: var(--accent-deep); }
.offer-box .btn { margin: 0; }

/* ── Galeri, kayıtlar, ayarlar ekleri ── */
.seg.wide { display: flex; margin-bottom: 12px; }
.seg.wide button { flex: 1; }
.seg.wide small { opacity: .6; font-weight: 600; }
.card .th { position: relative; display: block; }
.card .th .lock { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%; background: #241a48; border: 1px solid #5b44b0; display: grid; place-items: center; color: #d8c8ff; }
.card .th .lock svg { width: 12px; height: 12px; }
.card .th .free { position: absolute; left: 6px; top: 6px; font-size: 10.5px; font-weight: 800; letter-spacing: .4px; padding: 2px 7px; border-radius: 999px; background: #0f2a1b; color: #7fe0a8; border: 1px solid #2a6b45; }
.card .story { display: block; padding: 0 10px 10px; font-size: 12px; color: var(--muted); line-height: 1.35; }
.card.tpl .th { aspect-ratio: 3 / 4; }
.importrow { display: flex; gap: 8px; margin-bottom: 12px; }
.importrow input { flex: 1; min-width: 0; min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); padding: 0 12px; font: inherit; font-size: 14px; }
.importrow .btn { width: auto; padding: 0 16px; margin: 0; min-height: 44px; }
.rlock, .ok { display: grid; place-items: center; width: 24px; height: 24px; flex: none; }
.rlock svg { width: 16px; height: 16px; color: #b9a4ff; }
.ok svg { width: 18px; height: 18px; color: #5fd08a; }
.mini-lock { display: inline-block; vertical-align: -1px; }
.mini-lock svg { width: 10px; height: 10px; display: inline; }
.row.col { flex-wrap: wrap; padding-block: 10px; row-gap: 8px; }
.row.col .seg { flex-wrap: wrap; }

/* ── Fotoğraf çubuğu ekleri ── */
.ph-detail { display: flex; gap: 6px; justify-content: center; align-items: center; font-size: 12px; color: var(--muted); }
.ph-detail button { padding: 4px 10px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); font-size: 12px; font-weight: 650; color: var(--muted); }
.ph-detail button.on { background: var(--accent-bg); border-color: var(--accent-deep); color: #e2d6ff; }
.ph-btns { grid-template-columns: repeat(6, 1fr) !important; }
.ph-btn { position: relative; }
.ph-btn .ic { width: 22px; height: 18px; display: block; }
.ph-btn .ic svg { width: 18px; height: 18px; margin: 0 auto; }
.ph-btn .lock { position: absolute; top: 3px; right: 3px; width: 16px; height: 16px; border-radius: 50%; background: #241a48; border: 1px solid #5b44b0; display: grid; place-items: center; }
.ph-btn .lock svg { width: 9px; height: 9px; }
@media (max-width: 380px) {
  .ph-btns { grid-template-columns: repeat(3, 1fr) !important; }
  #challenge { width: calc(100% - 112px); padding: 8px 10px; gap: 5px; }
  .ch-top b { font-size: 12.5px; }
  .ch-goal { font-size: 11.5px; }
  .ch-btns .btn.sm { padding: 0 8px; font-size: 12px; }
}

@media (max-height: 700px) {
  .pro-hero { padding: 14px; margin-bottom: 10px; }
  .pro-hero h2 { font-size: 22px; }
  .pro-els { display: none; }
  .pro-list { gap: 6px; margin-top: 10px; }
  .pro-list div { font-size: 13.5px; }
  .btn { min-height: 46px; margin-bottom: 6px; }
  .btn.link { min-height: 34px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
