:root {
  --sky: #7ec8ff;
  --panel: #1e2b38;
  --panel2: #26384a;
  --text: #eaf3fb;
  --muted: #9fb4c6;
  --accent: #4dd0e1;
  --gold: #f1c40f;
}
* { box-sizing: border-box; }
html, body { margin: 0; touch-action: manipulation; }
button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; font-family: inherit; }

body {
  background: radial-gradient(circle at 50% 0%, #16222e, #0d151d);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  min-height: 100vh; min-height: 100dvh;
}
#app { max-width: 680px; margin: 0 auto; padding: 10px 10px 30px; }

header { text-align: center; position: relative; }
header h1 { margin: 6px 0; font-size: 26px; color: var(--accent); letter-spacing: 1px; }
#fs-btn, #sound-btn, #music-btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: var(--panel2); color: var(--text); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px; width: 40px; height: 36px; font-size: 18px; cursor: pointer;
}
#fs-btn { right: 4px; }
#sound-btn { right: 50px; }
#music-btn { right: 96px; }
#sound-btn.muted, #music-btn.off { opacity: 0.5; }

/* --- Telefonu yan çevir uyarısı (yalnız dokunmatik + dikey) --- */
#rotate-hint { display: none; }
.rot-emoji { font-size: 64px; animation: rotwiggle 1.6s ease-in-out infinite; }
@keyframes rotwiggle { 0%,100% { transform: rotate(-18deg); } 50% { transform: rotate(72deg); } }
@media (orientation: portrait) and (pointer: coarse) {
  #rotate-hint {
    display: flex; position: fixed; inset: 0; z-index: 9999;
    flex-direction: column; align-items: center; justify-content: center; gap: 18px;
    background: #0d151d; color: var(--text); text-align: center; padding: 24px;
  }
  #rotate-hint p { font-size: 20px; line-height: 1.6; }
  #rotate-hint small { color: var(--muted); font-size: 14px; }
}

/* --- Yatay (telefon) düzeni: dikey alan az, canvas'ı boya ölçekle + kontrolleri köşelere al --- */
@media (orientation: landscape) and (max-height: 560px) {
  #app { padding: 4px 8px; max-width: none; }
  header h1 { font-size: 18px; margin: 2px 0; }
  #levelbar { margin: 2px 0; }
  .hint, footer { display: none; }
  #hud { padding: 4px 10px; font-size: 12px; margin: 4px 0; }
  #stage { display: flex; justify-content: center; }
  #game { height: 74vh; width: auto; max-width: 100%; }
  #touch {
    position: fixed; bottom: 10px; left: 10px; right: 10px; margin: 0;
    justify-content: space-between; pointer-events: none; z-index: 60;
  }
  #touch .pad { pointer-events: auto; }
  .tbtn { opacity: 0.9; }
}

#levelbar { display: flex; gap: 6px; justify-content: center; margin: 6px 0; flex-wrap: wrap; }
.lvl-btn {
  min-width: 34px; min-height: 34px; padding: 2px 4px; border-radius: 8px; cursor: pointer;
  background: var(--panel2); color: var(--text); border: 1px solid rgba(255,255,255,0.12);
  font-weight: bold; font-size: 14px; line-height: 1.1;
}
.lvl-btn.cur { border-color: var(--accent); color: var(--accent); }
.lvl-btn.locked { opacity: 0.5; cursor: default; }
.lvl-stars { display: block; font-size: 9px; color: var(--gold); letter-spacing: -1px; }
.ov-stars { font-size: 34px; color: var(--gold); letter-spacing: 4px; margin-bottom: 4px; }
#progress-line { text-align: center; font-size: 13px; color: var(--gold); margin: 2px 0 4px; min-height: 16px; }
.ov-done { color: var(--gold); font-weight: bold; font-size: 15px; margin-bottom: 4px; }

#hud {
  display: flex; justify-content: space-between; gap: 8px;
  background: var(--panel); border-radius: 8px; padding: 8px 12px; margin: 6px 0;
  font-size: 14px; font-weight: bold;
}
#hud-level { color: var(--accent); }
#hud-coins { color: var(--gold); }

#stage { position: relative; width: 100%; }
#game {
  display: block; width: 100%; height: auto; aspect-ratio: 640 / 384;
  background: var(--sky); border-radius: 12px; border: 2px solid #2b3d4f;
  image-rendering: auto;
}

#overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px;
  background: rgba(8, 16, 24, 0.82); border-radius: 12px; text-align: center; padding: 16px;
}
#overlay.hidden { display: none; }

#level-intro {
  position: absolute; top: 16%; left: 50%; transform: translateX(-50%) translateY(-6px);
  background: rgba(8,16,24,0.7); color: var(--accent); font-weight: bold; font-size: 18px;
  padding: 8px 18px; border-radius: 10px; border: 1px solid rgba(77,208,225,0.4);
  opacity: 0; pointer-events: none; transition: opacity 0.35s, transform 0.35s;
}
#level-intro.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#overlay h2 { margin: 0 0 6px; color: var(--gold); font-size: 24px; }
.ov-stat { font-size: 15px; }
.ov-btns { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; justify-content: center; }
.ov-btn {
  background: var(--accent); color: #0d2b31; border: none; border-radius: 10px;
  padding: 10px 18px; font-weight: bold; font-size: 15px; cursor: pointer;
}
.ov-btn.ghost { background: transparent; color: var(--text); border: 1px solid rgba(255,255,255,0.25); }

#touch { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; }
.pad { display: flex; gap: 10px; align-items: center; }
.tbtn {
  background: var(--panel2); color: var(--text); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 12px; font-size: 22px; font-weight: bold; cursor: pointer;
  width: 64px; height: 56px;
}
.tbtn:active { background: var(--accent); color: #0d2b31; transform: scale(0.96); }
.tbtn.small { width: 48px; font-size: 18px; }
.tbtn.jump { width: 130px; background: var(--accent); color: #0d2b31; }

.hint { font-size: 12px; color: var(--muted); text-align: center; margin: 12px 4px 0; line-height: 1.5; }
footer { margin-top: 14px; display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 12px; color: var(--muted); }
#reset-prog { background: transparent; color: var(--muted); border: 1px solid rgba(255,255,255,0.15); border-radius: 8px; padding: 5px 10px; cursor: pointer; font-size: 12px; }
#reset-prog:hover { color: #e57373; border-color: #e57373; }
