/* Cardle — dark, one-thumb daily matching puzzle. */
:root {
  --bg: #14101c; --panel: #1d1826; --panel-2: #262031; --line: #352d44;
  --ink: #f2eff7; --dim: #9c93ad; --accent: #a48fff; --good: #4ade80; --bad: #f87171; --warn: #f0a33c;
  --sans: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--sans); min-height: 100vh; }

.topbar { display: flex; align-items: center; gap: .8rem; padding: .65rem .9rem; }
.hub-link { color: var(--dim); text-decoration: none; font-size: .78rem; font-weight: 700; }
.app-title { font-weight: 800; letter-spacing: -.02em; }
.daynum { color: var(--accent); font-weight: 800; }
.streak { margin-left: auto; color: var(--warn); font-weight: 800; font-size: .9rem; }

main { max-width: 560px; margin: 0 auto; padding: 0 .9rem 3rem; }
.hint { color: var(--dim); font-size: .85rem; }

/* Name tray */
.names { display: flex; flex-wrap: wrap; gap: .45rem; margin: .8rem 0; min-height: 2.4rem; position: sticky; top: 0; background: var(--bg); padding: .4rem 0; z-index: 5; }
.namechip {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); border-radius: 999px;
  font: inherit; font-size: .88rem; font-weight: 700; padding: .45rem .9rem; cursor: pointer;
}
.namechip.sel { background: var(--accent); border-color: var(--accent); color: #170f2b; }

/* Text cards */
.texts { display: flex; flex-direction: column; gap: .6rem; }
.textcard { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: .75rem .9rem; }
.textcard.locked { border-color: rgba(74, 222, 128, .5); }
.tc-meta { color: var(--dim); font-size: .74rem; font-weight: 700; margin-bottom: .3rem; }
.tc-text { font-size: .9rem; line-height: 1.55; }
.empty-slot {
  margin-top: .6rem; border: 1px dashed var(--line); border-radius: 10px; padding: .5rem .7rem;
  color: var(--dim); font-size: .82rem; text-align: center;
}
.placed {
  margin-top: .6rem; width: 100%; border: 1px solid var(--accent); background: rgba(164, 143, 255, .14);
  color: var(--ink); border-radius: 10px; padding: .5rem .7rem; font: inherit; font-weight: 800; cursor: pointer;
}
.placed.locked { border-color: var(--good); background: rgba(74, 222, 128, .12); color: var(--good); cursor: default; }

.checkrow { display: flex; align-items: center; gap: .8rem; margin: 1rem 0; }
.primary {
  border: none; border-radius: 12px; background: var(--accent); color: #170f2b;
  font: inherit; font-weight: 800; padding: .7rem 1.4rem; cursor: pointer;
}
.primary:disabled { opacity: .4; }

.result { text-align: center; margin-top: 1.2rem; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 1.2rem; }
.result h2 { margin: 0 0 .2rem; letter-spacing: -.02em; }
.result .sub { color: var(--dim); font-size: .9rem; margin-bottom: .7rem; }
.result .sub b { color: var(--warn); }
.share-grid { font-size: 1.25rem; letter-spacing: .12em; margin: .4rem 0 .9rem; }
.share-grid .hint { letter-spacing: 0; font-size: .75rem; }
.hidden { display: none !important; }

/* ---- Art matching ---- */
.names { display: grid; grid-template-columns: repeat(5, 1fr); gap: .45rem; }
.artchip { border: 2px solid var(--line); background: none; padding: 0; border-radius: 10px; overflow: hidden; cursor: pointer; aspect-ratio: 4/3; }
.artchip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.artchip.sel { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(164,143,255,.35); }
.tc-name { font-weight: 800; letter-spacing: -.01em; margin-bottom: .1rem; }
.placed-art { padding: 0; overflow: hidden; position: relative; background: none; }
.placed-art img { width: 100%; max-height: 110px; object-fit: cover; display: block; border-radius: 9px; }
.lock-tick { position: absolute; top: .35rem; right: .5rem; color: var(--good); font-weight: 900; text-shadow: 0 1px 4px #000; }
@media (max-width: 420px) { .names { grid-template-columns: repeat(5, 1fr); } }

/* ---- Drag & drop + desktop layout ---- */
.artchip { cursor: grab; }
.artchip:active { cursor: grabbing; }
.artchip:hover { border-color: var(--accent); }
.textcard.dragover { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(164, 143, 255, .3); }
.empty-slot { transition: border-color .12s; }
.textcard.dragover .empty-slot { border-color: var(--accent); color: var(--accent); }

@media (min-width: 760px) {
  main { max-width: 920px; display: grid; grid-template-columns: 250px 1fr; gap: 0 1.4rem; align-items: start; }
  #intro, .checkrow, .result { grid-column: 1 / -1; }
  .names { grid-template-columns: 1fr; position: sticky; top: .8rem; align-self: start; gap: .6rem; }
  .artchip { aspect-ratio: 16/9; border-radius: 12px; }
  .texts { margin-top: .8rem; }
  .tc-text { font-size: .95rem; }
}

/* ---- Solved-card reveal ---- */
.textcard.locked { cursor: pointer; }
.placed-art.locked { cursor: pointer; }
.lock-tick { font-size: .68rem; letter-spacing: .02em; background: rgba(10,6,18,.65); border-radius: 99px; padding: .15rem .5rem; }
.card-overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(10, 6, 18, .85);
  display: grid; place-items: center; padding: 1rem; cursor: pointer;
}
.card-overlay.hidden { display: none; }
.card-overlay img { max-width: min(92vw, 360px); width: 100%; border-radius: 4.5%/3.5%; box-shadow: 0 14px 40px rgba(0,0,0,.6); }

/* ---- Art zoom ---- */
.card-overlay img.zoom-art { max-width: min(96vw, 720px); border-radius: 14px; }
.artchip img, .placed-art img { -webkit-touch-callout: none; }
.artchip, .placed-art { touch-action: manipulation; }

/* ---- Pointer drag (mouse + touch) ---- */
.artchip { touch-action: none; } /* the chip itself is a drag handle; page scroll from elsewhere */
.artchip.dragging { opacity: .35; }
.drag-ghost {
  position: fixed; z-index: 200; pointer-events: none;
  width: 150px; border-radius: 10px; transform: translate(-50%, -60%);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .55); outline: 2px solid var(--accent);
}
