:root {
  --wood-hi: #f6b45f;
  --wood: #d9843a;
  --wood-lo: #a85a22;
  --wood-dark: #6b3311;
  --cream: #fff6df;
  --cream-2: #ffe8b8;
  --ink: #5a2e12;

  --green: #58cc02;   --green-hi: #7ee21f;  --green-lo: #46a302;
  --blue: #1cb0f6;    --blue-hi: #5fd0ff;   --blue-lo: #1584c2;
  --orange: #ff9600;  --orange-hi: #ffc040; --orange-lo: #d27500;
  --red: #ff4b4b;     --red-hi: #ff8080;    --red-lo: #d22f2f;
  --turq: #3fdde4;    --turq-lo: #19a9b4;
  --gold: #ffd23f;

  --title: 'Baloo 2', 'Nunito', system-ui, sans-serif;
  --body: 'Nunito', system-ui, sans-serif;
  --outline: 0 2px 0 var(--wood-dark), 0 -2px 0 var(--wood-dark), 2px 0 0 var(--wood-dark), -2px 0 0 var(--wood-dark),
             2px 2px 0 var(--wood-dark), -2px 2px 0 var(--wood-dark), 2px -2px 0 var(--wood-dark), -2px -2px 0 var(--wood-dark),
             0 5px 0 var(--wood-dark);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--body);
  color: var(--ink);
  background: #2f8f3a;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
img { -webkit-user-drag: none; }

.scene-bg {
  position: fixed; inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 214, 140, .15), rgba(30, 80, 30, .55)),
    url('../assets/bg.jpg') center 30% / cover no-repeat;
  filter: saturate(1.1);
}

/* ---------- ekranlar ---------- */
.screen {
  position: fixed; inset: 0;
  display: none;
  flex-direction: column; align-items: center; justify-content: center;
  gap: 14px;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  overflow-y: auto;
}
.screen.active { display: flex; animation: fade .25s ease-out; }
@keyframes fade { from { opacity: 0; transform: scale(.98); } }

.logo {
  width: min(360px, 82vw);
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, .35));
  animation: logo-in .6s cubic-bezier(.2, 1.6, .4, 1);
}
@keyframes logo-in { from { transform: scale(.6) rotate(-4deg); opacity: 0; } }

/* ---------- ahşap panel ---------- */
.panel {
  position: relative;
  width: min(420px, 100%);
  margin-top: 26px;
  padding: 14px;
  border-radius: 30px;
  background: linear-gradient(180deg, var(--wood-hi), var(--wood) 40%, var(--wood-lo));
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, .45),
    inset 0 -5px 0 rgba(0, 0, 0, .2),
    0 0 0 4px var(--wood-dark),
    0 14px 0 4px rgba(60, 25, 5, .55),
    0 24px 40px rgba(0, 0, 0, .35);
}
.panel-body {
  display: flex; flex-direction: column; gap: 12px;
  padding: 34px 18px 20px;
  border-radius: 20px;
  background: linear-gradient(180deg, var(--cream), var(--cream-2));
  box-shadow: inset 0 4px 0 rgba(160, 90, 30, .25), inset 0 -3px 0 rgba(255, 255, 255, .7);
}
.panel-body.center { align-items: center; text-align: center; }
.panel-pop { animation: pop .45s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { from { transform: scale(.5); opacity: 0; } }

.ribbon {
  position: absolute; left: 50%; top: -26px; transform: translateX(-50%);
  min-width: 72%;
  padding: 8px 28px 12px;
  text-align: center;
  border-radius: 16px;
  background: linear-gradient(180deg, #5fd36a, #2fa83c);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .45), inset 0 -4px 0 rgba(0, 0, 0, .18), 0 0 0 4px #1d6b27, 0 6px 0 4px #144d1c;
  z-index: 2;
}
.ribbon span {
  font-family: var(--title); font-size: 28px; color: #fff; white-space: nowrap;
  text-shadow: 0 2px 0 #1d6b27, 0 -2px 0 #1d6b27, 2px 0 0 #1d6b27, -2px 0 0 #1d6b27, 0 4px 0 #1d6b27;
}
.ribbon-red { background: linear-gradient(180deg, #ff7a6b, #e5413a); box-shadow: inset 0 3px 0 rgba(255,255,255,.45), inset 0 -4px 0 rgba(0,0,0,.18), 0 0 0 4px #8f1f1a, 0 6px 0 4px #6c1410; }
.ribbon-red span { text-shadow: 0 2px 0 #8f1f1a, 0 -2px 0 #8f1f1a, 2px 0 0 #8f1f1a, -2px 0 0 #8f1f1a, 0 4px 0 #8f1f1a; }
.ribbon-gold { background: linear-gradient(180deg, #ffe066, #ffb703); box-shadow: inset 0 3px 0 rgba(255,255,255,.6), inset 0 -4px 0 rgba(0,0,0,.15), 0 0 0 4px var(--wood-dark), 0 6px 0 4px #4a220a; }
.ribbon-gold span { text-shadow: var(--outline); }

/* Baloo 2: tüm başlık yazıları kalın ve sıkı satır aralıklı */
.btn, .ribbon span, .chip, .stat b, .mini b, .over-score b, .tap-card b, .badge-new, .rank, .row .name, .row .score, .url, .avatar {
  font-weight: 800; line-height: 1.15;
}

.notice {
  margin: 0; padding: 10px 12px; border-radius: 12px;
  background: #e3f6ff; color: #0f6a94; font-weight: 800; font-size: 14px; text-align: center;
}
.notice[hidden] { display: none; }

/* resimli ikon butonu (ses, çıkış) */
.img-btn {
  width: 52px; height: 52px; padding: 0; border: 0; background: none; cursor: pointer;
  pointer-events: auto;
  filter: drop-shadow(0 4px 0 rgba(0, 0, 0, .25)) drop-shadow(0 6px 8px rgba(0, 0, 0, .25));
  transition: transform .08s;
}
.img-btn img { width: 100%; height: 100%; object-fit: contain; }
.img-btn:hover { transform: scale(1.06); }
.img-btn:active { transform: translateY(3px) scale(.96); }

/* CSS ile çizilmiş kapat çarpısı (font gerektirmez) */
.x-icon { position: relative; display: block; width: 20px; height: 20px; margin: auto; }
.x-icon::before, .x-icon::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 24px; height: 6px; border-radius: 3px;
  background: #fff; box-shadow: 0 2px 0 var(--lo);
  transform: translate(-50%, -50%) rotate(45deg);
}
.x-icon::after { transform: translate(-50%, -50%) rotate(-45deg); }

.avatar {
  display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 50%;
  font-family: var(--title); font-size: 18px; color: #fff;
  background: linear-gradient(180deg, var(--green-hi), var(--green-lo));
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .45), 0 0 0 2px #fff;
  text-shadow: 0 2px 0 var(--green-lo);
  padding-top: 2px;
}

.hint { margin: 0; text-align: center; font-weight: 800; font-size: 15px; color: #8a5528; }

.field { display: flex; flex-direction: column; gap: 6px; font-weight: 900; font-size: 14px; }
.field input {
  font: 800 16px var(--body);
  color: var(--ink);
  padding: 13px 14px;
  border: 3px solid #e2b77a;
  border-radius: 14px;
  background: #fff;
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, .06);
  outline: none;
  transition: border-color .15s;
}
.field input:focus { border-color: var(--blue); }
.error {
  margin: 0; padding: 10px 12px;
  border-radius: 12px;
  background: #ffe1df; color: #c0261d;
  font-weight: 800; font-size: 14px; text-align: center;
}

/* ---------- Duolingo tarzı butonlar ---------- */
.btn {
  --c: var(--green); --hi: var(--green-hi); --lo: var(--green-lo);
  position: relative;
  font-family: var(--title);
  font-size: 20px;
  letter-spacing: .5px;
  color: #fff;
  padding: 12px 22px;
  border: 0;
  border-radius: 18px;
  background: linear-gradient(180deg, var(--hi), var(--c) 55%);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .45), 0 6px 0 var(--lo), 0 8px 12px rgba(0, 0, 0, .25);
  text-shadow: 0 2px 0 var(--lo);
  cursor: pointer;
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn::after { /* parlama */
  content: ''; position: absolute; left: 10px; right: 10px; top: 5px; height: 30%;
  border-radius: 12px; background: rgba(255, 255, 255, .28); pointer-events: none;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(5px); box-shadow: inset 0 3px 0 rgba(255, 255, 255, .45), 0 1px 0 var(--lo); }
.btn:disabled { filter: grayscale(.6) brightness(.9); pointer-events: none; }
.btn-green  { --c: var(--green);  --hi: var(--green-hi);  --lo: var(--green-lo); }
.btn-blue   { --c: var(--blue);   --hi: var(--blue-hi);   --lo: var(--blue-lo); }
.btn-orange { --c: var(--orange); --hi: var(--orange-hi); --lo: var(--orange-lo); }
.btn-red    { --c: var(--red);    --hi: var(--red-hi);    --lo: var(--red-lo); }
.btn-big  { font-size: 24px; padding: 14px 26px; width: 100%; }
.btn-huge { font-size: 38px; padding: 16px 30px; width: 100%; border-radius: 24px; animation: pulse 1.6s ease-in-out infinite; }
.btn-icon { width: 46px; height: 46px; padding: 0; font-size: 20px; border-radius: 14px; font-family: var(--body); font-weight: 900; }
.btn-small { font-size: 16px; padding: 8px 14px; border-radius: 14px; }
.btn-row { display: flex; gap: 10px; width: 100%; }
.btn-row .btn { flex: 1; }
@keyframes pulse { 50% { transform: scale(1.04); } }
.btn-huge:active { animation: none; }

/* ---------- chip ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px 6px 8px;
  border-radius: 999px;
  background: rgba(40, 20, 5, .55);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .15), 0 0 0 3px rgba(255, 255, 255, .25);
  color: #fff;
  font-family: var(--title); font-size: 18px;
  backdrop-filter: blur(4px);
}
.chip img { width: 28px; height: 28px; }
.chip small { font-family: var(--body); font-weight: 900; font-size: 11px; opacity: .8; }

/* ---------- menü ---------- */
.topbar {
  position: absolute; top: max(14px, env(safe-area-inset-top)); left: 16px; right: 16px;
  display: flex; justify-content: space-between; align-items: center;
}
.hero { position: relative; height: min(170px, 22vh); display: flex; justify-content: center; }
.hero-dino { height: 100%; filter: drop-shadow(0 10px 6px rgba(0, 0, 0, .35)); }
.bob { animation: bob 1.2s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes bob { 50% { transform: translateY(-8px) scale(1.02, .98); } }
.stats { display: flex; gap: 12px; width: min(420px, 100%); }
.stat {
  flex: 1; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, var(--cream), var(--cream-2));
  box-shadow: 0 0 0 3px var(--wood-dark), 0 5px 0 3px var(--wood-dark);
}
.stat img { width: 40px; height: 40px; object-fit: contain; }
.stat small { display: block; font-weight: 900; font-size: 12px; color: #a0693a; }
.stat b { font-family: var(--title); font-weight: 700; font-size: 26px; }
.menu-actions { display: flex; flex-direction: column; gap: 16px; width: min(420px, 100%); margin-top: 8px; }

/* ---------- oyun ---------- */
.screen-game { padding: 0; justify-content: flex-start; background: #8fd3ff; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hud {
  position: absolute; top: max(12px, env(safe-area-inset-top)); left: 12px; right: 12px;
  display: flex; align-items: center; gap: 10px;
  pointer-events: none;
}
.hud .btn { pointer-events: auto; }
.chip-score { font-size: 26px; min-width: 120px; transition: transform .15s; }
.chip-score.flash { transform: scale(1.18); background: rgba(255, 170, 0, .8); }
.chip-best { margin-left: auto; }
.tap-hint {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.tap-hint.hidden { display: none; }
.tap-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 14px 24px; border-radius: 20px;
  background: rgba(40, 20, 5, .6); color: #fff;
  animation: pulse 1.2s ease-in-out infinite;
}
.tap-card b { font-family: var(--title); font-weight: 700; font-size: 26px; }
.tap-card small { font-weight: 800; opacity: .85; }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(20, 10, 0, .5);
  backdrop-filter: blur(3px);
}
.modal[hidden] { display: none; }
.over-dino { height: 110px; margin-top: -6px; animation: wobble 1.4s ease-in-out infinite; }
@keyframes wobble { 0%, 100% { transform: rotate(-5deg); } 50% { transform: rotate(5deg); } }
.badge-new {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 16px 6px 8px; border-radius: 999px;
  background: linear-gradient(180deg, #ffe066, #ffb703);
  font-family: var(--title); color: #fff; font-size: 20px;
  text-shadow: var(--outline);
  box-shadow: 0 0 0 3px var(--wood-dark);
  animation: pulse .8s ease-in-out infinite;
}
.badge-new img { height: 34px; margin: -8px 0; }
.badge-new[hidden] { display: none; }
.over-score small { display: block; font-weight: 900; color: #a0693a; }
.over-score b { font-family: var(--title); font-weight: 700; font-size: 64px; line-height: 1; color: #fff; text-shadow: var(--outline); }
.over-row { display: flex; gap: 10px; width: 100%; }
.mini { flex: 1; padding: 8px; border-radius: 14px; background: rgba(160, 90, 30, .12); }
.mini small { display: block; font-weight: 900; font-size: 12px; color: #a0693a; }
.mini b { font-family: var(--title); font-weight: 700; font-size: 26px; }

/* ---------- liderlik ---------- */
.board {
  display: flex; flex-direction: column; gap: 10px;
  width: min(520px, 100%);
  max-height: calc(100dvh - 60px);
  padding-top: 40px;
}
.panel-close { position: absolute; right: -8px; top: -14px; z-index: 3; }
.board-sub { margin: 0; text-align: center; font-weight: 900; color: #fff; text-shadow: 0 2px 0 var(--wood-dark); }
.board-list {
  list-style: none; margin: 0; padding: 4px;
  display: flex; flex-direction: column; gap: 8px;
  overflow-y: auto; min-height: 120px;
  border-radius: 18px;
  background: rgba(107, 51, 17, .35);
  box-shadow: inset 0 4px 8px rgba(0, 0, 0, .25);
  padding: 10px;
}
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px;
  border-radius: 16px;
  background: linear-gradient(180deg, var(--cream), var(--cream-2));
  box-shadow: inset 0 -3px 0 rgba(160, 90, 30, .2), 0 3px 0 rgba(107, 51, 17, .5);
  animation: row-in .35s ease-out backwards;
}
@keyframes row-in { from { transform: translateX(-20px); opacity: 0; } }
.row.me {
  background: linear-gradient(180deg, #7ef3f7, var(--turq));
  box-shadow: inset 0 -3px 0 var(--turq-lo), 0 3px 0 #0d7880, 0 0 0 3px #fff;
}
.rank {
  flex: 0 0 42px; height: 42px;
  display: grid; place-items: center;
  font-family: var(--title); font-size: 20px; color: #a0693a;
  border-radius: 12px; background: rgba(160, 90, 30, .12);
}
.rank.r1, .rank.r2, .rank.r3 {
  background: none; color: #fff; font-size: 18px;
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  padding-top: 4px;
}
.rank.r1 { background: linear-gradient(180deg, #ffe066, #ff9f00); }
.rank.r2 { background: linear-gradient(180deg, #eef3ff, #9aa8c2); }
.rank.r3 { background: linear-gradient(180deg, #ffc58f, #d9732e); }
.row.me .rank:not(.r1):not(.r2):not(.r3) { background: rgba(255, 255, 255, .5); color: #0d7880; }
.row .name { flex: 1; min-width: 0; font-family: var(--title); font-size: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.me .name { color: #0b5a60; }
.row .score {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 12px 3px 4px; border-radius: 999px;
  background: rgba(160, 90, 30, .14);
  font-family: var(--title); font-size: 20px; color: #e07b00;
}
.row .score img { width: 26px; height: 26px; }
.board-me:empty { display: none; }
.board-empty { text-align: center; padding: 30px 10px; font-weight: 900; color: #fff; }

@media (max-height: 640px) {
  .logo { width: min(260px, 70vw); }
  .hero { height: 110px; }
  .btn-huge { font-size: 30px; padding: 12px; }
}
