:root {
  --font-size: 4rem;
  --wave-amp: 18px;
  --wave-duration: 1.2s;
  --delay-step: 0.07s;
  --gradient-duration: 3s;
}

.ai-btn-inner {
  display: flex;
  align-items: center;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
}

.ai-btn-icon-wrapper {
  display: flex;
  align-items: center;
  height: 100%;
  margin-right: 12px;
}

/* === Base Styles === */
body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: black;
  font-family: "MS Sans Serif", Arial, sans-serif;
  background-color: #000;
  background-image: url(../assets/background.gif);
  background-repeat: repeat;
  background-size: 4rem;

  image-rendering: pixelated;
  -ms-interpolation-mode: nearest-neighbor;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeSpeed;
  font-smooth: never;
  padding-top: 50px;
}

img {
  image-rendering: pixelated;
  -ms-interpolation-mode: nearest-neighbor;
  max-height: 120px;
}

/* === Button Styles === */
.button,
.button-bg,
.button-image {
  image-rendering: pixelated;
  -ms-interpolation-mode: nearest-neighbor;
}

.buttons-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 40px;
  width: 100%;
  z-index: 10;
}

.button-row {
  display: flex;
  justify-content: center;
  gap: 40px;
  width: 100%;
}

.button-container {
  position: relative;
  animation: appear-and-grow 1s ease-out forwards;
}

.button {
  position: relative;
  cursor: pointer;
  display: inline-block;
  width: auto;

  will-change: transform;
  transition: transform 200ms ease;
}

.button:hover .button-bg {
  content: url("../assets/buttonon.png");
}

@keyframes btn-swing {
  0% {
    transform: translateX(0) rotate(0deg) scale(1.15);
  }

  12% {
    transform: translateX(-6px) rotate(-3deg) scale(1.17);
  }

  25% {
    transform: translateX(-12px) rotate(-6deg) scale(1.2);
  }

  37% {
    transform: translateX(-6px) rotate(-3deg) scale(1.18);
  }

  50% {
    transform: translateX(0) rotate(0deg) scale(1.15);
  }

  62% {
    transform: translateX(6px) rotate(3deg) scale(1.18);
  }

  75% {
    transform: translateX(12px) rotate(6deg) scale(1.2);
  }

  87% {
    transform: translateX(6px) rotate(3deg) scale(1.17);
  }

  100% {
    transform: translateX(0) rotate(0deg) scale(1.15);
  }
}

.button:hover {
  animation: btn-swing 1000ms ease-in-out infinite;
  animation-fill-mode: both;
  transform-origin: center center;
}

.button-bg {
  width: 330px;
  height: auto;
  display: block;
}

.button-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 15px;
  box-sizing: border-box;
}

.button-text {
  color: white;
  font-size: 20px;
  text-shadow: 1px 1px 2px black;
  margin-right: 10px;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: none;
  text-rendering: optimizeSpeed;
  font-smooth: never;
}

.button-image {
  width: 100px;
  height: 100px;
  object-fit: contain;
}

.left {
  transform: translateX(-20px);
}

.right {
  transform: translateX(20px);
}

.button-text-image {
  max-height: 40px;
  margin-right: 10px;
  align-self: center;
  image-rendering: pixelated;
  opacity: 70;
}

/* === Special Buttons === */
.background-button {
  position: fixed;
  bottom: 20px;
  right: 24px;
  transform: translateX(-50%);
  z-index: 10;
  cursor: pointer;
}

.background-button img {
  width: 60px;
  height: auto;
  image-rendering: pixelated;
}

.kane-img {
  position: fixed;
  bottom: -100%;
  right: 20px;
  width: auto;
  max-height: 80vh;
  height: auto;
  transition: bottom 2.5s ease-in-out;
  z-index: 20;
  pointer-events: none;
}

/* === Frame (8-bit border) === */
.frame-wrapper {
  display: inline-block;
  image-rendering: pixelated;
}

.frame-top,
.frame-bottom,
.frame-middle {
  display: flex;
}

.corner {
  width: 9px;
  height: 9px;
  image-rendering: pixelated;
}

.edge.horizontal {
  flex: 1;
  height: 9px;
  background-repeat: repeat-x;
}

.edge.vertical {
  width: 9px;
  background-repeat: repeat-y;
}

/* === Things Block === */
.things-block {
  width: 75vw;
  background-color: #4433ba;
  padding: 10px;
  margin: -5px;
  color: white;
  image-rendering: pixelated;
  z-index: 1;
}

/* === Table === */
table {
  width: 100%;
  border: 2px solid #333;
  border-spacing: 0;
  border-collapse: separate;
  image-rendering: pixelated;
}

th,
td {
  border: 1px solid #666;
  padding: 6px;
  font-size: 14px;
  font-family: monospace;
  color: white;
  background-color: #222;
  text-align: left;
  image-rendering: pixelated;
}

th {
  background-color: #444;
}

.ai-win95-btn {
  display: flex;
  align-items: left;
  justify-content: flex-start;
  width: 340px;
  height: 72px;
  padding: 0.5rem;
  background: #c0c0c0;
  border: 2px solid #fff;
  border-bottom: 2px solid #808080;
  border-right: 2px solid #808080;
  box-shadow: 2px 2px 0 #000;
  font-family: "MS Sans Serif", Arial, sans-serif;
  font-size: 1.2rem;
  color: #222;
  text-decoration: none;
  margin-bottom: 0.5rem;
  transition: background 0.1s, box-shadow 0.1s;
  box-sizing: border-box;
  overflow: hidden;
  gap: 1rem;
}

.ai-btn-text {
  display: flex;
  flex-direction: column;
  font-size: 1.2rem;
}

.ai-btn-desc {
  font-size: 0.9rem;
  color: #444;
  margin-top: 2px;
  font-style: italic;
}

.ai-win95-btn:hover {
  background: #e0e0e0;
  box-shadow: 1px 1px 0 #000;
}

.ai-win95-btn:active {
  background: #a0a0a0;
  box-shadow: none;
}

.ai-btn-icon {
  height: 100%;
  width: auto;
  max-height: 100%;
  max-width: 52px;
  margin: 0 0.75rem 0 0.5rem;
  background: #fff;
  border: 1px solid #808080;
  box-shadow: 1px 1px 0 #fff;
  image-rendering: pixelated;
  object-fit: contain;
  align-self: center;
}

.categories-wrapper {
  width: 100%;
  max-width: 1100px;
  margin: 18px auto;
  padding: 12px 20px;
  box-sizing: border-box;
}

.category {
  margin: 18px 0 28px 0;
  padding: 6px 10px;
  box-sizing: border-box;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  color: white;
  font-family: "MS Sans Serif", Arial, sans-serif;
  text-shadow: 1px 1px 2px #000;
  justify-content: center;
}

.category-header img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  image-rendering: pixelated;
}

.category-title {
  font-size: 1.2rem;
  font-weight: 700;
}

.wavy-title {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 0.02em;
  font-size: var(--font-size);
  line-height: 1;
  user-select: none;
}

.wavy-title span {
  display: inline-block;
  white-space: pre;
  transform-origin: center bottom;
  background: linear-gradient(90deg, #3b82f6, #06b6d4, #10b981);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation-name: wave, gradientMove;
  animation-duration: var(--wave-duration), var(--gradient-duration);
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1), linear;
  animation-iteration-count: infinite, infinite;
  animation-delay: calc(var(--i) * var(--delay-step)), 0s;
}

@keyframes wave {
  0%,
  60%,
  100% {
    transform: translateY(0) rotate(0deg) scale(1);
  }
  30% {
    transform: translateY(calc(-1 * var(--wave-amp))) rotate(-2deg) scale(1.03);
  }
}

@keyframes gradientMove {
  0% {
    background-position: 0% 0%;
  }
  50% {
    background-position: 100% 0%;
  }
  100% {
    background-position: 0% 0%;
  }
}

.wavy-title .space {
  width: 0.5ch;
  display: inline-block;
  --i: 0;
  text-shadow: none;
  -webkit-text-fill-color: transparent;
}

.corner-button {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 100;
  width: 50px;
  height: 50px;
  background-image: url("../assets/home.png");
  background-size: contain;
  background-repeat: no-repeat;
  image-rendering: pixelated;
}

.corner-button:hover {
  background-image: url("../assets/buttons/home.gif");
}

.corner-gif {
  position: fixed;
  bottom: 1px;
  right: 20px;
  width: 240px;
  height: auto;
  image-rendering: pixelated;
  z-index: 1000;
  pointer-events: none;
}

.corner-gif:hover {
  cursor: url("https://media.tenor.com/GSz6LhaOMqIAAAAj/legs-undertale.gif"),
    auto;
}

.logo-container {
  display: flex;
  align-items: center;

  margin-top: -100px;
  margin-bottom: 40px;

  margin-left: 80px;

  opacity: 0;
  transform: scale(0.5);
  animation: appear-and-grow 3s ease-out forwards;
}

.logo-part {
  height: auto;
  max-width: 50vw;
  image-rendering: pixelated;
}

.logo-good {
  margin-right: -10px;
  animation: bobbing 2s ease-in-out infinite;
}

.logo-colours {
  margin-left: 5px;
  animation: bobbing 2s ease-in-out infinite 1s;
}

.music-corner-button {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;

  position: fixed;
  bottom: 20px;
  left: 24px;
  z-index: 5;
  opacity: 1;
}

.music-corner-button:hover {
  animation: shake-hover 0.9s ease-in-out infinite;
}

.music-corner-button img {
  width: 65px;
  height: auto;
  image-rendering: pixelated;
}

@keyframes shake-hover {
  0% {
    transform: rotate(0);
  }
  25% {
    transform: rotate(-5deg);
  }
  75% {
    transform: rotate(5deg);
  }
  100% {
    transform: rotate(0);
  }
}

@keyframes blinking {
  0% {
    filter: brightness(1.2);
  }
  50% {
    filter: brightness(0.8);
  }
  100% {
    filter: brightness(1.2);
  }
}

.music-corner-button.is-playing img {
  animation: blinking 1.5s step-end infinite;
}

@media (max-width: 768px) {
  :root {
    --font-size: 2rem;
  }

  .button-row {
    flex-direction: column;
    gap: 20px;
    align-items: center;
  }

  .button-container.left,
  .button-container.right {
    transform: none;
    width: 100%;
    display: flex;
    justify-content: center;
  }

  .button-bg {
    width: 280px;
  }

  .button-text {
    font-size: 18px;
  }

  .button-image {
    width: 80px;
    height: 80px;
  }

  .background-button {
    bottom: 10px;
    right: 10px;
    transform: none;
    z-index: 5;
  }

  .logo-container {
    margin-bottom: 20px;
    margin-left: 20px;
    transform: scale(0.6);
    animation: appear-and-grow 1s ease-out forwards;
  }

  .logo-part {
    max-width: 45vw;
  }

  @keyframes bobbing {
    0%,
    100% {
      transform: translateY(0);
    }
    50% {
      transform: translateY(-10px);
    }
  }
}

@keyframes appear-and-grow {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes bobbing {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-15px);
  }
}
