/* Countdown. Themes set --a/--b/--c (background gradient), --ink (text), --glow (accent), --card (panel). */
*, *::before, *::after { box-sizing: border-box; }
:root {
  --a: #0f0c29; --b: #302b63; --c: #24243e; --ink: #f6f4ff; --soft: rgba(246, 244, 255, .72);
  --glow: #ffb86b; --card: rgba(255, 255, 255, .09); --line: rgba(255, 255, 255, .18); --btn-ink: #1a1530;
  --font: ui-rounded, "SF Pro Rounded", "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
[data-theme="midnight"] { --a: #0f0c29; --b: #302b63; --c: #1d1a3a; --glow: #ffb86b; }
[data-theme="sunset"]   { --a: #ff5e62; --b: #ff9966; --c: #7a2a6b; --glow: #fff1a8; --card: rgba(60, 10, 40, .22); }
[data-theme="ocean"]    { --a: #0a2a43; --b: #0f6c8c; --c: #11998e; --glow: #7ff5d9; }
[data-theme="forest"]   { --a: #0b2b1f; --b: #1f6f4a; --c: #6fae5a; --glow: #f2e86d; --card: rgba(0, 30, 15, .22); }
[data-theme="ember"]    { --a: #1a0306; --b: #6b0f1a; --c: #e0502f; --glow: #ffd27a; }
[data-theme="aurora"]   { --a: #07101f; --b: #1b3b6f; --c: #2fd3a1; --glow: #c6ff7a; }
[data-theme="candy"]    { --a: #ff8fb1; --b: #c79bff; --c: #7fd6ff; --ink: #24113a; --soft: rgba(36, 17, 58, .75);
                          --glow: #fff; --card: rgba(255, 255, 255, .35); --line: rgba(36, 17, 58, .2); color-scheme: light; }
[data-theme="paper"]    { --a: #f7f1e3; --b: #efe4cc; --c: #e6d6b8; --ink: #2a2116; --soft: rgba(42, 33, 22, .72);
                          --glow: #c2410c; --card: rgba(255, 255, 255, .55); --line: rgba(42, 33, 22, .18); --btn-ink: #fff; color-scheme: light; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh; font-family: var(--font); color: var(--ink);
  background: var(--a); line-height: 1.45; overflow-x: hidden;
}
a { color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Soft moving light blobs behind everything. */
.sky { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0;
  background-image: linear-gradient(135deg, var(--a), var(--b) 55%, var(--c)); }
.sky span { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .35; background: var(--glow);
  width: 45vmax; height: 45vmax; animation: drift 28s ease-in-out infinite alternate; }
.sky span:nth-child(1) { left: -15vmax; top: -15vmax; }
.sky span:nth-child(2) { right: -18vmax; bottom: -20vmax; background: var(--c); opacity: .5; animation-duration: 34s; }
.sky span:nth-child(3) { left: 40%; top: 50%; width: 25vmax; height: 25vmax; opacity: .18; animation-duration: 40s; }
@keyframes drift { to { transform: translate(8vmax, 6vmax) scale(1.15); } }

.view { position: relative; z-index: 1; }

/* Buttons */
.btn { font: inherit; font-weight: 600; font-size: 1rem; display: inline-flex; align-items: center; justify-content: center;
  gap: .4em; min-height: 44px; padding: .55em 1.1em; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); text-decoration: none; cursor: pointer;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); transition: transform .15s, background .15s; }
.btn:hover { background: rgba(255, 255, 255, .18); }
.btn:active { transform: scale(.97); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .pick:focus-visible, .swatch:focus-within {
  outline: 3px solid var(--glow); outline-offset: 2px; }
.btn.primary { background: var(--ink); color: var(--btn-ink); border-color: transparent; }
[data-theme="paper"] .btn.primary { background: var(--ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.big { font-size: 1.15rem; padding: .75em 1.6em; }
.btn.small { min-height: 36px; font-size: .9rem; padding: .35em .9em; }
.btn.ghost { background: transparent; }

/* Start page */
#home { max-width: 1040px; margin: 0 auto; padding: max(24px, env(safe-area-inset-top)) 16px 40px; }
.hero { padding: 8vh 0 5vh; text-align: center; }
.kicker { margin: 0 0 .5rem; color: var(--soft); font-size: .9rem; letter-spacing: .04em; }
.hero h1 { font-size: clamp(2.3rem, 8vw, 4.6rem); line-height: 1.02; margin: 0 0 1rem; letter-spacing: -.02em; }
.lede { max-width: 36em; margin: 0 auto 1.8rem; font-size: 1.1rem; color: var(--soft); }
.block { margin-top: 2.2rem; }
.block h2 { font-size: 1.25rem; margin: 0 0 .8rem; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.block-head h2 { margin: 0; }
.note { margin: .2rem 0 .8rem; color: var(--soft); font-size: .9rem; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.card { position: relative; display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 18px;
  text-decoration: none; color: #fff; min-height: 84px; overflow: hidden;
  background-image: linear-gradient(135deg, var(--a), var(--b) 60%, var(--c)); border: 1px solid rgba(255, 255, 255, .15);
  box-shadow: 0 6px 22px rgba(0, 0, 0, .18); transition: transform .15s; }
.card[data-theme="candy"], .card[data-theme="paper"] { color: var(--ink); }
.card:hover { transform: translateY(-2px); }
.card .ce { font-size: 2rem; line-height: 1; flex: none; }
.card .ct { min-width: 0; }
.card .cn { display: block; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .cl { display: block; font-size: .92rem; opacity: .85; }
.card-wrap { position: relative; }
.card-wrap .card { padding-right: 48px; }
.card-del { position: absolute; top: 50%; right: 8px; transform: translateY(-50%); width: 36px; height: 36px; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, .25); color: #fff; font: inherit; font-size: 1.1rem; cursor: pointer; z-index: 2; }
.card-del:hover { background: rgba(0, 0, 0, .45); }
.foot { margin-top: 3rem; color: var(--soft); font-size: .9rem; text-align: center; }

/* Builder */
#builder { padding: max(16px, env(safe-area-inset-top)) 16px 48px; }
.builder-wrap { max-width: 620px; margin: 0 auto; }
.builder-top { display: flex; align-items: center; gap: 12px; margin: 8px 0 18px; }
.builder-top h1 { margin: 0; font-size: clamp(1.4rem, 5vw, 2rem); }
#form { background: var(--card); border: 1px solid var(--line); border-radius: 24px; padding: 20px;
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.field { display: block; border: 0; padding: 0; margin: 0 0 18px; min-width: 0; }
.field > span, .field > legend { display: block; font-weight: 600; margin-bottom: 6px; padding: 0; }
.field em { font-weight: 400; font-style: normal; color: var(--soft); }
.row { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; }
input[type="text"], input[type="date"], input[type="time"], select, textarea {
  width: 100%; font: inherit; font-size: 1rem; color: var(--ink); background: rgba(0, 0, 0, .18); border: 1px solid var(--line);
  border-radius: 12px; padding: .65em .8em; min-height: 46px; }
[data-theme="candy"] input, [data-theme="candy"] select, [data-theme="candy"] textarea,
[data-theme="paper"] input, [data-theme="paper"] select, [data-theme="paper"] textarea { background: rgba(255, 255, 255, .6); }
select option { color: #111; background: #fff; }
textarea { resize: vertical; }
.hint { display: block; margin-top: 6px; color: var(--soft); font-size: .88rem; }
.emoji-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.pick { width: 44px; height: 44px; font-size: 1.4rem; border-radius: 12px; border: 1px solid var(--line); background: transparent;
  cursor: pointer; color: var(--ink); font-family: inherit; display: inline-flex; align-items: center; justify-content: center; }
.pick[aria-pressed="true"] { background: var(--ink); color: var(--btn-ink); border-color: var(--ink); }
.pick.none { font-size: .8rem; width: auto; padding: 0 10px; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.swatch { position: relative; display: block; cursor: pointer; border-radius: 14px; overflow: hidden; }
.swatch input { position: absolute; opacity: 0; inset: 0; }
.swatch span { display: flex; align-items: flex-end; height: 58px; padding: 6px 9px; font-size: .85rem; font-weight: 600;
  color: #fff; background-image: linear-gradient(135deg, var(--a), var(--b) 60%, var(--c)); border: 2px solid transparent; border-radius: 14px; }
.swatch[data-theme="candy"] span, .swatch[data-theme="paper"] span { color: var(--ink); }
.swatch input:checked + span { border-color: var(--ink); box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .25); }
body[data-theme="candy"] .swatch input:checked + span, body[data-theme="paper"] .swatch input:checked + span { border-color: #24113a; }
.error { color: #fff; background: #b42318; padding: .6em .9em; border-radius: 12px; font-weight: 600; }
.actions { display: flex; justify-content: flex-end; }

/* Countdown page: fills the screen on a phone, scales up for a TV. */
#count { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: max(24px, env(safe-area-inset-top)) 16px 16px; gap: clamp(6px, 1.6vh, 18px); }
.emoji { font-size: clamp(3.2rem, 13vmin, 9rem); line-height: 1.1; }
.emoji:empty { display: none; }
.c-name { margin: 0; font-size: clamp(1.6rem, 6.5vmin, 4.4rem); line-height: 1.08; letter-spacing: -.01em; max-width: 22ch;
  overflow-wrap: anywhere; }
.c-when { margin: 0; color: var(--soft); font-size: clamp(.95rem, 2.2vmin, 1.5rem); max-width: 52ch; }
.clock { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(8px, 2vmin, 28px);
  margin-top: clamp(10px, 3vh, 36px); width: min(100%, 1400px); }
.unit { background: var(--card); border: 1px solid var(--line); border-radius: clamp(14px, 2.4vmin, 32px);
  padding: clamp(10px, 2.2vmin, 32px) 4px; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  display: flex; flex-direction: column; align-items: center; min-width: 0; }
.num { font-size: clamp(2.4rem, 11vmin, 11rem); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums;
  letter-spacing: -.03em; }
.clock.long .num { font-size: clamp(2rem, 8.5vmin, 8.5rem); }
.lbl { margin-top: .35em; font-size: clamp(.8rem, 2vmin, 1.6rem); color: var(--soft); text-transform: lowercase; letter-spacing: .05em; }
.num.tick { animation: tick .35s ease-out; }
@keyframes tick { from { transform: translateY(-.08em); opacity: .55; } to { transform: none; opacity: 1; } }
@media (orientation: portrait) and (max-width: 640px) {
  .clock { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 480px; }
  .num { font-size: clamp(3rem, 19vw, 6rem); }
  .clock.long .num { font-size: clamp(2.6rem, 15vw, 5rem); }
}
.done { margin-top: clamp(8px, 2vh, 24px); }
.ago { margin: 0; font-size: clamp(2.6rem, 12vmin, 10rem); font-weight: 800; line-height: 1; letter-spacing: -.03em; }
.since { margin: .6em 0 0; color: var(--soft); font-size: clamp(.95rem, 2.4vmin, 1.6rem); font-variant-numeric: tabular-nums; }
.msg { margin: clamp(8px, 2.5vh, 28px) 0 0; max-width: 30ch; font-size: clamp(1.2rem, 4.2vmin, 3rem); font-weight: 700;
  background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: .5em .9em; overflow-wrap: anywhere; }
.celebrate .emoji { animation: pop 1.2s cubic-bezier(.2, 1.6, .4, 1) 1; }
@keyframes pop { 0% { transform: scale(.4) rotate(-12deg); } 60% { transform: scale(1.25) rotate(6deg); } 100% { transform: none; } }

.toolbar { position: relative; z-index: 2; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px;
  padding: 12px 16px max(16px, env(safe-area-inset-bottom)); transition: opacity .4s; }
.idle .toolbar { opacity: 0; pointer-events: none; }
.idle { cursor: none; }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }

.bad-box { max-width: 520px; margin: 18vh auto 0; padding: 24px 16px; text-align: center; }
.bad-box h1 { font-size: 1.8rem; }
.bad-box p { color: var(--soft); }

.toast { position: fixed; left: 50%; bottom: max(84px, calc(env(safe-area-inset-bottom) + 84px)); transform: translateX(-50%);
  background: var(--ink); color: var(--btn-ink); padding: .7em 1.2em; border-radius: 999px; font-weight: 600; z-index: 10;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .3); max-width: calc(100vw - 32px); }
.noscript { position: relative; z-index: 1; text-align: center; padding: 40px 16px; }

@media (prefers-reduced-motion: reduce) {
  .sky span, .num.tick, .celebrate .emoji { animation: none !important; }
  .btn, .card, .toolbar { transition: none; }
}
