* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100svh;
  margin: 0;
  padding: 14px 12px;
  display: grid;
  place-items: center;
  font-family: "Trebuchet MS", Arial, sans-serif;
  background: linear-gradient(180deg, #f8e8ff 0%, #fff8ef 100%);
  color: #4b2d3b;
  overflow-x: hidden;
}

.game-wrapper {
  width: min(100%, 960px);
  margin: 0 auto;
  text-align: center;
}

.title {
  margin: 0 0 6px;
  font-size: 28px;
  color: #7a3f62;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.9);
}

.subtitle {
  margin: 0 0 12px;
  font-size: 16px;
  color: #7b6170;
}

.game-board {
  position: relative;
  width: 100%;
  margin: 0 auto;
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 698px) minmax(164px, 210px);
  justify-content: center;
  align-items: stretch;
  gap: 14px;
  background: rgba(255, 255, 255, 0.68);
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(120, 80, 120, 0.22);
}

.room-area {
  position: relative;
  width: 100%;
  max-width: 698px;
  aspect-ratio: 698 / 520;
  min-width: 0;
  border-radius: 10px;
  overflow: hidden;
  background-image: url("room.jpg");
  background-size: cover;
  background-position: center;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.4);
}

.drop-zone {
  position: absolute;
  border: 3px solid rgba(110, 53, 53, 0.85);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.30);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s ease;
}

.drop-zone span {
  padding: 0 8px;
  font-size: 18px;
  font-weight: bold;
  color: #6f2d4f;
  text-transform: capitalize;
  pointer-events: none;
}

.drop-zone.hovered,
.drop-zone.tap-target {
  transform: scale(1.04);
  background: rgba(255, 245, 250, 0.7);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.35);
}

.drop-zone.correct {
  background: rgba(230, 255, 235, 0.88);
  border-color: #3c9a5f;
}

.words-panel {
  width: 100%;
  min-width: 0;
  padding: 8px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: linear-gradient(180deg, #fff5fb 0%, #fffdf7 100%);
  border-radius: 14px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.85);
}

.words-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.word-card {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  background: linear-gradient(180deg, #ffb8d2 0%, #ff8cb2 100%);
  color: white;
  font-size: 18px;
  font-weight: bold;
  cursor: grab;
  user-select: none;
  box-shadow: 0 6px 14px rgba(215, 91, 141, 0.35);
  text-align: center;
  text-transform: capitalize;
  transition: transform 0.15s ease, box-shadow 0.15s ease, outline-color 0.15s ease;
}

.word-card:hover,
.word-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(215, 91, 141, 0.45);
}

.word-card:focus-visible {
  outline: 3px solid rgba(122, 63, 98, 0.45);
  outline-offset: 2px;
}

.word-card.dragging {
  opacity: 0.55;
  cursor: grabbing;
}

.word-card.selected {
  outline: 4px solid rgba(122, 63, 98, 0.42);
  outline-offset: 2px;
  transform: translateY(-2px);
}

.word-card.placed {
  visibility: hidden;
  pointer-events: none;
}

.success-message {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(87, 50, 80, 0.35);
  border-radius: 14px;
}

.success-message.show {
  display: flex;
}

.success-box {
  width: min(360px, 100%);
  padding: 26px 24px;
  border: 3px solid #ffd2e4;
  border-radius: 22px;
  background: linear-gradient(180deg, #fffdfd 0%, #fff3f9 100%);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
}

.success-box h2 {
  margin: 0 0 10px;
  font-size: 32px;
  color: #7a3f62;
}

.success-box p {
  margin: 0 0 18px;
  font-size: 18px;
  color: #6d5862;
}

.success-box button {
  border: none;
  border-radius: 999px;
  padding: 12px 24px;
  font-size: 17px;
  font-weight: bold;
  color: white;
  background: linear-gradient(180deg, #ff93bc 0%, #ef6498 100%);
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(214, 92, 144, 0.35);
}

.success-box button:hover {
  filter: brightness(1.05);
}

@keyframes shake {
  0% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
  100% { transform: translateX(0); }
}

.word-card.shake {
  animation: shake 0.3s ease;
}

@media (max-width: 820px) {
  body {
    padding: 10px;
    place-items: start center;
  }

  .game-wrapper {
    width: min(100%, 720px);
  }

  .title {
    font-size: 24px;
  }

  .subtitle {
    margin-bottom: 10px;
    font-size: 15px;
  }

  .game-board {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    padding: 10px;
  }

  .room-area {
    justify-self: center;
  }

  .drop-zone {
    border-width: 2px;
  }

  .drop-zone span {
    padding: 0 4px;
    font-size: 13px;
  }

  .words-container {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .word-card {
    min-height: 34px;
    padding: 6px 8px;
    font-size: 16px;
  }
}

@media (max-width: 420px) {
  body {
    padding: 8px;
  }

  .title {
    font-size: 22px;
  }

  .subtitle {
    font-size: 14px;
  }

  .game-board {
    padding: 8px;
  }

  .drop-zone span {
    font-size: 12px;
  }

  .word-card {
    min-height: 32px;
    font-size: 15px;
  }
}

@media (max-height: 650px) and (min-width: 821px) {
  body {
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .game-wrapper {
    width: min(100%, 880px);
  }

  .title {
    font-size: 24px;
  }

  .subtitle {
    margin-bottom: 8px;
    font-size: 15px;
  }

  .game-board {
    gap: 10px;
    padding: 10px;
    grid-template-columns: minmax(0, 650px) minmax(154px, 190px);
  }

  .word-card {
    min-height: 36px;
    padding: 6px 9px;
    font-size: 17px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
