/* ====== Base / Theme ====== */
:root {
  --bg: #0c1118;
  --bg-elev: #0f1623;
  --card: #121a28;
  --text: #e5ecf5;
  --muted: #9db0c9;
  --outline: #2a3a55;

  --accent: #7c5cff;         /* primary accent */
  --accent-2: #00e5ff;       /* subtle glow */
  --success: #3ad29f;

  --radius-xl: 18px;
  --radius-lg: 14px;
  --radius-md: 12px;

  --shadow-1: 0 2px 12px rgba(0,0,0,.35);
  --shadow-2: 0 10px 30px rgba(0,0,0,.45), 0 0 0 1px rgba(124,92,255,.1) inset;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
  background:
    radial-gradient(1200px 800px at 70% -10%, rgba(124,92,255,.15), transparent 60%),
    radial-gradient(900px 700px at -10% 120%, rgba(0,229,255,.12), transparent 55%),
    linear-gradient(180deg, var(--bg), #0a0f15 45%, #090e13 100%);
  color: var(--text);
}

/* ====== Layout ====== */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 56px;
}

.page-header {
  text-align: center;
  margin-bottom: 18px;
}
.page-header h1 {
  font-weight: 800;
  letter-spacing: .3px;
  margin: 0 0 8px;
}
.subtitle {
  color: var(--muted);
  margin: 0 auto;
  max-width: 720px;
  line-height: 1.5;
}

.card {
  background: linear-gradient(180deg, var(--card), #0f1623 100%);
  border: 1px solid var(--outline);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-1);
  padding: 20px;
  margin-top: 18px;
}

.section-title {
  margin: 4px 4px 16px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: .2px;
}

/* ====== Squares (drop targets) ====== */
.squares {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 16px;
  justify-items: center;
  align-items: stretch;
}

.square {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-lg);
  position: relative;
  border: 1px dashed rgba(255,255,255,.18);
  background:
    linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,0) 60%),
    radial-gradient(200px 160px at 30% 15%, rgba(124,92,255,.1), transparent 60%);
  display: grid;
  place-items: center;
  transition: border-color .25s ease, box-shadow .25s ease, transform .04s ease-in;
  overflow: hidden;
  outline: none;
}

.square::after {
  /* letter badge from data-letter */
  content: attr(data-letter);
  position: absolute;
  top: 10px; left: 10px;
  font-weight: 800;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(124,92,255,.15);
  color: #dcd7ff;
  border: 1px solid rgba(124,92,255,.35);
  pointer-events: none;
}

.square:hover {
  border-color: rgba(124,92,255,.65);
  box-shadow: 0 0 0 4px rgba(124,92,255,.12) inset, var(--shadow-1);
}

.square:focus-visible {
  box-shadow: 0 0 0 2px rgba(255,255,255,.2) inset, 0 0 0 4px rgba(124,92,255,.4);
}

.square.selected {
  border-style: solid;
  border-color: var(--accent);
  box-shadow:
    0 0 0 2px rgba(124,92,255,.45),
    0 0 24px 3px rgba(124,92,255,.25),
    var(--shadow-2);
}

/* Highlight square when a draggable is over it */
.square.drag-over {
  border-style: solid;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 4px rgba(0,229,255,.18) inset, var(--shadow-1);
}

.square img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 6px 16px rgba(0,0,0,.4));
  transition: transform .15s ease;
}
.square img:active { transform: scale(.98); }

/* Labels kept for compatibility, but styled as subtle guide */
.letters {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 16px;
  justify-items: center;
  margin-top: 10px;
}
.letters span {
  display: inline-block;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--outline);
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: .4px;
  padding: 6px 10px;
  border-radius: 999px;
}

/* ====== Images (pieces) ====== */
.images {
  /* grid with nice fit; images must remain direct children for JS logic */
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 14px;
}

.images img {
  width: 100%;
  height: 90px;
  object-fit: contain;
  border-radius: var(--radius-md);
  border: 1px solid var(--outline);
  background:
    linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.01)),
    radial-gradient(120px 80px at 60% -10%, rgba(0,229,255,.12), transparent 60%);
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, filter .18s ease;
  box-shadow: var(--shadow-1);
}
.images img.dragging { opacity: .8; filter: saturate(1.1); }
.images img:hover {
  transform: translateY(-2px);
  border-color: rgba(124,92,255,.5);
  box-shadow: 0 8px 18px rgba(0,0,0,.45), 0 0 0 3px rgba(124,92,255,.12);
}
.images img:active {
  transform: translateY(0);
  filter: saturate(1.1);
}

/* ====== Results / Stats ====== */
.results { margin-top: 18px; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 14px;
}

.stat {
  position: relative;
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
  border: 1px solid var(--outline);
  border-radius: var(--radius-lg);
  padding: 16px 14px;
  box-shadow: var(--shadow-1);
}

.stat::before {
  /* soft accent strip */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(220px 140px at -20% 0%, rgba(124,92,255,.17), transparent 60%);
  pointer-events: none;
}

.stat .label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .3px;
  margin-bottom: 6px;
}

.stat .value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  padding: 8px 12px;
  border-radius: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 22px;
  background: rgba(61, 237, 185, .1);
  color: #d8fff1;
  border: 1px solid rgba(61, 237, 185, .35);
  box-shadow: inset 0 0 0 1px rgba(61, 237, 185, .14);
}

.stat .hint {
  display: block;
  color: var(--muted);
  margin-top: 8px;
  font-size: 12px;
}

/* ====== Responsiveness ====== */
@media (max-width: 720px) {
  .container { padding: 18px 14px 40px; }
  .section-title { font-size: 16px; }
  .squares { grid-template-columns: repeat(3, 1fr); }
  .letters { grid-template-columns: repeat(3, 1fr); }
  .stats { grid-template-columns: 1fr; }
}

/* Visual cue when dragging over the pool */
.images.drag-over {
  outline: 2px dashed rgba(0,229,255,.35);
  outline-offset: 4px;
}

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