/* s'Kerzen-Spü – interaktive Übungsrunde
   Liegt als HTML-Ebene über dem Unity-Canvas. Das Spiel selbst bleibt unverändert. */

@font-face {
  font-family: "Kameron Tut";
  src: url("kameron.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: "Kameron Tut";
  src: url("kameron-bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

.kt-overlay {
  --kt-brown: #4b3826;
  --kt-red: #8e2a26;
  --kt-card: #f7f7f6;
  --kt-wood: #efd4a8;
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--kt-wood) url("img/hintergrund.webp") center / cover no-repeat;
  font-family: "Kameron Tut", Georgia, "Times New Roman", serif;
  color: var(--kt-brown);
  opacity: 0;
  transition: opacity 0.35s ease;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.kt-overlay *, .kt-overlay *::before, .kt-overlay *::after { box-sizing: border-box; }
.kt-overlay.is-open { opacity: 1; }
.kt-overlay[hidden] { display: none; }

/* Bühne im Hochformat 9:16 – Koordinaten entsprechen der Unity-Kamera (10 Einheiten hoch) */
.kt-stage {
  position: relative;
  flex: 0 0 auto;
  width: 56.25vh;
  height: 100vh;
  touch-action: none;
  overflow: hidden;
  cursor: default;
}
.kt-stage.is-grab { cursor: grab; }
.kt-stage.is-grabbing { cursor: grabbing; }

.kt-obj {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.kt-obj > img, img.kt-obj { display: block; }
img.kt-obj, .kt-obj > img.kt-fill { width: 100%; height: 100%; }
.kt-glide { transition: left 0.38s cubic-bezier(.2,.8,.3,1), top 0.38s cubic-bezier(.2,.8,.3,1), transform 0.25s ease; }
.kt-pop { animation: kt-pop 0.32s cubic-bezier(.3,1.6,.5,1); }
@keyframes kt-pop { from { transform: translate(-50%, -50%) scale(0.4); } to { transform: translate(-50%, -50%) scale(1); } }
.kt-lift { transform: translate(-50%, -50%) scale(1.06); filter: drop-shadow(0 0.6em 0.5em rgba(60,38,18,.35)); }
.kt-hidden { visibility: hidden; }

.kt-sold { transition: transform 0.5s ease-in, opacity 0.5s ease-in; transform: translate(-50%, -50%) scale(0.2) !important; opacity: 0; }

/* Wachs füllt sich von unten (scaleY) */
.kt-wax { transform-origin: 50% 50%; transform: translate(-50%, -50%) scaleY(0); }

/* Markierung des Ziels (wie der "Ping" im Spiel) */
.kt-ping {
  position: absolute;
  z-index: 40;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
  background: url("img/ping-sheet.png") no-repeat;
  background-size: 300% 200%;
  animation:
    kt-ping-frames 0.9s step-end infinite,
    kt-ping-move 0.9s linear infinite;
}
/* 6 Frames, jeder gleich lang (0,15 s) */
@keyframes kt-ping-frames {
  0%     { background-position: 0% 0%; }
  16.67% { background-position: 50% 0%; }
  33.33% { background-position: 100% 0%; }
  50%    { background-position: 0% 100%; }
  66.67% { background-position: 50% 100%; }
  83.33% { background-position: 100% 100%; }
  100%   { background-position: 100% 100%; }
}
/* läuft fließend mit: leicht wachsen, ein- und ausblenden */
@keyframes kt-ping-move {
  0%   { transform: translate(-50%, -50%) scale(0.9); opacity: 0; }
  8%   { opacity: 1; }
  85%  { opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.1); opacity: 0; }
}

/* Hinweis-Hand */
.kt-hand {
  position: absolute;
  z-index: 60;
  width: 11%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  filter: drop-shadow(0 0.25em 0.3em rgba(60, 38, 18, 0.35));
}
.kt-hand img { display: block; width: 100%; transform-origin: 18% 4%; transition: transform 0.15s ease; transform: rotate(-12deg); }
.kt-hand.is-visible { opacity: 1; }
.kt-hand.is-down img { transform: rotate(-12deg) scale(0.86); }

.kt-holdring {
  position: absolute;
  z-index: 55;
  width: 9%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%) rotate(-90deg);
  pointer-events: none;
}
.kt-holdring circle { fill: none; stroke-width: 5; }
.kt-holdring .bg { stroke: rgba(255, 255, 255, 0.8); }
.kt-holdring .fg { stroke: #f09c1e; stroke-linecap: round; }

/* Anleitungskarte – nach den Figma-Frames */
.kt-card {
  position: absolute;
  z-index: 70;
  left: 50%;
  top: 29.5%;
  width: 70%;
  transform: translateX(-50%);
  padding: 1.15em 1.1em 1.2em;
  background: var(--kt-card);
  border: 0.13em solid var(--kt-red);
  border-radius: 0.6em;
  box-shadow: 0 0.35em 1em rgba(75, 56, 38, 0.18);
  text-align: center;
  pointer-events: none;
  transition: top 0.35s ease, opacity 0.25s ease, transform 0.25s ease;
}
.kt-card.is-top { top: 2.5%; }
.kt-card.is-swap { opacity: 0; transform: translateX(-50%) translateY(-0.4em); }
.kt-card.is-final { top: 24%; width: 78%; }
.kt-card h2 {
  margin: 0 0 0.55em;
  font-weight: 700;
  font-size: 1.14em;
  line-height: 1.2;
  color: var(--kt-brown);
}
.kt-card p {
  margin: 0;
  font-weight: 400;
  font-size: 1em;
  line-height: 1.38;
  color: var(--kt-brown);
}
.kt-card .kt-count {
  display: inline-block;
  margin-top: 0.6em;
  padding: 0.12em 0.7em 0.18em;
  border-radius: 999px;
  background: #f0e2cc;
  color: var(--kt-red);
  font-weight: 700;
  font-size: 0.82em;
}
.kt-card .kt-count:empty { display: none; }
.kt-card .kt-actions { display: flex; flex-direction: column; align-items: center; gap: 0.55em; margin-top: 1em; }
.kt-card .kt-actions:empty { display: none; }

.kt-btn {
  appearance: none;
  pointer-events: auto;
  min-width: 62%;
  padding: 0.55em 1.2em 0.6em;
  border: 0.1em solid rgba(142, 42, 38, 0.35);
  border-radius: 0.2em;
  background: #f1dcb9;
  color: var(--kt-red);
  font: inherit;
  font-weight: 700;
  font-size: 1.05em;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 0.15em 0 rgba(142, 42, 38, 0.35);
}
.kt-btn:active { transform: translateY(0.1em); box-shadow: none; }
.kt-btn[disabled] { opacity: 0.6; cursor: default; }
.kt-btn.is-primary { background: var(--kt-red); color: #fff; border-color: var(--kt-red); box-shadow: 0 0.15em 0 #5e1916; }
.kt-link {
  appearance: none;
  pointer-events: auto;
  border: 0;
  background: none;
  padding: 0.3em 0.6em;
  color: var(--kt-brown);
  font: inherit;
  font-size: 0.86em;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}
.kt-btn:focus, .kt-link:focus, .kt-skip:focus, .kt-help:focus, .kt-btn:focus-visible, .kt-link:focus-visible, .kt-skip:focus-visible, .kt-help:focus-visible {
  outline: none;
}

/* Überspringen-Link */
.kt-skip {
  position: absolute;
  z-index: 80;
  right: max(10px, env(safe-area-inset-right));
  bottom: max(40px, env(safe-area-inset-bottom));
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.35em 0.9em 0.4em;
  background: rgba(247, 247, 246, 0.85);
  color: var(--kt-brown);
  font: inherit;
  font-size: 0.78em;
  text-decoration: underline;
  text-underline-offset: 0.18em;
  cursor: pointer;
  pointer-events: auto;
}
.kt-skip[hidden] { display: none; }

/* Erfolgs-Feedback */
.kt-toast {
  position: absolute;
  z-index: 65;
  transform: translate(-50%, -50%);
  font-weight: 700;
  font-size: 1.5em;
  color: #fff;
  text-shadow: 0 0.08em 0.2em rgba(75, 56, 38, 0.6);
  pointer-events: none;
  animation: kt-toast 1.2s ease-out forwards;
}
@keyframes kt-toast {
  0% { opacity: 0; transform: translate(-50%, -20%) scale(0.7); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
  100% { opacity: 0; transform: translate(-50%, -160%) scale(1); }
}
.kt-confetti {
  position: absolute;
  z-index: 64;
  width: 4%;
  pointer-events: none;
  animation: kt-confetti 1.4s cubic-bezier(.2,.7,.4,1) forwards;
}
@keyframes kt-confetti {
  0% { transform: translate(-50%, -50%) rotate(0) scale(0.4); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(var(--rot)) scale(1); opacity: 0; }
}
.kt-nope { animation: kt-nope 0.35s ease; }
@keyframes kt-nope {
  0%, 100% { margin-left: 0; }
  25% { margin-left: -1.2%; }
  75% { margin-left: 1.2%; }
}

/* Hilfe-Button während des echten Spiels */
.kt-help {
  position: absolute;
  z-index: 50;
  top: 44%;
  right: 6px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid #f8f2e7;
  background: #8e2a26;
  color: #fff;
  font-family: "Kameron Tut", Georgia, serif;
  font-weight: 700;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(60, 38, 18, 0.35);
  -webkit-tap-highlight-color: transparent;
}
.kt-help[hidden] { display: none; }
.kt-help:active { transform: scale(0.94); }

@media (prefers-reduced-motion: reduce) {
  .kt-glide, .kt-card, .kt-overlay { transition: none; }
  .kt-ping { animation: none; background-position: 0% 100%; }
}
