:root {
  --bg: #0b0626;
  --ink: #ffffff;
  --muted: #b9b2e8;
  --cyan: #3df5ff;
  --pink: #ff5dc8;
  --gold: #ffd23f;
  --violet: #a77bff;
  --red: #ff3d6e;
  --glass: rgba(30, 18, 80, .62);
  --glass-b: rgba(160, 140, 255, .35);
  --font: 'Baloo 2', 'Trebuchet MS', system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--font); user-select: none; -webkit-user-select: none; touch-action: none; }
[hidden] { display: none !important; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
button { font-family: inherit; color: inherit; cursor: pointer; border: 0; }
button:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

.sprite { display: inline-block; background-repeat: no-repeat; flex: none; }

/* ---------- HUD ---------- */
#hud { position: fixed; top: 0; left: 0; right: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: max(10px, env(safe-area-inset-top)) 14px 8px; pointer-events: none; }
#hud > * { pointer-events: auto; }
.hud-btn { width: 44px; height: 44px; border-radius: 14px; background: var(--glass); border: 2px solid var(--glass-b); font-size: 20px; font-weight: 800; backdrop-filter: blur(6px); transition: transform .15s; }
.hud-btn:hover { transform: scale(1.08); }
.hud-btn:active { transform: scale(.94); }
.hud-btn.off { opacity: .45; }
.hud-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.hud-title b { font-size: clamp(16px, 2.4vw, 22px); line-height: 1; white-space: nowrap; text-shadow: 0 2px 10px rgba(0,0,0,.5); }
.dots { display: flex; gap: 5px; margin-top: 5px; }
.dots i { width: 14px; height: 6px; border-radius: 4px; background: rgba(255,255,255,.18); transition: background .3s, width .3s; }
.dots i.done { background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.dots i.miss { background: var(--gold); }
.dots i.now { width: 24px; background: #fff; }
.hud-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.coins, .combo { display: flex; align-items: center; gap: 4px; height: 44px; padding: 0 12px 0 6px; border-radius: 22px; background: var(--glass); border: 2px solid var(--glass-b); font-size: 20px; }
.coins b { min-width: 2ch; }
.combo { border-color: var(--gold); color: var(--gold); animation: pulse .6s infinite alternate; }
@keyframes pulse { to { transform: scale(1.08); box-shadow: 0 0 18px rgba(255,210,63,.6); } }
.bump { animation: bump .35s; }
@keyframes bump { 40% { transform: scale(1.35); } }

/* ---------- prompt ---------- */
#prompt { position: fixed; z-index: 4; left: 50%; top: calc(max(10px, env(safe-area-inset-top)) + 58px); transform: translateX(-50%); max-width: min(92vw, 820px); text-align: center; font-size: clamp(18px, 3vw, 30px); font-weight: 800; line-height: 1.15; padding: 8px 22px; border-radius: 20px; background: linear-gradient(135deg, rgba(61,245,255,.16), rgba(167,123,255,.2)); border: 2px solid rgba(61,245,255,.35); text-shadow: 0 2px 12px rgba(0,0,0,.6); pointer-events: none; }
#prompt.pop { animation: promptIn .45s cubic-bezier(.2,1.6,.4,1); }
@keyframes promptIn { from { transform: translateX(-50%) scale(.6); opacity: 0; } }
#prompt em { font-style: normal; color: var(--gold); }

#timer { position: fixed; z-index: 4; left: 50%; transform: translateX(-50%); width: min(60vw, 420px); height: 10px; border-radius: 6px; background: rgba(255,255,255,.12); overflow: hidden; }
#timer-fill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--red), var(--gold), var(--cyan)); border-radius: 6px; transform-origin: left; }

/* ---------- bottom panel ---------- */
#panel { position: fixed; z-index: 4; left: 0; right: 0; bottom: 0; padding: 10px 12px max(14px, env(safe-area-inset-bottom)); display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.choice { position: relative; min-width: 140px; flex: 1 1 140px; max-width: 220px; min-height: 78px; padding: 8px 10px; border-radius: 20px; background: linear-gradient(180deg, rgba(70,48,170,.85), rgba(32,18,96,.9)); border: 2px solid var(--glass-b); box-shadow: 0 6px 0 rgba(10,4,40,.8), 0 10px 30px rgba(0,0,0,.35); font-size: clamp(16px, 2.3vw, 22px); font-weight: 800; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; transition: transform .12s, border-color .2s, background .2s; }
.choice:hover { transform: translateY(-3px); border-color: var(--cyan); }
.choice:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(10,4,40,.8); }
.choice canvas { width: 100%; height: 64px; display: block; pointer-events: none; }
.choice.big canvas { height: 92px; }
.choice.good { background: linear-gradient(180deg, #1ec98a, #0b7a55); border-color: #9fffd8; animation: bump .4s; }
.choice.bad { background: linear-gradient(180deg, #e0325f, #8a0f33); border-color: #ffb3c6; animation: shake .4s; }
.choice.dim { opacity: .45; }
.choice.tool.on { border-color: var(--gold); background: linear-gradient(180deg, rgba(255,210,63,.35), rgba(60,30,120,.9)); box-shadow: 0 0 0 3px rgba(255,210,63,.35), 0 6px 0 rgba(10,4,40,.8); }
.choice small { font-size: 13px; font-weight: 600; color: var(--muted); line-height: 1; }
@keyframes shake { 20%,60% { transform: translateX(-8px); } 40%,80% { transform: translateX(8px); } }

/* notation */
.nt { font-size: clamp(30px, 5vw, 44px); font-weight: 800; letter-spacing: 1px; font-family: 'Baloo 2', Georgia, serif; line-height: 1; display: inline-flex; align-items: flex-end; }
.nt .ov { position: relative; display: inline-block; padding-top: .42em; }
.nt .ov::before { content: ''; position: absolute; left: -2px; right: -2px; top: .14em; height: 3px; background: currentColor; border-radius: 2px; }
.nt .ov.r::after, .nt .ov.lr::after, .nt .ov.lr > i { content: ''; position: absolute; top: calc(.14em - 6px); width: 0; height: 0; border-top: 7.5px solid transparent; border-bottom: 7.5px solid transparent; }
.nt .ov.r::after, .nt .ov.lr::after { right: -6px; border-left: 12px solid currentColor; }
.nt .ov.lr > i { left: -6px; border-right: 12px solid currentColor; }
.nt.huge { font-size: clamp(60px, 11vw, 110px); color: var(--cyan); text-shadow: 0 0 30px rgba(61,245,255,.6); }
.nt.huge .ov::before { height: 6px; top: .1em; }
.nt.huge .ov.r::after, .nt.huge .ov.lr::after, .nt.huge .ov.lr > i { top: calc(.1em - 11px); border-top-width: 14px; border-bottom-width: 14px; }
.nt.huge .ov.r::after, .nt.huge .ov.lr::after { right: -12px; border-left-width: 22px; }
.nt.huge .ov.lr > i { left: -12px; border-right-width: 22px; }
#bigNotation { position: fixed; z-index: 3; left: 50%; top: 46%; transform: translate(-50%,-50%); pointer-events: none; }

/* ---------- toast / mascot ---------- */
#toast { position: fixed; z-index: 6; left: 50%; transform: translateX(-50%); bottom: 150px; display: flex; align-items: center; gap: 12px; max-width: min(92vw, 640px); padding: 10px 20px 10px 10px; border-radius: 26px; background: rgba(20,10,60,.92); border: 2px solid var(--glass-b); box-shadow: 0 14px 40px rgba(0,0,0,.5); animation: toastIn .4s cubic-bezier(.2,1.5,.4,1); pointer-events: none; }
#toast p { margin: 0; font-size: clamp(16px, 2.3vw, 21px); font-weight: 700; line-height: 1.2; }
#toast.good { border-color: #4dffb5; }
#toast.bad { border-color: var(--gold); }
#toast b { color: var(--gold); }
@keyframes toastIn { from { transform: translateX(-50%) translateY(30px) scale(.8); opacity: 0; } }

/* ---------- overlays ---------- */
#overlay { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#overlay > * { pointer-events: auto; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; text-align: center; animation: fadeIn .4s; }
.screen.dim { background: radial-gradient(ellipse at center, rgba(11,6,38,.55), rgba(11,6,38,.92)); }
@keyframes fadeIn { from { opacity: 0; } }
.title { font-size: clamp(46px, 10vw, 112px); font-weight: 800; line-height: .9; margin: 0; background: linear-gradient(180deg, #fff 20%, #8ff8ff 55%, #b48bff); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 24px rgba(61,245,255,.45)); animation: floaty 3s ease-in-out infinite; }
.title span { display: block; font-size: .45em; background: linear-gradient(90deg, var(--gold), #ff8a3d); -webkit-background-clip: text; background-clip: text; letter-spacing: .06em; }
@keyframes floaty { 50% { transform: translateY(-10px); } }
.sub { color: var(--muted); font-size: clamp(16px, 2.4vw, 22px); font-weight: 600; margin: 10px 0 26px; max-width: 600px; }
.cta { font-size: clamp(24px, 4vw, 36px); font-weight: 800; padding: 14px 54px; border-radius: 999px; background: linear-gradient(180deg, #ffe066, #ff9f1c); color: #3a1500; box-shadow: 0 8px 0 #b35c00, 0 0 40px rgba(255,210,63,.55); animation: ctaPulse 1.2s ease-in-out infinite; transition: transform .1s; }
.cta:active { transform: translateY(5px); box-shadow: 0 3px 0 #b35c00; }
.cta.alt { background: linear-gradient(180deg, #9ffcff, #2bb3ff); color: #062046; box-shadow: 0 8px 0 #135b9e, 0 0 30px rgba(61,245,255,.45); animation: none; }
@keyframes ctaPulse { 50% { transform: scale(1.06); } }
.row { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }

/* map */
.map { position: absolute; inset: 0; text-align: center; }
.map h2 { position: absolute; top: calc(max(10px, env(safe-area-inset-top)) + 54px); left: 0; right: 0; margin: 0; font-size: clamp(26px, 4.6vw, 46px); line-height: 1; text-shadow: 0 0 20px rgba(167,123,255,.8); }
.map h2 small { display: block; font-size: .42em; color: var(--muted); font-weight: 600; margin-top: 6px; }
.planet { position: absolute; transform: translate(-50%, -50%); background: none; display: flex; flex-direction: column; align-items: center; gap: 2px; transition: transform .2s; }
.planet:hover { transform: translate(-50%, -50%) scale(1.07); }
.planet .sprite { filter: drop-shadow(0 0 22px rgba(167,123,255,.55)); animation: spinFloat 6s ease-in-out infinite; }
.planet:nth-of-type(2) .sprite { animation-delay: -1.5s; }
.planet:nth-of-type(3) .sprite { animation-delay: -3s; }
.planet:nth-of-type(4) .sprite { animation-delay: -4.5s; }
@keyframes spinFloat { 50% { transform: translateY(-10px) rotate(4deg); } }
.planet b { font-size: clamp(16px, 2.3vw, 22px); line-height: 1; text-shadow: 0 2px 8px #000; }
.planet small { font-size: 13px; color: var(--muted); font-weight: 600; }
.planet .stars { color: rgba(255,255,255,.2); font-size: 20px; letter-spacing: 2px; line-height: 1; }
.planet .stars .on { color: var(--gold); text-shadow: 0 0 10px var(--gold); }
.planet.next::after { content: 'BURADAN BAŞLA'; position: absolute; top: -18px; font-size: 12px; font-weight: 800; letter-spacing: .08em; color: #2a1200; background: var(--gold); padding: 2px 10px; border-radius: 10px; animation: ctaPulse 1s infinite; white-space: nowrap; }
.rocket { position: absolute; transform: translate(-50%, -50%); pointer-events: none; transition: left 1.1s cubic-bezier(.6,0,.3,1), top 1.1s cubic-bezier(.6,0,.3,1); filter: drop-shadow(0 0 16px rgba(255,140,60,.8)); z-index: 2; }

/* teach cards */
.teach { width: min(94vw, 760px); background: linear-gradient(180deg, rgba(40,24,110,.95), rgba(18,10,58,.97)); border: 2px solid var(--glass-b); border-radius: 30px; padding: 20px 22px 22px; box-shadow: 0 30px 80px rgba(0,0,0,.6), 0 0 60px rgba(167,123,255,.25); position: relative; animation: cardIn .5s cubic-bezier(.2,1.4,.4,1); }
@keyframes cardIn { from { transform: scale(.7) rotate(-3deg); opacity: 0; } }
.teach .face { position: absolute; top: -48px; left: 22px; }
.teach h3 { margin: 6px 0 0; font-size: clamp(30px, 5vw, 46px); line-height: 1; }
.teach .tag { display: inline-block; font-size: 13px; letter-spacing: .1em; font-weight: 800; color: var(--muted); }
.teach canvas { width: 100%; height: clamp(150px, 30vh, 240px); display: block; margin: 10px 0; border-radius: 18px; background: rgba(0,0,0,.25); }
.teach p { margin: 0 0 8px; font-size: clamp(17px, 2.5vw, 22px); line-height: 1.3; font-weight: 600; }
.teach .facts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 6px 0 14px; }
.teach .facts span { padding: 4px 12px; border-radius: 12px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.15); font-size: 16px; font-weight: 700; }
.teach .steps { display: flex; justify-content: center; gap: 6px; margin-bottom: 12px; }
.teach .steps i { width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,.2); }
.teach .steps i.on { background: var(--gold); box-shadow: 0 0 10px var(--gold); }

/* results */
.result .sprite { filter: drop-shadow(0 0 30px rgba(255,210,63,.6)); animation: floaty 2.5s ease-in-out infinite; }
.bigstars { display: flex; gap: 10px; margin: 10px 0 4px; }
.bigstars span { font-size: clamp(54px, 9vw, 84px); color: rgba(255,255,255,.15); line-height: 1; transform: scale(0); animation: starIn .5s cubic-bezier(.2,1.8,.4,1) forwards; }
.bigstars span.on { color: var(--gold); text-shadow: 0 0 30px var(--gold); }
@keyframes starIn { to { transform: scale(1); } }
.result h2 { font-size: clamp(34px, 6vw, 60px); margin: 0; line-height: 1; }
.result .sub { margin: 8px 0 20px; }
.recap { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 6px 0 22px; width: min(94vw, 760px); }
.recap div { background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.14); border-radius: 18px; padding: 8px; }
.recap canvas { width: 100%; height: 60px; display: block; }
.recap b { font-size: 16px; display: block; }
.recap small { color: var(--muted); font-size: 13px; line-height: 1.1; display: block; }
@media (max-width: 560px) { .recap { grid-template-columns: repeat(2, 1fr); } }

@media (max-width: 640px) {
  .choice { min-width: calc(50% - 10px); flex-basis: calc(50% - 10px); min-height: 64px; }
  .choice canvas { height: 50px; }
  .choice.big canvas { height: 70px; }
  .hud-title b { display: none; }
  #hud { gap: 6px; padding-left: 8px; padding-right: 8px; }
  .hud-right { gap: 5px; }
  .hud-btn { width: 40px; height: 40px; }
  .coins, .combo { height: 40px; font-size: 18px; }
  #toast { bottom: 170px; }
}
@media (max-height: 520px) {
  .choice { min-height: 54px; }
  .choice canvas { height: 40px; }
  #toast { bottom: 96px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
#prompt .nt { font-size: 1.3em; vertical-align: -0.08em; }
.choice .nt { font-size: clamp(26px, 4vw, 36px); }
.nt.huge .ov { padding-top: .14em; }
.nt.huge .ov::before { top: .02em; }
.nt.huge .ov.r::after, .nt.huge .ov.lr::after, .nt.huge .ov.lr > i { top: calc(.02em - 11px); }
@media (max-width: 420px) { .dots i { width: 8px; } .dots i.now { width: 14px; } .dots { gap: 3px; } }
