/* ---------- ikonka dárku ---------- */

.gift {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 15;
  width: 58px;
  height: 58px;
  padding: 6px;
  border: 0;
  background: none;
  cursor: pointer;
  transform-origin: 50% 90%;
  animation: gift-wiggle 3s ease-in-out infinite;
  filter: drop-shadow(0 3px 0 rgba(27, 47, 107, .35));
  -webkit-tap-highlight-color: transparent;
}
.gift-ico { width: 100%; height: 100%; display: block; }
.gift:hover { animation-duration: 1.2s; }
.gift:focus-visible { outline: 3px dashed var(--navy); outline-offset: 2px; border-radius: 6px; }
body.gf-open .gift { visibility: hidden; }

@keyframes gift-wiggle {
  0%, 52%, 100% { transform: rotate(0) translateY(0); }
  56% { transform: rotate(-14deg) translateY(-4px); }
  62% { transform: rotate(13deg) translateY(-2px); }
  68% { transform: rotate(-11deg) translateY(-4px); }
  74% { transform: rotate(9deg) translateY(-1px); }
  80% { transform: rotate(-5deg); }
  86% { transform: rotate(3deg); }
}

/* ---------- okno ve stylu Minecraftu ---------- */

.gf-back {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, .62);
  user-select: none;
}
.gf-back[hidden] { display: none; }

.gf-box {
  --mc-light: #ffffff;
  --mc-dark: #555555;
  position: relative;
  width: min(440px, 100%);
  max-height: 100%;
  overflow: hidden;
  padding: 18px 20px 16px;
  background: #c6c6c6;
  color: #3a3a3a;
  text-align: center;
  border: 4px solid #000;
  box-shadow:
    inset 4px 4px 0 var(--mc-light),
    inset -4px -4px 0 var(--mc-dark),
    0 10px 0 rgba(0, 0, 0, .35);
  animation: gf-in .28s steps(6) both;
  font-family: "Fredoka", "Trebuchet MS", sans-serif;
}
.gf-box.good { animation: gf-good .9s ease-out; }
.gf-box.bad { animation: gf-bad .6s ease-out; }

@keyframes gf-in { from { transform: translateY(24px) scale(.9); opacity: 0; } }
@keyframes gf-good {
  0% { background: #c6c6c6; }
  15% { background: #c4f5a0; transform: scale(1.03); }
  100% { background: #c6c6c6; transform: scale(1); }
}
@keyframes gf-bad {
  0% { background: #ff6b6b; }
  100% { background: #c6c6c6; }
}
.gf-box.bad { animation-name: gf-bad, gf-shake; animation-duration: .7s, .45s; }
@keyframes gf-shake {
  0%, 100% { translate: 0 0; }
  15% { translate: -10px 0; }
  30% { translate: 9px 0; }
  45% { translate: -7px 0; }
  60% { translate: 5px 0; }
  75% { translate: -3px 0; }
}

.gf-x {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  border: 3px solid #000;
  background: #8b8b8b;
  color: #fff;
  font: 700 16px/1 "Fredoka", sans-serif;
  cursor: pointer;
  box-shadow: inset 2px 2px 0 #b9b9b9, inset -2px -2px 0 #4a4a4a;
}
.gf-x:hover { background: #7a8bd0; }

.gf-title {
  margin: 0 36px 14px;
  font: 700 22px/1.15 "Fredoka", sans-serif;
  color: #3a3a3a;
  text-shadow: 2px 2px 0 rgba(255, 255, 255, .55);
  letter-spacing: .02em;
}

.gf-body.enter { animation: gf-slide .3s steps(5) both; }
@keyframes gf-slide { from { transform: translateX(40px); opacity: 0; } }

.gf-text, .gf-q {
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 500;
  line-height: 1.35;
}
.gf-q { font-size: 21px; font-weight: 600; color: #222; }

.gf-in {
  width: 100%;
  padding: 10px 12px;
  border: 3px solid #fff;
  outline: 3px solid #000;
  outline-offset: 0;
  background: #000;
  color: #fff;
  font: 500 20px "Fredoka", sans-serif;
  text-align: center;
  user-select: text;
  -webkit-user-select: text;
  border-radius: 0;
}
.gf-in:focus { border-color: #ffff55; }
.gf-in.err {
  border-color: #ff3b3b;
  color: #ff8f8f;
  animation: gf-shake .45s;
}
.gf-in:disabled { border-color: #55ff55; color: #55ff55; }

.gf-msg {
  min-height: 1.5em;
  margin: 10px 0 8px;
  font-size: 16px;
  font-weight: 600;
}
.gf-msg.ok { color: #1d8a1d; }
.gf-msg.err { color: #c21f1f; }

.gf-btn, .gf-copy {
  display: block;
  width: 100%;
  padding: 11px 14px;
  border: 3px solid #000;
  background: #7d7d7d;
  color: #fff;
  font: 600 19px "Fredoka", sans-serif;
  text-shadow: 2px 2px 0 #3f3f3f;
  cursor: pointer;
  box-shadow: inset 3px 3px 0 #b4b4b4, inset -3px -3px 0 #4f4f4f;
  border-radius: 0;
}
.gf-btn:hover:not(:disabled), .gf-copy:hover { background: #7a8bd0; box-shadow: inset 3px 3px 0 #b4c0f2, inset -3px -3px 0 #4a56a0; }
.gf-btn:disabled { opacity: .55; cursor: default; }
.gf-btn:focus-visible, .gf-copy:focus-visible, .gf-chest:focus-visible, .gf-x:focus-visible {
  outline: 3px dashed #ffff55;
  outline-offset: 2px;
}

/* XP lišta */
.gf-xp {
  display: flex;
  gap: 4px;
  margin-top: 16px;
  padding: 4px;
  background: #000;
}
.gf-xp i {
  flex: 1;
  height: 12px;
  background: #2b2b2b;
  box-shadow: inset 0 -3px 0 #1a1a1a;
}
.gf-xp i.on {
  background: #7fff00;
  box-shadow: inset 0 3px 0 #c8ff7a, inset 0 -3px 0 #3f9a00;
  animation: gf-xp .5s steps(4);
}
@keyframes gf-xp { 0% { filter: brightness(2.6); transform: scaleY(1.7); } }

/* úspěch (achievement) */
.gf-toast {
  position: absolute;
  left: 50%;
  top: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 10px;
  background: #1c1c1c;
  border: 3px solid #fff;
  color: #fff;
  text-align: left;
  white-space: nowrap;
  translate: -50% -140%;
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}
.gf-toast.show { animation: gf-toast 2.2s ease-out both; }
.gf-toast b {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  background: #ffd23a;
  border: 3px solid #8a5a00;
  color: #8a5a00;
  font-size: 18px;
}
.gf-toast small { display: block; color: #ffff55; font-size: 12px; font-weight: 600; }
.gf-toast em { font-style: normal; font-size: 16px; font-weight: 600; }
@keyframes gf-toast {
  0% { translate: -50% -140%; opacity: 1; }
  12%, 80% { translate: -50% 0; opacity: 1; }
  100% { translate: -50% -140%; opacity: 1; }
}

/* částice (XP kuličky, kousky bloků) */
.gf-fx {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 2;
}
.gf-px {
  position: absolute;
  left: 50%;
  top: 48%;
  width: var(--s);
  height: var(--s);
  background: var(--c);
  box-shadow: inset -2px -2px 0 rgba(0, 0, 0, .25);
  animation: gf-fly var(--t) cubic-bezier(.2, .7, .3, 1) forwards;
}
@keyframes gf-fly {
  to {
    transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(.3);
    opacity: 0;
  }
}

/* ---------- truhla ---------- */

.gf-scene {
  position: relative;
  height: 290px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  perspective: 500px;
}

.gf-chest {
  position: relative;
  z-index: 2;
  display: block;
  width: 168px;
  height: 140px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  transform-style: preserve-3d;
  animation: gf-bob 1.6s ease-in-out infinite;
  -webkit-tap-highlight-color: transparent;
}
.gf-chest:hover:not(:disabled) { filter: brightness(1.15); }
.gf-chest:disabled { cursor: default; animation: none; }
.gf-chest svg { position: absolute; left: 0; width: 100%; display: block; }
.gf-chest .base { bottom: 0; height: 57%; }
.gf-chest .lid {
  top: 0;
  height: 43%;
  transform-origin: 50% 100%;
  transition: transform .55s cubic-bezier(.3, 1.4, .5, 1);
}
.gf-scene.open .lid { transform: rotateX(-118deg); }
@keyframes gf-bob { 50% { transform: translateY(-5px); } }

.gf-beam {
  position: absolute;
  bottom: 62px;
  left: 50%;
  width: 150px;
  height: 230px;
  translate: -50% 0;
  background: linear-gradient(to top, rgba(255, 233, 120, .95), rgba(255, 233, 120, 0));
  clip-path: polygon(30% 100%, 70% 100%, 100% 0, 0 0);
  opacity: 0;
  z-index: 1;
}
.gf-scene.open .gf-beam { animation: gf-beam 1.2s ease-out .4s forwards; }
@keyframes gf-beam { 30% { opacity: 1; } 100% { opacity: .5; } }

.gf-prize {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 3;
  padding: 10px 10px 12px;
  background: #1c1c1c;
  border: 3px solid #ffd23a;
  box-shadow: 0 0 0 3px #000, 0 0 24px rgba(255, 210, 58, .8);
  color: #fff;
  opacity: 0;
  visibility: hidden;
}
.gf-prize small { display: block; color: #ffff55; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.gf-code {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px 10px;
  margin-bottom: 10px;
  font: 600 clamp(19px, 5.6vw, 27px) "Fredoka", sans-serif;
  letter-spacing: .05em;
  color: #55ff55;
  user-select: text;
  -webkit-user-select: text;
}
.gf-copy { font-size: 16px; padding: 7px 10px; }
.gf-scene.open .gf-prize {
  visibility: visible;
  animation: gf-jump .9s cubic-bezier(.3, 1.2, .5, 1) .5s both;
}
@keyframes gf-jump {
  0% { opacity: 0; transform: translateY(210px) scale(.25); }
  25% { opacity: 1; }
  70% { transform: translateY(-16px) scale(1.06); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* postavičky vybíhající z truhly */
.gf-mobs { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.gf-mob {
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 40px;
  margin-left: -20px;
  translate: var(--tx) 0;
  animation: gf-walk .9s linear var(--d) backwards;
}
.gf-mob .in {
  animation: gf-arc .9s cubic-bezier(.3, .7, .5, 1) var(--d) backwards,
             gf-idle .9s steps(1) calc(var(--d) + .9s) infinite;
  transform-origin: 50% 100%;
}
.gf-mob .mob { display: block; width: 100%; height: auto; }
.gf-mob:nth-child(even) .in { animation-duration: .9s, 1.1s; }
@keyframes gf-walk {
  0% { translate: 0 60px; opacity: 0; }
  10% { opacity: 1; }
  100% { translate: var(--tx) 0; opacity: 1; }
}
@keyframes gf-arc {
  0% { transform: translateY(0) scale(.3); }
  45% { transform: translateY(-100px) scale(1.1); }
  75% { transform: translateY(0) scale(1); }
  88% { transform: translateY(-14px) scale(1); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes gf-idle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

@media (max-width: 420px) {
  .gf-box { padding: 16px 14px 14px; }
  .gf-q { font-size: 19px; }
  .gift { width: 50px; height: 50px; }
}

@media (prefers-reduced-motion: reduce) {
  .gift, .gf-chest, .gf-box, .gf-body.enter { animation: none !important; }
  .gf-box.good, .gf-box.bad { animation: none !important; }
  .gf-scene.open .gf-prize { animation: none; opacity: 1; }
  .gf-scene.open .gf-beam { animation: none; opacity: .5; }
  .gf-chest .lid { transition: none; }
  .gf-mob, .gf-mob .in { animation: none !important; }
}
