:root {
  --bg: #f4ead7;
  --bg2: #efe0c6;
  --ink: #4a3728;
  --muted: #8a7355;
  --card: #fffaf0;
  --accent: #c97b45;
  --accent2: #7a9e6e;
  --danger: #c85a54;
  --gold: #d9a441;
  --shadow: 0 6px 18px rgba(74, 55, 40, 0.15);
  --radius: 14px;
}

* { box-sizing: border-box; }

html {
  /* Adres cubugu acilip kapanirken zipplamayi onler */
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: "Segoe UI", -apple-system, "Helvetica Neue", sans-serif;
  background: radial-gradient(circle at 20% 0%, #fff5e4, var(--bg));
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  /* Mobil/TWA: cekme-yenile ve zincirli kaydirma kapali */
  overscroll-behavior-y: contain;
  -webkit-tap-highlight-color: transparent;
}

/* Dokunmatik: cift dokunma yakinlastirmasi ve metin secimi oyun icinde kapali */
button, .unit, .candidate, .upgrade, .tab, .mi, .diff-btn, .lb-tab, .bt {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
input, textarea { -webkit-user-select: text; user-select: text; }

/* ---------- Overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(74, 55, 40, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
  backdrop-filter: blur(3px);
}
.overlay.hidden { display: none; }
.hidden { display: none !important; }

.intro-card, .modal-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px 30px;
  max-width: 540px;
  width: 100%;
  box-shadow: var(--shadow);
  border: 2px solid #e6d3b3;
  animation: pop 0.3s ease;
  max-height: 90vh;
  overflow-y: auto;
}
@keyframes pop { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.intro-emoji { font-size: 46px; text-align: center; }
.intro-card h1 { text-align: center; margin: 8px 0 4px; color: var(--accent); }
.intro-card .tag { text-align: center; color: var(--muted); margin: 0 0 16px; font-style: italic; }
.intro-card .story { line-height: 1.55; }
.story-list { line-height: 1.8; padding-left: 18px; }
.story-list li { margin-bottom: 4px; }
.intro-actions { display: flex; gap: 10px; margin-top: 18px; }
.intro-actions .btn { flex: 1; font-size: 16px; }

/* ---------- Buttons ---------- */
.btn {
  border: none;
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease;
  font-family: inherit;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--accent2); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: #eaddc4; color: var(--ink); }
.btn-sm { padding: 8px 11px; font-size: 15px; }

/* ---------- HUD ---------- */
#hud {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--card);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}
.brand { font-size: 19px; font-weight: 800; color: var(--accent); }
.stats { display: flex; gap: 8px; flex-wrap: wrap; }
.controls { display: flex; gap: 6px; margin-left: auto; }
.stat {
  background: var(--bg2);
  border-radius: 10px;
  padding: 7px 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}
.stat.glory { background: linear-gradient(135deg, #ffe9b0, #f4c95d); }
.stat-ico { font-size: 16px; }

/* ---------- Layout ---------- */
main {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  padding: 20px;
  max-width: 1240px;
  margin: 0 auto;
}
@media (max-width: 900px) { main { grid-template-columns: 1fr; } }

.section-title { font-size: 18px; font-weight: 800; margin-bottom: 12px; color: var(--muted); }
.section-title .sub { font-size: 13px; font-weight: 600; color: var(--muted); }

/* ---------- Building ---------- */
#building {
  display: flex;
  flex-direction: column-reverse;
  gap: 9px;
  background: linear-gradient(180deg, #d9b98d, #c9a877);
  padding: 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border-bottom: 10px solid #8a6b45;
}
.floor { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }

.unit {
  background: var(--card);
  border-radius: 12px;
  padding: 10px;
  min-height: 112px;
  cursor: pointer;
  border: 2px solid #e6d3b3;
  transition: transform 0.1s ease, box-shadow 0.15s ease, border-color 0.15s;
  position: relative;
  display: flex;
  flex-direction: column;
}
.unit:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.unit.damaged { background: repeating-linear-gradient(45deg, #e9d9bd, #e9d9bd 8px, #ddc8a4 8px, #ddc8a4 16px); color: var(--muted); }
.unit.empty { border-style: dashed; color: var(--muted); align-items: center; justify-content: center; text-align: center; font-size: 13px; }
.unit.placeable { border-color: var(--accent2); box-shadow: 0 0 0 3px rgba(122,158,110,0.35); }
.unit.rivalpulse { animation: shake 0.5s ease; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-3px)} 75%{transform:translateX(3px)} }
.unit .unit-tag { font-size: 10px; color: var(--muted); position: absolute; top: 5px; left: 9px; }
.unit .badges { position: absolute; top: 4px; right: 7px; font-size: 13px; display: flex; gap: 2px; }

.tenant-emoji { font-size: 26px; }
.tenant-name { font-weight: 700; font-size: 13px; margin-top: 2px; }
.tenant-role { font-size: 10px; color: var(--muted); line-height: 1.25; }
.lvl { font-size: 10px; background: var(--gold); color: #fff; border-radius: 6px; padding: 1px 5px; font-weight: 800; }

.mood-bar { height: 7px; border-radius: 6px; background: #e6d3b3; margin-top: auto; overflow: hidden; }
.mood-fill { height: 100%; border-radius: 6px; transition: width 0.3s ease; }
.mood-label { font-size: 10px; margin-top: 3px; display: flex; justify-content: space-between; }

/* ---------- Sidebar ---------- */
#sidebar { display: flex; flex-direction: column; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tab {
  flex: 1;
  padding: 9px 6px;
  border: none;
  background: var(--bg2);
  border-radius: 10px 10px 0 0;
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  color: var(--muted);
  font-family: inherit;
}
.tab.active { background: var(--card); color: var(--accent); box-shadow: var(--shadow); }
.tab-panel { display: none; background: var(--card); border-radius: 0 12px 12px 12px; padding: 14px; box-shadow: var(--shadow); min-height: 360px; max-height: 62vh; overflow-y: auto; }
.tab-panel.active { display: block; }
.panel-note { font-size: 13px; color: var(--muted); margin-bottom: 10px; }

/* ---------- Cards ---------- */
.candidate, .upgrade {
  background: var(--bg);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 9px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.12s, transform 0.08s;
}
.candidate:hover, .upgrade:hover { transform: translateX(2px); }
.candidate.selected { border-color: var(--accent); background: #fff3e2; }
.cand-head { display: flex; align-items: center; gap: 9px; }
.cand-emoji { font-size: 26px; }
.cand-name { font-weight: 700; font-size: 14px; }
.cand-role { font-size: 11px; color: var(--muted); }
.cand-rent { margin-left: auto; font-weight: 800; color: var(--accent2); }
.cand-patience { font-size: 10px; color: var(--danger); margin-top: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.chip { font-size: 10px; background: #e9dcc2; padding: 2px 7px; border-radius: 20px; color: var(--muted); }
.chip.night { background: #d5d0ec; color: #4b3f7a; }
.chip.day { background: #fbe6b8; color: #8a6a1e; }
.chip.loud { background: #f3cfcb; color: #9c3f39; }
.chip.quiet { background: #cfe6d0; color: #3f7a48; }

.upgrade.owned { border-color: var(--accent2); background: #eef6ea; }
.up-head { display: flex; align-items: center; gap: 9px; }
.up-cost { margin-left: auto; font-weight: 800; color: var(--accent); }
.up-desc { font-size: 12px; color: var(--muted); margin-top: 5px; }

.end-month { margin-top: 14px; }

/* ---------- Log ---------- */
#eventLog .log-item { font-size: 13px; padding: 7px 9px; border-radius: 8px; margin-bottom: 6px; background: var(--bg); border-left: 3px solid var(--muted); }
.log-item.good { border-left-color: var(--accent2); }
.log-item.bad { border-left-color: var(--danger); }
.log-item.money { border-left-color: var(--gold); }
.log-item.chaos { border-left-color: #9b59b6; background: #f3e9f7; }

/* ---------- Modal detail ---------- */
.modal-card h2 { margin-top: 0; }
.reason { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px dashed #e6d3b3; font-size: 14px; }
.reason .val.pos { color: var(--accent2); font-weight: 700; }
.reason .val.neg { color: var(--danger); font-weight: 700; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.close-x { float: right; cursor: pointer; font-size: 22px; color: var(--muted); border: none; background: none; }
.rel-list { margin-top: 10px; }
.rel-item { font-size: 13px; padding: 4px 0; }
.xpbar { height: 8px; background: #e6d3b3; border-radius: 6px; overflow: hidden; margin: 6px 0 12px; }
.xpfill { height: 100%; background: var(--gold); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 11px 20px;
  border-radius: 30px;
  font-weight: 600;
  z-index: 60;
  box-shadow: var(--shadow);
  animation: rise 0.25s ease;
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- v3: mevsim, borç, istek, banka, başarımlar ---------- */
.stat.debt { background: linear-gradient(135deg, #f3cfcb, #e79b95); color: #7a2f2a; }

.quest-badge { font-size: 12px; }
.unit .quest-flag { position: absolute; bottom: 6px; right: 8px; font-size: 13px; }

.quest-box {
  background: #fff3e2; border: 1px dashed var(--accent);
  border-radius: 10px; padding: 10px 12px; margin: 12px 0;
}
.quest-box .q-title { font-weight: 800; font-size: 13px; margin-bottom: 3px; }
.quest-box .q-meta { font-size: 12px; color: var(--muted); }
.quest-box.done { background: #eef6ea; border-color: var(--accent2); }

.season-banner {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted); font-weight: 600;
}

/* Banka & başarım modalleri */
.bank-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; flex-wrap: wrap; }
.bank-info { background: var(--bg); border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.bank-info div { margin: 3px 0; font-size: 14px; }
.loan-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 6px; }

.ach-grid { display: grid; grid-template-columns: 1fr; gap: 8px; max-height: 55vh; overflow-y: auto; }
.ach-item {
  display: flex; align-items: center; gap: 11px;
  background: var(--bg); border-radius: 10px; padding: 10px 12px;
  border: 2px solid transparent;
}
.ach-item.unlocked { border-color: var(--gold); background: #fdf4dd; }
.ach-item.locked { opacity: 0.55; filter: grayscale(0.6); }
.ach-emoji { font-size: 26px; }
.ach-name { font-weight: 800; font-size: 14px; }
.ach-desc { font-size: 12px; color: var(--muted); }
.ach-progress { margin-left: auto; font-size: 18px; }

/* Mevsim arka plan ipucu */
body.season-spring { background: radial-gradient(circle at 20% 0%, #fff0f4, #f4ead7); }
body.season-summer { background: radial-gradient(circle at 20% 0%, #fff7df, #f4ead7); }
body.season-autumn { background: radial-gradient(circle at 20% 0%, #ffeeda, #f0e2c9); }
body.season-winter { background: radial-gradient(circle at 20% 0%, #eef3fb, #e6e2d5); }

/* ---------- v4: zorluk, yıldız, parçacık, gündüz/gece, çift, grafik ---------- */
.diff-select { margin: 16px 0 4px; }
.diff-title { font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 700; }
.diff-btns { display: flex; gap: 8px; }
.diff-btn { flex: 1; padding: 10px; border: 2px solid #e6d3b3; background: var(--bg); border-radius: 10px; cursor: pointer; font-weight: 700; font-family: inherit; color: var(--ink); }
.diff-btn.active { border-color: var(--accent); background: #fff3e2; color: var(--accent); }

.stars { color: var(--gold); font-weight: 800; letter-spacing: 1px; }

.candidate.rare { border-color: var(--gold); background: linear-gradient(135deg, #fff7e0, #fdeec2); }
.candidate.rare .cand-name { color: #b8860b; }

/* Parçacıklar */
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.particle { position: absolute; top: -30px; animation-name: fall; animation-timing-function: linear; animation-iteration-count: infinite; opacity: 0.8; }
@keyframes fall {
  0% { transform: translateY(-30px) rotate(0deg); }
  100% { transform: translateY(105vh) rotate(360deg); }
}

/* Gündüz / gece tonu */
body.is-night #hud, body.is-night #building { filter: brightness(0.94) saturate(0.95); }
body.is-night { --nighttint: 1; }
body.is-night::after {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(circle at 80% -10%, rgba(40,50,90,0.10), rgba(20,25,50,0.16));
}

/* Çift göstergesi */
.unit .tenant-emoji { line-height: 1; }

/* İstatistik grafiği */
.chart-label { font-size: 12px; color: var(--muted); font-weight: 700; margin: 12px 0 4px; }
.chart { display: flex; align-items: flex-end; gap: 3px; height: 90px; background: var(--bg); border-radius: 8px; padding: 8px; }
.chart .bar { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; transition: height 0.2s; }
.chart .bar.happy { background: var(--accent2); }

/* Müzik butonu aktif */
.btn.active { background: #ffe9b0; }

/* Nadir rozet vurgusu */
.badges { z-index: 2; }

/* ---------- v5: görsel cephe, sorunlar, kademeli geliştirme, skor tablosu ---------- */
#building { background: linear-gradient(180deg, #cdeafd 0%, #e6f2f7 22%, #d9b98d 22%); position: relative; }
body.is-night #building { background: linear-gradient(180deg, #2b3a5e 0%, #40507a 22%, #b89b73 22%); }

.roof { height: 26px; background: linear-gradient(180deg,#8a5a3c,#6f4428); border-radius: 10px 10px 4px 4px; margin: 0 -4px 8px; box-shadow: inset 0 -4px 0 rgba(0,0,0,0.15); position: relative; }
.roof::after { content:''; position:absolute; top:-10px; left:50%; transform:translateX(-50%); width:0; height:0; border-left:24px solid transparent; border-right:24px solid transparent; border-bottom:12px solid #6f4428; }

.ground { display:flex; align-items:center; justify-content:center; gap:12px; margin-top:8px; padding:10px; background:linear-gradient(180deg,#b89b73,#9c7f57); border-radius:6px; }
.ground .door { font-size:30px; background:#5b3f28; border-radius:8px 8px 0 0; padding:2px 6px; }
.ground .plate { font-weight:800; letter-spacing:2px; color:#fff6e6; font-size:14px; text-shadow:0 1px 2px rgba(0,0,0,0.3); }

.unit.occupied { box-shadow: inset 0 0 0 2px rgba(217,164,65,0.3); }
body.is-night .unit.occupied { background: #fff4d6; box-shadow: 0 0 14px rgba(255,214,120,0.7), inset 0 0 0 2px rgba(217,164,65,0.4); }
body.is-night .unit.empty { background: #d8dcea; color:#6b7290; }
body.is-night .unit.damaged { filter: brightness(0.8); }
.unit-mid { margin:auto; text-align:center; font-size:20px; }
.win-body { display:flex; flex-direction:column; align-items:center; gap:2px; padding-top:6px; }
.win-body .tenant-emoji { font-size:26px; }
.win-body .tenant-name { font-size:11px; font-weight:700; text-align:center; line-height:1.1; }

/* geliştirme seviye noktaları */
.up-dots { display:flex; gap:5px; margin-top:7px; }
.up-dots .dot { width:12px; height:6px; border-radius:3px; background:#e0d0b0; }
.up-dots .dot.on { background: var(--accent2); }

/* sorun butonu uyarı */
.btn.alert { background:#f3cfcb; color:#9c3f39; animation: pulseAlert 1.4s infinite; }
@keyframes pulseAlert { 0%,100%{ box-shadow:0 0 0 0 rgba(200,90,84,0.4);} 50%{ box-shadow:0 0 0 5px rgba(200,90,84,0);} }

/* skor girişi + tablo */
.score-input { width:100%; padding:9px 11px; border:2px solid #e6d3b3; border-radius:8px; margin:8px 0; font-family:inherit; font-size:14px; }
.lb-table { display:flex; flex-direction:column; gap:4px; max-height:52vh; overflow-y:auto; }
.lb-row { display:grid; grid-template-columns:32px 1fr 64px 48px 64px; gap:6px; padding:7px 9px; background:var(--bg); border-radius:8px; font-size:13px; align-items:center; }
.lb-row.lb-head { background:transparent; font-weight:800; color:var(--muted); font-size:11px; }
.lb-row span:nth-child(3),.lb-row span:nth-child(4){ text-align:center; font-weight:700; }

/* ---------- v6: hedef çubuğu, skor sekmeleri, prestij ---------- */
.goal-bar { background: linear-gradient(135deg,#fff3d6,#ffe6ad); border:1px solid #e8cf94; border-radius:10px; padding:8px 12px; margin-bottom:10px; font-size:13px; font-weight:700; color:#8a6a1e; min-height:18px; }
.goal-bar:empty { display:none; }
.prestige-label { text-align:center; color:var(--gold); font-weight:800; font-size:13px; margin:4px 0; }
.prestige-label:empty { display:none; }
.lb-tabs { display:flex; gap:6px; margin-bottom:10px; }
.lb-tab { flex:1; padding:7px 4px; border:none; background:var(--bg2); border-radius:8px; cursor:pointer; font-weight:700; font-size:12px; color:var(--muted); font-family:inherit; }
.lb-tab.active { background:var(--accent); color:#fff; }

/* ---------- v7: bina sekmeleri (portföy) ---------- */
.building-tabs { display:flex; gap:6px; flex-wrap:wrap; margin-bottom:10px; }
.building-tabs:empty { display:none; }
.bt { border:2px solid #e6d3b3; background:var(--card); border-radius:10px; padding:7px 12px; cursor:pointer; font-weight:700; font-family:inherit; font-size:13px; color:var(--ink); }
.bt small { color:var(--muted); font-weight:600; }
.bt.active { border-color:var(--accent); background:#fff3e2; color:var(--accent); }
.bt.buy { border-style:dashed; color:var(--accent2); }
.bt.buy.locked { color:var(--muted); border-color:#d8c7a4; }

/* ---------- v8: tutorial, konfeti, mobil, görsel derinlik ---------- */
.help-list{display:flex;flex-direction:column;gap:12px;margin:12px 0;}
.help-row{display:flex;gap:12px;align-items:flex-start;}
.help-ico{font-size:24px;flex:none;width:34px;text-align:center;}
.help-row b{font-size:14px;}
.help-desc{font-size:13px;color:var(--muted);}

/* Konfeti */
.confetti-layer{position:fixed;inset:0;pointer-events:none;z-index:80;overflow:hidden;}
.confetti-piece{position:absolute;top:-14px;width:9px;height:14px;border-radius:2px;opacity:.95;animation-name:confFall;animation-timing-function:linear;animation-iteration-count:1;}
@keyframes confFall{0%{transform:translateY(-20px) rotate(0)}100%{transform:translateY(102vh) rotate(680deg)}}

/* Görsel derinlik: balkon + pencere çerçevesi */
.unit.occupied{box-shadow:inset 0 0 0 2px rgba(217,164,65,.30);}
.unit.occupied::after{content:"";position:absolute;left:8px;right:8px;bottom:-2px;height:5px;border-radius:0 0 4px 4px;
  background:repeating-linear-gradient(90deg,#8a6b45,#8a6b45 3px,transparent 3px,transparent 7px);opacity:.5;}

/* ---------- Mobil düzen ---------- */
@media(max-width:900px){
  #hud{padding:10px 12px;gap:8px;}
  .brand{font-size:16px;width:100%;}
  .stats{gap:6px;order:3;width:100%;overflow-x:auto;flex-wrap:nowrap;padding-bottom:2px;}
  .stat{padding:6px 9px;font-size:13px;white-space:nowrap;}
  .controls{order:2;margin-left:auto;flex-wrap:wrap;justify-content:flex-end;gap:5px;}
  .btn-sm{padding:8px 9px;font-size:16px;}
  main{padding:12px;gap:14px;}
  .modal-card,.intro-card{padding:20px 18px;}
}
@media(max-width:520px){
  .floor{gap:6px;}
  .unit{min-height:96px;padding:8px;}
  .win-body .tenant-name{font-size:10px;}
  .tab{font-size:12px;padding:8px 4px;}
  .controls{width:100%;justify-content:flex-start;overflow-x:auto;flex-wrap:nowrap;}
  .lb-row{grid-template-columns:26px 1fr 52px 38px 50px;font-size:12px;}
  h1,.intro-card h1{font-size:26px;}
}

/* ---------- v8: sağ üst menü (dropdown) ---------- */
.menu-wrap{position:relative;}
.menu-btn{font-weight:800;}
.menu-dropdown{position:absolute;right:0;top:calc(100% + 8px);background:var(--card);
  border:1px solid #e6d3b3;border-radius:14px;box-shadow:var(--shadow);padding:8px;min-width:230px;
  z-index:40;display:flex;flex-direction:column;gap:2px;animation:pop .16s ease;}
.menu-dropdown.hidden{display:none;}
.menu-title{font-size:11px;text-transform:uppercase;letter-spacing:1px;color:var(--muted);font-weight:800;padding:9px 10px 4px;}
.mi{display:flex;align-items:center;gap:9px;width:100%;text-align:left;background:none;border:none;
  padding:10px;border-radius:9px;cursor:pointer;font-family:inherit;font-size:14px;color:var(--ink);font-weight:600;}
.mi:hover{background:var(--bg2);}
.mi:active{transform:translateY(1px);}
.mi-badge{margin-left:auto;background:var(--danger);color:#fff;border-radius:20px;padding:1px 9px;font-size:12px;font-weight:800;min-width:22px;text-align:center;}
.mi-badge:empty{display:none;}
@media(max-width:520px){
  .menu-dropdown{position:fixed;right:10px;left:10px;top:64px;min-width:0;max-height:75vh;overflow-y:auto;}
}

/* ---------- v8.2: gökyüzü (gündüz/gece) + kart animasyonları ---------- */
.sky{position:relative;height:64px;border-radius:14px 14px 0 0;overflow:hidden;margin-bottom:-8px;
  background:linear-gradient(180deg,#bfe3fb,#e8f4fb);transition:background .8s ease;}
body.is-night .sky{background:linear-gradient(180deg,#16233f,#2b3a5e);}
.sky .celestial{position:absolute;top:12px;right:44px;width:32px;height:32px;border-radius:50%;
  background:radial-gradient(circle at 35% 35%,#ffe680,#f6b73c);box-shadow:0 0 26px rgba(246,183,60,.75);transition:all .8s ease;}
body.is-night .sky .celestial{background:radial-gradient(circle at 62% 40%,#f5f3ea,#cfd3e0);box-shadow:0 0 20px rgba(220,225,240,.5);}
.sky .cloud{position:absolute;background:rgba(255,255,255,.9);border-radius:20px;height:11px;animation:drift linear infinite;}
.sky .cloud::before{content:"";position:absolute;top:-6px;left:10px;width:22px;height:16px;background:inherit;border-radius:50%;}
body.is-night .sky .cloud{background:rgba(190,200,225,.30);}
.cloud.c1{width:46px;top:14px;left:-70px;animation-duration:28s;}
.cloud.c2{width:34px;top:32px;left:-90px;animation-duration:38s;animation-delay:-10s;}
.cloud.c3{width:56px;top:6px;left:-120px;animation-duration:48s;animation-delay:-22s;}
@keyframes drift{from{transform:translateX(-10px);}to{transform:translateX(720px);}}
body.is-night .sky::after{content:"";position:absolute;inset:0;pointer-events:none;opacity:.7;
  background-image:radial-gradient(1px 1px at 15% 30%,#fff,transparent),radial-gradient(1px 1px at 55% 18%,#fff,transparent),radial-gradient(1px 1px at 78% 44%,#fff,transparent),radial-gradient(1px 1px at 35% 55%,#fff,transparent),radial-gradient(1px 1px at 90% 24%,#fff,transparent);}
#building{border-radius:0 0 var(--radius) var(--radius);}

/* kart & buton mikro-animasyonlar */
.candidate,.upgrade{transition:transform .12s ease,box-shadow .15s ease,border-color .12s;}
.candidate:hover,.upgrade:hover{transform:translateY(-2px);box-shadow:var(--shadow);}
.unit{transition:transform .12s ease,box-shadow .15s ease,border-color .15s;}
.stat{transition:transform .1s ease;}
.stat:hover{transform:translateY(-1px);}
.mood-fill{background-image:linear-gradient(90deg,rgba(255,255,255,.25),rgba(255,255,255,0));}

/* ---------- Mobil/TWA: centikli ekran guvenli alanlari ----------
   Dosyanin sonunda: onceki #hud / main padding kisayollarini gecersiz kilar. */
#hud { padding-top: max(12px, env(safe-area-inset-top)); }
main {
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}
@media (max-width: 900px) {
  main {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
}
.overlay {
  padding-top: max(20px, env(safe-area-inset-top));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}
@media (max-width: 520px) {
  .menu-dropdown { top: calc(56px + env(safe-area-inset-top)); }
}
/* Dokunma hedefleri en az 44px (erisilebilirlik + Play kalite kontrolu) */
@media (pointer: coarse) {
  .btn, .tab, .mi, .diff-btn, .lb-tab, .bt { min-height: 44px; }
  .close-x { min-width: 44px; min-height: 44px; }
}

/* ============================================================
   v11: MOBIL ARAYUZ — alt eylem cubugu + kayan panel (bottom sheet)
   Sorun: telefonda aday listesi 445px, "Ayi Bitir" 937px ekran altinda
   kaliyordu; her kiraci icin iki kez kaydirma gerekiyordu.
   Cozum: paneller yukari kayan bir tabakada, ana eylemler sabit cubukta.
   Masaustu duzeni (901px+) hic degismiyor.
   ============================================================ */

/* Masaustunde mobil bilesenleri hic gorunmez */
#mobileBar, #sheetBackdrop, .sheet-handle { display: none; }

@media (max-width: 900px) {

  /* --- Alt eylem cubugu --- */
  #mobileBar {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 45;
    gap: 6px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    background: var(--card);
    border-top: 1px solid #e6d3b3;
    box-shadow: 0 -4px 16px rgba(74, 55, 40, 0.14);
  }
  #mobileBar .mb {
    flex: 1 1 0;
    min-width: 0;
    min-height: 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 2px;
    border: none;
    border-radius: 11px;
    background: var(--bg2);
    color: var(--ink);
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.15;
    cursor: pointer;
    position: relative;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
  }
  #mobileBar .mb .mb-ico { font-size: 19px; }
  #mobileBar .mb.active { background: var(--accent); color: #fff; }
  #mobileBar .mb-end {
    flex: 1.5 1 0;
    background: var(--accent2);
    color: #fff;
    font-size: 12px;
  }
  #mobileBar .mb-end:disabled { opacity: .5; }
  #mobileBar .mb-badge {
    position: absolute;
    top: 3px; right: 6px;
    min-width: 18px;
    padding: 0 5px;
    border-radius: 20px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    line-height: 18px;
  }
  #mobileBar .mb-badge:empty { display: none; }

  /* Cubugun altinda kalan icerik icin bosluk */
  main { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }

  /* --- Kayan panel (bottom sheet) --- */
  #sheetBackdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 46;
    background: rgba(74, 55, 40, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease;
  }
  #sheetBackdrop.open { opacity: 1; pointer-events: auto; }

  #sidebar {
    position: fixed;
    left: 0; right: 0;
    bottom: 0;
    z-index: 47;
    max-height: 74vh;
    max-height: 74dvh;
    display: flex;
    flex-direction: column;
    margin: 0;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -10px 30px rgba(74, 55, 40, 0.26);
    background: var(--card);
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    transform: translateY(102%);
    transition: transform .26s cubic-bezier(.2, .8, .2, 1);
    will-change: transform;
  }
  #sidebar.sheet-open { transform: translateY(0); }

  .sheet-handle {
    display: block;
    flex: none;
    width: 44px;
    height: 5px;
    margin: 9px auto 3px;
    border-radius: 3px;
    background: #dcc9a8;
  }

  /* Panel govdesi kaydirilabilir, sekmeler sabit kalir */
  #sidebar .tabs { flex: none; }
  #sidebar .tab-panel.active {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  /* "Ayi Bitir" alt cubukta duruyor, panelde tekrar gosterme */
  #sidebar .end-month { display: none; }

  /* --- HUD: sarmak yerine sadelestir.
     Sarmali deneme HUD'u 187px yapip binayi ekran disina itmisti; bunun
     yerine ikincil istatistikler mobilde gizleniyor (📊 panelinde duruyorlar). */
  .stats {
    flex-wrap: nowrap;
    overflow: visible;
    gap: 5px;
  }
  .stat {
    padding: 5px 8px;
    font-size: 12.5px;
  }
  .stat-extra { display: none; }          /* kira endeksi, huzur, yildiz */
  .stats .stat-label { display: none; }   /* mevsim adi: yalniz ikon kalir */

  /* Surukleme sirasinda parmagi izleyen kart */
  .drag-ghost {
    position: fixed;
    z-index: 60;
    left: 0; top: 0;
    width: 190px;
    margin: 0;
    padding: 9px 11px;
    border-radius: 12px;
    background: var(--card);
    border: 2px solid var(--accent);
    box-shadow: 0 12px 26px rgba(74, 55, 40, 0.35);
    pointer-events: none;
    opacity: .95;
    transform-origin: center;
  }
  .unit.drop-target {
    outline: 3px dashed var(--accent);
    outline-offset: 2px;
    transform: scale(1.04);
  }
  body.is-dragging { touch-action: none; }
}

/* Oyun içi onay modalı butonları */
.confirm-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
.confirm-actions .btn { flex: 1; }
@media (max-width: 520px) {
  .confirm-actions { flex-direction: column-reverse; }
}

/* ============================================================
   v11b: DİKEY ALAN KAZANIMI (mobil)
   Ölçüm: binanın üstündeki başlık yığını 430px idi; 360x640 ekranda
   15 dairenin 0'ı görünüyordu. Aşağıdaki sıkıştırmalarla bu yığın
   ~175px'e indi. Masaüstü etkilenmez.
   ============================================================ */
@media (max-width: 900px) {

  /* HUD tek satır marka + tek satır istatistik */
  #hud {
    padding: 8px 12px;
    gap: 6px;
    row-gap: 6px;
  }
  .brand {
    font-size: 13.5px;
    width: auto;
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .controls { order: 2; width: auto; margin-left: auto; flex-wrap: nowrap; overflow: visible; }
  .stats { order: 3; width: 100%; }
  .btn-sm { padding: 6px 9px; font-size: 15px; min-width: 44px; }

  /* Bölüm başlığı + hedef çubuğu sıkı */
  .section-title {
    font-size: 12.5px;
    margin: 0 0 6px;
    line-height: 1.3;
  }
  .section-title .sub { font-size: 11px; }
  .goal-bar {
    padding: 6px 10px;
    font-size: 11.5px;
    margin-bottom: 6px;
    line-height: 1.3;
  }
  .goal-bar:empty { display: none; }

  /* Bina sekmeleri: sarmak yerine tek satır yatay kaydırma */
  .building-tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 2px;
    margin-bottom: 6px;
    scrollbar-width: none;
  }
  .building-tabs::-webkit-scrollbar { display: none; }
  .building-tabs .bt {
    flex: 0 0 auto;
    padding: 6px 11px;
    font-size: 11.5px;
    min-height: 44px;      /* erisilebilir dokunma hedefi */
    white-space: nowrap;
  }

  /* Gökyüzü dekoratif: yarı yükseklik */
  .sky { height: 40px; }

  /* Bina bölümü dış boşlukları */
  #buildingWrap { padding-top: 2px; }
  main { gap: 10px; padding-top: 10px; }

  /* İpucu tek satıra yakın, küçük */
  .hint { font-size: 11px; padding: 7px 9px; line-height: 1.35; margin-top: 6px; }
}

/* Küçük/kısa ekranlarda daireleri de biraz sıkıştır */
@media (max-width: 520px) {
  .unit { min-height: 84px; padding: 6px; }
  .floor { gap: 5px; }
  .brand { font-size: 12.5px; }
  .stat { padding: 4px 7px; font-size: 12px; }
}
@media (max-height: 700px) and (max-width: 900px) {
  .unit { min-height: 76px; }
  .sky { height: 30px; }
  .hint { display: none; }   /* çok kısa ekranda oyun alanına yer aç */
}
