:root {
  --bg: #0d0a14;
  --bg-glow: #2a1238;
  --panel: rgba(255, 255, 255, 0.04);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text: #eee6f5;
  --muted: #a397b3;
  --accent: #ff7a18;
  --accent-glow: rgba(255, 122, 24, 0.45);
  --danger: #ff4d6d;
  --item-size: clamp(2.6rem, 11vw, 3.4rem);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: radial-gradient(ellipse at top, var(--bg-glow), var(--bg) 70%) fixed, var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.puzzle {
  max-width: 900px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.zone {
  background: var(--panel);
  border: 2px dashed var(--panel-border);
  border-radius: 16px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  outline: none;
}

.zone:focus-visible {
  border-color: var(--muted);
}

.zone.is-over {
  border-color: var(--accent);
  box-shadow: 0 0 18px var(--accent-glow) inset;
}

@media (hover: hover) {
  .puzzle.has-selection .zone:hover {
    border-color: var(--accent);
    box-shadow: 0 0 18px var(--accent-glow) inset;
  }

  .item:hover {
    transform: scale(1.1);
  }
}

.column {
  min-height: 34vh;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
}

.column-title {
  margin: 0 0 8px;
  text-align: center;
  font-family: "Creepster", cursive;
  font-weight: 400;
  font-size: clamp(1.8rem, 8vw, 3rem);
  letter-spacing: 0.05em;
  color: var(--accent);
  text-shadow: 0 0 12px var(--accent-glow);
}

.zone-items {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  justify-content: center;
  gap: 4px;
  min-height: var(--item-size);
}

.pool {
  --item-size: clamp(2.1rem, 9vw, 2.8rem);
  padding: 8px;
}

.item {
  width: var(--item-size);
  height: var(--item-size);
  font-size: calc(var(--item-size) * 0.7);
  line-height: 1;
  display: grid;
  place-items: center;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 12px;
  background: none;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: transform 0.1s, border-color 0.1s, opacity 0.1s;
}

.item:focus-visible {
  outline: 2px solid var(--muted);
  outline-offset: 1px;
}

.item.is-selected {
  border-color: var(--accent);
  background: rgba(255, 122, 24, 0.15);
  transform: scale(1.1);
}

.item.is-dragging {
  opacity: 0.25;
}

.drag-proxy {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  pointer-events: none;
  width: var(--item-size);
  height: var(--item-size);
  font-size: calc(var(--item-size) * 0.85);
  line-height: 1;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.6));
  will-change: transform;
}

.actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.btn {
  font: inherit;
  font-size: 1.1rem;
  padding: 12px 28px;
  border-radius: 999px;
  border: 2px solid var(--accent);
  cursor: pointer;
  min-height: 48px;
}

.btn-primary {
  background: var(--accent);
  color: #1a0e00;
  font-weight: 700;
  box-shadow: 0 0 16px var(--accent-glow);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: wait;
}

.btn-secondary {
  background: transparent;
  color: var(--accent);
}

.feedback {
  margin: 0;
  min-height: 1.5em;
  text-align: center;
  color: var(--danger);
}

.puzzle.shake .columns {
  animation: shake 0.4s;
}

@keyframes shake {
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(5, 3, 8, 0.85);
  animation: fade-in 0.6s ease-out;
}

.overlay[hidden] {
  display: none;
}

.overlay-card {
  text-align: center;
}

.overlay-emoji {
  font-size: 5rem;
  animation: flicker 2s infinite;
}

.overlay-text {
  font-family: "Creepster", cursive;
  font-size: clamp(2rem, 9vw, 3.5rem);
  color: var(--accent);
  text-shadow: 0 0 16px var(--accent-glow);
  margin: 0.5em 0 0;
}

@keyframes fade-in {
  from { opacity: 0; }
}

@keyframes flicker {
  0%, 100% { opacity: 1; }
  45% { opacity: 0.8; }
  50% { opacity: 0.5; }
  55% { opacity: 0.9; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
