* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  overflow: hidden; position: fixed; inset: 0;
  overscroll-behavior: none; touch-action: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  background: #ffe3d3;
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: #6b3a55;
  -webkit-text-size-adjust: 100%;
}
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui button, #ui .card, #ui .level-grid { pointer-events: auto; }
.hidden { display: none !important; }

#hapticLbl { position: fixed; left: -100px; top: -100px; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }

.screen {
  position: absolute; inset: 0;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) calc(env(safe-area-inset-right, 0px) + 14px)
           calc(env(safe-area-inset-bottom, 0px) + 14px) calc(env(safe-area-inset-left, 0px) + 14px);
  display: flex; flex-direction: column;
}

/* ---------- przyciski ---------- */
.btn {
  appearance: none; border: 0; cursor: pointer; font: inherit; font-weight: 800;
  color: #6b3a55; background: #fffaf4;
  border-radius: 22px; padding: 14px 26px; font-size: 19px;
  box-shadow: 0 5px 0 #e9c9c0, 0 10px 22px rgba(160, 80, 70, .18);
  transition: transform .08s ease, box-shadow .08s ease;
  touch-action: manipulation;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #e9c9c0, 0 4px 10px rgba(160, 80, 70, .18); }
.btn.primary {
  color: #fff; background: linear-gradient(180deg, #ff8aa3 0%, #ff5d7c 100%);
  box-shadow: 0 5px 0 #d8406a, 0 12px 24px rgba(230, 70, 110, .35);
  text-shadow: 0 2px 0 rgba(170, 30, 70, .35);
}
.btn.primary:active { box-shadow: 0 1px 0 #d8406a, 0 4px 10px rgba(230, 70, 110, .3); }
.btn.big { padding: 16px 30px 14px; font-size: 30px; border-radius: 28px; display: flex; flex-direction: column; align-items: center; min-width: 230px; }
.btn.big .sub { font-size: 15px; opacity: .92; font-weight: 700; margin-top: 2px; }
.btn.small { padding: 10px 20px; font-size: 17px; border-radius: 18px; }
.icon-btn {
  appearance: none; border: 0; cursor: pointer; width: 48px; height: 48px; border-radius: 16px;
  background: #fffaf4; color: #6b3a55; display: grid; place-items: center; padding: 0;
  box-shadow: 0 4px 0 #e9c9c0, 0 8px 16px rgba(160, 80, 70, .16);
  transition: transform .08s ease, box-shadow .08s ease; touch-action: manipulation;
}
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #e9c9c0; }
.icon-btn svg { width: 26px; height: 26px; }
.icon-btn.used { opacity: .55; }

/* ---------- menu ---------- */
#menu { align-items: center; justify-content: flex-start; }
.logo {
  margin-top: 9vh; font-size: min(92px, 24vw); font-weight: 900; letter-spacing: -1px; line-height: 1;
  display: flex;
}
.logo span {
  color: var(--c); display: inline-block;
  -webkit-text-stroke: 3px #fff; paint-order: stroke fill;
  text-shadow: 0 6px 0 rgba(120, 50, 70, .16), 0 12px 26px rgba(150, 60, 80, .2);
  animation: wob 2.4s ease-in-out infinite; animation-delay: var(--d);
}
@keyframes wob {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  30% { transform: translateY(-8px) scale(.96, 1.05); }
  55% { transform: translateY(0) scale(1.06, .94); }
  70% { transform: translateY(-2px) scale(.99, 1.01); }
}
.tagline { margin: 14px 0 0; font-size: 18px; font-weight: 800; opacity: .75; }
.menu-buttons { margin-top: auto; margin-bottom: 11vh; display: flex; flex-direction: column; gap: 18px; align-items: center; }
.corner { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 12px); right: calc(env(safe-area-inset-right, 0px) + 14px); }

/* ---------- belki ---------- */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.bar h2 { margin: 0; font-size: 26px; font-weight: 900; }
.total-stars { font-weight: 900; font-size: 17px; background: #fffaf4; padding: 10px 14px; border-radius: 16px; color: #e8a400; box-shadow: 0 4px 0 #e9c9c0; }

/* ---------- poziomy ---------- */
.level-grid {
  margin-top: 22px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
  max-width: 420px; width: 100%; align-self: center;
}
.lvl {
  appearance: none; border: 0; font: inherit; cursor: pointer; aspect-ratio: 1 / 1.08;
  border-radius: 20px; background: #fffaf4; color: #6b3a55; font-weight: 900; font-size: 24px;
  box-shadow: 0 5px 0 #e9c9c0, 0 8px 16px rgba(160, 80, 70, .14);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  position: relative; touch-action: manipulation;
}
.lvl:active { transform: translateY(3px); box-shadow: 0 2px 0 #e9c9c0; }
.lvl .st { font-size: 13px; letter-spacing: 1px; color: #e3d2cc; }
.lvl .st b { color: #ffb800; font-weight: 900; }
.lvl.locked { background: #f1dcd5; color: #c7a9a2; box-shadow: 0 5px 0 #dcbfb6; }
.lvl.locked svg { width: 24px; height: 24px; opacity: .7; }
.lvl.boss { background: linear-gradient(180deg, #fff6d8, #ffe9a8); box-shadow: 0 5px 0 #e6bd55, 0 8px 16px rgba(200, 150, 40, .25); }
.lvl.boss.locked { background: #f1dcd5; box-shadow: 0 5px 0 #dcbfb6; }
.lvl .crown { position: absolute; top: -9px; font-size: 16px; }
.lvl.next { animation: pulse 1.3s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }

/* ---------- HUD gry ---------- */
.hud-top .title { text-align: center; flex: 1; }
.lvl-num { font-size: 13px; font-weight: 800; opacity: .65; text-transform: uppercase; letter-spacing: 1.5px; }
.lvl-name { font-size: 21px; font-weight: 900; line-height: 1.15; }
.status { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 10px; }
.moves { background: #fffaf4; border-radius: 16px; padding: 5px 14px; font-weight: 900; font-size: 22px; display: flex; align-items: baseline; gap: 6px; box-shadow: 0 3px 0 #e9c9c0; }
.moves small { font-size: 13px; opacity: .6; font-weight: 800; }
.hud-stars { display: flex; gap: 2px; }
.hud-stars i, .win-stars i {
  display: inline-block; width: 30px; height: 30px; background: #ffc21a;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 1.8l3.1 6.5 7 .9-5.1 4.9 1.3 7-6.3-3.4-6.3 3.4 1.3-7L1.9 9.2l7-.9z'/></svg>") center / contain no-repeat;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 1.8l3.1 6.5 7 .9-5.1 4.9 1.3 7-6.3-3.4-6.3 3.4 1.3-7L1.9 9.2l7-.9z'/></svg>") center / contain no-repeat;
  transition: background .3s, transform .3s;
}
.hud-stars i.off { background: #e6cfc8; transform: scale(.85); }
.hud-stars i.lose { animation: lose .5s ease; }
@keyframes lose { 0% { transform: scale(1.3) rotate(0); } 40% { transform: scale(.8) rotate(-18deg); } 100% { transform: scale(.85) rotate(0); } }
.target { font-size: 13px; font-weight: 800; opacity: .6; }
.hud-bottom { margin-top: auto; justify-content: center; gap: 16px; }
.btn.tool { display: flex; align-items: center; gap: 8px; padding: 12px 20px; font-size: 17px; }
.btn.tool .ico svg { width: 22px; height: 22px; display: block; }
.btn.tool.pulse { animation: pulse 1s ease-in-out infinite; background: #fff0c9; }

.hint-bubble {
  position: absolute; left: 50%; transform: translateX(-50%);
  max-width: 86%; background: #fffaf4; border-radius: 18px; padding: 10px 16px;
  font-weight: 800; font-size: 16px; text-align: center; line-height: 1.3;
  box-shadow: 0 4px 0 #e9c9c0, 0 10px 20px rgba(160, 80, 70, .15);
  animation: pop .35s cubic-bezier(.3, 1.6, .5, 1) both;
}
@keyframes pop { from { transform: translateX(-50%) scale(.6); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }

.stuck {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 92px);
  background: #fffaf4; border-radius: 22px; padding: 12px 16px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  box-shadow: 0 5px 0 #e9c9c0, 0 12px 24px rgba(160, 80, 70, .2); pointer-events: auto; width: max-content; max-width: 90%;
  animation: pop .35s cubic-bezier(.3, 1.6, .5, 1) both;
}
.stuck-txt { font-weight: 900; font-size: 17px; }

/* ---------- nakładki ---------- */
.overlay {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: auto;
  background: rgba(255, 228, 214, .55);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  animation: fade .25s ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.card {
  background: #fffaf4; border-radius: 30px; padding: 22px 24px 24px; text-align: center; width: min(330px, 86vw);
  box-shadow: 0 8px 0 #e9c9c0, 0 24px 50px rgba(150, 60, 70, .28);
  animation: cardIn .45s cubic-bezier(.3, 1.5, .5, 1) both;
}
@keyframes cardIn { from { transform: scale(.5) translateY(30px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }
.win-title { font-size: 34px; font-weight: 900; color: #ff5d7c; -webkit-text-stroke: 0; line-height: 1.1; }
.win-stars { display: flex; justify-content: center; gap: 8px; margin: 14px 0 8px; }
.win-stars i { width: 58px; height: 58px; background: #ecd9d3; }
.win-stars i:nth-child(2) { transform: translateY(-12px); }
.win-stars i.on { background: #ffc21a; animation: starIn .45s cubic-bezier(.3, 1.8, .5, 1) both; }
.win-stars i:nth-child(2).on { animation-name: starIn2; }
@keyframes starIn { from { transform: scale(0) rotate(-90deg); } to { transform: scale(1) rotate(0); } }
@keyframes starIn2 { from { transform: translateY(-12px) scale(0) rotate(-90deg); } to { transform: translateY(-12px) scale(1) rotate(0); } }
.win-info { font-weight: 800; font-size: 16px; opacity: .75; min-height: 22px; }
.win-next { position: relative; margin: 16px auto 4px; height: 30px; border-radius: 15px; background: #f6e4dd; overflow: hidden; width: 100%; display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.win-next span { position: relative; }
.bar-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg, #ffd0dc, #ffb3c6); }
.win-buttons { display: flex; justify-content: center; gap: 14px; margin-top: 14px; }

.disc-head { font-size: 15px; font-weight: 900; letter-spacing: 2px; text-transform: uppercase; color: #ff9638; }
#discCanvas { width: 200px; height: 170px; display: block; margin: 0 auto; }
.disc-name { font-size: 32px; font-weight: 900; margin-top: -6px; }
.disc-desc { font-size: 16px; font-weight: 700; opacity: .8; margin: 6px 4px 18px; line-height: 1.35; }

.end-txt { font-weight: 800; font-size: 18px; margin: 12px 0; }
.end-txt.small { font-size: 15px; opacity: .7; }
