@font-face {
  font-family: "Lucky";
  font-display: swap;
  src: url(fonts/lucky-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Lucky";
  font-display: swap;
  src: url(fonts/lucky-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Fredoka";
  font-weight: 400 700;
  font-display: swap;
  src: url(fonts/fredoka-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Fredoka";
  font-weight: 400 700;
  font-display: swap;
  src: url(fonts/fredoka-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --yellow: #ffcb05;
  --blue: #2a5ab8;
  --navy: #1b2f6b;
  --red: #ee1c25;
  --ink: #26304f;
  --size: min(58vw, 34vh, 300px);
  --bw: calc(var(--size) * .44);
  --off: min(calc(var(--size) * .92), calc(50vw - var(--bw) * .6));
  --bass: 0;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #7cc9ff;
  color: var(--ink);
}

body {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100svh;
  font-family: "Fredoka", "Trebuchet MS", sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

/* ---------- svět ---------- */

.sky, .clouds, .hills, #fx, .flash {
  position: fixed;
  pointer-events: none;
}
.sky, .clouds, #fx, .flash { inset: 0; }

.sky {
  z-index: 0;
  background: linear-gradient(#4fb3ff 0%, #8fd8ff 50%, #d9f6ff 100%);
  transition: filter 1s ease;
}
body.open .sky { filter: saturate(1.25) hue-rotate(-8deg); }

.clouds { z-index: 2; overflow: hidden; }
.cloud {
  position: absolute;
  left: 0;
  width: 150px;
  height: 46px;
  border-radius: 999px;
  background: #fff;
  box-shadow: inset 0 -8px 0 rgba(160, 205, 240, .45);
  animation: cloud 90s linear infinite;
  opacity: .95;
}
.cloud::before, .cloud::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: #fff;
}
.cloud::before { width: 64px; height: 64px; left: 22px; top: -30px; }
.cloud::after { width: 84px; height: 84px; left: 58px; top: -46px; }
.cloud:nth-child(1) { top: 8%;  scale: .9;  animation-duration: 95s;  animation-delay: -20s; }
.cloud:nth-child(2) { top: 22%; scale: .6;  animation-duration: 120s; animation-delay: -75s; opacity: .8; }
.cloud:nth-child(3) { top: 40%; scale: 1.1; animation-duration: 80s;  animation-delay: -50s; }
.cloud:nth-child(4) { top: 14%; scale: .75; animation-duration: 110s; animation-delay: -5s; }
.cloud:nth-child(5) { top: 55%; scale: .7;  animation-duration: 100s; animation-delay: -35s; opacity: .85; }
@keyframes cloud {
  from { transform: translateX(-260px); }
  to   { transform: translateX(calc(100vw + 60px)); }
}

.hills {
  z-index: 3;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 34vh;
}
.hills .h1 { fill: #8fe06a; }
.hills .h2 { fill: #52c451; }

#fx { z-index: 7; width: 100%; height: 100%; }

.flash {
  z-index: 20;
  background: #fff;
  opacity: 0;
}
.flash.go { animation: flash .6s ease-out; }
@keyframes flash { 0% { opacity: 0; } 15% { opacity: .85; } 100% { opacity: 0; } }

/* ---------- logo ---------- */

.head {
  position: relative;
  z-index: 8;
  display: flex;
  justify-content: center;
  padding: max(14px, 3vh) 16px 0;
}

.logo {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  column-gap: .35em;
  row-gap: 0;
  font-family: "Lucky", "Arial Black", sans-serif;
  font-weight: 400;
  font-size: clamp(40px, min(12vw, 9vh), 92px);
  line-height: 1;
  letter-spacing: .02em;
  text-transform: uppercase;
  text-align: center;
}
.logo .word { display: inline-flex; }
.logo .ch {
  display: inline-block;
  color: var(--yellow);
  -webkit-text-stroke: .13em var(--blue);
  paint-order: stroke fill;
  text-shadow: 0 .09em 0 var(--navy), 0 .16em .12em rgba(20, 40, 100, .35);
  rotate: var(--r, 0deg);
  animation: drop .8s cubic-bezier(.3, 1.6, .5, 1) both;
  animation-delay: calc(var(--i) * 45ms);
}
.logo .ch.big { font-size: 1.12em; }
@keyframes drop {
  from { transform: translateY(-120%) scale(.6); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
.logo.ready .ch { animation: none; }
.logo.ready.hop .ch { animation: hop .45s cubic-bezier(.3, 1.8, .5, 1) both; animation-delay: calc(var(--i) * 18ms); }
@keyframes hop {
  0% { transform: none; }
  40% { transform: translateY(-.16em) scale(1.06); }
  100% { transform: none; }
}

/* ---------- aréna ---------- */

.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 0;
  padding: 0 16px max(14px, env(safe-area-inset-bottom));
}

.arena {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
}

.rays {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 50%;
  width: 240vmax;
  height: 240vmax;
  translate: -50% -50%;
  background: repeating-conic-gradient(rgba(255, 255, 255, .34) 0deg 9deg, rgba(255, 255, 255, 0) 9deg 22.5deg);
  -webkit-mask-image: radial-gradient(circle, #000 0%, rgba(0, 0, 0, .75) 12%, transparent 32%);
  mask-image: radial-gradient(circle, #000 0%, rgba(0, 0, 0, .75) 12%, transparent 32%);
  animation: spin 60s linear infinite;
  transition: opacity .8s ease;
}
body.open .rays {
  background: repeating-conic-gradient(rgba(255, 236, 120, .55) 0deg 9deg, rgba(255, 255, 255, 0) 9deg 22.5deg);
  animation-duration: 14s;
  scale: calc(1 + var(--bass) * .12);
}
@keyframes spin { to { rotate: 360deg; } }

.ground {
  position: relative;
  z-index: 5;
  width: 100%;
  height: var(--size);
}

.ballwrap {
  position: absolute;
  left: 50%;
  top: 0;
  width: var(--size);
  height: var(--size);
  margin-left: calc(var(--size) / -2);
  z-index: 2;
  animation: bob 3.2s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}
body.open .ballwrap { animation-duration: .9s; }

.shadow {
  position: absolute;
  left: 50%;
  bottom: -4%;
  width: calc(var(--size) * .7);
  height: calc(var(--size) * .1);
  translate: -50% 0;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(20, 60, 20, .35), transparent);
  z-index: 1;
}

/* ---------- Pokéball ---------- */

.ball {
  position: absolute;
  inset: 0;
  padding: 0;
  border: 0;
  background: none;
  border-radius: 50%;
  cursor: pointer;
  perspective: 900px;
  -webkit-tap-highlight-color: transparent;
  transform-origin: 50% 90%;
  filter: drop-shadow(0 10px 0 rgba(20, 40, 90, .18));
  transition: transform .2s ease;
  touch-action: manipulation;
}
.ball:hover { transform: scale(1.04); }
.ball:active { transform: scale(.95); }
.ball:focus-visible { outline: 4px dashed var(--blue); outline-offset: 10px; }
body[data-state="idle"] .ball { animation: wiggle 4s ease-in-out 2s infinite; }
@keyframes wiggle {
  0%, 80%, 100% { rotate: 0deg; }
  84% { rotate: -12deg; }
  88% { rotate: 10deg; }
  92% { rotate: -5deg; }
  96% { rotate: 0deg; }
}
.ball.shaking { animation: catch 1.2s ease-in-out both !important; }
@keyframes catch {
  0%, 22%, 48%, 74%, 100% { rotate: 0deg; }
  6%, 32%, 58%  { rotate: -26deg; }
  14%, 40%, 66% { rotate: 22deg; }
}
.ball.caught { animation: squish .35s ease-out; }
@keyframes squish {
  0% { scale: 1; }
  40% { scale: 1.12 .9; }
  100% { scale: 1; }
}

.half {
  position: absolute;
  left: 0;
  width: 100%;
  height: 50%;
  border: calc(var(--size) * .04) solid #1d1d2b;
}
.half.top {
  top: 0;
  z-index: 3;
  border-bottom: 0;
  border-radius: calc(var(--size) / 2) calc(var(--size) / 2) 0 0;
  background:
    radial-gradient(circle at 30% 34%, rgba(255, 255, 255, .95) 0 5%, rgba(255, 255, 255, 0) 10%),
    radial-gradient(120% 140% at 35% 30%, #ff6b5b 0%, #f0262c 40%, #c8121a 85%);
  transform-origin: 50% 100%;
  transition: transform .7s cubic-bezier(.25, 1.6, .4, 1);
}
.half.bottom {
  bottom: 0;
  z-index: 1;
  border-top: 0;
  border-radius: 0 0 calc(var(--size) / 2) calc(var(--size) / 2);
  background: radial-gradient(130% 130% at 38% -10%, #fff 0%, #f6f6f6 55%, #d9dde6 100%);
}
.inside {
  position: absolute;
  z-index: 2;
  left: 4%;
  right: 4%;
  top: 38%;
  height: 24%;
  border-radius: 50%;
  background: radial-gradient(50% 50% at 50% 50%, #fff 0%, #fff6c4 35%, #ffcb05 70%, #e0a000 100%);
  box-shadow: 0 0 40px 12px rgba(255, 230, 120, .8);
  opacity: 0;
  transition: opacity .3s ease;
}
.band {
  position: absolute;
  z-index: 5;
  left: .5%;
  right: .5%;
  top: 50%;
  height: 8%;
  translate: 0 -50%;
  background: #1d1d2b;
  border-radius: 40%;
}
.core {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: 50%;
  width: 28%;
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: #1d1d2b;
  display: grid;
  place-items: center;
}
.core-in {
  width: 64%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #fff 0%, #f3f3f3 60%, #cfd4de 100%);
  box-shadow: inset 0 0 0 calc(var(--size) * .014) #dde1ea;
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: inset 0 0 0 calc(var(--size) * .014) #dde1ea, 0 0 0 0 rgba(255, 203, 5, 0); }
  50% { box-shadow: inset 0 0 0 calc(var(--size) * .014) #dde1ea, 0 0 18px 8px rgba(255, 220, 60, .9); }
}
.ball.shaking .core-in { animation: blink .2s steps(2, jump-none) infinite; }
@keyframes blink {
  from { background: #ff4040; }
  to   { background: #f3f3f3; }
}

body.open .half.top { transform: translateY(-30%) rotateX(42deg); }
body.open .inside { opacity: 1; }
body.open .core-in {
  animation: none;
  background: radial-gradient(circle, #fff 0%, #fff3a8 50%, #ffcb05 100%);
  box-shadow: 0 0 calc(10px + var(--bass) * 30px) calc(3px + var(--bass) * 10px) rgba(255, 210, 40, .95);
}

.gotcha {
  position: absolute;
  z-index: 9;
  left: 50%;
  top: -6%;
  translate: -50% 0;
  font-family: "Lucky", sans-serif;
  font-size: calc(var(--size) * .2);
  color: #fff;
  -webkit-text-stroke: .14em var(--red);
  paint-order: stroke fill;
  text-shadow: 0 .1em 0 #8a0c12;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
}
.gotcha.go { animation: gotcha 1.5s cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes gotcha {
  0% { opacity: 0; transform: scale(.3) rotate(-10deg); }
  20% { opacity: 1; transform: scale(1.1) rotate(-4deg); }
  75% { opacity: 1; transform: translateY(-10%) scale(1) rotate(-4deg); }
  100% { opacity: 0; transform: translateY(-40%) scale(.9) rotate(-4deg); }
}

/* ---------- tornáda-kamarádi ---------- */

.buddy {
  position: absolute;
  z-index: 4;
  width: var(--bw);
  aspect-ratio: 100 / 120;
  pointer-events: none;
  opacity: 0;
  transition: transform .7s cubic-bezier(.3, 1.5, .5, 1), opacity .25s ease;
}
.buddy .dance {
  display: block;
  width: 100%;
  height: 100%;
  transform-origin: 50% 100%;
  animation: sway .8s ease-in-out infinite alternate;
  animation-play-state: paused;
}
.buddy svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  transform-origin: 50% 100%;
  scale: calc(1 + var(--bass) * .14) calc(1 + var(--bass) * .1);
}
body.open .buddy { opacity: 1; }
body.open .buddy .dance { animation-play-state: running; }
@keyframes sway {
  from { rotate: -8deg; }
  to   { rotate: 8deg; }
}

.b1, .b2 {
  bottom: -2%;
  left: 50%;
  margin-left: calc(var(--bw) / -2);
}
.b1 {
  --tc: #b48cff; --tl: #e6d9ff; --tk: #7a4fe0;
  transform: translate(0, -30%) scale(.1);
}
.b2 {
  --tc: #ff8fca; --tl: #ffd6ec; --tk: #e0529c;
  transform: translate(0, -30%) scale(.1);
}
.b2 .dance { animation-delay: -.4s; }
body.open .b1 { transform: translateX(calc(var(--off) * -1)); transition-delay: .1s; }
body.open .b2 { transform: translateX(var(--off)); transition-delay: .22s; }

.b3 {
  --tc: #ffd23a; --tl: #fff1b0; --tk: #d99a00;
  width: 44%;
  left: 28%;
  bottom: 48%;
  transform: translateY(40%) scale(.1);
}
.b3 .dance { animation-duration: .6s; animation-delay: -.2s; }
body.open .b3 { transform: none; }

/* triky */
.buddy .trick {
  display: block;
  width: 100%;
  height: 100%;
  transform-origin: 50% 70%;
}
.trick.spin { animation: t-spin 1.2s cubic-bezier(.45, 0, .2, 1); }
@keyframes t-spin {
  0%   { transform: none; }
  15%  { transform: translateY(-10%); }
  85%  { transform: translateY(-10%) rotateY(1080deg); }
  100% { transform: rotateY(1080deg); }
}
.trick.flip { animation: t-flip 1.1s cubic-bezier(.3, .6, .3, 1); }
@keyframes t-flip {
  0%   { transform: none; }
  18%  { transform: translateY(4%) scale(1.12, .84); }
  55%  { transform: translateY(-75%) rotate(360deg); }
  82%  { transform: translateY(0) rotate(360deg) scale(1.12, .88); }
  100% { transform: rotate(360deg); }
}
.trick.jump { animation: t-jump 1s ease-in-out; }
@keyframes t-jump {
  0%, 100% { transform: none; }
  12% { transform: scale(1.15, .8); }
  30% { transform: translateY(-45%) scale(.9, 1.15); }
  45% { transform: translateY(-50%) rotate(-12deg); }
  60% { transform: translateY(-45%) rotate(12deg); }
  80% { transform: scale(1.12, .88); }
}
.trick.grow { animation: t-grow 1.1s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes t-grow {
  0%, 100% { transform: none; }
  25% { transform: scale(1.4); }
  40% { transform: scale(1.3) rotate(-8deg); }
  55% { transform: scale(1.35) rotate(8deg); }
  70% { transform: scale(1.3); }
}
.trick.dizzy { animation: t-dizzy 1.3s ease-in-out; }
@keyframes t-dizzy {
  0%, 100% { transform: none; }
  20% { transform: rotate(-25deg) translateX(-12%); }
  40% { transform: rotate(25deg) translateX(12%); }
  60% { transform: rotate(-18deg) translateX(-8%); }
  80% { transform: rotate(10deg) translateX(4%); }
}

.buddy .tag {
  position: absolute;
  left: 50%;
  bottom: 100%;
  margin-bottom: 6px;
  padding: .2em .75em .25em;
  border: 3px solid var(--tk);
  border-radius: 999px;
  background: #fff;
  color: var(--tk);
  font: 700 clamp(14px, calc(var(--size) * .075), 22px)/1.1 "Fredoka", sans-serif;
  white-space: nowrap;
  box-shadow: 0 3px 0 rgba(20, 40, 90, .25);
  opacity: 0;
  transform: translate(-50%, 12px) scale(.5);
  transition: opacity .25s ease, transform .4s cubic-bezier(.3, 1.7, .5, 1), translate .3s ease;
}
.buddy .tag::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  margin-left: -6px;
  border: 6px solid transparent;
  border-top-color: var(--tk);
}
.buddy.named .tag { opacity: 1; transform: translate(-50%, 0) scale(1); }
.buddy:has(.trick.spin) .tag { translate: 0 calc(var(--bw) * -.14); }
.buddy:has(.trick.grow) .tag { translate: 0 calc(var(--bw) * -.42); }

.tw .s { fill: var(--tc); }
.tw .s.l { fill: var(--tl); }
.tw .st {
  animation: swirl .5s ease-in-out infinite alternate;
  transform-box: fill-box;
}
.tw .st:nth-child(even) { animation-direction: alternate-reverse; }
@keyframes swirl {
  from { transform: translateX(-3px); }
  to   { transform: translateX(3px); }
}
.tw .glint {
  fill: rgba(255, 255, 255, .85);
  animation: glint .7s linear infinite;
}
@keyframes glint {
  from { transform: translateX(0); }
  to   { transform: translateX(calc(var(--w) * 1px)); }
}
.tw .eye { fill: #fff; stroke: #26304f; stroke-width: 1.6; }
.tw .pupil { fill: #26304f; }
.tw .shine { fill: #fff; }
.tw .cheek { fill: #ff7aa8; opacity: .75; }
.tw .mouth { fill: #7a2236; stroke: #26304f; stroke-width: 1.6; stroke-linejoin: round; }
.tw .tongue { fill: #ff6f8f; }
.tw .face { animation: blinkeye 4s infinite; transform-origin: 50% 28%; transform-box: view-box; }
@keyframes blinkeye {
  0%, 92%, 100% { scale: 1 1; }
  95% { scale: 1 .15; }
}

/* ---------- panel (jako ve hře) ---------- */

.panel {
  position: relative;
  z-index: 8;
  width: min(560px, 100%);
  margin-top: 10px;
  padding: 12px 16px 12px;
  background: #fbfbf4;
  border: 4px solid #2f3a66;
  border-radius: 14px;
  box-shadow:
    inset 0 0 0 3px #fff,
    inset 0 0 0 6px #7f97e0,
    0 6px 0 rgba(20, 40, 90, .35);
  font-size: clamp(15px, 4vw, 19px);
}

.stat {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lv { flex: none; }

.hprow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 8px;
}
.hp-label {
  flex: none;
  padding: 1px 6px;
  border-radius: 6px 0 0 6px;
  background: #3a3f5a;
  color: #ffb000;
  font-weight: 700;
  font-size: .8em;
}
.hp-bar {
  flex: 1;
  display: flex;
  justify-content: flex-end;
  height: 12px;
  padding: 2px;
  border: 2px solid #3a3f5a;
  border-radius: 0 8px 8px 0;
  background: #e8e8e0;
}
.hp-fill {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 4px;
  background: #3fd162;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .15);
  transition: background-color .4s ease;
}
.hp-fill.mid { background: #f8c630; }
.hp-fill.low { background: #f05a3c; }
.time { flex: none; min-width: 3.2em; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

.dialog {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 3.1em;
  padding-top: 8px;
  border-top: 3px dashed #c9cfe6;
}
.say {
  flex: 1;
  margin: 0;
  font-weight: 500;
  line-height: 1.3;
}
.say::after {
  content: "▼";
  display: inline-block;
  margin-left: .35em;
  font-size: .7em;
  color: var(--red);
  animation: caret .6s steps(2, jump-none) infinite;
}
body[data-state="playing"] .say::after { content: none; }
@keyframes caret { from { transform: translateY(0); } to { transform: translateY(3px); } }
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stop {
  flex: none;
  padding: 8px 14px 7px;
  border: 3px solid #2f3a66;
  border-radius: 10px;
  background: var(--red);
  color: #fff;
  font: 700 1em/1 "Fredoka", sans-serif;
  text-transform: uppercase;
  letter-spacing: .04em;
  cursor: pointer;
  box-shadow: 0 4px 0 #2f3a66;
  transition: transform .08s ease, box-shadow .08s ease, opacity .3s ease;
  touch-action: manipulation;
}
.stop:hover { background: #ff3b42; }
.stop:active { transform: translateY(3px); box-shadow: 0 1px 0 #2f3a66; }
.stop:focus-visible { outline: 3px dashed var(--blue); outline-offset: 3px; }
body[data-state="idle"] .stop { display: none; }

@media (max-height: 600px) {
  :root { --size: min(50vw, 30vh, 240px); }
  .panel { padding: 8px 12px; }
  .hprow { margin: 3px 0 5px; }
  .dialog { min-height: 2.6em; padding-top: 5px; }
}

@media (prefers-reduced-motion: reduce) {
  .cloud, .rays, .ballwrap, .ball, .buddy .dance, .buddy .trick, .tw .st, .tw .glint, .core-in, .logo .ch { animation: none !important; }
}
