/* Living room at night: deep plum ground, one lamp of amber, a teal check. */
:root {
  --bg: #191221;
  --surface: #221a2e;
  --surface-2: #2b2139;
  --line: #392c4a;
  --text: #f3ece4;
  --muted: #b9aec4;
  --amber: #f0a95c;
  --amber-ink: #2a1c08;
  --teal: #5fc9b0;
  --danger: #e8697d;
  --radius: 14px;
  --serif: ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

/* A class that sets display beats the hidden attribute, and every panel here
   is a grid or a flex box. This one line keeps hidden meaning hidden. */
[hidden] { display: none !important; }

body {
  margin: 0;
  padding: 1.25rem 1rem calc(3rem + env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

#gate, #app { max-width: 28rem; margin: 0 auto; }

.serif { font-family: var(--serif); font-weight: 600; letter-spacing: .01em; }

/* Nothing is reachable without a ring you can actually see. */
:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ------------------------------------------------------------- controls -- */

input[type="text"], input[type="email"] {
  width: 100%;
  padding: .8rem .9rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
}
input::placeholder { color: #7e7289; }
input:focus { border-color: var(--amber); }

.btn {
  padding: .8rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform .12s ease, filter .12s ease, background .12s ease;
}
.btn:active { transform: scale(.97); }

.btn-primary { background: var(--amber); color: var(--amber-ink); }
.btn-primary:hover { filter: brightness(1.08); }

.btn-quiet {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}
.btn-quiet:hover { color: var(--text); border-color: var(--amber); }

/* --------------------------------------------------------------- gate -- */

.gate { padding-top: 12vh; text-align: center; }
.gate-title { font-size: 2rem; margin: 0 0 .4rem; }
.gate-line { color: var(--muted); margin: 0 0 2rem; }
.gate-form { display: grid; gap: .7rem; text-align: left; }
.label { color: var(--muted); font-size: .85rem; }

#code {
  font-size: 1.6rem;
  letter-spacing: .6rem;
  text-align: center;
  font-family: var(--serif);
}

.error { color: var(--danger); margin-top: 1rem; font-size: .9rem; }

/* --------------------------------------------------------------- head -- */

.head { margin-bottom: 1.4rem; }
.title { font-size: 1.9rem; margin: 0; }
.counts { color: var(--muted); margin: .1rem 0 .7rem; font-size: .95rem; }

.who {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .3rem .7rem .3rem .5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font: inherit;
  font-size: .85rem;
  cursor: pointer;
}
.who:hover { border-color: var(--amber); }

.dot {
  width: .65rem;
  height: .65rem;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}

/* ---------------------------------------------------------------- add -- */

.add { display: grid; gap: .6rem; margin-bottom: .8rem; }
.row { display: flex; gap: .6rem; }

.segmented {
  display: flex;
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 3px;
  gap: 3px;
}
.seg {
  flex: 1;
  padding: .55rem .2rem;
  background: transparent;
  border: 0;
  border-radius: 11px;
  color: var(--muted);
  font: inherit;
  font-size: .9rem;
  cursor: pointer;
  transition: background .16s ease, color .16s ease;
}
.seg.on { background: var(--surface-2); color: var(--text); box-shadow: 0 1px 0 rgba(0,0,0,.3); }

.btn-add { padding-inline: 1.4rem; }

.btn-pick {
  width: 100%;
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--muted);
  margin-bottom: 1.4rem;
}
.btn-pick:hover { border-color: var(--amber); color: var(--amber); border-style: solid; }
.btn-pick[disabled] { opacity: .4; cursor: not-allowed; }

/* --------------------------------------------------------------- tabs -- */

.tabs { display: flex; gap: 1.2rem; border-bottom: 1px solid var(--line); margin-bottom: .9rem; }
.tab {
  padding: .5rem 0 .7rem;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--muted);
  font: inherit;
  font-size: .95rem;
  cursor: pointer;
  transition: color .16s ease, border-color .16s ease;
}
.tab.on { color: var(--text); border-bottom-color: var(--amber); }

/* --------------------------------------------------------------- list -- */

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }

.item {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: start;
  gap: .6rem;
  padding: .75rem .8rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  animation: in .22s ease both;
}
@keyframes in { from { opacity: 0; transform: translateY(6px); } }

.item.leaving { animation: out .18s ease both; }
@keyframes out { to { opacity: 0; transform: translateX(-14px) scale(.97); } }

/* The lifted row follows the finger while its neighbours shuffle underneath. */
.item.dragging {
  position: relative;
  z-index: 5;
  border-color: var(--amber);
  box-shadow: 0 12px 28px rgba(0,0,0,.45);
  cursor: grabbing;
}

.grip {
  padding: .15rem .1rem;
  background: none;
  border: 0;
  color: #6d6178;
  font-size: 1.05rem;
  line-height: 1.2;
  cursor: grab;
  touch-action: none; /* the browser must not steal the drag to scroll */
}
.grip:hover { color: var(--amber); }

.rank {
  min-width: 1.3rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: .9rem;
  padding-top: .1rem;
  text-align: right;
}

.body { min-width: 0; }
.name {
  font-family: var(--serif);
  font-size: 1.05rem;
  word-break: break-word;
}
.item.done .name { text-decoration: line-through; color: var(--muted); }

.meta {
  display: flex;
  align-items: center;
  gap: .4rem;
  color: var(--muted);
  font-size: .8rem;
  margin-top: .15rem;
}
.kind {
  text-transform: uppercase;
  letter-spacing: .07em;
  font-size: .68rem;
  padding: .1rem .4rem;
  border: 1px solid var(--line);
  border-radius: 5px;
}
.note { color: var(--muted); font-size: .85rem; margin-top: .3rem; font-style: italic; }

.acts { display: flex; gap: .15rem; }
.act {
  width: 2.1rem;
  height: 2.1rem;
  display: grid;
  place-items: center;
  background: none;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  transition: color .14s ease, border-color .14s ease, transform .14s ease;
}
.act:hover { border-color: var(--line); color: var(--text); }
.act.check:hover { color: var(--teal); border-color: var(--teal); }
.act.check.on { color: var(--teal); }
.act.del:hover { color: var(--danger); border-color: var(--danger); }
.act:active { transform: scale(.88); }

/* The check pops when it lands, which is the whole reward for finishing one. */
@keyframes pop { 50% { transform: scale(1.45) rotate(-8deg); } }
.act.popping { animation: pop .34s ease; color: var(--teal); }

.empty {
  color: var(--muted);
  text-align: center;
  padding: 2.5rem 1rem;
  line-height: 1.6;
}

.scores {
  margin-top: 1.6rem;
  color: var(--muted);
  font-size: .82rem;
  display: flex;
  flex-wrap: wrap;
  gap: .8rem;
  justify-content: center;
}
.score { display: inline-flex; align-items: center; gap: .35rem; }

/* ----------------------------------------------------------- overlays -- */

.sheet {
  width: min(24rem, calc(100vw - 2rem));
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--text);
  text-align: center;
}
.sheet::backdrop { background: rgba(12, 7, 18, .72); backdrop-filter: blur(2px); }
.sheet[open] { animation: rise .2s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.98); } }

.sheet form { display: grid; gap: .8rem; }
.sheet-title { font-size: 1.3rem; margin: 0; }
.sheet-line { color: var(--muted); font-size: .9rem; margin: .2rem 0 0; }
.sheet .row { margin-top: 1.1rem; }
.sheet .row .btn { flex: 1; }

.pick-title {
  font-size: 1.5rem;
  margin: 1.1rem 0 .2rem;
  min-height: 2.2rem;
  color: var(--amber);
}
/* While the reel spins the title blurs a little, so the stop reads as a stop. */
.spinning .pick-title { filter: blur(1.1px); opacity: .85; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.2rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100vw - 2rem);
  padding: .7rem 1.1rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: .88rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  animation: toast .25s ease both;
  z-index: 30;
}
@keyframes toast { from { opacity: 0; transform: translate(-50%, 10px); } }

/* Popcorn that jumps out of a row when it gets checked off. */
.burst { position: fixed; inset: 0; pointer-events: none; z-index: 40; }
.kernel {
  position: absolute;
  font-size: 1.1rem;
  animation: fly .9s cubic-bezier(.2, .7, .4, 1) forwards;
}
@keyframes fly {
  from { opacity: 1; transform: translate(0, 0) rotate(0); }
  to   { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
