:root {
  --paper: #efe7d6;
  --paper-deep: #e6dcc6;
  --ink: #1a1612;
  --ink-soft: #56463a;
  --accent: #b8412f;
  --accent-soft: #d6816f;
  --rule: #c8b99a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Fraunces', Georgia, 'Times New Roman', serif;
  font-feature-settings: "liga", "calt", "ss01";
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* paper grain via SVG noise */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  opacity: .35;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.1  0 0 0 0 0.08  0 0 0 0 0.06  0 0 0 0.5 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
/* warm vignette */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(60,40,20,.18) 100%);
}

canvas#bg, canvas#fx {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
canvas#bg { z-index: 0; opacity: 0; transition: opacity 1.2s ease; }
canvas#fx { z-index: 1; pointer-events: none; }

#notes-layer {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}

/* ---------- Header ---------- */
.page-head {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 6;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 1.6rem 2rem;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .72rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.brand { display: flex; align-items: center; gap: .55rem; }
.brand .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(184,65,47,.18);
}
.head-target { display: flex; gap: 1.1rem; }
.head-target-time { color: var(--accent); }

/* ---------- Stage ---------- */
.stage {
  position: relative;
  z-index: 6;
  height: 100%;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 0 1rem;
  pointer-events: none;
}
.stage > * { pointer-events: auto; }

.kicker {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .72rem;
  letter-spacing: .35em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 1.2rem;
  position: relative;
  display: inline-block;
}
.kicker::before, .kicker::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 38px;
  height: 1px;
  background: var(--rule);
}
.kicker::before { right: calc(100% + 14px); }
.kicker::after { left: calc(100% + 14px); }

.countdown {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0;
  grid-row: 2;
}

.big-num {
  font-family: 'Fraunces', serif;
  font-weight: 300;
  font-variation-settings: "opsz" 144, "SOFT" 50;
  font-size: clamp(9rem, 28vw, 22rem);
  line-height: .85;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  display: block;
}
.big-label {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  color: var(--accent);
  margin-top: -.2em;
  letter-spacing: .02em;
}
.small-row {
  margin-top: 1.4rem;
  display: flex;
  align-items: baseline;
  gap: .9rem;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 500;
  font-size: clamp(1rem, 1.4vw, 1.15rem);
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.small-num em {
  font-style: normal;
  color: var(--accent);
  margin-left: 1px;
  font-weight: 400;
}
.small-row .sep { color: var(--rule); }

.subline {
  font-style: italic;
  font-weight: 300;
  color: var(--ink-soft);
  font-size: clamp(.95rem, 1.3vw, 1.1rem);
  margin: 1.4rem 0 0;
  letter-spacing: .01em;
}

/* ---------- Form ---------- */
form#msg-form {
  position: fixed;
  bottom: 1.6rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 7;
  width: min(560px, calc(100% - 2rem));
}
.form-row {
  display: flex;
  align-items: stretch;
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 0;
  box-shadow: 4px 4px 0 var(--ink);
  overflow: hidden;
}
.form-row input {
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--ink);
  font: 400 1rem 'Fraunces', serif;
  padding: .85rem 1rem;
  min-width: 0;
}
.form-row input::placeholder {
  color: var(--ink-soft);
  opacity: .6;
  font-style: italic;
}
.form-row input:focus { background: rgba(184,65,47,.05); }
.form-row #author { width: 32%; max-width: 160px; }
.form-row .form-sep {
  width: 1px;
  background: var(--ink);
  opacity: .25;
}
.form-row #content { flex: 1; }
.form-row button {
  background: var(--ink);
  color: var(--paper);
  border: 0;
  padding: 0 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease;
}
.form-row button:hover { background: var(--accent); }
.form-row button:disabled { opacity: .5; cursor: not-allowed; }

.error {
  text-align: center;
  color: var(--accent);
  font-style: italic;
  margin: .5rem 0 0;
  font-size: .9rem;
}

/* ---------- Floating notes ---------- */
.note {
  position: absolute;
  font-family: 'Caveat', cursive;
  font-weight: 500;
  font-size: clamp(1.05rem, 1.6vw, 1.55rem);
  line-height: 1.15;
  color: var(--ink);
  padding: .85rem 1rem .7rem;
  max-width: 240px;
  word-wrap: break-word;
  opacity: 0;
  will-change: transform, opacity;
  filter: drop-shadow(2px 4px 6px rgba(60, 40, 20, 0.18));
}
.note .author {
  display: block;
  margin-top: .25rem;
  font-size: .72em;
  color: var(--ink-soft);
  font-style: italic;
}
/* Six paper colors */
.note.p1 { background: #f7e5a3; }
.note.p2 { background: #f3b8a3; }
.note.p3 { background: #b8d4b3; }
.note.p4 { background: #a5c8de; }
.note.p5 { background: #e9bfd0; }
.note.p6 { background: #e3cfa7; }

/* ---------- Finale ---------- */
#finale {
  grid-row: 2;
  text-align: center;
  pointer-events: none;
}
#finale h2 {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-weight: 400;
  font-size: clamp(3.5rem, 11vw, 9rem);
  margin: 0;
  color: var(--paper);
  letter-spacing: .01em;
  text-shadow: 0 2px 30px rgba(0,0,0,.5);
}

body.finale { background: #07060d; color: var(--paper); }
body.finale::before { opacity: .15; }
body.finale::after { background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,.65) 100%); }
body.finale canvas#bg { opacity: 1; }
body.finale .page-head,
body.finale form#msg-form { color: rgba(239,231,214,.7); }
body.finale .form-row {
  background: rgba(20,15,30,.5);
  border-color: rgba(239,231,214,.4);
  box-shadow: 4px 4px 0 rgba(239,231,214,.4);
}
body.finale .form-row input { color: var(--paper); }
body.finale .form-row input::placeholder { color: rgba(239,231,214,.5); }
body.finale .form-row .form-sep { background: rgba(239,231,214,.3); }
body.finale .form-row button { background: var(--paper); color: var(--ink); }

@media (max-width: 600px) {
  .page-head { padding: 1rem 1.1rem; font-size: .65rem; }
  .head-target { gap: .7rem; }
  .kicker::before, .kicker::after { width: 22px; }
  .small-row { gap: .55rem; }
  .form-row #author { width: 38%; max-width: none; }
  .note { max-width: 180px; font-size: 1.1rem; }
}
