:root {
  --bg-1: #35159f;
  --bg-2: #1f0e62;
  --bg-3: #0f0535;
  --panel: rgba(7, 4, 27, 0.84);
  --text: #f7f5ff;
  --muted: #c6baf8;
  --primary: #ffd22e;
  --secondary: #2ce7ff;
  --accent: #ff4e9b;
  --danger: #ff7a7a;
  --edge: rgba(255, 255, 255, 0.24);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Nunito', 'Trebuchet MS', 'Segoe UI', sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 18%, #5f34ff 0%, transparent 38%),
    radial-gradient(circle at 82% 12%, #ff4ea0 0%, transparent 32%),
    radial-gradient(circle at 14% 88%, #11d6ff 0%, transparent 34%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2) 40%, var(--bg-3));
  overflow-x: hidden;
}

body::before,
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  background-image: linear-gradient(115deg, rgba(255, 255, 255, 0.04) 18%, transparent 18%, transparent 50%, rgba(255, 255, 255, 0.04) 50%, rgba(255, 255, 255, 0.04) 68%, transparent 68%, transparent);
  background-size: 140px 140px;
  opacity: 0.2;
}

body::after {
  background: radial-gradient(circle at center, transparent 0, rgba(0, 0, 0, 0.22) 80%);
}

.bg-orb {
  position: fixed;
  border-radius: 999px;
  filter: blur(52px);
  opacity: 0.35;
  pointer-events: none;
}

.orb-a {
  width: 320px;
  height: 320px;
  background: #ffc21c;
  top: -80px;
  right: -30px;
}

.orb-b {
  width: 420px;
  height: 420px;
  background: #06dbff;
  bottom: -120px;
  left: -120px;
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1040px;
  margin: 0 auto;
  padding: 26px 18px 52px;
}

.masthead {
  margin-bottom: 22px;
}

.kicker {
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--secondary);
  font-size: 0.84rem;
  margin: 0 0 8px;
  font-weight: 800;
}

h1,
h2,
h3 {
  font-family: 'Fredoka', 'Nunito', sans-serif;
}

h1 {
  margin: 0;
  font-size: clamp(2.3rem, 6vw, 4.4rem);
  line-height: 0.95;
  letter-spacing: 0.01em;
}

.subtitle {
  margin-top: 8px;
  color: var(--muted);
  font-size: 1.05rem;
}

.card {
  background: var(--panel);
  border: 2px solid var(--edge);
  border-radius: 20px;
  padding: 22px;
  backdrop-filter: blur(8px);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  animation: rise 200ms ease;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.row {
  display: flex;
  gap: 10px;
  margin: 10px 0;
}

input,
select {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(8, 16, 52, 0.74);
  color: var(--text);
  font-size: 0.98rem;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(44, 231, 255, 0.2);
}

.label {
  display: block;
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.94rem;
}

.btn {
  border: 0;
  border-radius: 13px;
  padding: 11px 16px;
  font-weight: 900;
  cursor: pointer;
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-size: 1.02rem;
  transition: transform 120ms ease, opacity 120ms ease, filter 120ms ease;
}

.btn:hover {
  transform: translateY(-1px) scale(1.01);
  filter: brightness(1.04);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

.btn-primary {
  background: var(--primary);
  color: #1d1132;
}

.btn-accent {
  background: var(--secondary);
  color: #06233a;
}

.prompt {
  font-size: 1.24rem;
  margin: 8px 0 14px;
  font-weight: 800;
}

.quick-picks,
.gif-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(138px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.pick,
.gif-result {
  border: 2px solid rgba(255, 255, 255, 0.16);
  background: rgba(17, 32, 88, 0.8);
  color: var(--text);
  border-radius: 12px;
  padding: 8px;
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.gif-result {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.gif-result.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 210, 46, 0.28);
  transform: translateY(-1px);
}

.gif-result img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 10px;
}

.gif-result span {
  font-size: 0.82rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.preview-wrap {
  margin-top: 12px;
}

.preview-wrap img {
  width: min(100%, 380px);
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  display: block;
}

.battle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.battle-card {
  background: rgba(11, 18, 62, 0.8);
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  padding: 10px;
}

.battle-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.14);
}

.score-list {
  margin: 0 0 14px;
  padding-left: 24px;
}

.score-list li {
  margin: 6px 0;
  font-weight: 700;
}

.error {
  color: var(--danger);
  min-height: 22px;
}

.notice {
  color: var(--secondary);
  min-height: 22px;
}

@media (max-width: 700px) {
  .battle-grid {
    grid-template-columns: 1fr;
  }

  .stack-mobile {
    flex-direction: column;
  }
}
