:root {
  --bg-top: #a7f3d0;
  --bg-mid: #67e8f9;
  --bg-bot: #fde68a;
  --card: rgba(255, 255, 255, 0.78);
  --text: #1e293b;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --ok: #166534;
  --bad: #b91c1c;
  --history-bg: rgba(240, 249, 255, 0.8);
  --line: rgba(14, 116, 144, 0.32);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 15%, rgba(14, 165, 233, 0.42), transparent 36%),
    radial-gradient(circle at 85% 78%, rgba(250, 204, 21, 0.45), transparent 42%),
    linear-gradient(145deg, var(--bg-top), var(--bg-mid) 45%, var(--bg-bot));
  display: grid;
  place-items: center;
  padding: 1.2rem;
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  border-radius: 999px;
  filter: blur(6px);
  pointer-events: none;
}

body::before {
  width: 320px;
  height: 320px;
  top: -80px;
  left: -70px;
  background: rgba(255, 255, 255, 0.42);
}

body::after {
  width: 300px;
  height: 300px;
  bottom: -90px;
  right: -80px;
  background: rgba(15, 118, 110, 0.2);
}

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.1;
  background-image: radial-gradient(rgba(15, 23, 42, 0.28) 0.5px, transparent 0.5px);
  background-size: 4px 4px;
}

.app {
  width: min(760px, 100%);
  position: relative;
  animation: rise-in 650ms ease-out both;
}

.hero {
  margin-bottom: 1rem;
  text-align: center;
}

.kicker {
  font-size: 0.9rem;
  letter-spacing: 0.1rem;
  text-transform: uppercase;
  color: #155e75;
  margin: 0;
  font-weight: 700;
}

h1 {
  margin: 0.2rem 0 0;
  font-family: "Bangers", "Trebuchet MS", sans-serif;
  font-size: clamp(2.7rem, 8vw, 4.4rem);
  letter-spacing: 0.06em;
  color: #0f172a;
  text-shadow: 0 4px 0 rgba(255, 255, 255, 0.5);
}

.subtitle {
  margin: 0.3rem auto 0;
  color: #164e63;
  max-width: 60ch;
  font-weight: 500;
}

.card {
  background: var(--card);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 1.3rem;
  padding: 1.1rem;
  box-shadow:
    0 18px 40px rgba(14, 116, 144, 0.22),
    0 2px 0 rgba(255, 255, 255, 0.58) inset;
}

.card-head {
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  font-size: 0.8rem;
  background: rgba(12, 74, 110, 0.09);
  border: 1px solid rgba(8, 145, 178, 0.3);
  color: #155e75;
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  font-weight: 700;
}

button {
  border: 0;
  border-radius: 0.8rem;
  padding: 0.66rem 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 130ms ease, filter 130ms ease, box-shadow 130ms ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
  box-shadow: 0 10px 18px rgba(15, 118, 110, 0.2);
}

#newSpellBtn,
.guess-row button {
  background: linear-gradient(180deg, #14b8a6, var(--accent));
  color: #f0fdfa;
}

.description {
  min-height: 4.2rem;
  margin: 1rem 0 1.1rem;
  font-size: 1.03rem;
  line-height: 1.55;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 0.9rem;
  padding: 0.9rem;
  border: 1px solid var(--line);
}

.guess-form label {
  font-weight: 700;
}

.guess-row {
  margin-top: 0.4rem;
  display: flex;
  gap: 0.6rem;
}

.guess-row input {
  flex: 1;
  min-width: 0;
  border-radius: 0.7rem;
  border: 2px solid rgba(8, 145, 178, 0.38);
  background: rgba(255, 255, 255, 0.9);
  padding: 0.66rem 0.8rem;
  font: inherit;
}

.guess-row input:focus {
  outline: 3px solid rgba(13, 148, 136, 0.22);
  border-color: var(--accent);
}

.suggestions-list {
  margin: 0.45rem 0 0;
  padding: 0.25rem;
  list-style: none;
  border-radius: 0.75rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  max-height: 190px;
  overflow-y: auto;
  display: none;
}

.suggestions-list.visible {
  display: grid;
  gap: 0.2rem;
}

.suggestions-list li {
  border-radius: 0.55rem;
}

.suggestion-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-align: left;
  border: 0;
  padding: 0.45rem 0.55rem;
  border-radius: 0.55rem;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
}

.suggestion-btn:hover,
.suggestion-btn.active {
  background: rgba(45, 212, 191, 0.22);
}

.suggestion-thumb {
  width: 26px;
  height: 26px;
  object-fit: contain;
  border-radius: 0.45rem;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(8, 145, 178, 0.45);
  flex: 0 0 auto;
}

.result {
  min-height: 1.5rem;
  margin: 0.95rem 0 0.5rem;
  font-weight: 700;
}

.result.ok {
  color: var(--ok);
}

.result.bad {
  color: var(--bad);
}

.hint-panel {
  margin: 0.15rem 0 0.7rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 0.85rem;
  background: linear-gradient(135deg, rgba(239, 246, 255, 0.95), rgba(224, 242, 254, 0.75));
  padding: 0.6rem 0.72rem;
  box-shadow: 0 8px 16px rgba(59, 130, 246, 0.12);
}

.hint-panel[hidden] {
  display: none !important;
}

.hint-panel img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  border-radius: 0.7rem;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(59, 130, 246, 0.25);
  padding: 0.24rem;
}

.hint-title {
  margin: 0;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #1d4ed8;
  font-weight: 700;
}

.hint-text {
  margin: 0.1rem 0 0;
  font-weight: 700;
  color: #1e3a8a;
}

.reveal-panel {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  border-radius: 0.95rem;
  border: 2px dashed rgba(8, 145, 178, 0.45);
  background: rgba(255, 255, 255, 0.62);
  padding: 0.7rem;
}

.reveal-panel img {
  width: 84px;
  height: 84px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 0.85rem;
  border: 1px solid rgba(8, 145, 178, 0.32);
}

.reveal-copy {
  flex: 1;
}

.reveal-state {
  margin: 0;
  font-weight: 700;
}

.reveal-name {
  margin: 0.25rem 0 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.reveal-panel.success {
  border-color: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}

.reveal-panel.fail {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.16);
}

.reveal-panel.animate.success {
  animation: pop-win 480ms ease;
}

.reveal-panel.animate.fail {
  animation: shake-lose 420ms ease;
}

.meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.95rem;
  color: #0f172a;
}

.history {
  margin-top: 1rem;
  background: var(--history-bg);
  border-radius: 0.9rem;
  padding: 0.8rem;
  border: 1px solid var(--line);
}

.history-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.history-head h2 {
  margin: 0;
  font-size: 1rem;
}

#clearHistoryBtn {
  background: linear-gradient(180deg, #0ea5a4, #0f766e);
  color: #ecfeff;
  font-size: 0.85rem;
  padding: 0.45rem 0.65rem;
}

.history-list {
  margin: 0.65rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.45rem;
  max-height: 230px;
  overflow-y: auto;
}

.history-item {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 0.65rem;
  align-items: center;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(8, 145, 178, 0.24);
  border-radius: 0.75rem;
  padding: 0.4rem 0.55rem;
}

.history-item img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 0.55rem;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(8, 145, 178, 0.28);
}

.history-main {
  min-width: 0;
}

.history-main p {
  margin: 0;
  font-size: 0.9rem;
}

.history-item .tag {
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.2rem 0.48rem;
}

.history-item.success .tag {
  color: #064e3b;
  background: rgba(167, 243, 208, 0.95);
}

.history-item.fail .tag {
  color: #7f1d1d;
  background: rgba(254, 215, 170, 0.92);
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes pop-win {
  0% {
    transform: scale(0.96);
  }
  55% {
    transform: scale(1.03);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes shake-lose {
  0% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-6px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-5px);
  }
  80% {
    transform: translateX(5px);
  }
  100% {
    transform: translateX(0);
  }
}

@media (max-width: 600px) {
  .card {
    padding: 0.9rem;
  }

  .guess-row {
    flex-direction: column;
  }

  .guess-row button,
  #newSpellBtn {
    width: 100%;
  }

  .reveal-panel {
    align-items: flex-start;
  }

  .history-item {
    grid-template-columns: 42px 1fr;
  }

  .history-item .tag {
    justify-self: start;
    grid-column: 2;
  }
}
