/* Katla: sicak yesil-altin arayuz. Palet: panel karari (HAN OYUN uyumlu). */
:root {
  --brand: #1FB574;
  --brand-deep: #0C7A4D;
  --coin: #E9B949;
  --coin-text: #5A4408;
  --success: #4FD8A0;
  --danger: #E07A4A;
  --danger-deep: #C2532B;
  --ink: #2C2622;
  --ink-soft: #6A6258;
  --paper: #F7EFE2;
  --cream: #FBF6EC;
  --sky-top: #0E2A22;
  --sky-bottom: #08201A;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--sky-top);
  touch-action: manipulation; /* pinch-zoom serbest, sadece canvas jest yutar */
  user-select: none;
  -webkit-user-select: none;
}
#mult, #cash-label, #cash-amount, .primary-btn, .ghost-btn, .chip,
h1, h2, .tagline, #res-big, #res-title, #balance, #bet-balance, .banner-gold, #banner {
  font-family: 'Fredoka', -apple-system, BlinkMacSystemFont, sans-serif;
}
/* Oyun kolonu: mobilde tam ekran, genis ekranda telefon oraninda; ust sinir sabit. */
#app {
  position: absolute; top: 0; bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: min(100vw, 480px, calc(100dvh * 0.62));
  overflow: hidden;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.5);
}
#game { position: absolute; inset: 0; display: block; touch-action: none; cursor: pointer; }
.hidden { display: none !important; }

/* Genis ekranda yan bosluk olu durmasin: ambient zemin */
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(120% 80% at 50% 0%, #15392E 0%, #0E2A22 45%, #061712 100%);
}

/* --- Ust bar --- */
#topbar {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 4px);
  left: env(safe-area-inset-left, 0px); right: env(safe-area-inset-right, 0px);
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px; padding: 10px 12px; pointer-events: none;
}
/* Giris veya sonuc ekrani acikken ust serit/carpan/topla gizlensin (yarim kesik gorunmesin) */
#app:has(#screen-bet:not(.hidden)) #topbar,
#app:has(#screen-result:not(.hidden)) #topbar,
#app:has(.overlay:not(.hidden)) #topbar { opacity: 0; pointer-events: none; }
#app:has(.overlay:not(.hidden)) #mult { opacity: 0 !important; }
#topbar .pill-link {
  text-decoration: none; display: inline-flex; align-items: center; gap: 5px;
  padding: 8px 12px; border-radius: 12px; border: 1px solid rgba(120,220,170,.4);
  background: rgba(8,24,18,.5); color: var(--success); font-weight: 800;
  font-size: clamp(12px, 3.6vw, 14px); min-height: 40px;
}
#balance-wrap {
  display: flex; align-items: center; gap: 7px; min-width: 0;
  background: linear-gradient(180deg, rgba(20,56,42,0.7), rgba(8,28,20,0.7));
  backdrop-filter: blur(6px);
  border: 1px solid rgba(120, 220, 170, 0.28);
  box-shadow: 0 4px 14px rgba(0,0,0,0.32), inset 0 1px 0 rgba(180,255,220,0.16);
  border-radius: 999px; padding: 7px 14px;
  color: #EAFBF1; font-weight: 700; font-size: clamp(13px, 4vw, 16.5px);
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.coin-ico {
  display: inline-block; width: 17px; height: 17px; vertical-align: -3px;
  background: url(../assets/img/coin.png) center/contain no-repeat;
  background-image: image-set(url(../assets/img/coin.webp) type("image/webp"), url(../assets/img/coin.png) type("image/png"));
}
#balance { display: inline-block; }
#balance.bal-bump { animation: balBump 0.42s cubic-bezier(.34,1.56,.64,1); }
@keyframes balBump {
  0% { transform: scale(1); }
  35% { transform: scale(1.28); color: var(--coin); text-shadow: 0 0 12px rgba(233,185,73,.7); }
  100% { transform: scale(1); }
}
.top-actions { display: flex; gap: 8px; pointer-events: auto; }
/* Dokunma hedefi >=44px (gorsel daire kucuk gorunse de hit-area genis) */
.icon-btn {
  width: 44px; height: 44px; border-radius: 999px;
  border: 1px solid rgba(120, 220, 170, 0.28);
  background: linear-gradient(180deg, rgba(20,56,42,0.7), rgba(8,28,20,0.7));
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3), inset 0 1px 0 rgba(180,255,220,0.16);
  color: #EAFBF1; font-size: 17px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* --- Carpan --- */
#mult {
  position: absolute; top: calc(env(safe-area-inset-top, 0px) + 64px);
  left: 0; right: 0; text-align: center;
  font-size: 58px; font-weight: 900; color: #EAFBF1;
  text-shadow: 0 3px 14px rgba(0, 0, 0, 0.5), 0 0 24px rgba(233, 185, 73, 0.28);
  -webkit-text-stroke: 1.5px rgba(8, 26, 18, 0.5); paint-order: stroke fill;
  pointer-events: none; opacity: 0; transition: opacity 0.2s;
  font-variant-numeric: tabular-nums; letter-spacing: 1px;
}
#mult.punch { animation: punch 0.28s ease-out; }
#mult.mult-hot { text-shadow: 0 0 18px rgba(233, 185, 73, 0.85), 0 2px 12px rgba(0,0,0,0.35); }
@keyframes punch { 0% { transform: scale(1); } 35% { transform: scale(1.28); } 100% { transform: scale(1); } }

/* --- Banner --- */
#banner {
  position: absolute; top: calc(env(safe-area-inset-top, 0px) + 132px);
  left: 50%; transform: translateX(-50%) translateY(-8px);
  padding: 8px 18px; border-radius: 999px; max-width: 90%;
  font-weight: 800; font-size: 14.5px; letter-spacing: 0.3px;
  opacity: 0; transition: opacity 0.18s ease-in, transform 0.24s ease-out;
  pointer-events: none; white-space: nowrap; z-index: 5;
  overflow: hidden; text-overflow: ellipsis;
}
#banner.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.banner-gold { background: linear-gradient(180deg, #FFD27A, #E8A219); color: #5A2E06; box-shadow: 0 0 18px rgba(255, 210, 122, 0.6); }
.banner-diamond { background: linear-gradient(180deg, #EAF6FF, #9ED2E8); color: #1E4356; box-shadow: 0 0 22px rgba(234, 246, 255, 0.7); }
.banner-esinti { background: rgba(31, 181, 116, 0.94); color: #04140d; }
.banner-isin { background: rgba(233, 222, 200, 0.95); color: #2C2622; }
.banner-zemin { background: rgba(79, 216, 160, 0.95); color: #04140d; }
.banner-zone { background: rgba(8, 28, 20, 0.9); color: var(--coin); border: 1px solid rgba(233,185,73,.5); }

#flash { position: absolute; inset: 0; pointer-events: none; z-index: 8; opacity: 0; transition: opacity 0.12s ease-out; }
#flash.show { opacity: 1; }

/* Kazanma isini (ChatGPT burst gorseli) - buyuk kazancta merkezde patlar */
#winburst {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%,-50%) scale(.4);
  width: 130%; aspect-ratio: 1; pointer-events: none; z-index: 7; opacity: 0;
  background: center/contain no-repeat; background-image: url(../assets/img/burst.webp);
}
#winburst.show { animation: burstPop 0.95s ease-out; }
@keyframes burstPop {
  0% { opacity: 0; transform: translate(-50%,-50%) scale(.4) rotate(0deg); }
  28% { opacity: .92; }
  100% { opacity: 0; transform: translate(-50%,-50%) scale(1.35) rotate(22deg); }
}

#form-chip {
  position: absolute; top: calc(env(safe-area-inset-top, 0px) + 132px);
  left: 50%; transform: translateX(-50%);
  background: rgba(31, 181, 116, 0.92); color: #04140d;
  padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: 13px;
  pointer-events: none; white-space: nowrap;
}

/* --- Toast & ipucu --- */
#toast {
  position: absolute; top: 32%; left: 50%; transform: translateX(-50%) scale(0.9);
  background: rgba(8, 28, 20, 0.9); color: var(--cream);
  padding: 10px 18px; border-radius: 999px; font-weight: 700; font-size: 15px;
  opacity: 0; transition: opacity 0.2s, transform 0.2s; pointer-events: none;
  white-space: nowrap; max-width: 92%; text-overflow: ellipsis; overflow: hidden; z-index: 9;
}
#toast.show { opacity: 1; transform: translateX(-50%) scale(1); }
#hint {
  position: absolute; top: 46%; left: 50%; transform: translateX(-50%);
  color: var(--cream); font-size: 17px; font-weight: 700;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
  animation: hintPulse 1.2s ease-in-out infinite; pointer-events: none;
}
@keyframes hintPulse { 0%,100% { opacity: 0.6; } 50% { opacity: 1; } }

/* --- TOPLA --- */
#btn-cashout {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 22px);
  min-width: 230px; padding: 15px 32px; border: 1px solid rgba(255, 240, 200, 0.55); border-radius: 999px;
  background: linear-gradient(180deg, #FFEFA6 0%, #F4D06A 46%, #D79A22 100%);
  box-shadow: 0 7px 0 #936610, 0 14px 30px rgba(0, 0, 0, 0.45),
    inset 0 2px 0 rgba(255, 255, 255, 0.7), inset 0 -4px 9px rgba(150, 100, 12, 0.4);
  cursor: pointer; animation: cashPulse 1.4s ease-in-out infinite;
  display: flex; flex-direction: column; align-items: center; gap: 2px; z-index: 6;
}
#btn-cashout:active { transform: translateX(-50%) translateY(3px); box-shadow: 0 3px 0 #836014; }
#cash-label { font-size: 28px; font-weight: 800; color: #5A2E06; letter-spacing: 1px; }
#cash-amount { font-size: 14px; font-weight: 700; color: #7A3D08; font-variant-numeric: tabular-nums; }
@keyframes cashPulse { 0%, 100% { transform: translateX(-50%) scale(1); } 50% { transform: translateX(-50%) scale(1.045); } }

/* --- Overlay panelleri --- */
.overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(4, 14, 10, 0.82); backdrop-filter: blur(4px); z-index: 10;
  padding: 16px;
}
.panel {
  width: min(360px, 100%); background: linear-gradient(160deg,#0f2a20,#0a1c14);
  border: 1px solid rgba(120,220,170,.4);
  border-radius: 22px; padding: 24px 20px; text-align: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6), 0 0 40px rgba(31,181,116,.1);
  max-height: 92vh; overflow-y: auto;
}
/* Metin-logo: gorsel asset bagimliligi YOK (oran/fallback/glow sorunlari cozuldu) */
.logo {
  width: min(248px, 74%); aspect-ratio: 1313 / 552; height: auto;
  margin: 2px auto 6px;
  background: center/contain no-repeat;
  background-image: image-set(url(../assets/img/logo.webp) type("image/webp"), url(../assets/img/logo.png) type("image/png"));
  text-indent: -9999px; overflow: hidden; font-size: 0; color: transparent;
  filter: drop-shadow(0 4px 12px rgba(233,185,73,.25));
}
.tagline { color: rgba(220,246,233,.65); font-size: 14px; margin: 4px 0 16px; }
.bet-balance-line { font-size: 18px; font-weight: 800; color: #EAFBF1; margin-bottom: 16px; }
.bet-balance-line .coin-ico { margin-right: 4px; }
.label { font-size: 13px; color: var(--success); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }

/* Cipler: 3 sutun sabit grid (tasma/kirpilma YOK, her ekran genisliginde sigar) */
#bet-chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 18px; }
.chip {
  padding: clamp(9px, 2.6vw, 11px) clamp(6px, 2vw, 12px); border-radius: 14px;
  border: 1.5px solid rgba(120,220,170,.3);
  background: linear-gradient(180deg, rgba(31,181,116,.14), rgba(31,181,116,.05));
  box-shadow: inset 0 1px 0 rgba(180,255,220,.12);
  color: #EAFBF1; font-weight: 800; font-size: clamp(13px, 3.8vw, 15px); cursor: pointer;
  font-variant-numeric: tabular-nums; transition: transform .12s; min-height: 44px;
}
.chip.sel {
  background: linear-gradient(180deg,#FFE89A,#D79A22); border-color: #ffe6a6; color: #2a1808;
  box-shadow: 0 4px 14px rgba(233,185,73,.4), inset 0 1px 0 rgba(255,255,255,.6);
  transform: translateY(-1px);
}
.chip:disabled { opacity: 0.35; cursor: default; }

.primary-btn {
  display: block; width: 100%; padding: 15px; border: none; border-radius: 16px;
  background: linear-gradient(180deg, #ffd86a, #D79A22);
  box-shadow: 0 4px 0 #836014;
  color: #5A2E06; font-size: 20px; font-weight: 900; letter-spacing: 1px; cursor: pointer;
  margin-bottom: 10px; min-height: 50px;
}
.primary-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #836014; }
.ghost-btn {
  display: block; width: 100%; padding: 12px; border: none; border-radius: 14px;
  background: transparent; color: rgba(220,246,233,.6); font-size: 15px; font-weight: 700; cursor: pointer;
  min-height: 44px;
}
.ad-btn { color: var(--coin); border: 1px dashed rgba(233,185,73,.5); background: rgba(233,185,73,.08); }
.best-line { margin-top: 8px; font-size: 13px; color: rgba(220,246,233,.55); font-weight: 600; }
.legal-line { margin-top: 12px; font-size: 11px; color: rgba(220,246,233,.42); line-height: 1.4; }

/* Hover (sadece fareli cihaz): masaustu olu hissetmesin */
@media (hover: hover) {
  .chip:hover { transform: translateY(-2px); filter: brightness(1.08); }
  .primary-btn:hover, .ad-btn:hover { filter: brightness(1.06); }
  .ghost-btn:hover { color: var(--cream); }
  .icon-btn:hover, .pill-link:hover { filter: brightness(1.12); }
  #btn-cashout:hover { filter: brightness(1.05); }
  .moment-share:hover { filter: brightness(1.15); }
}

/* Sonuc ekrani */
#screen-result .panel h2 { font-size: 27px; font-weight: 900; color: #EAFBF1; margin-bottom: 8px; }
#screen-result.win .panel h2 { color: #FFD970; text-shadow: 0 0 16px rgba(233,185,73,.5); }
#screen-result.lose .panel h2 { color: var(--danger); }
#screen-result.win .panel {
  border-color: rgba(233,185,73,.55);
  box-shadow: 0 18px 50px rgba(0,0,0,.6), 0 0 72px rgba(233,185,73,.24);
  border-top: 4px solid var(--coin);
}
#screen-result.lose .panel { border-top: 4px solid var(--danger); }
.overlay:not(.hidden) .panel { animation: panelPop .42s cubic-bezier(.34,1.56,.64,1); }
@keyframes panelPop { 0% { transform: scale(.82); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
#res-big { font-size: 46px; font-weight: 900; margin: 6px 0 10px; font-variant-numeric: tabular-nums; }
#screen-result.win #res-big {
  background: linear-gradient(180deg, #FFF1C2, #E9B949 48%, #C89A3A);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  text-shadow: 0 0 24px rgba(233, 201, 93, 0.5);
}
/* Kayip: vurgu basari (kat) uzerinde, ceza degil. Notr sicak ton. */
#screen-result.lose #res-big.lose-floors { color: #EADfce; font-size: 50px; }
#res-sub { font-size: 14px; color: rgba(220,246,233,.72); margin-bottom: 18px; line-height: 1.5; white-space: pre-line; }

/* Kutlama kademeleri */
#res-big.win-t1 { font-size: 38px; }
#res-big.win-t2 { font-size: 46px; }
#res-big.win-t3 { font-size: 54px; }
#res-big.win-t4 { font-size: 62px; }
#res-big.win-t5 {
  font-size: 72px;
  background: linear-gradient(180deg, #FFE6AE, #E8A219);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  text-shadow: 0 0 24px rgba(233, 201, 93, 0.45);
}

.star-btn {
  display: block; width: 100%; padding: 12px; margin-bottom: 10px;
  border: 2px dashed #C99A2E; border-radius: 14px;
  background: linear-gradient(180deg, #FFF0C2, #E9B949);
  color: #5A4408; font-size: 16px; font-weight: 800; cursor: pointer; min-height: 48px;
  animation: starPulse 1s ease-in-out infinite;
}
.star-btn::before {
  content: ''; display: inline-block; width: 22px; height: 22px; vertical-align: -5px; margin-right: 8px;
  background: center/contain no-repeat;
  background-image: image-set(url(../assets/img/star.webp) type("image/webp"), url(../assets/img/star.png) type("image/png"));
}
@keyframes starPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.03); } }

/* Gizem Kasası */
.chest-btn { color: var(--coin); font-weight: 800; }
.chest-btn.chest-dim { color: #8A9E90; font-weight: 700; }
.chest-title { color: #EAFBF1; margin-bottom: 6px; }
#chest-box {
  width: 132px; height: 100px; margin: 8px auto; display: block;
  background: url(../assets/img/chest.png) center/contain no-repeat;
  background-image: image-set(url(../assets/img/chest.webp) type("image/webp"), url(../assets/img/chest.png) type("image/png"));
  font-size: 0; transition: transform 0.15s;
}
#chest-box.opening { animation: chestShake 0.9s ease-in-out; }
#chest-box.open {
  background-image: url(../assets/img/chest-open.png);
  background-image: image-set(url(../assets/img/chest-open.webp) type("image/webp"), url(../assets/img/chest-open.png) type("image/png"));
}
@keyframes chestShake {
  0%, 100% { transform: rotate(0); }
  15% { transform: rotate(-8deg); } 30% { transform: rotate(8deg); }
  45% { transform: rotate(-6deg); } 60% { transform: rotate(6deg) scale(1.1); }
  80% { transform: scale(1.25); }
}
#chest-result { min-height: 34px; font-size: 28px; font-weight: 900; color: var(--success); font-variant-numeric: tabular-nums; margin-bottom: 6px; }
#chest-table { width: 100%; border-collapse: collapse; margin-bottom: 10px; font-size: 13px; }
#chest-table th, #chest-table td { padding: 4px 10px; text-align: center; border-bottom: 1px solid rgba(120,220,170,.2); color: #EAFBF1; font-variant-numeric: tabular-nums; }
#chest-table th { color: rgba(220,246,233,.6); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }

/* Görev ve galeri */
.quest-chip {
  margin: 4px 0 2px; padding: 8px 14px; border-radius: 12px;
  background: rgba(31, 181, 116, 0.1); border: 1px dashed rgba(31, 181, 116, 0.45);
  color: var(--success); font-size: 14px; font-weight: 700;
}
.share-btn { color: var(--coin); font-weight: 800; }
.moment-row { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid rgba(120,220,170,.2); }
.moment-ico { font-size: 22px; }
.moment-text { flex: 1; font-size: 15px; color: #EAFBF1; line-height: 1.3; text-align: left; }
.moment-text small { color: rgba(220,246,233,.55); }
.moment-share { border: none; background: rgba(31,181,116,.16); border-radius: 10px; padding: 8px 12px; font-size: 16px; cursor: pointer; min-height: 44px; min-width: 44px; }

/* Bilgi / magaza tablolari */
.info-panel { text-align: left; }
.info-panel h2 { text-align: center; color: #EAFBF1; margin-bottom: 10px; }
.info-panel p { font-size: 14px; color: rgba(220,246,233,.72); line-height: 1.55; margin-bottom: 12px; }
#info-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; font-size: 14px; }
#info-table th, #info-table td { padding: 5px 10px; text-align: center; border-bottom: 1px solid rgba(120,220,170,.2); color: #EAFBF1; font-variant-numeric: tabular-nums; }
#info-table th { color: rgba(220,246,233,.6); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }

/* Magaza (placeholder) */
.store-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; margin-bottom: 8px; border-radius: 14px;
  border: 1px solid rgba(120,220,170,.25); background: rgba(31,181,116,.06);
}
.store-item b { color: var(--coin); font-size: 16px; }
.store-soon { font-size: 12px; color: rgba(220,246,233,.5); font-weight: 700; border: 1px solid rgba(220,246,233,.25); border-radius: 999px; padding: 4px 10px; }

/* Yas kapisi */
#age-blocked { color: var(--danger); font-weight: 700; margin-top: 10px; }

/* ChatGPT UI ikon seti (3x3'ten kesildi) - butonlara premium ikon */
#btn-chest::before,#btn-ad::before,#btn-revive::before,#btn-store::before,#btn-invite::before,#btn-remind::before,#btn-gallery::before,#btn-share::before,.moment-share::before,#quest-chip::before{
  content:''; display:inline-block; width:20px; height:20px; vertical-align:-5px; margin-right:8px;
  background:center/contain no-repeat;
}
#btn-chest::before{background-image:image-set(url(../assets/img/ic-chest.webp) type("image/webp"),url(../assets/img/ic-chest.png) type("image/png"));}
#btn-ad::before,#btn-revive::before{background-image:image-set(url(../assets/img/ic-ad.webp) type("image/webp"),url(../assets/img/ic-ad.png) type("image/png"));}
#btn-store::before{background-image:image-set(url(../assets/img/ic-store.webp) type("image/webp"),url(../assets/img/ic-store.png) type("image/png"));}
#btn-invite::before{background-image:image-set(url(../assets/img/ic-invite.webp) type("image/webp"),url(../assets/img/ic-invite.png) type("image/png"));}
#btn-remind::before{background-image:image-set(url(../assets/img/ic-remind.webp) type("image/webp"),url(../assets/img/ic-remind.png) type("image/png"));}
#btn-gallery::before{background-image:image-set(url(../assets/img/ic-gallery.webp) type("image/webp"),url(../assets/img/ic-gallery.png) type("image/png"));}
#btn-share::before,.moment-share::before{background-image:image-set(url(../assets/img/ic-share.webp) type("image/webp"),url(../assets/img/ic-share.png) type("image/png"));}
#quest-chip::before{background-image:image-set(url(../assets/img/ic-quest.webp) type("image/webp"),url(../assets/img/ic-quest.png) type("image/png"));}
.moment-share::before{ width:16px; height:16px; margin-right:5px; vertical-align:-3px; }
/* Ses butonu: hoparlor ikonu (metin yerine) */
#btn-sound{ position:relative; }
#btn-sound::before{ content:''; position:absolute; inset:0; background:center/54% no-repeat;
  background-image:image-set(url(../assets/img/ic-sound.webp) type("image/webp"),url(../assets/img/ic-sound.png) type("image/png")); }
#btn-sound.muted::before{ opacity:.38; }
