/* Freddie's stars. A night sky: deep indigo, warm gold stars, rounded type.
   The grid is the one loud thing; everything else keeps quiet around it. */
:root {
  --sky: #141733;
  --sky-deep: #0E1026;
  --panel: #1C2043;
  --panel-edge: #2A2F5C;
  --text: #F7F3E8;
  --muted: #A3A8CC;
  --gold: #F6C544;
  --gold-deep: #D99A14;
  --gold-glow: rgba(246, 197, 68, 0.35);
  --danger: #FF8C8C;
  --radius: 22px;
  --gap: 20px;
  --display: "Fredoka", "Nunito", system-ui, sans-serif;
  --body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--sky);
  color: var(--text);
  font: 400 17px/1.5 var(--body);
}
.sky {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(1px 1px at 12% 18%, rgba(255,255,255,.55) 50%, transparent 51%),
    radial-gradient(1px 1px at 78% 9%, rgba(255,255,255,.4) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 62% 31%, rgba(255,255,255,.45) 50%, transparent 51%),
    radial-gradient(1px 1px at 31% 54%, rgba(255,255,255,.35) 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 62%, rgba(255,255,255,.4) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 20% 82%, rgba(255,255,255,.3) 50%, transparent 51%),
    radial-gradient(1px 1px at 55% 90%, rgba(255,255,255,.35) 50%, transparent 51%),
    radial-gradient(ellipse at 50% -10%, #232862 0%, var(--sky) 55%, var(--sky-deep) 100%);
}

h1, h2, .count, .treat-name, button.primary {
  font-family: var(--display);
  font-weight: 600;
  letter-spacing: 0.01em;
}
h1 { font-size: 32px; margin: 0; line-height: 1.1; }
h2 { font-size: 22px; margin: 0 0 12px; color: var(--text); }
.muted, .hint, .treat-meta { color: var(--muted); }
.hint { font-size: 14px; margin: 4px 0 0; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: calc(16px + env(safe-area-inset-top)) 20px 8px;
  max-width: 1040px; margin: 0 auto;
}
.who { display: flex; align-items: center; gap: 12px; margin: 0; color: var(--muted); }
button.link {
  background: none; border: 0; color: var(--muted); font: inherit; text-decoration: underline;
  text-underline-offset: 3px; cursor: pointer; padding: 6px 0;
}
button.link:hover { color: var(--text); }

.page {
  max-width: 1040px; margin: 0 auto; padding: 8px 16px calc(40px + env(safe-area-inset-bottom));
  display: grid; gap: var(--gap);
  grid-template-columns: 1fr;
  grid-template-areas: "chart" "treat" "history";
}
.chart { grid-area: chart; }
.treat { grid-area: treat; }
.history { grid-area: history; }

@media (min-width: 820px) {
  .page {
    grid-template-columns: minmax(0, 1.25fr) minmax(300px, 1fr);
    grid-template-areas: "chart treat" "history history";
    align-items: start;
  }
}

/* the chart */
.chart, .treat, .history {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 22px 20px 20px;
}
.grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  max-width: 400px; margin: 0 auto;
}
.star { width: 100%; height: auto; display: block; aspect-ratio: 1; }
.star.gold.pop { animation: pop 650ms cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes pop {
  0%   { transform: scale(0.2) rotate(-25deg); opacity: 0; filter: drop-shadow(0 0 0 var(--gold-glow)); }
  60%  { transform: scale(1.12) rotate(4deg); opacity: 1; filter: drop-shadow(0 0 28px var(--gold)); }
  100% { transform: scale(1) rotate(0); filter: drop-shadow(0 0 0 var(--gold-glow)); }
}
@media (prefers-reduced-motion: reduce) {
  .star.gold.pop { animation: none; }
}
.count { text-align: center; font-size: 24px; margin: 14px 0 18px; min-height: 1.3em; }
.count.complete { color: var(--gold); }

.give { display: grid; gap: 12px; }
input[type="text"], input:not([type]), input[type="password"] {
  width: 100%; font: inherit; color: var(--text);
  background: var(--sky-deep); border: 1.5px solid var(--panel-edge); border-radius: 14px;
  padding: 12px 14px; outline: none;
}
input:focus-visible { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-glow); }
input::placeholder { color: #6E739A; }
input[type="file"] { color: var(--muted); font: inherit; max-width: 100%; }
input[type="file"]::file-selector-button {
  font: 600 15px var(--body); color: var(--text); background: var(--panel-edge);
  border: 0; border-radius: 12px; padding: 9px 14px; margin-right: 12px; cursor: pointer;
}

/* Button rows: the positive action is always last and flush right. */
.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; align-items: center; }
button.primary, button.quiet {
  font: 600 18px/1 var(--body); border-radius: 16px; padding: 14px 22px; cursor: pointer; border: 0;
  transition: transform 120ms ease, filter 120ms ease;
}
button.primary {
  background: linear-gradient(180deg, #FFDD7A, var(--gold) 55%, var(--gold-deep));
  color: #2B1E00; box-shadow: 0 6px 20px var(--gold-glow);
}
button.primary:hover { filter: brightness(1.05); }
button.primary:active { transform: translateY(1px) scale(0.99); }
button.quiet { background: transparent; color: var(--muted); border: 1.5px solid var(--panel-edge); }
button.quiet:hover { color: var(--text); border-color: var(--muted); }
button:disabled { opacity: .55; cursor: wait; }
button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.complete-row { margin-top: 12px; }
.notice { min-height: 1.4em; margin: 10px 0 0; color: var(--muted); font-size: 15px; text-align: right; }
.notice.error { color: var(--danger); }

/* the treat */
.treat-picture {
  background: radial-gradient(ellipse at 50% 60%, #262B5A, var(--sky-deep));
  border-radius: 18px; min-height: 240px; display: grid; place-items: center; padding: 14px;
}
.treat-picture img { max-width: 100%; max-height: 320px; width: auto; height: auto; display: block; }
.treat-picture img.busy { opacity: .4; }
.treat-empty { color: var(--muted); text-align: center; margin: 0; max-width: 26ch; }
.treat-name { font-size: 26px; text-align: center; margin: 14px 0 0; min-height: 1.2em; }
.treat-meta { text-align: center; font-size: 14px; margin: 2px 0 16px; min-height: 1.2em; }
.treat-form { display: grid; gap: 12px; border-top: 1px solid var(--panel-edge); padding-top: 16px; }
.field { display: grid; gap: 6px; font-size: 15px; color: var(--muted); }

/* history */
.stars-list, .rounds-list { list-style: none; margin: 0; padding: 0; }
.stars-list li {
  display: grid; grid-template-columns: 9.5em 5em 1fr; gap: 8px 12px; align-items: baseline;
  padding: 9px 0; border-bottom: 1px solid var(--panel-edge);
}
.stars-list li:last-child { border-bottom: 0; }
.stars-list .when { color: var(--muted); font-size: 14px; }
.stars-list .by { font-weight: 700; }
.stars-list .reason { color: var(--text); }
.stars-list .reason:empty::before { content: "no note"; color: #6E739A; }
.stars-list li.revoked .by, .stars-list li.revoked .reason { text-decoration: line-through; color: var(--muted); }
.stars-list .taken { grid-column: 2 / -1; font-size: 14px; color: var(--muted); }
@media (max-width: 480px) {
  .stars-list li { grid-template-columns: 1fr; gap: 2px; }
}
.rounds-list li { display: flex; gap: 14px; padding: 7px 0; }
.rounds-list time { color: var(--muted); min-width: 7em; }
.history h2 + h2, .rounds-list { margin-top: 20px; }
.stars-list + h2 { margin-top: 24px; }

/* sign in */
.login {
  min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 10px;
  padding: 24px; text-align: center;
}
.login-star { filter: drop-shadow(0 0 24px var(--gold-glow)); }
.login-form { display: grid; gap: 14px; width: min(360px, 90vw); text-align: left; margin-top: 12px; }
.login-form label { display: grid; gap: 6px; color: var(--muted); font-size: 15px; }
.form-error { color: var(--danger); margin: 0; }
