:root {
  --bg: #fdf6ec;
  --ink: #43356b;
  --muted: #8a7bb0;
  --teal: #2bb3a3;
  --teal-dark: #1f8d80;
  --orange: #ff8a3d;
  --orange-dark: #e8752c;
  --green: #4aa870;
  --green-dark: #38875a;
  --red: #dd5566;
  --red-dark: #b64252;
  --yellow: #ffc93c;
  --card-shadow: #e3d8c7;
  --track: #ece2d2;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overscroll-behavior: none;
  touch-action: manipulation;
}

body {
  font-family: 'Baloo 2', 'Trebuchet MS', sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
}

.screen {
  min-height: 100dvh;
  max-width: 620px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 24px max(20px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  position: relative;
}

.hidden { display: none !important; }

/* ---------- ortak parçalar ---------- */

.btn {
  font-family: inherit;
  font-weight: 800;
  font-size: 24px;
  letter-spacing: 0.5px;
  border: none;
  border-radius: 20px;
  min-height: 68px;
  padding: 0 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  cursor: pointer;
  color: var(--ink);
}
.btn:active { transform: translateY(3px); }

.btn-primary {
  background: var(--teal);
  color: #fff;
  box-shadow: 0 6px 0 var(--teal-dark);
  min-height: 76px;
  font-size: 27px;
}
.btn-primary:active { box-shadow: 0 3px 0 var(--teal-dark); }

.btn-outline {
  background: #fff;
  border: 3px solid #d9cdf0;
  box-shadow: none;
}
.btn-outline .hint { font-size: 14px; font-weight: 700; color: var(--muted); }
.btn.small { min-height: 52px; font-size: 18px; padding: 0 18px; }
.btn.wide { width: 100%; max-width: 440px; }

.icon-btn {
  width: 54px;
  height: 54px;
  border: none;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 4px 0 var(--card-shadow);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--card-shadow); }
.icon-btn.corner { position: absolute; top: max(20px, env(safe-area-inset-top)); right: 20px; z-index: 5; }

.screen-title { font-size: 38px; font-weight: 800; margin: 0; text-align: center; }

/* ---------- giriş ---------- */

.deco { position: absolute; pointer-events: none; animation: floaty 3.5s ease-in-out infinite; font-family: inherit; }
.deco-1 { top: 7%; left: 8%; animation-duration: 3.2s; }
.deco-2 { top: 14%; right: 12%; animation-delay: 0.6s; animation-duration: 3.8s; }
.deco-3 { bottom: 17%; left: 11%; animation-delay: 0.9s; animation-duration: 4s; }
.deco-4 { bottom: 9%; right: 14%; animation-delay: 1.4s; animation-duration: 3.4s; }
.deco-5 { top: 32%; left: 6%; animation-delay: 1.1s; animation-duration: 4.4s; }
.deco-6 { top: 41%; right: 6%; animation-delay: 0.3s; }
.deco text { font-family: 'Baloo 2', 'Trebuchet MS', sans-serif; }

.hero { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.mascot-bob { animation: bob 2.6s ease-in-out infinite; }
.hero h1 { font-size: clamp(38px, 9vw, 54px); font-weight: 800; margin: 0; line-height: 1.05; }
.hero h1 span { color: var(--orange); }
.subtitle { font-size: 19px; font-weight: 600; color: var(--muted); margin: 0; }

.card {
  width: 100%;
  max-width: 440px;
  background: #fff;
  border-radius: 26px;
  box-shadow: 0 10px 24px rgba(67, 53, 107, 0.12);
  padding: 26px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.card-label { font-size: 20px; font-weight: 700; }
.entry-card { transform: rotate(-1deg); }

.name-error { font-size: 16px; font-weight: 700; color: var(--red-dark); }

.greet-row { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.greet-text { font-size: 25px; font-weight: 700; }
.greet-text b { color: var(--orange); }
.change-name {
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  font-weight: 700;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 10px;
}

.btn-row { display: flex; gap: 12px; }
.btn-row .btn { flex: 1; min-height: 60px; font-size: 17px; padding: 0 10px; border-radius: 18px; gap: 8px; }

#nameInput {
  font-family: inherit;
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  height: 64px;
  border: 3px solid #e8dff5;
  border-radius: 18px;
  background: #faf7ff;
  padding: 0 20px;
  outline: none;
  width: 100%;
  -webkit-user-select: text;
  user-select: text;
}
#nameInput:focus { border-color: var(--teal); }

.mini-board {
  width: 100%;
  max-width: 440px;
  background: #fff3d6;
  border-radius: 22px;
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transform: rotate(0.8deg);
}
.mini-board-title { display: flex; align-items: center; gap: 8px; font-size: 19px; font-weight: 700; color: #a6740c; }
.mini-list { display: flex; flex-direction: column; gap: 6px; }
.mini-row { display: flex; justify-content: space-between; font-size: 18px; font-weight: 600; }
.mini-row b { font-weight: 800; }
.mini-empty { font-size: 16px; font-weight: 600; color: #a6740c; }

/* ---------- pratik seçimi ---------- */

.table-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  width: 100%;
  max-width: 440px;
}
.table-btn {
  font-family: inherit;
  font-size: 30px;
  font-weight: 800;
  color: var(--ink);
  background: #fff;
  border: none;
  border-radius: 20px;
  box-shadow: 0 5px 0 var(--card-shadow);
  aspect-ratio: 1;
  cursor: pointer;
}
.table-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--card-shadow); }

/* ---------- oyun ---------- */

#screen-game { justify-content: flex-start; gap: 16px; }

.topbar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.pill {
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 16px;
  padding: 8px 16px;
}
.timer-pill { background: #fff; box-shadow: 0 4px 12px rgba(67, 53, 107, 0.1); font-size: 26px; font-weight: 800; }
.timer-pill.low { color: var(--red-dark); }
.score-pill { position: relative; background: var(--ink); color: #fff; font-size: 26px; font-weight: 800; }
.score-label { font-size: 15px; font-weight: 700; color: #b7a8e0; letter-spacing: 2px; }

#floatLayer { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.float-note {
  position: absolute;
  top: -4px;
  right: 8px;
  font-size: 38px;
  font-weight: 800;
  text-shadow: 0 2px 0 #fff;
  pointer-events: none;
}
.float-plus { color: var(--green); animation: floatUp 1s ease-out forwards; }
.float-bonus { color: var(--orange); animation: floatUp 1.3s ease-out forwards; }
.float-minus { color: var(--red); animation: dropShake 1.1s ease-in forwards; }

@keyframes floatUp {
  0% { opacity: 0; transform: translateY(6px) scale(0.7); }
  18% { opacity: 1; transform: translateY(-14px) scale(1.15); }
  65% { opacity: 1; transform: translateY(-44px) scale(1); }
  100% { opacity: 0; transform: translateY(-78px) scale(0.95); }
}
@keyframes dropShake {
  0% { opacity: 0; transform: translateY(-16px) rotate(0deg); }
  15% { opacity: 1; transform: translateY(4px) rotate(-6deg); }
  40% { opacity: 1; transform: translateY(20px) rotate(5deg); }
  65% { opacity: 1; transform: translateY(36px) rotate(-4deg); }
  100% { opacity: 0; transform: translateY(64px) rotate(2deg); }
}

.progress-track { position: relative; width: 100%; height: 16px; border-radius: 8px; background: var(--track); }
.progress-fill { height: 100%; border-radius: 8px; background: var(--teal); width: 100%; transition: width 0.95s linear, background-color 0.3s; }
.progress-fill.low { background: var(--red); }
#progressStar {
  position: absolute;
  top: -9px;
  left: 100%;
  transform: translateX(-50%) rotate(-10deg);
  transition: left 0.95s linear;
  pointer-events: none;
}

.game-middle {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
}
.streak-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff3d6;
  border-radius: 999px;
  padding: 5px 18px 5px 10px;
  font-size: 18px;
  font-weight: 800;
  color: #d97a1b;
}
.question-card {
  position: relative;
  background: #fff;
  border-radius: 28px;
  box-shadow: 0 12px 28px rgba(67, 53, 107, 0.12);
  padding: 8vh 5vw;
  min-width: 70%;
  text-align: center;
  transform: rotate(-1.5deg);
}
.q-star { position: absolute; pointer-events: none; }
.q-star-1 { top: -14px; right: 26px; transform: rotate(18deg); }
.q-star-2 { bottom: -8px; left: 34px; transform: rotate(-14deg); opacity: 0.7; }

.cheer-pill {
  visibility: hidden;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border-radius: 999px;
  padding: 5px 20px 5px 8px;
  box-shadow: 0 4px 12px rgba(67, 53, 107, 0.1);
  font-size: 17px;
  font-weight: 800;
  color: var(--muted);
}
.cheer-pill.show { visibility: visible; }
#questionText { font-size: clamp(52px, 13vw, 92px); font-weight: 800; line-height: 1; white-space: nowrap; }

.answers { width: 100%; display: flex; flex-direction: column; gap: 14px; }
.answer-btn {
  font-family: inherit;
  min-height: 86px;
  border: none;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 6px 0 var(--card-shadow);
  font-size: 40px;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  position: relative;
}
.answer-btn:active { transform: translateY(3px); box-shadow: 0 3px 0 var(--card-shadow); }
.answer-btn:disabled { cursor: default; }
.answer-btn[data-i="0"] { background: #eaf3ff; box-shadow: 0 6px 0 #c3d9f2; }
.answer-btn[data-i="1"] { background: #fff3d6; box-shadow: 0 6px 0 #eeda9f; }
.answer-btn[data-i="2"] { background: #ffe9ee; box-shadow: 0 6px 0 #f0c6d2; }
.answer-btn.correct { background: var(--green); box-shadow: 0 6px 0 var(--green-dark); color: #fff; animation: popIn 0.5s ease-out; }
.answer-btn.wrong { background: var(--red); box-shadow: 0 6px 0 var(--red-dark); color: #fff; animation: wiggle 0.6s ease-in-out; }
.answer-btn.reveal { background: var(--green); box-shadow: 0 6px 0 var(--green-dark); color: #fff; animation: blinkGreen 0.45s ease-in-out 4; }
.answer-btn .tag {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  padding: 2px 12px;
}

@keyframes popIn { 0% { transform: scale(1); } 40% { transform: scale(1.04); } 100% { transform: scale(1); } }
@keyframes wiggle {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}
@keyframes blinkGreen {
  0%, 100% { filter: none; }
  50% { filter: brightness(1.18); }
}
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-9px) rotate(3deg); }
}
@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}
@keyframes spinRays {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
@keyframes confDrift {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-10px) rotate(18deg); }
}

/* ---------- tur sonu ---------- */

.end-title-row { display: flex; align-items: flex-end; gap: 12px; }
.end-title-row .screen-title { padding-bottom: 10px; }

.score-circle-wrap { position: relative; display: flex; flex-direction: column; align-items: center; }
.rays {
  position: absolute;
  top: 110px;
  left: 50%;
  width: 340px;
  height: 340px;
  margin: -170px 0 0 -170px;
  animation: spinRays 24s linear infinite;
  opacity: 0.5;
  pointer-events: none;
}
.drift { position: absolute; width: 13px; height: 20px; border-radius: 4px; animation: confDrift 3.5s ease-in-out infinite; pointer-events: none; }
.d1 { top: 8%; left: 12%; background: var(--teal); animation-duration: 3s; }
.d2 { top: 13%; right: 15%; background: var(--red); animation-delay: 0.5s; animation-duration: 3.6s; }
.d3 { top: 24%; left: 22%; background: var(--orange); animation-delay: 0.9s; animation-duration: 3.3s; }
.d4 { top: 20%; right: 9%; width: 14px; height: 14px; border-radius: 50%; background: var(--yellow); animation-delay: 0.2s; animation-duration: 4s; }
.d5 { bottom: 20%; left: 10%; background: var(--muted); animation-delay: 1.2s; animation-duration: 3.8s; }
.d6 { bottom: 13%; right: 12%; background: var(--teal); animation-delay: 0.7s; }
.score-circle {
  position: relative;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: #fff;
  border: 11px solid var(--yellow);
  box-shadow: 0 14px 30px rgba(67, 53, 107, 0.14);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.end-score { font-size: 72px; font-weight: 800; line-height: 1; }
.end-score-label { font-size: 20px; font-weight: 700; color: var(--muted); letter-spacing: 3px; }
.record-ribbon {
  position: relative;
  transform: rotate(-2deg);
  margin-top: -20px;
  background: var(--orange);
  border-radius: 14px;
  padding: 8px 22px;
  box-shadow: 0 4px 0 var(--orange-dark);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 21px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 1px;
}

.stats-row { display: flex; gap: 16px; }
.stat { display: flex; align-items: center; gap: 10px; border-radius: 18px; padding: 12px 22px; font-size: 22px; font-weight: 700; }
.stat-good { background: #e4f6ea; color: var(--green-dark); transform: rotate(-1deg); }
.stat-bad { background: #fde5e9; color: var(--red-dark); transform: rotate(1deg); }

.save-status { font-size: 16px; font-weight: 600; color: var(--muted); min-height: 22px; }
.end-buttons { display: flex; flex-direction: column; gap: 14px; width: 100%; align-items: center; }

/* ---------- puan tablosu ---------- */

#screen-board { justify-content: flex-start; }
.board-header { width: 100%; display: flex; align-items: center; justify-content: space-between; }
.board-title { display: flex; align-items: center; gap: 10px; font-size: 32px; font-weight: 800; }
.board-spacer { width: 54px; }

.tabs { width: 100%; display: flex; gap: 10px; background: var(--track); border-radius: 18px; padding: 7px; }
.tab {
  flex: 1;
  font-family: inherit;
  font-size: 19px;
  font-weight: 700;
  color: #7a6f96;
  border: none;
  border-radius: 12px;
  background: transparent;
  min-height: 50px;
  cursor: pointer;
}
.tab.active { background: var(--ink); color: #fff; font-weight: 800; }

.board-list { width: 100%; flex: 1; display: flex; flex-direction: column; gap: 11px; overflow-y: auto; padding-top: 10px; }
.rank-wrap { position: relative; flex-shrink: 0; }
.rank-wrap .crown { position: absolute; top: -17px; left: 6px; transform: rotate(8deg); }
.board-row {
  display: flex;
  align-items: center;
  gap: 15px;
  background: #fff;
  border-radius: 20px;
  padding: 12px 18px;
  box-shadow: 0 4px 12px rgba(67, 53, 107, 0.08);
}
.board-row .rank {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #f1ece2;
  color: #8a8375;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  font-weight: 800;
  flex-shrink: 0;
}
.board-row.r1 { background: #fff3d6; border: 3px solid var(--yellow); transform: rotate(-0.6deg); }
.board-row.r1 .rank { background: var(--yellow); color: #7a5a00; }
.board-row.r2 .rank { background: #d6d9e0; color: #5c6270; }
.board-row.r3 .rank { background: #e8b98c; color: #7a4a12; }
.board-row.me { background: #e9f8f5; border: 3px solid var(--teal); }
.board-row.me .rank { background: var(--teal); color: #fff; }
.board-row.me .name { color: var(--teal-dark); }
.board-row .name { flex: 1; font-size: 22px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.board-row .you-tag { font-size: 14px; font-weight: 700; color: #fff; background: var(--teal); border-radius: 9px; padding: 1px 10px; }
.board-row .best { font-size: 24px; font-weight: 800; }
.board-empty { text-align: center; font-size: 18px; font-weight: 600; color: var(--muted); padding: 30px 0; }

/* ---------- istatistikler ---------- */

#screen-stats { justify-content: flex-start; }
.stats-content { width: 100%; flex: 1; display: flex; flex-direction: column; gap: 20px; overflow-y: auto; }
.stats-section {
  background: #fff;
  border-radius: 22px;
  padding: 20px 22px;
  box-shadow: 0 4px 12px rgba(67, 53, 107, 0.08);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.stats-section h3 { margin: 0; font-size: 21px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.stats-note { font-size: 15px; font-weight: 600; color: var(--muted); }
.table-stat { display: flex; align-items: center; gap: 12px; }
.table-stat .t-label { width: 62px; font-size: 19px; font-weight: 800; flex-shrink: 0; }
.table-stat .t-track { flex: 1; height: 20px; border-radius: 10px; background: var(--track); overflow: hidden; }
.table-stat .t-fill { height: 100%; border-radius: 10px; }
.table-stat .t-fill.good { background: var(--green); }
.table-stat .t-fill.mid { background: var(--orange); }
.table-stat .t-fill.bad { background: var(--red); }
.table-stat .t-pct { width: 88px; text-align: right; font-size: 16px; font-weight: 700; color: var(--muted); flex-shrink: 0; }
.fact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fde5e9;
  border-radius: 16px;
  padding: 10px 18px;
}
.fact-row .fact { font-size: 22px; font-weight: 800; color: var(--red-dark); }
.fact-row .fact-count { font-size: 16px; font-weight: 700; color: var(--red-dark); }
.stats-empty { text-align: center; font-size: 18px; font-weight: 600; color: var(--muted); padding: 30px 0; }
.badge-row { display: flex; flex-wrap: wrap; gap: 10px; }
.badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #e4f6ea;
  color: var(--green-dark);
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 18px;
  font-weight: 800;
}

/* ---------- konfeti ---------- */

#confettiLayer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 50; }
.confetti {
  position: absolute;
  top: -16px;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(105vh) rotate(560deg); opacity: 0.8; }
}

/* yatay iPad: soru ve cevaplar yanyana sığmasa da dikey düzen korunur, sadece boşluklar kısılır */
@media (max-height: 620px) {
  .question-card { padding: 4vh 5vw; }
  .answer-btn { min-height: 66px; font-size: 32px; }
  .screen { gap: 12px; }
}
