:root {
  --cream: #FBF5E6;
  --paper: #FFFDF7;
  --ink: #1F2614;
  --ink-2: #4A5236;
  --olive: #7C8A2B;
  --olive-d: #5E6A1C;
  --olive-l: #E9EBC9;
  --sun: #F6B915;
  --sun-d: #D99A00;
  --brain: #F2899A;
  --brain-l: #FDE3E7;
  --red: #C8342B;
  --line: #E6DDC4;
  --r: 22px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --shadow: 0 2px 0 rgba(31,38,20,.9), 0 10px 24px -12px rgba(60,55,20,.35);
  font-family: Nunito, system-ui, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--cream);
  background-image: radial-gradient(circle at 1px 1px, rgba(124,138,43,.13) 1px, transparent 0);
  background-size: 22px 22px;
  font-size: 16px; line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
::selection { background: var(--sun); color: var(--ink); }
:focus-visible { outline: 3px solid var(--olive); outline-offset: 3px; border-radius: 10px; }
h1, h2 { font-family: Fredoka, Nunito, sans-serif; line-height: 1.1; margin: 0; text-wrap: balance; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1040px; margin: 0 auto; padding: max(14px, env(safe-area-inset-top)) 16px 6px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-family: Fredoka; font-weight: 700; font-size: 21px; }
.brand img { border-radius: 50%; background: var(--paper); border: 2px solid var(--ink); }
.brand b { color: #9A6500; }
.date { font-weight: 800; font-size: 14px; color: var(--ink-2); background: var(--paper); border: 2px solid var(--ink); border-radius: 999px; padding: 4px 12px; }

main { max-width: 1040px; margin: 0 auto; padding: 8px 16px 48px; }
.view { display: none; }
.view[data-active] { display: block; animation: enter 320ms var(--ease-out); }
#v-home[data-active] { display: grid; grid-template-columns: 1fr; gap: 28px; }
@media (min-width: 880px) { #v-home[data-active] { grid-template-columns: 1.05fr 1fr; align-items: start; gap: 40px; } }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }

.card { background: var(--paper); border: 2px solid var(--ink); border-radius: var(--r); box-shadow: var(--shadow); }

/* ---- hero ---- */
.hero { text-align: center; }
.mascot { width: 200px; height: 200px; border-radius: 50%; margin: 6px auto 0; display: block; animation: bob 4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-1.5deg); } }
h1 { font-size: clamp(34px, 7vw, 52px); font-weight: 700; margin-top: 6px; letter-spacing: -0.01em; }
.lead { font-size: 18px; color: var(--ink-2); margin: 10px auto 22px; max-width: 34ch; }

.start { text-align: left; padding: 20px; }
.start label { font-weight: 800; font-size: 15px; display: block; margin-bottom: 8px; }
.field { display: flex; align-items: center; border: 2px solid var(--ink); border-radius: 14px; background: #fff; transition: box-shadow 160ms ease; }
.field:focus-within { box-shadow: 0 0 0 4px var(--olive-l); }
.at { padding-left: 14px; font-weight: 800; color: var(--olive-d); font-size: 18px; }
.field input { flex: 1; min-width: 0; border: 0; background: transparent; font: 700 18px Nunito; padding: 13px 14px 13px 4px; color: var(--ink); outline: none; caret-color: var(--olive); }
.field input::placeholder { color: #6B6957; font-weight: 600; }
.help { font-size: 14px; color: var(--ink-2); margin: 8px 2px 0; }
.err { font-size: 14px; color: var(--red); font-weight: 800; margin: 6px 2px 0; min-height: 0; }
.err:empty { display: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 54px; padding: 0 22px; border-radius: 16px; border: 2px solid var(--ink);
  font: 600 19px Fredoka; cursor: pointer; color: var(--ink);
  transition: transform 140ms var(--ease-out), box-shadow 140ms var(--ease-out), background-color 160ms ease;
}
.btn:active { transform: translateY(2px) scale(0.98); box-shadow: 0 0 0 var(--ink); }
.btn[disabled] { opacity: .6; cursor: progress; }
.primary { background: var(--sun); box-shadow: 0 3px 0 var(--ink); width: 100%; margin-top: 16px; }
.ghost { background: var(--paper); box-shadow: 0 3px 0 var(--ink); }
@media (hover: hover) and (pointer: fine) {
  .primary:hover { background: #FFC83A; }
  .ghost:hover { background: var(--olive-l); }
  .primary:hover svg { transform: translateX(3px); }
}
.btn svg { transition: transform 160ms var(--ease-out); }

.done-card { padding: 20px; text-align: left; }
.done-card h3 { font: 600 20px Fredoka; margin: 0 0 4px; }
.done-card p { margin: 0; color: var(--ink-2); }
.done-card .big { font: 700 34px Fredoka; color: var(--olive-d); font-variant-numeric: tabular-nums; }

.rules { list-style: none; padding: 0; margin: 22px 0 0; display: grid; gap: 10px; text-align: left; }
.rules li { display: flex; gap: 12px; align-items: center; font-weight: 700; color: var(--ink-2); }
.rules svg { width: 34px; height: 34px; padding: 7px; border-radius: 10px; background: var(--olive-l); color: var(--olive-d); }

/* ---- leaderboard ---- */
.board { padding: 20px 8px 10px; }
@media (min-width: 880px) { .board { position: sticky; top: 16px; margin-top: 30px; } }
.board-head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 12px 10px; border-bottom: 2px dashed var(--line); }
.board h2 { font-size: 24px; }
.count { font-weight: 800; font-size: 14px; color: var(--ink-2); }
/* Sıralama tablosu: sabit sütun genişlikleri (table-layout: fixed), kaydırma yok, tek birim */
.lb { width: 100%; border-collapse: separate; border-spacing: 0 4px; table-layout: fixed; margin-top: 4px; font-variant-numeric: tabular-nums; }
.lb .c-rk { width: 50px; } .lb .c-er { width: 64px; } .lb .c-tm { width: 92px; }
.lb th { font: 800 12px Nunito, sans-serif; color: var(--ink-2); text-transform: uppercase; letter-spacing: .05em; text-align: left; padding: 8px 10px 2px; }
.lb th:first-child { text-align: center; } .lb th:nth-child(3), .lb th:last-child { text-align: right; }
.lb td { padding: 9px 10px; vertical-align: middle; background: #fff; border-top: 1.5px solid var(--line); border-bottom: 1.5px solid var(--line); }
.lb td:first-child { text-align: center; border-left: 1.5px solid var(--line); border-radius: 14px 0 0 14px; padding-inline: 6px; }
.lb td:last-child { border-right: 1.5px solid var(--line); border-radius: 0 14px 14px 0; }
.lb tbody tr { animation: enter 280ms var(--ease-out) backwards; animation-delay: calc(var(--i) * 30ms); }
.lb .rk { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; font: 700 16px Fredoka; color: var(--ink-2); border: 2px solid transparent; }
.lb .rk.m1 { background: var(--sun); border-color: var(--ink); color: var(--ink); }
.lb .rk.m2 { background: #E4E2D6; border-color: var(--ink); color: var(--ink); }
.lb .rk.m3 { background: #EBB98A; border-color: var(--ink); color: var(--ink); }
.lb .nm { display: block; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.3; }
.lb .me-tag { display: inline-block; margin-top: 2px; } .lb .me-tag, .lb .nm em { font-style: normal; font-size: 12px; font-weight: 800; color: #fff; background: #B04A5C; border-radius: 6px; padding: 1px 6px; vertical-align: 1px; }
.lb .tag { display: inline-block; margin-top: 3px; font-size: 12px; font-weight: 800; line-height: 1.5; padding: 0 8px; border-radius: 999px; white-space: nowrap; }
.lb .tag.ok { background: var(--olive-l); color: var(--olive-d); }
.lb .tag.bad { background: #FBE1DE; color: #A1281F; }
.lb .er { text-align: right; font: 600 19px Fredoka; line-height: 1.1; white-space: nowrap; }
.lb .er small { display: block; text-align: right; font: 800 11px Nunito, sans-serif; margin-top: 2px; }
.lb .er.bad { color: #A1281F; } .lb .er.ok { color: var(--olive-d); }
.lb .tm { text-align: right; font: 600 19px Fredoka; white-space: nowrap; }
.lb .tm small { font: 700 13px Nunito; color: var(--ink-2); }
.lb tr.mine-label td { background: none; border: 0; padding: 10px 4px 0; text-align: left; font: 800 12px Nunito, sans-serif; color: #B04A5C; text-transform: uppercase; letter-spacing: .05em; }
/* Kendi satırın: ilk 10'da da, dışında da aynı güçlü vurgu */
.lb tr.me td { background: var(--brain-l); border-color: #B04A5C; border-top-width: 2px; border-bottom-width: 2px; }
.lb tr.me td:first-child { border-left-width: 2px; } .lb tr.me td:last-child { border-right-width: 2px; }
.lb tr.me .rk { background: #B04A5C; color: #fff; border-color: var(--ink); width: auto; min-width: 34px; padding: 0 6px; border-radius: 17px; }
.lb tr.me .rk.m1, .lb tr.me .rk.m2, .lb tr.me .rk.m3 { color: var(--ink); box-shadow: 0 0 0 3px #B04A5C; }
.lb tr.me .rk.m1 { background: var(--sun); } .lb tr.me .rk.m2 { background: #E4E2D6; } .lb tr.me .rk.m3 { background: #EBB98A; }
.lb tr.gap td { background: none; border: 0; text-align: center; padding: 2px; }
.lb tr.gap span { display: inline-block; width: 5px; height: 5px; margin: 0 3px; border-radius: 50%; background: var(--ink-2); opacity: .5; }
.lb td.empty { text-align: center; padding: 28px 16px; color: var(--ink-2); font-weight: 700; border-radius: 14px; border: 1.5px dashed var(--line); }

/* ---- game ---- */
#v-game { max-width: 620px; margin: 0 auto; }
.hud { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 0 16px; }
.steps { display: flex; gap: 6px; }
.steps i { width: 34px; height: 10px; border-radius: 99px; border: 2px solid var(--ink); background: var(--paper); transition: background-color 240ms ease; }
.steps i.on { background: var(--sun); }
.steps i.ok { background: var(--olive); }
.timer { font: 700 34px Fredoka; font-variant-numeric: tabular-nums; background: var(--paper); border: 2px solid var(--ink); border-radius: 14px; padding: 2px 14px; min-width: 120px; text-align: right; box-shadow: 0 3px 0 var(--ink); }
.timer small { font-size: 16px; margin-left: 4px; color: var(--ink-2); }
.q-head { margin-bottom: 14px; }
.q-head h2 { font-size: clamp(26px, 6vw, 34px); }
.q-head p { margin: 4px 0 0; color: var(--ink-2); font-weight: 700; }
.stage {
  position: relative; padding: 14px; overflow: hidden;
  background: var(--olive-l);
  background-image: radial-gradient(circle at 1px 1px, rgba(94,106,28,.18) 1px, transparent 0);
  background-size: 14px 14px;
  box-shadow: var(--shadow), inset 0 2px 0 rgba(255,255,255,.6);
}
.stage[data-type="cups"] { background-color: var(--paper); }
.stage.in #cv { animation: qin 360ms var(--ease-out); }
@keyframes qin { from { opacity: 0; transform: translateY(10px) scale(.985); filter: blur(3px); } }
.q-head h2 { transition: opacity 200ms ease; }
#cv { display: block; width: 100%; height: auto; touch-action: manipulation; cursor: pointer; border-radius: 12px; }
.penalty { position: absolute; top: 14px; right: 14px; background: var(--red); color: #fff; font: 700 20px Fredoka; padding: 4px 12px; border-radius: 10px; opacity: 0; transform: translateY(6px); pointer-events: none; }
.penalty.show { animation: pen 900ms var(--ease-out); }
@keyframes pen { 15% { opacity: 1; transform: none; } 75% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-8px); } }

/* ---- hazır mısın + 3-2-1 ---- */
.ready { max-width: 440px; margin: 24px auto 0; padding: 28px 22px 22px; text-align: center; min-height: 450px; display: grid; place-items: center; }
.ready h2 { font-size: clamp(26px, 7vw, 32px); overflow-wrap: anywhere; }
.ready-facts { list-style: none; padding: 0; margin: 16px 0 6px; display: grid; gap: 8px; text-align: left; }
.ready-facts li { background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 14px; font-weight: 700; color: var(--ink-2); }
.ready-facts b { color: var(--ink); }
.linkish { margin-top: 12px; background: none; border: 0; font: 800 15px Nunito, sans-serif; color: var(--olive-d); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 12px; min-height: 44px; }
.count { display: grid; place-items: center; }
.count { width: 100%; height: 100%; }
.count span { display: grid; place-items: center; width: 148px; height: 148px; border-radius: 50%; background: var(--sun); border: 3px solid var(--ink); box-shadow: 0 5px 0 var(--ink); font: 700 84px/1 Fredoka; color: var(--ink); padding-top: 4px; }
.count span.pop { animation: pop 1000ms var(--ease-out); }
@keyframes pop { 0% { transform: scale(.7); opacity: 0; } 18% { transform: scale(1.06); opacity: 1; } 30% { transform: scale(1); } 85% { opacity: 1; } 100% { transform: scale(.96); opacity: .3; } }

/* ---- result ---- */
.result { max-width: 440px; margin: 16px auto 0; padding: 26px 20px 22px; text-align: center; }
.r-hero p { margin: 0; }
.r-rank span { display: inline-grid; place-items: center; min-width: 132px; height: 132px; padding: 0 18px; border-radius: 66px; border: 3px solid var(--ink); background: var(--olive-l); color: var(--olive-d); font: 700 72px/1 Fredoka; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; box-shadow: 0 4px 0 var(--ink); }
.r-rank span.m1 { background: var(--sun); color: var(--ink); }
.r-rank span.m2 { background: #E4E2D6; color: var(--ink); }
.r-rank span.m3 { background: #EBB98A; color: var(--ink); }
.r-of { margin-top: 14px !important; font: 600 22px Fredoka; }
.r-gap { margin-top: 4px !important; font-weight: 800; color: #B04A5C; min-height: 1.5em; }
.r-gap:empty { display: none; }
.r-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0 0; }
.r-stats div { background: #fff; border: 1.5px solid var(--line); border-radius: 16px; padding: 10px 12px 12px; }
.r-stats dt { font: 800 12px Nunito, sans-serif; color: var(--ink-2); text-transform: uppercase; letter-spacing: .05em; }
.r-stats dd { margin: 2px 0 0; font: 700 32px/1.15 Fredoka; font-variant-numeric: tabular-nums; }
.r-stats dd small { font: 800 13px Nunito, sans-serif; color: var(--ink-2); }
#r-err small { display: block; margin-top: 2px; }
#r-err .bad { color: #A1281F; } #r-err .ok { color: var(--olive-d); }
.r-actions { display: grid; gap: 10px; margin-top: 18px; }
.r-actions .primary { margin-top: 0; }
.r-next { font-size: 15px; color: var(--ink-2); margin: 16px 0 0; font-weight: 700; }
.r-next b { color: var(--ink); font-variant-numeric: tabular-nums; }
.toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translate(-50%, 16px); opacity: 0; visibility: hidden; pointer-events: none; background: var(--ink); color: var(--cream); padding: 12px 18px; border-radius: 14px; font-weight: 800; transition: transform 260ms var(--ease-out), opacity 200ms ease, visibility 0s linear 260ms; max-width: calc(100% - 32px); z-index: 9; }
.toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; transition: transform 260ms var(--ease-out), opacity 200ms ease, visibility 0s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; }
  .view[data-active] { animation: none; }
}

/* ---- dokunmatik ekran güvenliği ---- */
html { touch-action: manipulation; }
button, .btn, a, input, #cv { touch-action: manipulation; }
#v-game, .btn, .lb { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#cv.wait { cursor: progress; }
@media (max-width: 520px) {
  main { padding-inline: 10px; }
  .stage { padding: 6px; border-radius: 18px; }
  .hud { margin-bottom: 10px; }
  .q-head { margin-bottom: 10px; }
  .timer { font-size: 28px; min-width: 104px; }
  .steps i { width: 28px; }
}

/* ---- reklam alanları (yalnızca AdSense açıkken görünür) ---- */
.ad { display: none; }
.ad.on { display: block; margin: 22px auto 0; max-width: 728px; min-height: 120px; text-align: center; }
.ad-label { display: block; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: #6B6957; margin-bottom: 4px; }
[hidden] { display: none !important; }

/* Masaüstü: sonuç ve hazır ekranları dikeyde ortalı, daha geniş */
@media (min-width: 720px) {
  #v-result[data-active], #v-ready[data-active] { display: grid; place-items: center; padding-block: clamp(16px, 6vh, 72px); }
  .result, .ready { margin: 0 auto; width: min(640px, 100%); max-width: none; padding: 40px 48px 34px; }
  .result { display: grid; grid-template-columns: 1fr 1fr; column-gap: 32px; align-items: center; text-align: center; }
  .result .r-hero { grid-row: 1 / span 2; }
  .result .r-stats { margin-top: 0; grid-template-columns: 1fr; }
  .result .r-actions, .result .ad-result, .result .r-next { grid-column: 1 / -1; }
  .r-rank span { min-width: 168px; height: 168px; border-radius: 84px; font-size: 92px; }
}

/* ---- sıralama: 20 kişi, ilk 10 görünür ---- */
.lb-scroll { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--olive) transparent; border-radius: 14px; }
.lb-scroll::-webkit-scrollbar { width: 6px; } .lb-scroll::-webkit-scrollbar-thumb { background: var(--olive); border-radius: 3px; }
.lb-scroll thead th { position: sticky; top: 0; z-index: 1; background: var(--paper); }
.lb-more { margin: 6px 0 0; text-align: center; font-size: 13px; font-weight: 800; color: var(--olive-d); transition: opacity 200ms ease; }
.lb-more::after { content: " ↓"; }
.lb-more.done { opacity: 0; }
.lb-mine { margin-top: 6px; }

/* ---- Masaüstü: ana sayfa tek ekrana sığar (kaydırma yok), 20 sıralama satırı dahil ---- */
.lb-scroll { overflow-y: auto; }
@media (min-width: 880px) and (min-height: 600px) {
  body { display: flex; flex-direction: column; min-height: 100dvh; }
  body > main { flex: 1; width: 100%; padding-bottom: 8px; }
  body > .top, body > .foot { width: 100%; }
  body .foot { margin-top: 0; padding: 8px 16px 10px; flex-wrap: nowrap; gap: 8px 18px; font-size: 14px; }
  body .foot nav { flex-wrap: nowrap; gap: 4px 14px; }
  body .foot .social a { min-height: 36px; padding: 3px 12px 3px 8px; }
  body .foot small { white-space: nowrap; }
  body .foot .social { flex-wrap: nowrap; }
  body .foot nav a { font-size: 13.5px; white-space: nowrap; padding: 4px 0; }
  body .foot nav { flex-wrap: nowrap; }

  /* sol sütun ekran boyuna göre küçülür */
  #v-home[data-active] { align-items: start; gap: 32px; }
  .hero .mascot { width: clamp(92px, 17dvh, 200px); height: clamp(92px, 17dvh, 200px); }
  .hero h1 { font-size: clamp(32px, 5.2dvh, 52px); }
  .hero .lead { margin: 6px auto 14px; }
  .rules { margin-top: 14px; gap: 6px; }

  /* sıralama: kart kalan yüksekliği doldurur, 20 satır ona sığacak şekilde sıkışır */
  .board { margin-top: 0; position: static; padding-top: 12px; padding-bottom: 6px;
           --rowh: clamp(30px, calc((100dvh - 278px) / 10 - 2px), 58px); }
  .board h2 { white-space: nowrap; }
  .lb { border-spacing: 0 2px; }
  .board-head { padding-bottom: 6px; }
  .board h2 { font-size: clamp(20px, 3dvh, 24px); }
  .lb th { padding-top: 4px; }
  .lb tbody td { height: var(--rowh); padding-block: 0; line-height: 1.1; }
  .lb .rk { width: calc(var(--rowh) - 8px); height: calc(var(--rowh) - 8px); min-width: 0; font-size: min(16px, calc(var(--rowh) * .45)); }
  .lb .nm { font-size: min(16px, calc(var(--rowh) * .48)); }
  .lb .tm { font-size: min(19px, calc(var(--rowh) * .5)); }
  .lb .me-tag { margin: 0 0 0 6px; vertical-align: 1px; }
  .lb td .nm { display: inline; }
}
@media (min-width: 880px) and (max-width: 1279px) and (min-height: 600px) { body .foot small { display: none; } body .foot .social span { display: none; } body .foot .social a { padding: 3px 8px; } }
