:root {
  --ink: #3b3550;
  --ink-soft: rgba(59, 53, 80, 0.65);
  --glass: rgba(255, 255, 255, 0.55);
  --glass-strong: rgba(255, 255, 255, 0.8);
  --accent: #e2604a;
  --serif: "Noto Serif", "Georgia", "Times New Roman", serif;
  --sans: "Roboto", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #f6e3d8; color: var(--ink); font-family: var(--sans); touch-action: none; }
canvas { position: fixed; inset: 0; display: block; }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; opacity: 0; pointer-events: none; transition: opacity .5s ease; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); }
.screen.show { opacity: 1; pointer-events: auto; }
#hud { pointer-events: none; }
#hud.show .topbar, #hud.show .icon { pointer-events: auto; }

button { font: inherit; color: inherit; border: 0; cursor: pointer; }

/* Başlık */
#title { justify-content: space-between; padding-top: max(10vh, env(safe-area-inset-top)); padding-bottom: max(8vh, env(safe-area-inset-bottom)); }
.logo { text-align: center; }
.gem { width: 46px; height: 46px; filter: drop-shadow(0 0 12px rgba(255, 220, 140, .9)); animation: float 4s ease-in-out infinite; }
h1 { font-family: var(--serif); font-weight: 400; letter-spacing: .42em; margin: 10px 0 4px .42em; font-size: clamp(34px, 10vw, 54px); color: #fff; text-shadow: 0 2px 18px rgba(30, 20, 60, .35); }
#subtitle { margin: 0; font-family: var(--serif); font-style: italic; letter-spacing: .12em; color: rgba(255, 255, 255, .9); text-shadow: 0 1px 10px rgba(30, 20, 60, .4); }
.menu { display: flex; flex-direction: column; gap: 12px; width: min(300px, 100%); }
.menu button { padding: 15px 20px; border-radius: 999px; background: var(--glass); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); font-size: 17px; letter-spacing: .06em; box-shadow: 0 6px 24px rgba(40, 30, 70, .12); transition: transform .15s, background .2s; }
.menu button:active { transform: scale(.96); }
.menu button.primary { background: var(--glass-strong); font-weight: 600; }

/* Paneller */
.panel { justify-content: center; gap: 18px; background: rgba(255, 248, 244, .55); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.panel.soft { background: rgba(255, 250, 240, .35); }
h2 { font-family: var(--serif); font-weight: 400; letter-spacing: .18em; margin: 0; font-size: 26px; text-align: center; }
h2 small, #levelTitle small { display: block; font-size: 13px; letter-spacing: .3em; color: var(--ink-soft); margin-bottom: 4px; }
.kicker { margin: 0; letter-spacing: .3em; font-size: 13px; text-transform: uppercase; color: var(--ink-soft); }
.backBtn { padding: 12px 34px; border-radius: 999px; background: var(--glass-strong); letter-spacing: .08em; }

#levelGrid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 9px; width: min(400px, 100%); max-height: 68vh; overflow-y: auto; touch-action: pan-y; padding: 4px 4px 16px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
#levelGrid::-webkit-scrollbar { display: none; }
.chapter { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: baseline; padding: 12px 4px 2px; font-family: var(--serif); letter-spacing: .08em; }
.chapter b { font-family: var(--sans); font-weight: 500; font-size: 13px; color: var(--ink-soft); }
.lvl { position: relative; display: grid; place-items: center; aspect-ratio: 1; border-radius: 14px; background: var(--glass-strong); box-shadow: 0 4px 14px rgba(40, 30, 70, .1); transition: transform .15s; }
.lvl:active { transform: scale(.94); }
.lvl .num { font-family: var(--serif); font-size: 20px; }
.lvl.done::after { content: "✦"; position: absolute; top: 3px; right: 6px; font-size: 11px; color: #d6a245; }
.lvl.locked { opacity: .4; }
#settingsList { display: flex; flex-direction: column; gap: 10px; width: min(340px, 100%); }
.row { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; border-radius: 16px; background: var(--glass-strong); font-size: 16px; }
.row b { font-weight: 600; color: var(--accent); }
.row.danger span { color: #b14a4a; }
.about { text-align: center; font-size: 13px; color: var(--ink-soft); margin: 8px 0 0; line-height: 1.5; }

/* Oyun içi */
.topbar { display: flex; align-items: flex-start; justify-content: space-between; width: 100%; max-width: 560px; }
.icon { width: 46px; height: 46px; border-radius: 50%; background: var(--glass); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: grid; place-items: center; }
.icon svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon:active { transform: scale(.92); }
#levelTitle { flex: 1; text-align: center; font-family: var(--serif); font-size: 20px; letter-spacing: .14em; padding-top: 4px; color: var(--ink); text-shadow: 0 1px 8px rgba(255, 255, 255, .6); opacity: .85; }
#levelTitle.intro { animation: intro 3.2s ease both; }
#hint { position: absolute; left: 16px; right: 16px; bottom: max(28px, env(safe-area-inset-bottom)); text-align: center; font-family: var(--serif); font-style: italic; font-size: 16px; color: var(--ink); opacity: 0; transform: translateY(8px); transition: opacity .8s, transform .8s; text-shadow: 0 1px 8px rgba(255, 255, 255, .8); }
#hint.show { opacity: .85; transform: none; }

.endText { max-width: 320px; text-align: center; font-family: var(--serif); font-style: italic; line-height: 1.6; margin: 0; }

@keyframes intro { 0% { opacity: 0; transform: translateY(-6px) scale(1.04); } 20% { opacity: 1; transform: none; } 100% { opacity: .85; } }
@keyframes float { 50% { transform: translateY(-6px) rotate(4deg); } }

.noanim *, .noanim *::before { transition: none !important; animation: none !important; }
.noanim #levelTitle { opacity: .85; }

/* Koyu paletlerde açık renkli yazı */
[data-pal="night"] #levelTitle, [data-pal="night"] #hint, [data-pal="aurora"] #levelTitle, [data-pal="aurora"] #hint { color: #f1eefc; text-shadow: 0 1px 10px rgba(10, 8, 30, .8); }
[data-pal="night"] #levelTitle small, [data-pal="aurora"] #levelTitle small { color: rgba(241, 238, 252, .7); }
[data-pal="night"] .icon, [data-pal="aurora"] .icon { background: rgba(255, 255, 255, .22); }
[data-pal="night"] .icon svg, [data-pal="aurora"] .icon svg { stroke: #f1eefc; }

/* Film modu (tanıtım videosu kaydı) */
.film #hud .topbar, .film #hint { display: none !important; }
#filmCap { position: fixed; left: 0; right: 0; top: 7%; text-align: center; font-family: var(--serif); color: #fff; font-size: 54px; letter-spacing: .06em; line-height: 1.25; padding: 0 60px; text-shadow: 0 2px 24px rgba(20, 12, 50, .55), 0 0 2px rgba(20, 12, 50, .4); pointer-events: none; z-index: 20; }
#filmCap small { display: block; font-family: var(--sans); font-size: 26px; letter-spacing: .3em; text-transform: uppercase; opacity: .85; margin-bottom: 14px; }
#filmEnd { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; background: linear-gradient(#171c38, #3d3f70); color: #fff; z-index: 30; pointer-events: none; }
#filmEnd h1 { font-size: 110px; margin: 0 0 0 .42em; }
#filmEnd p { margin: 0; font-family: var(--serif); font-size: 40px; font-style: italic; opacity: .9; }
#filmEnd .tag { font-family: var(--sans); font-style: normal; font-size: 30px; letter-spacing: .2em; opacity: .75; margin-top: 40px; }
#filmEnd svg { width: 120px; height: 120px; filter: drop-shadow(0 0 30px rgba(255, 220, 140, .9)); }
