/* ===== Aniččino bludiště za pitíčkem — styly ===== */

:root {
  --sky-1: #a7e0ff;
  --sky-2: #ffd6ec;
  --ink: #3a2b4a;
  --card: #ffffff;
  --pink: #ff6fae;
  --pink-dark: #e2478f;
  --grape: #8a5cff;
  --sun: #ffd23f;
  --mint: #56d6a0;
  --shadow: 0 10px 30px rgba(90, 50, 120, .25);
  --radius: 24px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  font-family: 'Comic Sans MS', 'Baloo 2', 'Trebuchet MS', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, var(--sky-1) 0%, var(--sky-2) 100%);
}

#app { position: fixed; inset: 0; }

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.hidden { display: none !important; }

/* ---------- Poletující ozdoby na pozadí menu ---------- */
.floaties { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.floaties span {
  position: absolute;
  font-size: clamp(26px, 5vw, 44px);
  opacity: .55;
  animation: floaty linear infinite;
  will-change: transform;
}
.floaties span:nth-child(1){ left: 6%;  top: 12%; animation-duration: 9s;  }
.floaties span:nth-child(2){ left: 84%; top: 8%;  animation-duration: 11s; }
.floaties span:nth-child(3){ left: 14%; top: 74%; animation-duration: 8s;  }
.floaties span:nth-child(4){ left: 90%; top: 66%; animation-duration: 12s; }
.floaties span:nth-child(5){ left: 4%;  top: 44%; animation-duration: 10s; }
.floaties span:nth-child(6){ left: 78%; top: 40%; animation-duration: 9.5s;}
.floaties span:nth-child(7){ left: 22%; top: 24%; animation-duration: 13s; }
.floaties span:nth-child(8){ left: 68%; top: 82%; animation-duration: 8.5s;}
.floaties span:nth-child(9){ left: 40%; top: 88%; animation-duration: 11.5s;}
.floaties span:nth-child(10){left: 54%; top: 6%;  animation-duration: 10.5s;}
@keyframes floaty {
  0%   { transform: translateY(0) rotate(-8deg); }
  50%  { transform: translateY(-26px) rotate(8deg); }
  100% { transform: translateY(0) rotate(-8deg); }
}

/* ---------- Úvodní obrazovka ---------- */
.card {
  position: relative;
  z-index: 1;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 26px 26px;
  max-width: min(440px, 92vw);
  width: 92vw;
  text-align: center;
  max-height: 96vh;
  overflow: auto;
  border: 4px solid #fff;
}
#hero { width: 170px; height: 162px; margin-top: -4px; }
h1 {
  margin: 0 0 8px;
  font-size: clamp(26px, 7vw, 38px);
  line-height: 1.05;
  color: var(--pink-dark);
  text-shadow: 0 2px 0 #ffd9ec;
}
h1 small { font-size: .62em; color: var(--grape); }
.lead { margin: 0 6px 14px; font-size: 16px; }
.pick-label { margin: 6px 0 8px; font-weight: bold; }

.difficulty { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.diff-btn {
  border: 3px solid transparent;
  background: #f1ecff;
  color: var(--ink);
  font-family: inherit;
  font-size: 16px;
  font-weight: bold;
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform .08s ease, border-color .15s, background .15s;
}
.diff-btn:hover { transform: translateY(-2px); }
.diff-btn.is-active { background: #fff0f7; border-color: var(--pink); transform: scale(1.05); }
.diff-desc { min-height: 34px; margin: 10px 6px 6px; font-size: 14px; color: #6a5a7a; }

.big-btn {
  display: inline-block;
  border: none;
  background: linear-gradient(180deg, #ff8ac0, var(--pink));
  color: #fff;
  font-family: inherit;
  font-weight: bold;
  font-size: 22px;
  padding: 14px 34px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 6px 0 var(--pink-dark), 0 12px 20px rgba(226,71,143,.35);
  transition: transform .06s ease, box-shadow .06s ease;
  margin-top: 4px;
  animation: btnpulse 1.8s ease-in-out infinite;
}
@keyframes btnpulse { 0%,100%{ transform: scale(1);} 50%{ transform: scale(1.04);} }
.big-btn:active { transform: translateY(4px) scale(1); box-shadow: 0 2px 0 var(--pink-dark); animation: none; }

.ghost-btn {
  border: 3px solid #d9cdf0;
  background: #fff;
  color: var(--grape);
  font-family: inherit;
  font-weight: bold;
  font-size: 16px;
  padding: 11px 22px;
  border-radius: 999px;
  cursor: pointer;
}
.ghost-btn:active { transform: translateY(2px); }

.best { margin: 14px 0 2px; font-size: 15px; color: var(--grape); font-weight: bold; min-height: 20px; }
.stat { font-size: 14px; color: var(--pink-dark); font-weight: bold; min-height: 18px; }
.hint { font-size: 12.5px; color: #7d6f8c; margin: 8px 4px 0; }

/* ---------- Herní obrazovka ---------- */
#screen-game { justify-content: flex-start; }

#hud {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px calc(10px + env(safe-area-inset-right)) 10px calc(10px + env(safe-area-inset-left));
  padding-top: calc(8px + env(safe-area-inset-top));
  flex-wrap: wrap;
  z-index: 2;
}
.hud-item {
  background: rgba(255,255,255,.9);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: bold;
  font-size: 15px;
  box-shadow: 0 3px 8px rgba(90,50,120,.15);
  white-space: nowrap;
}
.hud-item span { color: var(--pink-dark); }
.hud-item.low { animation: heartLow .55s ease-in-out infinite; background: #ffe1e8; }
@keyframes heartLow { 0%,100%{ transform: scale(1); } 50%{ transform: scale(1.14); box-shadow: 0 0 12px rgba(255,90,120,.6); } }
#hud-level { margin-right: auto; }
.hud-btn {
  border: none;
  background: rgba(255,255,255,.9);
  width: 40px; height: 40px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(90,50,120,.15);
}
.hud-btn:active { transform: scale(.92); }
.hud-btn.off { opacity: .45; }

#stage {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#game { display: block; touch-action: none; }

/* Banner s tématem kola */
.banner {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #fff, #ffe9f5);
  color: var(--pink-dark);
  font-weight: bold;
  font-size: clamp(18px, 4.5vw, 26px);
  padding: 10px 24px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  border: 3px solid #fff;
  pointer-events: none;
  z-index: 4;
  animation: bannerIn .5s cubic-bezier(.2,1.5,.4,1);
}
@keyframes bannerIn { from{ transform: translateX(-50%) translateY(-30px) scale(.8); opacity: 0; } to{ transform: translateX(-50%) translateY(0) scale(1); opacity: 1; } }

.toast {
  position: absolute;
  top: 62px;
  left: 50%;
  transform: translateX(-50%) scale(1);
  background: rgba(255,255,255,.96);
  color: var(--pink-dark);
  font-weight: bold;
  font-size: 20px;
  padding: 8px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  pointer-events: none;
  z-index: 3;
  animation: pop .5s ease;
}
@keyframes pop { 0%{transform:translateX(-50%) scale(.5); opacity:0} 60%{transform:translateX(-50%) scale(1.1)} 100%{transform:translateX(-50%) scale(1); opacity:1} }

/* ---------- Dotykový křížek ---------- */
#dpad {
  --pad: 62px;
  position: relative;
  width: calc(var(--pad) * 3 + 10px);
  height: calc(var(--pad) * 3 + 10px);
  margin: 6px auto calc(10px + env(safe-area-inset-bottom));
  flex: 0 0 auto;
}
.pad {
  position: absolute;
  width: var(--pad);
  height: var(--pad);
  border: none;
  border-radius: 18px;
  background: rgba(255,255,255,.92);
  color: var(--grape);
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(138,92,255,.35);
  display: flex; align-items: center; justify-content: center;
  user-select: none;
  touch-action: none;
}
.pad:active, .pad.pressed { transform: translateY(3px); box-shadow: 0 1px 0 rgba(138,92,255,.35); background: #f3ecff; }
.pad.up    { left: var(--pad); top: 0; }
.pad.left  { left: 0; top: var(--pad); }
.pad.right { right: 0; top: var(--pad); }
.pad.down  { left: var(--pad); bottom: 0; }
.pad.sprint {
  left: var(--pad); top: var(--pad);
  background: linear-gradient(180deg, #ffe37a, #ffb03a);
  color: #fff; font-size: 26px;
  box-shadow: 0 4px 0 rgba(220,140,0,.4);
  text-shadow: 0 1px 2px rgba(180,110,0,.5);
}
.pad.sprint:active, .pad.sprint.pressed { transform: translateY(3px); box-shadow: 0 1px 0 rgba(220,140,0,.4); }

@media (min-width: 820px) and (pointer: fine) {
  #dpad { --pad: 52px; opacity: .85; }
}

/* ---------- Překryvné okno ---------- */
.overlay {
  position: fixed; inset: 0;
  background: rgba(58,43,74,.45);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  z-index: 20;
  animation: fade .25s ease;
}
@keyframes fade { from{opacity:0} to{opacity:1} }
.overlay-card {
  position: relative;
  overflow: hidden;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 28px 26px;
  text-align: center;
  max-width: min(400px, 90vw);
  border: 4px solid #fff;
  animation: rise .35s cubic-bezier(.2,1.4,.5,1);
}
@keyframes rise { from{transform:translateY(30px) scale(.9); opacity:0} to{transform:none; opacity:1} }
#celebrate { width: 130px; height: 130px; position: relative; z-index: 1; }
.overlay-card h2 { margin: 4px 0 6px; color: var(--grape); font-size: 28px; position: relative; z-index: 1; }
.ov-medal { font-size: 46px; margin: 2px 0; animation: btnpulse 1.5s ease-in-out infinite; }
.ov-stars { font-size: 36px; letter-spacing: 6px; min-height: 44px; }
.ov-stars .star { display: inline-block; }
.ov-stars .dim { filter: grayscale(1); opacity: .3; }
.ov-stars .pop { animation: starpop .4s cubic-bezier(.2,1.6,.4,1); }
/* Cíle kola (hvězdy) */
.ov-stars { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; letter-spacing: normal; }
.goal-row { font-size: 16px; font-weight: bold; color: var(--pink-dark); display: flex; align-items: center; gap: 6px; }
.goal-row .gstar { font-size: 22px; }
.goal-row.dim { color: #b3a6c6; opacity: .75; }
.goal-row.pop { animation: starpop .4s cubic-bezier(.2,1.6,.4,1); }
@keyframes starpop { from{ transform: scale(0) rotate(-40deg);} to{ transform: scale(1) rotate(0);} }
.ov-text { margin: 8px 6px 16px; font-size: 16px; position: relative; z-index: 1; }
.ov-buttons { display: flex; gap: 12px; justify-content: center; align-items: center; flex-wrap: wrap; position: relative; z-index: 1; }

/* padající konfety v oslavném okně */
.ov-confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.ov-confetti span {
  position: absolute; top: -26px;
  animation-name: conffall; animation-timing-function: ease-in; animation-fill-mode: forwards; animation-iteration-count: 1;
}
@keyframes conffall {
  0%   { transform: translateY(0) rotate(0); opacity: 1; }
  100% { transform: translateY(360px) rotate(400deg); opacity: 0; }
}

/* Landscape na telefonu */
@media (max-height: 520px) and (orientation: landscape) {
  #screen-game { flex-direction: row; flex-wrap: wrap; align-content: stretch; }
  #hud { order: 0; width: 100%; }
  #stage { order: 1; flex: 1 1 60%; }
  #dpad { order: 2; --pad: 50px; align-self: center; margin: 0 10px; }
}

/* ---------- Šatník ---------- */
.big-btn.ward-open { background: linear-gradient(180deg,#b79bff,#8a6bff); box-shadow: 0 5px 0 #6f4de0; margin-top: 10px; font-size: 20px; padding: 12px 30px; }
.ward-card {
  background: rgba(255,255,255,.95);
  border-radius: 26px;
  box-shadow: var(--shadow);
  width: min(680px, 94vw);
  max-height: 92vh;
  display: flex; flex-direction: column;
  padding: 14px 16px 18px;
  z-index: 1;
}
.ward-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.ward-head h2 { margin: 0 auto; color: var(--grape); font-size: 26px; }
.ward-coins { background: #fff6d8; border-radius: 999px; padding: 6px 14px; font-weight: bold; color: #b8860b; box-shadow: 0 2px 6px rgba(180,140,0,.2); white-space: nowrap; }
#ward-preview { align-self: center; margin: 2px 0 6px; }
.ward-grid { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px; display: flex; flex-direction: column; gap: 12px; }
.ward-section-title { font-weight: bold; color: var(--pink-dark); margin: 2px 0 -4px; font-size: 15px; }
.ward-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 10px; }
.ward-item {
  background: #f4efff; border: 3px solid transparent; border-radius: 16px;
  padding: 8px 4px 6px; text-align: center; cursor: pointer; user-select: none;
  transition: transform .08s;
}
.ward-item:active { transform: scale(.95); }
.ward-item .emo { font-size: 30px; line-height: 1.1; }
.ward-item .nm { font-size: 11px; color: #6a5a80; margin-top: 2px; height: 26px; display: flex; align-items: center; justify-content: center; }
.ward-item .pr { font-size: 12px; font-weight: bold; margin-top: 2px; }
.ward-item.locked .pr { color: #b8860b; }
.ward-item.locked.cant { opacity: .5; }
.ward-item.owned { background: #eafbe8; }
.ward-item.owned .pr { color: #3aa33a; }
.ward-item.equipped { border-color: var(--grape); background: #efe6ff; box-shadow: 0 3px 10px rgba(138,92,255,.3); }
.ward-item.equipped .pr { color: var(--grape); }
