:root {
  --ink: #3b2a1f;
  --paper: #fffaf0;
  --gold: #ffbf3f;
  --green: #4cc16a;
  --red: #e0524b;
  font: 18px/1.3 "Nunito", "Trebuchet MS", system-ui, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #8fd0f5; overscroll-behavior: none; }
body { user-select: none; -webkit-user-select: none; }
[hidden] { display: none !important; }
#app { position: fixed; inset: 0; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: pointer; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; touch-action: manipulation; }
button:focus-visible { outline: 4px solid #2b6fff; outline-offset: 2px; }

/* ---------- HUD ---------- */
#hud { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 10px; right: 10px; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; pointer-events: none; z-index: 10; }
#hud > * { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#hud-right, .hud-right { justify-content: flex-end; }
.chip { pointer-events: auto; display: flex; gap: 6px; align-items: center; padding: 8px 16px; border-radius: 999px; background: rgba(255, 250, 240, .93); box-shadow: 0 3px 0 rgba(0, 0, 0, .15); font-weight: 800; font-size: 1.15rem; }
.round { pointer-events: auto; width: 56px; height: 56px; border-radius: 50%; background: rgba(255, 250, 240, .95); box-shadow: 0 4px 0 rgba(0, 0, 0, .18); font-size: 1.8rem; display: grid; place-items: center; }
.round:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, .18); }
.round.quiet { opacity: .7; width: 46px; height: 46px; font-size: 1.3rem; }

/* ---------- Maskot ---------- */
#mascot { position: absolute; left: 10px; top: 76px; display: flex; gap: 8px; align-items: flex-start; max-width: min(78vw, 420px); pointer-events: none; z-index: 9; }
.mascot-face { flex: none; width: 64px; height: 64px; border-radius: 18px; background: #ffd9a0; display: grid; place-items: center; font-size: 2.6rem; box-shadow: 0 4px 0 rgba(0, 0, 0, .18); animation: bob 2.4s ease-in-out infinite; }
#bubble { background: #fff; border-radius: 18px; padding: 10px 14px; font-weight: 800; font-size: 1.15rem; box-shadow: 0 4px 0 rgba(0, 0, 0, .15); opacity: 0; transform: translateY(-6px) scale(.95); transition: .25s; position: relative; margin-top: 6px; }
#bubble.show { opacity: 1; transform: none; }
#bubble::before { content: ""; position: absolute; left: -8px; top: 14px; border: 8px solid transparent; border-right-color: #fff; border-left: 0; }
@keyframes bob { 50% { transform: translateY(-4px); } }

/* ---------- Joystick ve kamera ---------- */
#joystick { position: absolute; left: max(18px, env(safe-area-inset-left)); bottom: max(22px, env(safe-area-inset-bottom)); width: 150px; height: 150px; border-radius: 50%; background: rgba(255, 255, 255, .38); border: 4px solid rgba(255, 255, 255, .7); touch-action: none; z-index: 8; display: grid; place-items: center; }
#knob { width: 66px; height: 66px; border-radius: 50%; background: rgba(255, 191, 63, .95); box-shadow: 0 4px 0 rgba(0, 0, 0, .2); pointer-events: none; transition: transform .05s; }
#cam-btns { position: absolute; right: 16px; bottom: max(22px, env(safe-area-inset-bottom)); display: flex; gap: 10px; z-index: 8; }
body.building #joystick { display: none; }
body.building #cam-btns { bottom: 190px; }

#play-btn { --c: var(--green); position: absolute; left: 50%; bottom: max(30px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: center; gap: 14px; padding: 14px 28px; border-radius: 999px; background: var(--c); color: #fff; font-size: 1.7rem; font-weight: 900; box-shadow: 0 7px 0 rgba(0, 0, 0, .25); z-index: 9; animation: pulse 1.1s ease-in-out infinite; text-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
#play-btn #play-icon { font-size: 2.4rem; text-shadow: none; }
@keyframes pulse { 50% { transform: translateX(-50%) scale(1.07); } }

/* ---------- İnşa çubuğu ---------- */
#buildbar { position: absolute; left: 0; right: 0; bottom: 0; z-index: 9; background: rgba(255, 250, 240, .96); border-radius: 26px 26px 0 0; padding: 10px 12px max(12px, env(safe-area-inset-bottom)); box-shadow: 0 -4px 0 rgba(0, 0, 0, .12); }
#taskbar { display: flex; align-items: center; gap: 10px; background: #fff0b8; border-radius: 16px; padding: 8px 12px; margin-bottom: 8px; font-size: 1.15rem; }
#taskbar #task-icon { font-size: 1.8rem; }
#taskbar #task-text { flex: 1; }
#task-progress { font-weight: 900; font-size: 1.3rem; }
.small-btn { min-width: 48px; height: 48px; border-radius: 14px; background: #eadfca; font-size: 1.4rem; box-shadow: 0 3px 0 rgba(0, 0, 0, .15); }
.palette { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: thin; }
.swatch-btn { position: relative; flex: none; width: 68px; height: 68px; border-radius: 18px; background: #f1e6d0; border: 5px solid transparent; display: grid; place-items: center; box-shadow: 0 3px 0 rgba(0, 0, 0, .15); }
.swatch-btn.on { border-color: #2b6fff; background: #fff; }
.swatch-btn .chip-color { width: 40px; height: 40px; border-radius: 10px; box-shadow: inset 0 -5px rgba(0, 0, 0, .15), inset 0 0 0 2px rgba(0, 0, 0, .1); }
.swatch-btn .emoji { font-size: 2.1rem; }
.swatch-btn.locked { opacity: .55; }
.swatch-btn em { position: absolute; bottom: -2px; left: 0; right: 0; font-style: normal; font-size: .7rem; font-weight: 900; background: rgba(60, 40, 30, .8); color: #fff; border-radius: 8px; padding: 1px 0; }
.tools { display: flex; gap: 8px; justify-content: space-between; }
.tools button { flex: 1; height: 58px; border-radius: 16px; background: #eadfca; font-size: 1.9rem; box-shadow: 0 4px 0 rgba(0, 0, 0, .15); }
.tools button.on { background: #ffd36b; }
.tools button.armed { background: #ff9d8f; animation: pulse2 .5s infinite alternate; }
.tools button.ok { background: var(--green); color: #fff; }
@keyframes pulse2 { to { transform: scale(1.06); } }

/* ---------- Paneller ---------- */
#screen { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(30, 50, 90, .5); padding: 12px; backdrop-filter: blur(3px); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet { position: relative; width: min(100%, 640px); max-height: 100%; overflow: auto; background: var(--paper); border-radius: 30px; padding: 22px 20px 24px; box-shadow: 0 10px 0 rgba(0, 0, 0, .18); animation: pop .25s; }
.sheet.wide { width: min(100%, 760px); }
@keyframes pop { from { transform: scale(.9); opacity: 0; } }
.sheet h2 { margin: 0 56px 8px 0; font-size: 1.7rem; }
.rest h2, .gate h2, .result h2 { margin-right: 0; text-align: center; }
.sub { margin: 0 0 12px; opacity: .75; }
.close { position: absolute; top: 12px; right: 12px; width: 56px; height: 56px; border-radius: 50%; background: var(--red); color: #fff; font-size: 1.5rem; font-weight: 900; box-shadow: 0 4px 0 rgba(0, 0, 0, .2); z-index: 2; }
.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-10px); } 75% { transform: translateX(10px); } }

.big-btn { padding: 16px 30px; border-radius: 22px; background: var(--green); color: #fff; font-size: 1.6rem; font-weight: 900; box-shadow: 0 6px 0 rgba(0, 0, 0, .22); text-shadow: 0 2px 0 rgba(0, 0, 0, .2); }
.big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0, 0, 0, .22); }

.map-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 10px; }
.map-btn { --c: #ffb347; padding: 16px 8px; border-radius: 24px; background: var(--c); color: #fff; display: grid; gap: 4px; place-items: center; font-size: 1.25rem; box-shadow: 0 6px 0 rgba(0, 0, 0, .22); text-shadow: 0 2px 0 rgba(0, 0, 0, .22); }
.map-btn span { font-size: 3.6rem; text-shadow: none; }
a.map-btn { text-decoration: none; }
.map-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0, 0, 0, .22); }

/* ---------- Soru ekranı ---------- */
.quiz, .cafe, .memory { --c: #4a8fe0; }
.q-top { display: flex; align-items: center; gap: 12px; margin-right: 64px; }
.q-icon { font-size: 2.4rem; }
.q-level { margin-left: auto; font-size: .9rem; font-weight: 800; }
.dots { display: flex; gap: 8px; }
.dots i { width: 20px; height: 20px; border-radius: 50%; background: #e3d8c3; }
.dots i.now { background: #fff; box-shadow: 0 0 0 4px var(--gold); }
.dots i.gold { background: var(--gold); }
.dots i.green { background: var(--green); }
.q-prompt { display: flex; align-items: center; gap: 12px; margin: 14px 0 4px; }
.replay { flex: none; width: 60px; height: 60px; border-radius: 50%; background: var(--c); color: #fff; font-size: 1.8rem; box-shadow: 0 4px 0 rgba(0, 0, 0, .2); }
.q-text { font-size: 1.5rem; font-weight: 900; }
.q-show { min-height: 120px; display: grid; place-items: center; padding: 8px 0; text-align: center; }
.items { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; font-size: 3rem; line-height: 1.1; }
.items span { animation: drop .4s backwards; }
.items.shapes { gap: 8px; }
.sum { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center; }
.sum b { font-size: 3rem; }
@keyframes drop { from { transform: translateY(-14px) scale(.6); opacity: 0; } }
.big-emoji { font-size: 6rem; line-height: 1; }
.caption { font-size: 1.3rem; font-weight: 800; }
.big-letter { font-size: 7.5rem; font-weight: 900; line-height: 1; color: var(--c); font-family: "Comic Sans MS", "Chalkboard SE", system-ui, sans-serif; }
.sound-word { font-size: 2.6rem; font-weight: 900; color: var(--c); }
.pattern, .stack { display: flex; gap: 10px; font-size: 3.2rem; justify-content: center; align-items: center; }
.stack { flex-direction: column; gap: 14px; }
.pattern .hole { animation: bob 1s infinite; }
.q-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-top: 10px; }
.q-options.wide { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.opt { min-height: 110px; padding: 10px; border-radius: 24px; background: #fff; border: 5px solid color-mix(in srgb, var(--c) 55%, #fff); box-shadow: 0 6px 0 rgba(0, 0, 0, .15); display: grid; place-items: center; gap: 2px; font-size: 2.6rem; }
.opt:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0, 0, 0, .15); }
.opt .num { font-size: 3.8rem; font-weight: 900; color: var(--c); }
.opt .letter { font-size: 4rem; font-weight: 900; color: var(--c); }
.opt .pic { font-size: 4rem; line-height: 1; }
.opt small { font-size: 1.05rem; font-weight: 800; }
.opt .swatch { width: 70px; height: 70px; border-radius: 50%; box-shadow: inset 0 -6px rgba(0, 0, 0, .15), 0 0 0 3px rgba(0, 0, 0, .1); }
.opt .items { font-size: 2rem; }
.opt.right { background: #d6f7dc; border-color: var(--green); animation: hop .4s; }
.opt.wrong { opacity: .35; }
.opt.hint { animation: glow .7s infinite alternate; }
@keyframes hop { 50% { transform: scale(1.1); } }
@keyframes glow { to { box-shadow: 0 0 0 8px rgba(255, 191, 63, .85); } }

/* ---------- Ver oyunu ---------- */
.give { display: grid; gap: 10px; width: 100%; }
.bin { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; background: #f1e6d0; border-radius: 18px; padding: 8px; }
.bin-item { font-size: 2.4rem; background: transparent; padding: 4px; border-radius: 12px; line-height: 1.1; min-height: 56px; }
.bin-item.gone { visibility: hidden; }
.basket { min-height: 76px; border: 4px dashed #c9ac7a; border-radius: 20px; display: flex; align-items: center; gap: 8px; padding: 6px 10px; }
.basket-label { font-size: 2.4rem; }
.basket-items { display: flex; flex-wrap: wrap; font-size: 2rem; }
.basket-items span { animation: drop .3s backwards; }
.give-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.basket-count { font-size: 2.6rem; color: var(--c); }

/* ---------- Kafe ---------- */
.cafe-top { display: flex; align-items: center; gap: 12px; margin: 12px 0; }
.guest { font-size: 4.2rem; line-height: 1; flex: none; animation: bob 2s infinite; }
.order-card { flex: 1; background: #fff; border: 4px solid #d9c3a0; border-radius: 20px; padding: 8px 12px; display: grid; gap: 4px; }
.o-row { display: flex; align-items: center; gap: 10px; }
.o-row .num { font-size: 2.4rem; font-weight: 900; color: var(--c); min-width: 1ch; }
.o-row .x { font-size: 1.4rem; opacity: .6; }
.cups { display: flex; flex-wrap: wrap; gap: 4px; }
.cup { display: inline-block; position: relative; width: 28px; height: 34px; background: var(--cc); border-radius: 4px 4px 12px 12px; box-shadow: inset 0 -5px rgba(0, 0, 0, .15); }
.cup::after { content: ""; position: absolute; right: -10px; top: 7px; width: 12px; height: 16px; border: 4px solid #d9c3a0; border-left: 0; border-radius: 0 10px 10px 0; }
.cup.big { width: 54px; height: 64px; }
.cup.big::after { right: -16px; top: 12px; width: 20px; height: 28px; border-width: 6px; }
.tray-area { display: flex; align-items: center; gap: 10px; }
.tray { flex: 1; min-height: 80px; background: #c9a36a; border-radius: 18px; border-bottom: 8px solid #a67f48; display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; padding: 10px 18px; }
.tray .cup { animation: drop .3s backwards; }
.stations { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.station { padding: 14px 4px 10px; border-radius: 22px; background: #fff; border: 5px solid #d9c3a0; display: grid; place-items: center; gap: 8px; font-size: 1.2rem; box-shadow: 0 6px 0 rgba(0, 0, 0, .15); }
.station:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0, 0, 0, .15); }
.station b { text-transform: capitalize; }

/* ---------- Hafıza ---------- */
.cards { display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: 10px; margin-top: 16px; max-width: 520px; margin-inline: auto; }
.mcard { aspect-ratio: 1; border-radius: 20px; background: var(--c); box-shadow: 0 6px 0 rgba(0, 0, 0, .2); font-size: 3.2rem; display: grid; place-items: center; }
.mcard .face { display: grid; place-items: center; width: 100%; height: 100%; border-radius: 20px; }
.mcard .front { color: #fff; font-weight: 900; }
.mcard .back { display: none; background: #fff; border: 5px solid var(--c); font-size: 3.4rem; animation: hop .35s; }
.mcard.flip .front, .mcard.matched .front { display: none; }
.mcard.flip .back, .mcard.matched .back { display: grid; }
.mcard.matched .back { background: #d6f7dc; border-color: var(--green); }

/* ---------- Sonuç ---------- */
.result { text-align: center; padding-top: 6px; }
.result h2 { margin: 0 0 10px; }
.stars { font-size: 4.2rem; display: flex; justify-content: center; gap: 6px; }
.stars span { filter: grayscale(1); opacity: .25; transform: scale(.8); }
.stars span.on { filter: none; opacity: 1; animation: starpop .5s backwards; transform: none; }
@keyframes starpop { from { transform: scale(0) rotate(-90deg); } 60% { transform: scale(1.4); } }
.new-sticker { margin: 10px 0; display: grid; place-items: center; }
.new-sticker span { font-size: 5rem; animation: starpop .7s .8s backwards; }
.level-up { display: inline-block; background: #d6f7dc; padding: 6px 16px; border-radius: 999px; font-weight: 900; margin: 6px 0; }
.r-btns { display: flex; gap: 12px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.r-btns .done { background: var(--gold); }

/* ---------- Albüm ve ebeveyn ---------- */
.album { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 10px; }
.sticker { aspect-ratio: 1; border-radius: 20px; background: #e9dfca; display: grid; place-items: center; font-size: 2.6rem; color: #b8a98a; font-weight: 900; }
.sticker.got { background: #fff; box-shadow: 0 4px 0 rgba(0, 0, 0, .12); font-size: 3.2rem; animation: hop .4s; }
.gate { text-align: center; }
.gate-q { font-size: 3rem; font-weight: 900; margin: 10px 0 16px; }
.numpad { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; max-width: 460px; margin: auto; }
.numpad button { height: 64px; border-radius: 16px; background: #eadfca; font-size: 1.8rem; font-weight: 900; box-shadow: 0 4px 0 rgba(0, 0, 0, .15); }
.parent .settings { display: grid; gap: 8px; }
.row { display: flex; justify-content: space-between; align-items: center; background: #fff; border-radius: 14px; padding: 10px 14px; font-size: 1.05rem; font-weight: 800; }
.row input[type="checkbox"] { width: 28px; height: 28px; accent-color: var(--green); }
.row select { font: inherit; padding: 6px 8px; border-radius: 10px; border: 2px solid #d9c3a0; background: #fff; }
.progress { width: 100%; border-collapse: collapse; margin: 8px 0 14px; font-size: .95rem; }
.progress th, .progress td { padding: 6px 8px; border-bottom: 1px solid #e3d8c3; text-align: left; }
.danger { padding: 10px 18px; border-radius: 12px; background: #ffd8d3; color: #8a2a22; font-weight: 800; }
.rest { text-align: center; }
.rest .big { font-size: 6rem; }
.adult-btn { margin-top: 12px; padding: 12px 20px; border-radius: 16px; background: #eadfca; font-weight: 800; font-size: 1.05rem; }

/* ---------- Konfeti ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.confetti span { position: absolute; top: -50px; animation: fall 1.7s ease-in forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

/* ---------- Karşılama ---------- */
#welcome { position: absolute; inset: 0; z-index: 40; display: grid; place-items: center; padding: 14px; background: linear-gradient(rgba(143, 208, 245, .15), rgba(30, 50, 90, .35)); transition: opacity .5s; }
#welcome.gone { opacity: 0; pointer-events: none; }
.welcome-card { width: min(100%, 520px); text-align: center; background: var(--paper); border-radius: 34px; padding: 26px 20px 22px; box-shadow: 0 12px 0 rgba(0, 0, 0, .18); }
.welcome-card h1 { margin: 0; font-size: 3.2rem; letter-spacing: -.03em; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.welcome-card h1 span { color: #e0803a; }
.tagline { font-size: 1.4rem; font-weight: 800; margin: 4px 0 14px; }
.avatars { display: flex; justify-content: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.avatar-btn { width: 92px; padding: 10px 4px 6px; border-radius: 22px; background: #f1e6d0; border: 5px solid transparent; display: grid; place-items: center; gap: 4px; font-weight: 800; box-shadow: 0 4px 0 rgba(0, 0, 0, .15); }
.avatar-btn.on { border-color: #2b6fff; background: #fff; }
.av { position: relative; width: 52px; height: 64px; background: var(--shirt); border-radius: 6px; }
.av::before { content: ""; position: absolute; left: 6px; top: -10px; width: 40px; height: 36px; background: #e8b48c; border-radius: 6px; border-top: 9px solid var(--hair); }
.av::after { content: ""; position: absolute; left: 13px; top: 8px; width: 7px; height: 7px; background: #222; border-radius: 2px; box-shadow: 19px 0 #222; }
.hint { opacity: .7; font-size: .95rem; margin: 14px 0 0; }

@media (max-width: 640px) {
  :root { font-size: 16px; }
  .round { width: 50px; height: 50px; font-size: 1.5rem; }
  .chip { padding: 6px 12px; font-size: 1rem; }
  #joystick { width: 128px; height: 128px; }
  #knob { width: 56px; height: 56px; }
  #mascot { top: 128px; }
  .q-text { font-size: 1.25rem; }
  .big-letter { font-size: 6rem; }
}
@media (max-height: 520px) {
  #joystick { width: 108px; height: 108px; }
  #mascot { top: 70px; }
  .sheet { padding: 14px; }
  .q-show { min-height: 80px; }
  .items { font-size: 2.2rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
