:root {
  --bg: #fbf8f2;
  --surface: #ffffff;
  --ink: #1f2a44;
  --muted: #55607a;         /* küçük gri yazılar; krem zeminde ~5,9:1, beyazda ~6,3:1 (WCAG AA) */
  --blue: #a9d3f5;
  --blue-strong: #4a90d9;
  --mint: #bfe9d6;
  --mint-strong: #2f9e75;
  --lilac: #d8cdf7;
  --lilac-strong: #7b5fd0;
  --neg: #d9534f;
  --line: #e8e3d8;
  --shadow: 0 6px 16px rgba(31, 42, 68, 0.10);
  --radius: 18px;
  --flip: 380ms;            /* kart çevirme süresi (ui.js'teki FLIP_MS bunu ezer) */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
button { touch-action: manipulation; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  transition: background 0.45s ease;
}
body.dark {
  background: radial-gradient(ellipse at 50% 18%, #4a1018 0%, #1a0b12 55%, #0d060a 100%);
  color: #fff;
}

.app { width: 100%; max-width: 420px; margin: 0 auto; }

/* JavaScript kapalıyken görünen mesaj (index.html'deki <noscript>) */
.noscript {
  max-width: 420px; margin: 18vh auto 0; padding: 26px 22px; text-align: center;
  background: var(--surface); border-radius: 22px; box-shadow: var(--shadow);
}
.noscript h1 { margin: 0 0 10px; font-size: 1.8rem; letter-spacing: -0.5px; }
.noscript p { margin: 0; font-size: 1.05rem; line-height: 1.5; }

.screen { display: none; flex-direction: column; gap: 16px; }
.screen.active { display: flex; }

.title { margin: 0; font-size: 2rem; text-align: center; letter-spacing: -0.5px; }
.title.small { font-size: 1.3rem; text-align: left; }
.title.big { font-size: 2.8rem; line-height: 1.05; letter-spacing: -1px; }
.muted { margin: 0; text-align: center; color: var(--muted); }
.label { font-size: 0.75rem; font-weight: 700; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; }

/* ---------- Ana menü: tek ekrana sığar (kaydırma kilidi yok; çek-yenile çalışır) ---------- */

.menu {
  --safe-t: max(16px, env(safe-area-inset-top));
  --safe-b: max(20px, env(safe-area-inset-bottom));
  gap: clamp(8px, 2dvh, 16px);
  height: calc(100vh - var(--safe-t) - var(--safe-b));
  height: calc(100dvh - var(--safe-t) - var(--safe-b));
}

.menu-top { flex: none; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 11px;
  background: linear-gradient(135deg, var(--blue-strong), var(--lilac-strong));
  color: #fff; font-size: 1.1rem; font-weight: 800;
  box-shadow: 0 4px 10px rgba(74, 90, 217, 0.28);
}
.brand-name { font-size: 1.1rem; font-weight: 800; letter-spacing: -0.2px; }

.hero-panel {
  flex: 1 1 0; min-height: 0;
  display: flex; flex-direction: column; align-items: stretch; justify-content: center;
  gap: clamp(12px, 3dvh, 30px);
  padding: clamp(14px, 3dvh, 28px) 20px; text-align: center; border-radius: 28px;
  background: linear-gradient(165deg, #e6f2fd 0%, #efeafc 100%);
  border: 1px solid #dde6f5; box-shadow: var(--shadow);
}

/* Başlık + açıklama: tek blok, sıkı ve dengeli aralık */
.hero-copy { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.hero-title {
  margin: 0; font-size: clamp(1.55rem, min(4.8dvh, 9vw), 2.5rem); font-weight: 800;
  line-height: 1.12; letter-spacing: -0.02em; text-wrap: balance;
}
.hero-sub {
  margin: 0; max-width: 34ch; color: var(--muted);
  font-size: 0.98rem; line-height: 1.5; text-wrap: balance;
}

/* Kart görseli: üç kart simetrik, ölçüler --ch'den türer */
.hero { --ch: clamp(48px, 15dvh, 128px); position: relative; flex: none; height: calc(var(--ch) * 1.2); }
.fcard {
  position: absolute; bottom: 0; left: 50%;
  width: calc(var(--ch) * 0.8); height: var(--ch); margin-left: calc(var(--ch) * -0.4);
  display: grid; place-items: center; border-radius: calc(var(--ch) * 0.2);
  font-size: calc(var(--ch) * 0.34); font-weight: 800; line-height: 1; color: rgba(255, 255, 255, 0.95);
  background: linear-gradient(135deg, var(--blue-strong), #7fb6ee);
  box-shadow: 0 10px 20px rgba(31, 42, 68, 0.16);
  transform-origin: 50% 120%;
}
.fcard.c1 { transform: translateX(calc(var(--ch) * -0.56)) rotate(-12deg); animation: float 4.2s ease-in-out infinite; }
.fcard.c2 {
  z-index: 2; background: linear-gradient(135deg, var(--mint-strong), #7fd1b0); font-size: calc(var(--ch) * 0.42);
  animation: float 4.2s ease-in-out -1.4s infinite;
}
.fcard.c3 {
  background: linear-gradient(135deg, var(--lilac-strong), #b3a1ec);
  transform: translateX(calc(var(--ch) * 0.56)) rotate(12deg); animation: float 4.2s ease-in-out -2.8s infinite;
}
@keyframes float {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -6px; }
}

/* Düğme + alt not: aynı genişlik ve ritim */
.menu-actions { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.menu-actions .btn.primary.big { min-height: 58px; font-size: 1.15rem; border-radius: 18px; letter-spacing: 0.01em; }
.foot { margin: 0; text-align: center; color: var(--muted); font-size: 0.82rem; line-height: 1.3; }
.menu-actions:has(.best:not(:empty)) .foot { display: none; }
.menu-actions .best { font-size: 0.88rem; padding: 7px 14px; }

.section-title {
  margin: 0; font-size: 0.78rem; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--muted);
}

/* İletişim: sayfaya gömülü, tek renk, minimal */
.site-footer { flex: none; display: flex; flex-direction: column; align-items: center; padding-bottom: 2px; }
.ct {
  display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 0 8px;
  color: var(--muted); font-size: 0.9rem; font-weight: 600; text-decoration: none;
  transition: color 0.2s;
}
.ct svg { flex: none; }
.ct-row { display: flex; align-items: center; justify-content: center; }
.ct-dot { color: var(--muted); opacity: 0.5; }
@media (hover: hover) { .ct:hover { color: var(--ink); } }
.ct:focus-visible { outline: 3px solid var(--blue-strong); outline-offset: 2px; border-radius: 8px; }
.copyright { margin: 2px 0 0; color: var(--muted); font-size: 0.75rem; text-align: center; }

/* Kısa ekranlar: önce ikincil metinler gider, böylece menü hep tek ekrana sığar */
@media (max-height: 720px) { .foot { display: none; } }
@media (max-height: 640px) {
  .hero-sub { display: none; }
  .menu-actions .btn.primary.big { min-height: 52px; font-size: 1.1rem; }
}
@media (max-width: 360px) {
  .ct { font-size: 0.85rem; padding: 0 6px; gap: 6px; }
}
@media (max-height: 540px) {
  .hero { --ch: 50px; }
  .brand-mark { width: 30px; height: 30px; font-size: 1rem; }
  .copyright { display: none; }
  .hero-panel { padding-top: 8px; padding-bottom: 8px; }
}

/* Yatay telefon: iki sütun (sol: oyuna giriş, sağ: iletişim) */
@media (orientation: landscape) and (max-height: 520px) {
  body:has(#screen-menu.active) .app { max-width: 880px; }
  .menu.active { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto minmax(0, 1fr); column-gap: 16px; row-gap: 8px; }
  .menu-top { grid-column: 1 / -1; }
  .hero-panel { grid-column: 1; grid-row: 2; }
  .site-footer { grid-column: 2; grid-row: 2; justify-content: center; align-self: stretch; }
  .hero-sub, .foot { display: none; }
  .copyright { display: block; }
  .hero { --ch: clamp(44px, 14dvh, 70px); }
  .hero-title { font-size: clamp(1.3rem, 7dvh, 1.9rem); }
  .hero-copy { gap: 0; }
}

/* Butonlar */
.btn {
  min-height: 52px; padding: 0 20px; border: 0; border-radius: 16px;
  font: inherit; font-size: 1.05rem; font-weight: 700; cursor: pointer;
  transition: transform 0.08s, filter 0.15s, background 0.2s, opacity 0.2s;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { cursor: default; opacity: 0.5; }
.btn.primary { background: var(--blue-strong); color: #fff; }
.btn.primary.big {
  min-height: 62px; font-size: 1.25rem; border-radius: 20px;
  background: linear-gradient(135deg, #4a90d9, #7b5fd0);
  box-shadow: 0 10px 22px rgba(74, 90, 217, 0.35);
}
.btn.secondary { background: var(--mint); color: #145a42; }
.btn.ghost { background: transparent; color: var(--ink); border: 2px solid var(--line); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row .btn { width: 100%; }

/* ---------- Oyun ekranı ---------- */
.game-head { display: flex; align-items: center; justify-content: space-between; }
.head-right { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 999px; border: 2px solid var(--line);
  background: var(--surface); font-size: 1.05rem; display: grid; place-items: center;
  cursor: pointer; transition: transform 0.08s; padding: 0;
}
.icon-btn:active { transform: scale(0.92); }
.pill {
  padding: 8px 14px; border-radius: 999px; background: var(--lilac);
  color: #3d2c85; font-weight: 800; font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}
.pill.bump { animation: bump 0.3s ease; }

.score-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 12px 10px; background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.score-card.big {
  padding: 22px 14px;
}
.score { font-size: 2.9rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.score.neg { color: var(--neg); }
.score.bump { animation: bump 0.3s ease; }
.score-card.big .score { font-size: 4.2rem; }

.score-breakdown {
  margin-top: 4px; font-size: 0.92rem; font-weight: 700; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.score-breakdown:empty { display: none; }

@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.15); } 100% { transform: scale(1); } }

/* Kart alanı */
.grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  width: 100%; max-width: 380px; margin: 0 auto;
}

.card {
  position: relative; aspect-ratio: 1 / 1; padding: 0; border: 0;
  background: none; -webkit-perspective: 700px; perspective: 700px; cursor: pointer; font: inherit;
  -webkit-appearance: none; appearance: none;
  transition: opacity 0.28s ease, transform 0.28s ease;
}
.card-inner {
  position: absolute; inset: 0;
  -webkit-transform-style: preserve-3d; transform-style: preserve-3d;
  transition: transform var(--flip) cubic-bezier(0.25, 0.8, 0.25, 1);
  will-change: transform;
}
.card.revealed .card-inner,
.card.peek .card-inner { -webkit-transform: rotateY(180deg); transform: rotateY(180deg); }
.card:not(.revealed):not(.peek):not(.closing):active .card-inner { transform: scale(0.95); }

/* Yeni tura geçerken: kartlar sol üstten sağ alta çapraz dalgayla kapanır ve hafifçe yerinde karışır */
.card.closing {
  pointer-events: none;
  transition-delay: var(--wave, 0ms);
  animation: redeal var(--flip) cubic-bezier(0.25, 0.8, 0.25, 1) var(--wave, 0ms);
}
.card.closing .card-inner {
  transition-delay: var(--wave, 0ms);
}
@keyframes redeal {
  0%, 100% { translate: 0 0; }
  45% { translate: 0 -5px; }
}

.face {
  position: absolute; inset: 0; display: grid; place-items: center;
  border-radius: var(--radius); backface-visibility: hidden; -webkit-backface-visibility: hidden;
  box-shadow: var(--shadow);
}
.face.back {
  background: linear-gradient(135deg, var(--blue), var(--lilac));
  color: rgba(255, 255, 255, 0.95); font-size: 2.2rem; font-weight: 800;
}
.face.front {
  -webkit-transform: rotateY(180deg); transform: rotateY(180deg);
  background: var(--surface); border: 3px solid var(--line);
  font-size: clamp(2rem, 11vw, 2.8rem); font-weight: 800; font-variant-numeric: tabular-nums;
}
.card.revealed, .card.peek { cursor: default; }

/* Renk sınıfları (.picked, .neg, .zero) kapanış dönüşü bitene kadar korunduğu için renk sıçraması olmaz */
.card.picked .face.front { border-color: var(--mint-strong); background: #f3fbf7; }
.card.neg .face.front,
.card.zero .face.front { border-color: var(--neg); background: #fdf3f2; color: var(--neg); }

/* FOMO Etkisi: seçilmeyen diğer 8 kartın yarı saydam açılışı */
.card.peek {
  opacity: 0.42;
  transform: scale(0.94);
  pointer-events: none;
}

/* Sıfır açıldı */
.card.doom .face.front {
  border-color: var(--neg); background: #fdecea; color: var(--neg);
}
.card.doom .face.front::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: 0 0 0 8px rgba(217, 83, 79, 0.35), 0 0 30px 10px rgba(217, 83, 79, 0.6);
  opacity: 0; animation: doom-glow 0.55s ease 2;
}
@keyframes doom-glow { 50% { opacity: 1; } }
.grid.dead .card:not(.revealed) { opacity: 0.32; transform: scale(0.93); filter: grayscale(0.45); pointer-events: none; }
.screen.shake { animation: shake 0.5s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  12% { transform: translateX(-12px); } 25% { transform: translateX(11px); }
  38% { transform: translateX(-9px); }  52% { transform: translateX(7px); }
  66% { transform: translateX(-4px); }  80% { transform: translateX(2px); }
}
.flash {
  position: fixed; inset: 0; z-index: 50; pointer-events: none; opacity: 0; will-change: opacity;
  background: radial-gradient(ellipse at center, rgba(255, 60, 50, 0.55), rgba(120, 0, 10, 0.75));
}
.flash.on { animation: flash 0.95s ease-out; }
@keyframes flash { 0% { opacity: 0; } 12% { opacity: 1; } 100% { opacity: 0; } }

.last-op {
  min-height: 44px; display: grid; place-items: center;
  padding: 10px 14px; text-align: center; font-weight: 700; font-size: 1.05rem;
  background: var(--surface); border: 2px dashed var(--line); border-radius: 14px;
  font-variant-numeric: tabular-nums;
  white-space: pre-line; line-height: 1.35;
}

.combo-banner {
  min-height: 0;
  margin: -4px 0;
  color: var(--lilac-strong);
  font-size: 1.7rem;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  opacity: 0;
  transform: scale(0.65) translateY(8px);
  pointer-events: none;
}
.combo-banner.show { animation: combo-pop 1.35s ease-out both; }
@keyframes combo-pop {
  0% { opacity: 0; transform: scale(0.65) translateY(8px); }
  22% { opacity: 1; transform: scale(1.18) translateY(0); }
  45% { transform: scale(0.98) translateY(0); }
  100% { opacity: 0; transform: scale(1) translateY(-10px); }
}

/* ---------- Sonuç ekranı ---------- */
.best {
  margin: 0; align-self: center; padding: 8px 16px; border-radius: 999px;
  background: var(--mint); color: #145a42; font-weight: 800; font-size: 0.95rem;
}
.best:empty { display: none; }
.best.dark { background: rgba(255, 255, 255, 0.12); color: #ffd7d4; }

.picked { display: flex; flex-direction: column; gap: 8px; }
.picked-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.picked-item {
  min-width: 40px; padding: 8px 10px; text-align: center; font-weight: 800;
  background: var(--surface); border: 2px solid var(--line); border-radius: 12px;
  color: var(--ink);
}
.picked-item.neg { color: var(--neg); border-color: var(--neg); }
.picked-arrow { color: var(--muted); }

/* ---------- Game over ---------- */
.gameover { align-items: center; text-align: center; gap: 14px; min-height: calc(100dvh - 40px); justify-content: center; }
.gameover > * { animation: rise 0.45s ease both; }

.go-zero {
  font-size: 9.5rem; line-height: 0.95; font-weight: 900; color: #ff5a52;
  text-shadow: 0 0 24px rgba(255, 70, 60, 0.7), 0 0 60px rgba(255, 40, 30, 0.45);
  position: relative; isolation: isolate;
  animation: slam 0.55s cubic-bezier(0.2, 1.5, 0.4, 1) both;
}
@keyframes slam {
  0% { transform: scale(3.2) rotate(-8deg); opacity: 0; }
  60% { transform: scale(0.94) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.go-zero::after {
  content: ""; position: absolute; inset: -10% -25%; z-index: -1; pointer-events: none;
  background: radial-gradient(closest-side, rgba(255, 60, 50, 0.38), transparent);
  opacity: 0.5; animation: glow 2.4s ease-in-out 0.6s infinite;
}
@keyframes glow { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

.go-title {
  margin: 0; font-size: 2.2rem; font-weight: 900; letter-spacing: 0.22em; padding-left: 0.22em;
  animation-delay: 0.3s;
}
.go-sub { margin: 0; color: #ffb9b4; font-size: 1.1rem; animation-delay: 0.5s; }

.go-lost { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; animation-delay: 0.7s; }
.go-label { font-size: 0.75rem; font-weight: 700; letter-spacing: 1px; color: rgba(255, 255, 255, 0.6); text-transform: uppercase; }
.go-score { font-size: 3.2rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; color: #fff; }
.go-score.zeroed { color: #ff5a52; }
.go-detail { margin: 0; color: rgba(255, 255, 255, 0.75); animation-delay: 0.85s; }
.go-combo {
  margin: -8px 0 0;
  color: #fce8b2;
  font-size: 1.15rem;
  font-weight: 800;
  animation-delay: 0.95s;
}
.go-combo:empty { display: none; }
.go-picks { display: flex; flex-direction: column; gap: 8px; align-items: center; animation-delay: 1.35s; }
.go-picks .picked-list { justify-content: center; }
.go-picks .picked-item { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.25); color: #fff; }
.go-picks .picked-item.neg { color: #ff9a94; border-color: #ff9a94; }
.go-picks .picked-item.doom { background: #ff5a52; border-color: #ff5a52; color: #fff; }
.go-picks .picked-arrow { color: rgba(255, 255, 255, 0.5); }
#go-best { animation-delay: 1.5s; }

.go-actions { width: 100%; margin-top: 6px; animation-delay: 1.7s; }
.btn.danger-btn { background: #ff5a52; color: #fff; box-shadow: 0 10px 22px rgba(255, 70, 60, 0.35); }
.btn.ghost-dark { background: transparent; color: #fff; border: 2px solid rgba(255, 255, 255, 0.3); }

/* ---------- Onay kutusu (<dialog class="confirm">) ---------- */
.confirm {
  width: calc(100% - 40px); max-width: 340px; padding: 22px 20px;
  border: 0; border-radius: 22px;
  background: var(--surface); color: var(--ink);
  box-shadow: 0 16px 36px rgba(31, 42, 68, 0.22);
}
.confirm[open] { animation: modal-pop 0.24s cubic-bezier(0.2, 1.3, 0.4, 1); }
.confirm::backdrop {
  background: rgba(31, 42, 68, 0.45);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.confirm[open]::backdrop { animation: fade-in 0.2s ease; }
.confirm form { margin: 0; display: flex; flex-direction: column; gap: 16px; }
.confirm p {
  margin: 0; text-align: center; font-size: 1.1rem; font-weight: 700; line-height: 1.4;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-pop { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

@media (max-width: 340px) {
  .grid { gap: 8px; }
  .score { font-size: 2.3rem; }
  .go-zero { font-size: 7.5rem; }
}
/* Işık ve hareket hassasiyeti: flaş, sarsıntı ve çevirme/ölçekleme hareketleri kapanır.
   Geri bildirim (renkler, metin, ses) olduğu gibi kalır. */
@media (prefers-reduced-motion: reduce) {
  /* Işık: kırmızı flaş hiç gösterilmez */
  .flash, .flash.on { display: none; animation: none; }

  /* Sarsıntı */
  .screen.shake { animation: none; }

  /* Kart çevirme: 3B dönüş yok, kart anında açılır/kapanır; yeniden karıştırma dalgası yok */
  .card { transition: opacity 0.15s ease; }
  .card-inner { transition: none; }
  .card.closing { animation: none; transition-delay: 0s; }
  .card.closing .card-inner { transition-delay: 0s; }
  .card:not(.revealed):not(.peek):not(.closing):active .card-inner { transform: none; }

  /* Skor, tur ve düğme vurguları */
  .pill.bump, .score.bump { animation: none; }
  .btn, .icon-btn, .ct { transition: none; }
  .btn:active:not(:disabled), .icon-btn:active { transform: none; }
  body { transition: none; }
  .fcard { animation: none; }

  /* Combo: zıplamak yerine yalnızca belirir ve söner */
  .combo-banner { transform: none; }
  .combo-banner.show { animation: combo-fade 1.35s ease-out both; }
  @keyframes combo-fade {
    0% { opacity: 0; }
    15%, 70% { opacity: 1; }
    100% { opacity: 0; }
  }

  /* Game over: büyüme/kayma yok, öğeler yumuşakça belirir; yanıp sönen parıltılar sabit */
  .gameover > *, .go-zero { animation: fade-in 0.3s ease both; }
  .go-zero::after { animation: none; }
  .card.doom .face.front::after { animation: none; opacity: 1; }

  /* Onay kutusu */
  .confirm[open], .confirm[open]::backdrop { animation: none; }
}