/* ───── sahne katmanları ───── */
#world, #bgs, #cg, #sprites { position: absolute; inset: 0; }
.bgl { position: absolute; inset: 0; }
.bgl::after { content: attr(data-label); position: absolute; left: 36px; top: 28px; font: 500 20px var(--mono); color: rgba(255, 255, 255, .22); letter-spacing: .04em; }
#cg { opacity: 0; transition: opacity .6s var(--ease); pointer-events: none; background: #000; }
#cg.show { opacity: 1; }
#cg img { width: 100%; height: 100%; object-fit: cover; }
.cg-ph { position: absolute; inset: 0; display: grid; place-items: center; font: 600 44px var(--font); color: rgba(255, 255, 255, .35); }
#vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, .55) 100%); }
#fx-flash, #fx-fade { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
#fx-fade { z-index: 4; }
@keyframes shake { 0%, 100% { transform: translate(0, 0); } 10% { transform: translate(calc(var(--sh) * -1), calc(var(--sh) * .5)); } 25% { transform: translate(var(--sh), calc(var(--sh) * -.7)); } 40% { transform: translate(calc(var(--sh) * -.8), var(--sh)); } 55% { transform: translate(calc(var(--sh) * .9), calc(var(--sh) * -.4)); } 70% { transform: translate(calc(var(--sh) * -.5), calc(var(--sh) * .6)); } 85% { transform: translate(calc(var(--sh) * .3), calc(var(--sh) * -.2)); } }

/* ───── karakterler ───── */
.sprite { position: absolute; bottom: 0; height: 92%; aspect-ratio: 1 / 1.9; transform: translateX(-50%); display: flex; align-items: flex-end; justify-content: center; transition: left .5s var(--ease), filter .35s, opacity .35s; }
.sprite img { max-height: 100%; max-width: 100%; object-fit: contain; filter: drop-shadow(0 12px 30px rgba(0, 0, 0, .55)); }
.sprite.enter { animation: sprite-in .5s var(--ease); }
.sprite.enter[data-anim="left"] { animation-name: sprite-left; } .sprite.enter[data-anim="right"] { animation-name: sprite-right; } .sprite.enter[data-anim="zoom"] { animation-name: sprite-zoom; }
.sprite.leaving { opacity: 0; transform: translateX(-50%) translateY(14px); transition: opacity .3s, transform .3s; }
.sprite.dim { filter: brightness(.55) saturate(.8); }
@keyframes sprite-in { from { opacity: 0; transform: translateX(-50%) translateY(28px); } to { opacity: 1; transform: translateX(-50%); } }
@keyframes sprite-left { from { opacity: 0; transform: translateX(-120%); } to { opacity: 1; transform: translateX(-50%); } }
@keyframes sprite-right { from { opacity: 0; transform: translateX(20%); } to { opacity: 1; transform: translateX(-50%); } }
@keyframes sprite-zoom { from { opacity: 0; transform: translateX(-50%) scale(.85); } to { opacity: 1; transform: translateX(-50%) scale(1); } }

/* görseli olmayan karakter için gölge figür */
.ph { position: relative; width: 62%; height: 78%; margin-bottom: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.ph-head { width: 34%; aspect-ratio: 1; border-radius: 50%; background: linear-gradient(160deg, color-mix(in srgb, var(--c) 70%, #fff 10%), color-mix(in srgb, var(--c) 40%, #000)); box-shadow: 0 0 60px color-mix(in srgb, var(--c) 40%, transparent); }
.ph-body { width: 100%; height: 62%; margin-top: 3%; border-radius: 46% 46% 0 0 / 28% 28% 0 0; background: linear-gradient(180deg, color-mix(in srgb, var(--c) 55%, #000), color-mix(in srgb, var(--c) 18%, #000) 90%); border: 1px solid rgba(255, 255, 255, .1); border-bottom: 0; }
.ph-name { position: absolute; bottom: 34%; font: 700 40px var(--font); letter-spacing: .02em; color: #fff; text-shadow: 0 2px 14px rgba(0, 0, 0, .8); }
.ph-expr { position: absolute; bottom: 28%; font: 500 22px var(--mono); color: rgba(255, 255, 255, .6); }

/* ───── metin kutusu ───── */
#game { position: absolute; inset: 0; z-index: 3; }
#textbox { position: absolute; left: 160px; right: 160px; bottom: 44px; min-height: 270px; padding: 54px 80px 46px; border-radius: var(--r-lg); background: rgb(8 8 10 / var(--box-a, .82)); border: 1px solid var(--line-2); backdrop-filter: blur(14px); box-shadow: 0 30px 80px rgba(0, 0, 0, .55); cursor: pointer; }
#text { font-size: var(--fs, 36px); line-height: 1.6; color: var(--text); min-height: 3.2em; white-space: pre-wrap; }
#text .c { opacity: 0; } #text .c.on { opacity: 1; }
#text .b { font-weight: 700; } #text .i { font-style: italic; }
#textbox.narr #text { color: #dcdce2; font-style: italic; }
#namebox { position: absolute; left: 200px; bottom: 296px; padding: 10px 32px; border-radius: 999px; font-size: 32px; font-weight: 700; letter-spacing: .01em; background: var(--bg-1); border: 1px solid var(--line-3); color: var(--nc, var(--accent)); box-shadow: 0 8px 28px rgba(0, 0, 0, .5); z-index: 2; }
#namebox::before { content: ''; display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--nc, var(--accent)); margin-right: 14px; box-shadow: 0 0 12px var(--nc, var(--accent)); }
#arrow { position: absolute; right: 44px; bottom: 28px; width: 18px; height: 18px; border-right: 4px solid var(--accent); border-bottom: 4px solid var(--accent); transform: rotate(45deg); opacity: 0; }
#arrow.show { opacity: 1; animation: bob 1.1s var(--ease) infinite; }
@keyframes bob { 50% { transform: rotate(45deg) translate(5px, 5px); } }
#stage.ui-hidden #textbox, #stage.ui-hidden #namebox, #stage.ui-hidden #quick, #stage.ui-hidden #choices, #stage.ui-hidden #badges { opacity: 0; pointer-events: none; }
#game.no-text #textbox, #game.no-text #namebox { display: none; }

/* ───── seçimler ───── */
#choices { position: absolute; inset: 0; display: none; flex-direction: column; justify-content: center; align-items: center; gap: 18px; background: rgba(0, 0, 0, .42); backdrop-filter: blur(3px); z-index: 2; }
#choices.show { display: flex; animation: fadeIn .25s var(--ease); }
.choice-prompt { font-size: 40px; font-weight: 600; margin-bottom: 14px; max-width: 1200px; text-align: center; color: var(--text); text-shadow: 0 2px 18px #000; }
.choice { width: 1100px; max-width: 80%; display: flex; align-items: center; gap: 26px; padding: 22px 34px; border-radius: var(--r); font-size: 34px; text-align: left; background: rgba(14, 14, 17, .92); border: 1px solid var(--line-2); transition: transform .2s var(--ease), border-color .2s, background .2s; }
.choice:hover { transform: translateX(10px); border-color: rgb(var(--a1) / .7); background: rgba(27, 27, 32, .96); }
.choice-n { flex: none; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font: 600 24px var(--mono); background: var(--accent-soft); color: var(--accent); border: 1px solid rgb(var(--a1) / .35); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ───── hızlı menü & rozetler ───── */
#quick { position: absolute; right: 160px; bottom: 322px; display: flex; gap: 6px; padding: 6px; border-radius: 999px; background: rgba(8, 8, 10, .6); border: 1px solid var(--line); backdrop-filter: blur(10px); opacity: .35; transition: opacity .25s; }
#quick:hover { opacity: 1; }
#quick button { padding: 6px 16px; border-radius: 999px; border: 0; background: transparent; font-size: 20px; color: var(--text-2); transition: background .2s, color .2s; }
#quick button:hover { background: var(--bg-3); color: var(--text); }
#quick button.on { background: var(--accent); color: var(--on-accent); }
#badges { position: absolute; top: 28px; right: 36px; display: flex; gap: 12px; }
#badges span { display: none; padding: 6px 18px; border-radius: 999px; font: 600 20px var(--mono); letter-spacing: .08em; background: var(--accent); color: var(--on-accent); animation: fadeIn .2s; }
#badges span.on { display: block; }

/* ───── bölüm kartı ───── */
#card { position: absolute; inset: 0; z-index: 6; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 16px; background: radial-gradient(ellipse at center, rgba(14, 14, 17, .9), rgba(0, 0, 0, .96)); pointer-events: none; }
#card.show { display: flex; animation: card-life var(--dur, 3s) linear forwards; }
#card-title { font-size: 84px; font-weight: 700; letter-spacing: -.02em; }
#card-sub { font-size: 32px; color: var(--text-2); letter-spacing: .12em; text-transform: uppercase; }
#card::after { content: ''; width: 120px; height: 2px; background: var(--accent); order: -1; }
@keyframes card-life { 0% { opacity: 0; } 12% { opacity: 1; } 82% { opacity: 1; } 100% { opacity: 0; } }

/* ───── açılış ───── */
#splash { position: absolute; inset: 0; z-index: 100; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 44px; transition: opacity .6s var(--ease); }
#splash.gone { opacity: 0; pointer-events: none; }
#splash img { width: 180px; height: 180px; animation: pulse 2s ease-in-out infinite; }
.splash-bar { width: 320px; height: 3px; background: var(--bg-3); border-radius: 3px; overflow: hidden; }
.splash-bar span { display: block; height: 100%; width: 40%; background: var(--accent); border-radius: 3px; animation: slide 1.2s var(--ease) infinite; }
@keyframes pulse { 50% { transform: scale(1.04); opacity: .85; } }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

/* ───── bildirim & modal ───── */
#toasts { position: absolute; top: 36px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 12px; align-items: center; pointer-events: none; }
.toast { padding: 14px 28px; border-radius: 999px; font-size: 24px; background: var(--bg-2); border: 1px solid var(--line-3); box-shadow: 0 14px 40px rgba(0, 0, 0, .5); animation: toast-in .35s var(--ease), toast-out .4s 3.2s forwards; display: flex; gap: 14px; align-items: center; }
.toast.ok { border-color: rgb(var(--a1) / .5); } .toast.warn { border-color: var(--amber); } .toast.err { border-color: var(--red); }
.toast b { color: var(--accent); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-20px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-14px); } }
#modal-layer { position: absolute; inset: 0; z-index: 80; display: none; place-items: center; background: rgba(0, 0, 0, .6); backdrop-filter: blur(4px); }
#modal-layer.show { display: grid; animation: fadeIn .2s; }
.modal { width: 760px; padding: 44px; border-radius: var(--r-lg); background: var(--bg-1); border: 1px solid var(--line-2); box-shadow: 0 40px 100px rgba(0, 0, 0, .7); }
.modal h3 { font-size: 34px; margin-bottom: 14px; } .modal p { font-size: 25px; color: var(--text-2); line-height: 1.5; white-space: pre-wrap; }
.modal input { width: 100%; margin-top: 24px; padding: 16px 20px; border-radius: var(--r-sm); background: var(--bg); border: 1px solid var(--line-3); color: var(--text); font: 500 30px var(--font); outline: none; user-select: text; }
.modal input:focus { border-color: var(--accent); }
.modal .row { display: flex; justify-content: flex-end; gap: 14px; margin-top: 34px; }

/* katman sırası: arka plan < karakterler < CG */
#bgs { z-index: 0; } #sprites { z-index: 1; } #cg { z-index: 2; }

/* ───── iç ses ───── */
#textbox.thought #text { color: #b9b9c6; }
#textbox.thought { border-style: dashed; }

/* ───── gün / saat ───── */
#hud { position: absolute; left: 36px; top: 28px; display: none; align-items: center; gap: 14px; padding: 8px 22px 8px 8px; border-radius: 999px; background: rgba(8, 8, 10, .62); border: 1px solid var(--line-2); backdrop-filter: blur(10px); font: 500 22px var(--mono); color: var(--text-2); }
#hud.show { display: flex; }
#hud b { padding: 4px 14px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-weight: 700; letter-spacing: .06em; }
#hud b:empty, #hud span:empty { display: none; }
#hud-place { color: var(--text-3); font-family: var(--font); }
#hud-place::before { content: '· '; }

/* ───── telefon ───── */
#phone { position: absolute; right: 220px; top: 40px; width: 440px; height: 640px; display: none; flex-direction: column; border-radius: 46px; padding: 14px; background: #050507; border: 2px solid #2a2a31; box-shadow: 0 40px 100px rgba(0, 0, 0, .7), inset 0 0 0 6px #111115; z-index: 1; }
#phone.show { display: flex; animation: phone-in .45s var(--ease); }
@keyframes phone-in { from { opacity: 0; transform: translateY(60px) rotate(2deg); } }
.ph-status { display: flex; justify-content: space-between; padding: 8px 26px 4px; font: 600 18px var(--mono); color: var(--text-2); }
.ph-head2 { display: flex; align-items: center; gap: 14px; padding: 12px 18px; border-bottom: 1px solid var(--line); font-size: 24px; font-weight: 600; }
.ph-head2 i { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 20px; color: #0a0a0c; font-weight: 700; }
#phone-body { flex: 1; overflow-y: auto; padding: 16px 12px; display: flex; flex-direction: column; gap: 10px; }
#phone-body::-webkit-scrollbar { width: 0; }
.bub { max-width: 82%; padding: 10px 16px 8px; border-radius: 20px 20px 20px 6px; background: var(--bg-3); font-size: 22px; line-height: 1.4; align-self: flex-start; white-space: pre-wrap; }
.bub b { display: block; font-size: 16px; margin-bottom: 2px; }
.bub small { display: block; text-align: right; font: 500 13px var(--mono); color: var(--text-3); margin-top: 3px; }
.bub.me { align-self: flex-end; border-radius: 20px 20px 6px 20px; background: var(--accent); color: var(--on-accent); }
.bub.me small { color: rgb(0 0 0 / .45); }
.bub.pop { animation: bub-in .3s var(--ease); }
@keyframes bub-in { from { opacity: 0; transform: translateY(14px) scale(.96); } }
.ph-input { margin: 8px 10px 6px; padding: 12px 20px; border-radius: 999px; background: var(--bg-2); color: var(--text-3); font-size: 19px; }
#game.no-text #phone { cursor: pointer; }

/* ───── süreli seçim ───── */
.choice-timer { width: 1100px; max-width: 80%; height: 6px; border-radius: 6px; background: var(--bg-3); overflow: hidden; margin-bottom: 6px; }
.choice-timer span { display: block; height: 100%; background: var(--red); transform-origin: left; animation: timer-run linear forwards; }
@keyframes timer-run { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ───── rüya ───── */
#stage.dream #world { filter: blur(1.6px) saturate(.55) brightness(1.08) hue-rotate(-12deg); animation: dream-float 7s ease-in-out infinite; }
#stage.dream #vignette { background: radial-gradient(ellipse at center, transparent 40%, rgba(225, 225, 245, .35) 100%); }
#stage.dream #textbox { background: rgb(20 18 34 / .72); border-color: rgb(196 181 253 / .25); }
@keyframes dream-float { 50% { transform: scale(1.03) translateY(-8px); } }

/* ───── bozulma ───── */
#stage[data-glitch="1"] #world { animation: glitch-a 2.6s steps(1) infinite; }
#stage[data-glitch="2"] #world, #stage[data-glitch="3"] #world { animation: glitch-a .9s steps(1) infinite; filter: contrast(1.2) saturate(1.3); }
#stage[data-glitch="2"] #text, #stage[data-glitch="3"] #text { text-shadow: 2px 0 rgba(255, 45, 53, .7), -2px 0 rgba(0, 200, 255, .6); animation: glitch-t .5s steps(1) infinite; }
#stage[data-glitch="3"] #game { animation: glitch-t .3s steps(1) infinite; }
#stage[data-glitch="3"]::after { content: ''; position: absolute; inset: 0; z-index: 7; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(255, 255, 255, .04) 0 2px, transparent 2px 5px); animation: glitch-scan .2s steps(2) infinite; }
@keyframes glitch-a { 0%, 100% { transform: none; clip-path: none; } 92% { transform: translate(14px, -4px); clip-path: inset(20% 0 55% 0); } 95% { transform: translate(-10px, 6px); clip-path: inset(60% 0 10% 0); } 97% { transform: translate(6px, 0); filter: hue-rotate(90deg); } }
@keyframes glitch-t { 0%, 100% { transform: none; } 50% { transform: translateX(3px); } 75% { transform: translateX(-2px); } }
@keyframes glitch-scan { 50% { transform: translateY(3px); } }

/* yağmur: iki katman, farklı hız ve açı (weather rain) */
#rain { position: absolute; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; opacity: 0; transition: opacity 1.2s; }
#stage[data-weather="rain"] #rain { opacity: 1; }
#rain i { position: absolute; inset: -20% -10%; background-image: repeating-linear-gradient(103deg, transparent 0 46px, rgba(200, 215, 235, .22) 46px 47px, transparent 47px 92px); background-size: 92px 120px; animation: rain-fall .45s linear infinite; }
#rain i:nth-child(2) { opacity: .55; background-size: 61px 90px; animation-duration: .7s; filter: blur(.6px); }
#stage[data-weather="rain"] #world { filter: saturate(.8) brightness(.9); }
@keyframes rain-fall { from { transform: translate(0, -120px); } to { transform: translate(-26px, 0); } }

/* karanlıkta tanınmayan figür (show x bos_golge) */
.sprite.silhouette img { filter: brightness(0) drop-shadow(0 0 18px rgba(0, 0, 0, .8)); opacity: .9; }
.sprite.silhouette .ph { filter: brightness(.08); }

.choice-back { margin-top: 26px; padding: 10px 28px; border-radius: 999px; background: rgba(14, 14, 17, .85); border: 1px solid var(--line-2); font-size: 24px; color: var(--text-2); transition: .18s var(--ease); } .choice-back:hover { color: var(--text); border-color: rgb(var(--a1) / .7); }
