
/* =========================
   GAME: MAGIC HAT
========================= */

.magic-hat-game {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 22px;
  font-family: "Fredoka", Arial, sans-serif;
  color: #000;
  overflow: hidden;
}

.magic-hat-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 8px solid #000;
  border-radius: 28px;
  background:
    radial-gradient(circle at 50% 65%, rgba(255, 70, 70, 0.9), transparent 28%),
    repeating-linear-gradient(
      90deg,
      #8b0000 0 28px,
      #b00000 28px 56px,
      #600000 56px 68px
    );
  box-shadow: 10px 10px 0 rgba(0,0,0,0.28);
}

.magic-hat-curtain {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.curtain-top {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 115px;
  background:
    radial-gradient(ellipse at 15% 0%, #5a0000 0 45%, transparent 47%),
    radial-gradient(ellipse at 38% 0%, #800000 0 45%, transparent 47%),
    radial-gradient(ellipse at 62% 0%, #5a0000 0 45%, transparent 47%),
    radial-gradient(ellipse at 85% 0%, #800000 0 45%, transparent 47%);
  opacity: 0.95;
}

.curtain-left,
.curtain-right {
  position: absolute;
  top: 0;
  width: 22%;
  height: 100%;
  background: linear-gradient(90deg, #420000, #990000, #500000);
  opacity: 0.75;
}

.curtain-left {
  left: 0;
  clip-path: polygon(0 0, 100% 0, 58% 70%, 0 100%);
}

.curtain-right {
  right: 0;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 42% 70%);
}

.magic-word-area {
  position: absolute;
  left: 50%;
  top: 41%;
  transform: translate(-50%, -50%);
  z-index: 3;
  display: grid;
  justify-items: center;
  gap: 10px;
  transition: opacity 0.25s ease;
}

.magic-word-area.hidden-word {
  opacity: 0;
  pointer-events: none;
}

.magic-word-area.show {
  opacity: 1;
}

.magic-word-img {
  max-width: min(310px, 38vw);
  max-height: min(310px, 40vh);
  object-fit: contain;
  -webkit-user-drag: none;
  user-select: none;
  filter: drop-shadow(7px 7px 0 rgba(0,0,0,0.35));
}

.magic-word-label {
  background: #d3ff00;
  border: 6px solid #000;
  border-radius: 18px;
  padding: 10px 22px;
  font-size: 28px;
  font-weight: 900;
  box-shadow: 6px 6px 0 rgba(0,0,0,0.3);
}

.magic-pop {
  animation: magicPop 1.1s ease forwards;
}

@keyframes magicPop {
  0% {
    opacity: 0;
    top: 72%;
    transform: translate(-50%, -50%) scale(0.1) rotate(-6deg);
  }

  65% {
    opacity: 1;
    top: 37%;
    transform: translate(-50%, -50%) scale(1.12) rotate(3deg);
  }

  100% {
    opacity: 1;
    top: 41%;
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
  }
}

/* CSS magic hat */

.magic-hat-button {
  position: absolute;
  left: 50%;
  bottom: 26px;
  width: 220px;
  height: 180px;
  transform: translateX(-50%);
  z-index: 4;
  border: none;
  background: transparent;
  box-shadow: none;
  padding: 0;
  cursor: var(--cursor-pointer);
}

.magic-hat-button:hover {
  transform: translateX(-50%) translateY(-3px) scale(1.03);
}

.magic-hat-top {
  position: absolute;
  left: 50%;
  top: 5px;
  width: 195px;
  height: 64px;
  transform: translateX(-50%);
  background: #202020;
  border: 7px solid #000;
  border-radius: 50%;
  z-index: 3;
}

.magic-hat-top::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 14px;
  width: 120px;
  height: 28px;
  transform: translateX(-50%);
  background: #000;
  border-radius: 50%;
}

.magic-hat-brim {
  position: absolute;
  left: 50%;
  top: 34px;
  width: 220px;
  height: 52px;
  transform: translateX(-50%);
  background: #3a3a3a;
  border: 7px solid #000;
  border-radius: 50%;
  z-index: 2;
}

.magic-hat-body {
  position: absolute;
  left: 50%;
  top: 64px;
  width: 150px;
  height: 105px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #1d1d1d, #000);
  border: 7px solid #000;
  border-top: none;
  border-radius: 0 0 28px 28px;
  z-index: 1;
}

.magic-hat-band {
  position: absolute;
  left: 50%;
  top: 94px;
  width: 154px;
  height: 35px;
  transform: translateX(-50%);
  background: #ff1d1d;
  border-top: 5px solid #000;
  border-bottom: 5px solid #000;
  z-index: 5;
}

.magic-hat-shake {
  animation: magicHatShake 0.5s ease-in-out 3;
}

@keyframes magicHatShake {
  0% {
    transform: translateX(-50%) rotate(0deg);
  }

  20% {
    transform: translateX(-53%) rotate(-3deg);
  }

  40% {
    transform: translateX(-47%) rotate(3deg);
  }

  60% {
    transform: translateX(-52%) rotate(-2deg);
  }

  80% {
    transform: translateX(-48%) rotate(2deg);
  }

  100% {
    transform: translateX(-50%) rotate(0deg);
  }
}

.magic-hat-sparkles {
  position: absolute;
  left: 50%;
  top: 36%;
  width: 320px;
  height: 220px;
  transform: translate(-50%, -50%);
  z-index: 2;
  pointer-events: none;
}

.magic-hat-sparkles span {
  position: absolute;
  color: #fff066;
  font-size: 34px;
  text-shadow: 3px 3px 0 #000;
  animation: sparkleFloat 1.6s ease-in-out infinite;
}

.magic-hat-sparkles span:nth-child(1) {
  left: 10%;
  top: 20%;
}

.magic-hat-sparkles span:nth-child(2) {
  right: 8%;
  top: 14%;
  animation-delay: 0.2s;
}

.magic-hat-sparkles span:nth-child(3) {
  left: 22%;
  bottom: 12%;
  animation-delay: 0.4s;
}

.magic-hat-sparkles span:nth-child(4) {
  right: 18%;
  bottom: 16%;
  animation-delay: 0.6s;
}

@keyframes sparkleFloat {
  0%, 100% {
    opacity: 0.35;
    transform: translateY(0) scale(0.85);
  }

  50% {
    opacity: 1;
    transform: translateY(-10px) scale(1.1);
  }
}

/* side panel */

.magic-hat-side {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.magic-hat-info-card,
.magic-hat-result-card {
  background: #bff1ea;
  border: 7px solid #000;
  border-radius: 24px;
  padding: 16px;
  box-shadow: 8px 8px 0 rgba(0,0,0,0.25);
}

.magic-hat-icon-big {
  height: 120px;
  background: #fff;
  border: 6px solid #000;
  border-radius: 20px;
  display: grid;
  place-items: center;
  font-size: 70px;
  margin-bottom: 12px;
}

.magic-hat-title {
  background: #d3ff00;
  border: 5px solid #000;
  border-radius: 16px;
  padding: 10px;
  text-align: center;
  font-size: 26px;
  font-weight: 900;
  margin-bottom: 10px;
}

.magic-hat-info-card p {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
}

.magic-hat-result-card h3 {
  margin: 0 0 10px;
  font-size: 24px;
}

.magic-hat-preview-img {
  height: 145px;
  background: #fff;
  border: 6px solid #000;
  border-radius: 20px;
  display: grid;
  place-items: center;
  overflow: hidden;
  margin-bottom: 12px;
}

.magic-hat-preview-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  -webkit-user-drag: none;
  user-select: none;
}

.magic-preview-name {
  background: #d3ff00;
  border: 5px solid #000;
  border-radius: 16px;
  padding: 10px;
  text-align: center;
  font-size: 24px;
  font-weight: 900;
}

#magic-preview-meta {
  text-align: center;
  font-size: 17px;
  font-weight: 800;
}

.magic-next-btn {
  width: 100%;
  background: #23d8ff;
  font-size: 20px;
  margin-top: auto;
}

.magic-hat-error-box {
  max-width: 560px;
  margin: 80px auto;
  background: #fff0a8;
  border: 7px solid #000;
  border-radius: 26px;
  padding: 28px;
  text-align: center;
  font-family: "Fredoka", Arial, sans-serif;
  box-shadow: 8px 8px 0 rgba(0,0,0,0.25);
}

.magic-hat-error-box h2 {
  font-size: 36px;
  margin-top: 0;
}

.magic-hat-error-box p {
  font-size: 22px;
  font-weight: 800;
}

@media (max-width: 900px) {
  .magic-hat-game {
    grid-template-columns: 1fr;
  }

  .magic-hat-side {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .magic-next-btn {
    grid-column: 1 / -1;
  }
}

@media (max-width: 600px) {
  .magic-hat-stage {
    min-height: 520px;
  }

  .magic-word-img {
    max-width: 70vw;
    max-height: 220px;
  }

  .magic-hat-button {
    width: 180px;
    height: 150px;
  }

  .magic-hat-brim {
    width: 180px;
  }

  .magic-hat-top {
    width: 160px;
  }

  .magic-hat-body {
    width: 120px;
  }

  .magic-hat-band {
    width: 124px;
  }

  .magic-hat-side {
    grid-template-columns: 1fr;
  }
}
