/* Wspólne style imapancake: kolory, tło, przyciski, naleśnik-głośnik, górny pasek, ramka gry. */
:root {
  --bg1: #fff4dc;
  --bg2: #ffd98a;
  --ink: #3b2410;
  --syrup: #b8621b;
  --syrup-dark: #8a4512;
  --syrup-deep: #6e360d;
  --butter: #ffe58a;
  --cream: #fff7e6;
  --line: #e0b56e;
}
* { box-sizing: border-box; }
/* tło na całym płótnie (html), nie tylko na body – odsłonięte pasy (iOS: paski przeglądarki, odbicie) mają ten sam kolor */
html {
  margin: 0; min-height: 100%;
  background: radial-gradient(ellipse at 50% 35%, var(--bg1) 0%, var(--bg2) 75%, #f5b95a 100%) no-repeat, #f5b95a;
}
body {
  margin: 0;
  font-family: "Fredoka", ui-rounded, system-ui, sans-serif;
  color: var(--ink);
  background: transparent;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
}
[hidden] { display: none !important; }

/* ---- przyciski ---- */
button, .btn {
  font: inherit; font-weight: 700; font-size: 1.15rem; color: #fff; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: .35em;
  background: var(--syrup); border: 0; border-radius: 999px; padding: 12px 26px;
  box-shadow: 0 5px 0 var(--syrup-dark); cursor: pointer; transition: transform .08s, box-shadow .08s;
  -webkit-tap-highlight-color: transparent;
}
button:active, .btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--syrup-dark); }
.btn.secondary, button.secondary { background: var(--cream); color: var(--syrup-dark); box-shadow: 0 5px 0 var(--line); }
.btn.secondary:active, button.secondary:active { box-shadow: 0 1px 0 var(--line); }
/* syropowy (mniejszy, bez stróżek) */
.syrup-sm {
  color: #fff7e6; text-shadow: 0 2px 0 rgba(90,40,5,.5);
  background: linear-gradient(180deg, #e7953a 0%, #c46d20 45%, #9c4f14 100%);
  box-shadow: inset 0 3px 0 rgba(255,226,160,.6), inset 0 -4px 0 rgba(90,40,5,.3), 0 5px 0 var(--syrup-deep);
}
.syrup-sm:active { box-shadow: inset 0 3px 0 rgba(255,226,160,.6), 0 1px 0 var(--syrup-deep); }

/* ---- przycisk ociekający syropem ---- */
.syrup {
  position: relative; font-size: 1.9rem; letter-spacing: .02em; padding: 14px 54px 16px;
  border-radius: 999px; color: #fff7e6; text-shadow: 0 2px 0 rgba(90,40,5,.55); font-weight: 700; text-decoration: none; display: inline-flex; align-items: center; cursor: pointer; -webkit-tap-highlight-color: transparent;
  background: linear-gradient(180deg, #e7953a 0%, #c46d20 45%, #9c4f14 100%);
  box-shadow: inset 0 3px 0 rgba(255,226,160,.65), inset 0 -5px 0 rgba(90,40,5,.35),
              0 6px 0 var(--syrup-deep), 0 12px 20px rgba(110,54,13,.35);
  transition: transform .12s;
}
.syrup:hover { transform: rotate(-2deg) scale(1.03); }
.syrup:active { transform: translateY(4px); box-shadow: inset 0 3px 0 rgba(255,226,160,.65), inset 0 -5px 0 rgba(90,40,5,.35), 0 2px 0 var(--syrup-deep); }
.syrup::before { /* połysk */
  content: ""; position: absolute; left: 18%; top: 6px; width: 38%; height: 10px; border-radius: 999px;
  background: rgba(255,240,205,.55); pointer-events: none;
}
.syrup .arrow { display: inline-block; font-size: .7em; margin-left: 8px; transition: transform .25s; }

/* ---- naleśnik-głośnik (lewy górny róg) ---- */
#sound { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 10px); left: calc(env(safe-area-inset-left, 0px) + 12px); z-index: 30; }
#soundBtn {
  width: 54px; height: 54px; padding: 0; border-radius: 50%; background: none; box-shadow: none;
  display: grid; place-items: center; transition: transform .1s;
  filter: drop-shadow(0 4px 0 #8a4512) drop-shadow(0 6px 10px rgba(138,69,18,.3));
}
#soundBtn:active { transform: translateY(3px); box-shadow: none; }
#soundBtn.beat { transform: scale(1.08) rotate(-4deg); }
#soundBtn svg { width: 54px; height: 54px; display: block; }
#soundBtn .wave { transition: opacity .2s; }
#soundBtn[data-state="on"] .wave { animation: wave 0.97s ease-in-out infinite; }
#soundBtn[data-state="on"] .wave2 { animation-delay: .15s; }
#soundBtn[data-state="off"] .wave { opacity: .35; }
#soundBtn[data-state="muted"] .wave { opacity: 0; }
#soundBtn .cross { opacity: 0; transition: opacity .2s; }
#soundBtn[data-state="muted"] .cross { opacity: 1; }
@keyframes wave { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
#soundHint {
  position: absolute; top: 62px; left: 0; width: max-content; max-width: 190px;
  background: var(--cream); color: var(--syrup-dark); border: 2px solid var(--line); border-radius: 14px;
  padding: 6px 10px; font-size: .85rem; font-weight: 500; line-height: 1.25;
  animation: nudge 1.6s ease-in-out infinite; pointer-events: none;
}
#soundHint::before {
  content: ""; position: absolute; top: -8px; left: 20px; width: 12px; height: 12px;
  background: var(--cream); border-left: 2px solid var(--line); border-top: 2px solid var(--line); transform: rotate(45deg);
}
@keyframes nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(4px); } }
#soundPanel {
  position: absolute; top: 64px; left: 0; width: 250px; max-height: calc(100dvh - 90px); overflow-y: auto; padding: 14px;
  background: var(--cream); border: 2px solid var(--line); border-radius: 18px;
  box-shadow: 0 5px 0 var(--line), 0 12px 24px rgba(138,69,18,.2);
  display: flex; flex-direction: column; gap: 12px;
}
#muteBtn { font-size: 1rem; padding: 9px 16px; }
.tracks { display: flex; flex-direction: column; gap: 6px; }
.tracks-label { font-weight: 700; color: var(--syrup-dark); font-size: .9rem; }
.tracks button {
  font-size: .92rem; padding: 7px 12px; text-align: left; border-radius: 12px; min-width: 0;
  background: #fff; color: var(--syrup-dark); box-shadow: 0 2px 0 var(--line); border: 2px solid var(--line);
}
.tracks button[aria-checked="true"] { background: var(--butter); border-color: var(--syrup); font-weight: 700; }
.tracks button[aria-checked="true"]::before { content: "♪ "; }
.tracks-dl { font-size: .82rem; color: var(--syrup); font-weight: 700; text-decoration: none; padding-left: 4px; }
.vol { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--syrup-dark); }
.vol input { accent-color: var(--syrup); flex: 1; min-width: 0; }

/* ---- górny pasek: ← Gry, wybór języka ---- */
.topbar {
  position: relative; z-index: 20; width: 100%; display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) calc(env(safe-area-inset-right, 0px) + 16px) 0
           calc(env(safe-area-inset-left, 0px) + 78px); /* miejsce na naleśnik-głośnik */
}
body.game-page .topbar { min-height: calc(env(safe-area-inset-top, 0px) + 66px); padding-bottom: 6px; }
.topbar .spacer { flex: 1; }
.topbar .back {
  font-weight: 700; color: var(--syrup-dark); text-decoration: none; background: var(--cream);
  border: 2px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 1rem;
  box-shadow: 0 3px 0 var(--line); white-space: nowrap;
}
.topbar .back:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.lang { display: flex; align-items: center; gap: 6px; font-weight: 500; font-size: .95rem; }
.lang select {
  font: inherit; color: var(--syrup-dark); background: var(--cream); border: 2px solid var(--line);
  border-radius: 999px; padding: 6px 12px; cursor: pointer;
  font-size: 16px; /* <16px = iOS powiększa stronę przy dotknięciu */
}

/* ---- strona gry ---- */
body.game-page { height: 100vh; height: 100dvh; overflow: hidden; overscroll-behavior: none; }
.game-area {
  position: relative; flex: 1; width: 100%; min-height: 0; overflow: hidden;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.game-area canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---- ramka gry: nakładki start / pauza / koniec ---- */
.shell-overlay {
  position: absolute; inset: 0; z-index: 10; display: grid; place-items: center; padding: 16px;
  background: rgba(255, 236, 200, .55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: shellIn .25s ease-out;
}
@keyframes shellIn { from { opacity: 0; } to { opacity: 1; } }
.shell-card {
  width: min(100%, 380px); background: var(--cream); border: 3px solid var(--line); border-radius: 26px;
  padding: 22px 20px 24px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px;
  box-shadow: 0 6px 0 var(--line), 0 18px 40px rgba(110,54,13,.25);
}
.shell-icon { width: 84px; height: 84px; }
.shell-title { margin: 0; font-size: 2rem; color: var(--syrup); text-shadow: 0 2px 0 var(--syrup-dark); }
.shell-text { margin: 0; font-size: 1.05rem; line-height: 1.4; color: var(--ink); }
.shell-best { margin: 0; color: var(--syrup-dark); }
.shell-score-label { margin: 0; text-transform: uppercase; letter-spacing: .08em; font-size: .85rem; color: var(--syrup-dark); }
.shell-score { margin: -6px 0 0; font-size: 3.4rem; font-weight: 700; color: var(--syrup); line-height: 1; }
.shell-record { margin: 0; font-weight: 700; color: #c2410c; animation: nudge 1s ease-in-out infinite; }
.shell-quip { margin: 0; font-style: italic; color: var(--syrup-dark); line-height: 1.35; }
.shell-card .btn, .shell-card button { min-width: 220px; }
.shell-pause {
  position: absolute; z-index: 5; top: 10px; right: calc(env(safe-area-inset-right, 0px) + 14px);
  width: 46px; height: 46px; padding: 0; font-size: 1.2rem; border-radius: 50%;
  background: var(--cream); color: var(--syrup-dark); box-shadow: 0 4px 0 var(--line);
}
.shell-pause:active { box-shadow: 0 1px 0 var(--line); }

/* niskie ekrany (telefon w poziomie): kompaktowa karta, przewijanie zamiast ucinania */
@media (max-height: 480px) {
  .shell-overlay { display: flex; overflow-y: auto; padding: 8px; }
  .shell-card { margin: auto; width: min(100%, 560px); gap: 6px; padding: 12px 16px 14px; }
  .shell-icon { width: 48px; height: 48px; }
  .shell-title { font-size: 1.5rem; }
  .shell-text { font-size: .92rem; line-height: 1.3; }
  .shell-score { margin: 0; font-size: 2.4rem; }
  .shell-card .btn, .shell-card button { padding-top: 8px; padding-bottom: 8px; }
}
