:root {
  --sky1: #1e40af;
  --sky2: #2563eb;
  --sky3: #0ea5e9;
  --frame: #2563eb;
  --ink: #0f172a;
  --muted: #64748b;
  --white: #ffffff;
  --yellow: #facc15;
  --radius: 28px;
  --font: 'Baloo 2', ui-rounded, 'SF Pro Rounded', 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; }

/* Sayfa kendisi asla kaymaz: tahta yerinde sabit kalır (iOS lastik efekti dahil). */
html, body { height: 100%; margin: 0; overscroll-behavior: none; }
body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  font-family: var(--font);
  color: var(--white);
  background: radial-gradient(ellipse at 50% 0%, #3b82f6 0%, var(--sky2) 35%, var(--sky1) 100%);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  flex-direction: column;
}

a, button { touch-action: manipulation; font-family: inherit; }

/* ---------- arka plan ---------- */
.sky {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
  background-image:
    radial-gradient(2px 2px at 12% 18%, #fff8 50%, transparent 51%),
    radial-gradient(2px 2px at 82% 12%, #fff9 50%, transparent 51%),
    radial-gradient(3px 3px at 70% 40%, #fff6 50%, transparent 51%),
    radial-gradient(2px 2px at 30% 70%, #fff7 50%, transparent 51%),
    radial-gradient(3px 3px at 90% 78%, #fff8 50%, transparent 51%),
    radial-gradient(2px 2px at 8% 88%, #fff6 50%, transparent 51%),
    radial-gradient(2px 2px at 50% 92%, #fff6 50%, transparent 51%);
}
.float-letter {
  position: absolute; font-weight: 800; font-size: clamp(34px, 6vw, 72px); line-height: 1;
  text-shadow: 0 4px 0 rgba(0,0,0,.18), 0 10px 18px rgba(0,0,0,.25);
  animation: bob 6s ease-in-out infinite;
}
.fl-a { color: #a855f7; left: 2%; top: 12%; }
.fl-b { color: #facc15; right: 3%; top: 11%; animation-delay: -2s; }
.fl-c { color: #84cc16; left: 22%; top: 7%; animation-delay: -1s; font-size: clamp(28px, 4vw, 52px); }
.fl-d { color: #ec4899; right: 2%; top: 48%; animation-delay: -3s; }
.fl-e { color: #fb923c; right: 20%; top: 7%; animation-delay: -4s; font-size: clamp(28px, 4vw, 52px); }
.fl-f { color: #facc15; right: 3%; top: 30%; animation-delay: -2.5s; font-size: clamp(28px, 4vw, 52px); }
.fl-g { color: #67e8f9; right: 3%; top: 66%; animation-delay: -5s; font-size: clamp(28px, 4vw, 52px); }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-4deg); } }

/* ---------- üst menü ---------- */
.topbar {
  position: relative; z-index: 3;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(8px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  background: rgba(15, 23, 42, .28);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-size: 22px; font-weight: 800; }
.brand b { color: var(--yellow); }
.brand-icon { font-size: 22px; }
.toplinks { display: flex; gap: 8px; flex-wrap: nowrap; }
.toplinks a {
  color: #fff; text-decoration: none; font-weight: 600; font-size: 15px; white-space: nowrap;
  padding: 6px 14px; border-radius: 999px; background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2); transition: background .15s;
}
.toplinks a:hover { background: rgba(255,255,255,.25); }

/* ---------- yerleşim ---------- */
.layout {
  position: relative; z-index: 1; flex: 1; min-height: 0;
  display: grid; grid-template-columns: 132px 1fr; gap: 16px;
  padding: 14px max(16px, env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.grades {
  align-self: center;
  background: rgba(15, 23, 42, .25); border: 1px solid rgba(255,255,255,.15);
  border-radius: 22px; padding: 12px 10px;
}
.grades-title { margin: 0 0 8px; text-align: center; font-weight: 800; font-size: 15px; color: #dbeafe; }
.grade-list { display: flex; flex-direction: column; gap: 8px; }
.grade-btn {
  display: flex; align-items: baseline; justify-content: center;
  padding: 7px 6px; border-radius: 16px; text-decoration: none; color: #fff;
  background: linear-gradient(#60a5fa, #3b82f6); border: 2px solid rgba(255,255,255,.35);
  box-shadow: 0 4px 0 #1e3a8a; font-size: 16px; transition: transform .1s;
}
.grade-btn b { font-size: 22px; line-height: 1; }
.grade-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #1e3a8a; }
.grade-btn.active { background: linear-gradient(#fde047, #f59e0b); color: #78350f; box-shadow: 0 4px 0 #b45309; }

.stage {
  min-width: 0; min-height: 0;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  touch-action: none;
}

.title-banner {
  margin: 0; padding: 4px 30px 2px; border-radius: 22px; line-height: 1.1;
  font-size: clamp(26px, 4.4vw, 46px); font-weight: 800; letter-spacing: 1px;
  background: linear-gradient(#1d4ed8, #1e3a8a);
  border: 3px solid #93c5fd; box-shadow: 0 6px 0 #172554, 0 12px 26px rgba(0,0,0,.3);
  position: relative;
}
.title-banner::before, .title-banner::after { content: '★'; position: absolute; color: var(--yellow); font-size: .7em; top: -10px; }
.title-banner::before { left: -14px; transform: rotate(-18deg); }
.title-banner::after { right: -14px; transform: rotate(18deg); }
.t1 { color: var(--yellow); text-shadow: 0 3px 0 #b45309; }
.t2 { color: #fff; font-size: .7em; }
.t3 { color: #67e8f9; text-shadow: 0 3px 0 #0369a1; }

.board-wrap {
  flex: 1; min-height: 0; width: 100%; max-width: 1100px;
  padding: 12px; border-radius: calc(var(--radius) + 10px);
  background: linear-gradient(#3b82f6, #1d4ed8);
  border: 3px solid #93c5fd;
  box-shadow: 0 10px 0 #1e3a8a, 0 20px 40px rgba(0,0,0,.35);
}
.board {
  position: relative; width: 100%; height: 100%;
  background: #fff; border-radius: var(--radius); overflow: hidden;
  box-shadow: inset 0 0 0 2px #e2e8f0, inset 0 8px 24px rgba(15,23,42,.08);
  touch-action: none;
}
#canvas { display: block; position: absolute; inset: 0; touch-action: none; cursor: none; }

.pencil {
  position: absolute; left: 0; top: 0; pointer-events: none; opacity: 0;
  transition: opacity .15s; filter: drop-shadow(0 6px 6px rgba(0,0,0,.25)); z-index: 2;
}
.pencil.show { opacity: 1; }

.controls { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; position: relative; }

/* Baykuş: düğme satırının solunda, tahtanın çerçevesine konmuş gibi durur */
.owl {
  width: 108px; height: 50px; position: relative; flex: none; pointer-events: none;
}
.owl svg {
  position: absolute; left: 0; bottom: -6px; width: 108px; height: auto;
  filter: drop-shadow(0 6px 8px rgba(0,0,0,.3));
  transform-origin: 50% 100%;
}
.owl.hop svg { animation: owl-hop .7s ease; }
@keyframes owl-hop { 30% { transform: translateY(-14px) rotate(-6deg); } 60% { transform: translateY(0) rotate(4deg); } }
.progress {
  font-weight: 800; padding: 6px 14px; border-radius: 999px;
  background: rgba(15,23,42,.3); border: 1px solid rgba(255,255,255,.2);
}
.case-toggle { display: flex; background: rgba(15,23,42,.3); border-radius: 999px; padding: 3px; border: 1px solid rgba(255,255,255,.2); }
.case-btn {
  border: 0; background: transparent; color: #dbeafe; font-weight: 800; font-size: 17px;
  padding: 4px 16px; border-radius: 999px; cursor: pointer;
}
.case-btn.active { background: #fff; color: #1d4ed8; }

.btn {
  border: 0; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 17px; padding: 8px 18px; border-radius: 999px; color: #fff;
}
.btn-ghost { background: rgba(255,255,255,.16); border: 2px solid rgba(255,255,255,.35); }
.btn-ghost:hover { background: rgba(255,255,255,.26); }
.btn-play { background: linear-gradient(#4ade80, #16a34a); box-shadow: 0 4px 0 #166534; }
.btn-next { background: linear-gradient(#60a5fa, #2563eb); box-shadow: 0 4px 0 #1e3a8a; }

/* ---------- geri bildirim ---------- */
.toast {
  position: absolute; left: 50%; top: 14px; transform: translate(-50%, -20px); z-index: 4;
  background: #1d4ed8; color: #fff; font-weight: 700; padding: 8px 18px; border-radius: 999px;
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; white-space: nowrap;
  max-width: 92%; overflow: hidden; text-overflow: ellipsis; font-size: 16px;
}
.toast.warn { background: #f97316; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.sparkle { position: absolute; transform: translate(-50%, -50%); font-size: 30px; pointer-events: none; animation: spark .9s ease-out forwards; z-index: 3; }
@keyframes spark { from { opacity: 1; transform: translate(-50%, -30%) scale(.5); } to { opacity: 0; transform: translate(-50%, -120%) scale(1.4); } }

.confetti { position: absolute; top: -20px; font-size: 22px; pointer-events: none; z-index: 3; animation: fall 1.6s ease-in forwards; }
@keyframes fall { to { transform: translate(var(--dx), 110vh) rotate(540deg); opacity: .6; } }

.win {
  position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.55); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  padding: 12px;
}
.win[hidden] { display: none; }
.win-card {
  width: min(520px, 100%); text-align: center; color: var(--ink);
  background: linear-gradient(#fff, #eff6ff); border: 3px solid #93c5fd; border-radius: 26px;
  padding: 16px 20px 20px; box-shadow: 0 16px 40px rgba(30,64,175,.35);
  animation: pop .35s cubic-bezier(.2,1.6,.4,1);
}
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
.win-stars { font-size: 26px; letter-spacing: 6px; }
.win-title { margin: 2px 0 8px; font-size: 30px; font-weight: 800; color: #1d4ed8; }
.suggest {
  display: flex; gap: 10px; align-items: center; text-align: left;
  background: #fef9c3; border: 2px dashed #facc15; border-radius: 18px; padding: 10px 14px;
  font-size: 17px; line-height: 1.35; color: #713f12;
}
.suggest b { color: #b45309; }
.sug-icon { font-size: 34px; }
.win-actions { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }

/* ---------- süsler ---------- */
.decor { position: fixed; inset: 0; pointer-events: none; z-index: 2; }
.books { position: absolute; right: 6px; bottom: 0; width: clamp(100px, 12vw, 170px); filter: drop-shadow(0 8px 12px rgba(0,0,0,.3)); }

/* Arama motorları ve ekran okuyucular için; görsel olarak gizli */
.seo-text {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ---------- tablet ---------- */
@media (max-width: 1100px) {
  .books { display: none; }
  .controls { flex-wrap: nowrap; gap: 8px; }
  .btn { font-size: 15px; padding: 7px 13px; white-space: nowrap; }
  .owl { width: 84px; }
  .owl svg { width: 84px; }
}
@media (max-width: 1300px) {
  .fl-c, .fl-e { display: none; }
}

/* ---------- telefon / dar ekran ---------- */
@media (max-width: 760px) {
  .topbar { padding-top: calc(6px + env(safe-area-inset-top)); padding-bottom: 6px; }
  .brand-name { display: none; }
  .toplinks { gap: 5px; }
  .toplinks a { font-size: 13px; padding: 5px 9px; }
  .progress .pl { display: none; }
  .controls { flex-wrap: nowrap; }
  .layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; gap: 8px; padding-top: 8px; }
  .grades { align-self: stretch; padding: 6px 8px; border-radius: 16px; display: flex; align-items: center; gap: 8px; }
  .grades-title { margin: 0; font-size: 13px; white-space: nowrap; }
  .grade-list { flex-direction: row; flex: 1; gap: 5px; }
  .grade-btn { flex: 1; padding: 5px 0; border-radius: 12px; box-shadow: 0 3px 0 #1e3a8a; }
  .grade-btn span { display: none; }
  .grade-btn b { font-size: 19px; }
  .stage { gap: 8px; }
  .title-banner { font-size: 24px; padding: 2px 18px; border-width: 2px; }
  .board-wrap { padding: 7px; border-radius: 24px; box-shadow: 0 6px 0 #1e3a8a; }
  .board { border-radius: 18px; }
  .controls { gap: 6px; }
  .btn { font-size: 14px; padding: 6px 10px; white-space: nowrap; }
  .progress { font-size: 14px; padding: 5px 10px; }
  .case-btn { font-size: 14px; padding: 3px 9px; }
  .decor, .float-letter { display: none; }
  .owl { width: 54px; height: 36px; }
  .owl svg { width: 54px; bottom: -4px; }
  .win-title { font-size: 24px; }
  .suggest { font-size: 15px; }
}
@media (max-width: 420px) {
  .owl { display: none; }
}
@media (max-width: 340px) {
  .toplinks a span { display: none; }
  .toplinks a { font-size: 18px; padding: 4px 10px; }
}

/* Yatay telefon: başlığı gizle, tahtaya yer aç */
@media (max-height: 500px) and (orientation: landscape) {
  .title-banner, .decor, .float-letter, .owl { display: none; }
  .layout { grid-template-columns: 96px 1fr; grid-template-rows: 1fr; padding-top: 6px; padding-bottom: 6px; }
  .grades { padding: 6px; }
  .grades-title { display: none; }
  .grade-list { flex-direction: column; gap: 4px; }
  .grade-btn { padding: 2px 0; }
  .grade-btn span { display: inline; font-size: 12px; }
  .grade-btn b { font-size: 16px; }
  .topbar { padding-top: 4px; padding-bottom: 4px; }
  .stage { gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .float-letter, .confetti, .sparkle, .win-card { animation: none; }
}
