*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  background: #000;
  color: #fff;
  overflow: hidden;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root {
  --scene-width: 1920px;
  --scene-height: 1080px;
  --bg-image: url("bg_trolljak.png");
  --title-top: 130px;
  --title-left: 50%;
  --title-width: 800px;
  --char-bottom: -20px;
  --char-left: 50%;
  --char-width: 650px;
  --text-top: 500px;
  --text-left: 80%;
  --text-width: 380px;
  --arrows-left: 40px;
  --arrows-bottom: 0px;
  --arrows-width: 200px;
  --arrows-height: 1000px;
  --sound-btn-right: 40px;
  --sound-btn-bottom: 40px;
  --sound-btn-width: 150px;
  --top-btn-x-top: 35px;
  --top-btn-x-left: 30%;
  --top-btn-x-width: 50px;
  --top-btn-right-top: 35px;
  --top-btn-right-left: 70%;
  --top-btn-right-width: 50px;
  --ca-top: 30px;
  --ca-left: 50%;
  --ca-width: 520px;
  --ca-height: 60px;
  --ca-border-radius: 0px;
  --toast-top: 100px;
  --toast-left: 50%;
}

.page-wrapper {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.scene {
  position: relative;
  width: var(--scene-width);
  height: var(--scene-height);
  transform-origin: center center;
}

.bg-layer {
  position: absolute;
  inset: 0;
  background-image: var(--bg-image);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  z-index: 1;
}

.top-bar {
  position: absolute;
  inset: 0;
  height: 0;
  z-index: 5;
  pointer-events: none;
}

.top-btn {
  position: absolute;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s ease-out;
}

.top-btn img {
  width: 100%;
  height: auto;
  display: block;
}

.top-btn-x {
  top: var(--top-btn-x-top);
  left: var(--top-btn-x-left);
  transform: translateX(-50%);
  width: var(--top-btn-x-width);
}

.top-btn-right {
  top: var(--top-btn-right-top);
  left: var(--top-btn-right-left);
  transform: translateX(-50%);
  width: var(--top-btn-right-width);
}

.ca-frame {
  position: absolute;
  top: var(--ca-top);
  left: var(--ca-left);
  transform: translateX(-50%) rotate(0deg);
  transform-origin: center center;
  width: var(--ca-width);
  height: var(--ca-height);
  background-image: url("ca_frame_trolljak.png");
  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;
  border: none;
  border-radius: var(--ca-border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  padding-inline: 24px;
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.18s ease-out;
}

.ca-frame:hover {
  transform: translateX(-50%) rotate(90deg);
}

.ca-frame span {
  width: 100%;
  text-align: center;
  font-family: "Kirang Haerang", system-ui, sans-serif;
  font-size: 22px;
  letter-spacing: 1px;
  color: #00ff9d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.title-image {
  position: absolute;
  top: var(--title-top);
  left: var(--title-left);
  transform: translateX(-50%);
  width: var(--title-width);
  height: auto;
  z-index: 2;
}

.char-image {
  position: absolute;
  bottom: var(--char-bottom);
  left: var(--char-left);
  transform: translateX(-50%);
  width: var(--char-width);
  height: auto;
  z-index: 2;
}

.text-image {
  position: absolute;
  top: var(--text-top);
  left: var(--text-left);
  transform: translateX(-50%);
  width: var(--text-width);
  height: auto;
  z-index: 3;
}

.arrows-column {
  position: absolute;
  left: var(--arrows-left);
  bottom: var(--arrows-bottom);
  width: var(--arrows-width);
  height: var(--arrows-height);
  overflow: visible;
  z-index: 2;
  pointer-events: none;
}

.arrow-instance {
  position: absolute;
  width: 70px;
  height: auto;
  left: 0;
  bottom: -120px;
  image-rendering: auto;
  will-change: transform, bottom;
  animation-name: arrow-move, arrow-jitter;
  animation-timing-function: linear, ease-in-out;
  animation-iteration-count: infinite, infinite;
}

@keyframes arrow-move {
  0% { bottom: -120px; }
  100% { bottom: 110%; }
}

@keyframes arrow-jitter {
  0% { transform: translate3d(0, 0, 0) rotate(-3deg); }
  50% { transform: translate3d(4px, -3px, 0) rotate(2deg); }
  100% { transform: translate3d(-3px, 2px, 0) rotate(-2deg); }
}

.sound-btn {
  position: absolute;
  right: var(--sound-btn-right);
  bottom: var(--sound-btn-bottom);
  width: var(--sound-btn-width);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
  transition: transform 0.1s ease-out;
}

.sound-btn img {
  width: 100%;
  height: auto;
  display: block;
}

.sound-btn:active,
.sound-btn.pressed {
  animation: none;
  transform: translateY(6px) scale(0.97);
}

@keyframes btn-wiggle {
  0% { transform: translateX(0) translateY(0) rotate(0deg); }
  25% { transform: translateX(-1px) translateY(-1px) rotate(-2deg); }
  50% { transform: translateX(1px) translateY(0) rotate(2deg); }
  75% { transform: translateX(-1px) translateY(1px) rotate(-1deg); }
  100% { transform: translateX(0) translateY(0) rotate(0deg); }
}

.top-btn:hover:not(:active),
.sound-btn:hover:not(:active) {
  animation: btn-wiggle 0.22s ease-in-out infinite;
}

.top-btn:active {
  animation: none;
  transform: translateX(-50%) translateY(4px) scale(0.97);
}

.top-btn-x:active {
  animation: none;
  transform: translateX(-50%) translateY(4px) scale(0.97);
}

.top-btn-right:active {
  animation: none;
  transform: translateX(-50%) translateY(4px) scale(0.97);
}

.toast {
  position: absolute;
  top: var(--toast-top);
  left: var(--toast-left);
  transform: translateX(-50%);
  padding: 10px 24px;
  background: rgba(0, 0, 0, 0.9);
  border-radius: 999px;
  border: 2px solid #00ff9d;
  font-family: "Kirang Haerang", system-ui, sans-serif;
  font-size: 20px;
  letter-spacing: 1px;
  color: #00ff9d;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease-out, transform 0.25s ease-out;
  z-index: 10;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(-6px);
}

button {
  cursor: pointer;
}
