:root {
  --ink: #0f1d36;
  --cream: #fff6dc;
  --muted: rgba(255, 246, 220, 0.72);
  --glass: rgba(11, 22, 44, 0.62);
  --line: rgba(255, 246, 220, 0.2);
  --gold: #ffd54a;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ink) url("/art/meadow.jpg") center bottom / cover no-repeat;
  color: var(--cream);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

#sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: manipulation;
}

.sr {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* header */
.top {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: max(14px, env(safe-area-inset-top)) 18px 0;
  pointer-events: none;
}
.top > * { pointer-events: auto; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--cream);
  text-decoration: none;
  font-family: var(--serif);
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
}
.tools { display: flex; gap: 8px; }
.chip {
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}
.chip.icon { padding: 8px 10px; display: grid; place-items: center; }
.chip:hover { background: rgba(11, 22, 44, 0.8); border-color: rgba(255, 246, 220, 0.45); }
.chip:active { transform: scale(0.96); }
#btn-sound .mute { display: block; }
#btn-sound .waves { display: none; }
#btn-sound[aria-pressed="true"] .mute { display: none; }
#btn-sound[aria-pressed="true"] .waves { display: block; }

/* soft shade so the text stays readable over the grass */
body::after {
  content: "";
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 42vh;
  background: linear-gradient(to top, rgba(8, 16, 34, 0.78), rgba(8, 16, 34, 0.35) 55%, rgba(8, 16, 34, 0));
  pointer-events: none;
  z-index: 0;
}
#sky { z-index: 1; }
.dock, .top { z-index: 2; }

/* bottom dock */
.dock {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 32px));
  text-align: left;
  animation: rise 1.2s ease-out both;
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 14px); } to { opacity: 1; transform: translate(-50%, 0); } }

.count {
  margin: 0 0 6px 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}
h1 {
  margin: 0 0 10px 4px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.45rem, 3.6vw, 2.1rem);
  line-height: 1.15;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.65);
}
.field {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 8px 6px 20px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field:focus-within {
  border-color: rgba(255, 213, 74, 0.7);
  box-shadow: 0 0 0 4px rgba(255, 213, 74, 0.14), 0 0 30px rgba(255, 213, 74, 0.25);
}
#text {
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  outline: 0;
  color: var(--cream);
  font: 500 1rem var(--sans);
  padding: 10px 0;
}
#text::placeholder { color: rgba(255, 246, 220, 0.55); }
.left {
  font-size: 0.75rem;
  color: var(--muted);
  margin-right: 8px;
  min-width: 2ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.left.warn { color: #ffb26b; }
#send {
  flex: none;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 213, 74, 0.16);
  display: grid;
  place-items: center;
  transition: background 0.2s, transform 0.2s;
}
#send:hover { background: rgba(255, 213, 74, 0.32); transform: scale(1.06); }
#send:disabled { opacity: 0.5; cursor: progress; }

.sign { margin: 8px 0 0 12px; font-size: 0.8rem; }
.link {
  background: none; border: 0; padding: 0;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}
#name {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--cream);
  font: 500 0.85rem var(--sans);
  padding: 8px 14px;
  width: 220px;
  max-width: 100%;
  outline: 0;
}
#name:focus { border-color: rgba(255, 213, 74, 0.7); }
.last {
  margin: 8px 0 0 4px;
  font-size: 0.78rem;
  color: var(--muted);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7);
}

.privacy {
  margin: 4px 0 0 4px;
  font-size: 0.7rem;
  color: rgba(255, 246, 220, 0.5);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7);
}

/* message card */
.card {
  position: fixed;
  z-index: 5;
  width: min(300px, calc(100vw - 24px));
  background: rgba(255, 250, 232, 0.97);
  color: #1d2a44;
  border-radius: 18px;
  padding: 18px 18px 12px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), 0 0 40px rgba(255, 213, 74, 0.35);
  animation: pop 0.28s cubic-bezier(0.2, 1.2, 0.4, 1) both;
}
.card[hidden] { display: none; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.94); } to { opacity: 1; transform: none; } }
.card-prompt {
  margin: 0 22px 8px 0;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7b6a3a;
}
.card-text {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: 1.28rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.card-meta { margin: 0 0 12px; font-size: 0.78rem; color: #66708a; }
.card-actions { display: flex; gap: 4px; border-top: 1px solid rgba(29, 42, 68, 0.12); padding-top: 8px; }
.act {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 0;
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  color: #34425f;
}
.act:hover { background: rgba(29, 42, 68, 0.08); }
.act[aria-pressed="true"] { color: #b57d00; }
.act[aria-pressed="true"] svg { fill: currentColor; }
.act.quiet { margin-left: auto; color: #7a849b; }
.close {
  position: absolute;
  top: 8px; right: 10px;
  width: 30px; height: 30px;
  border: 0;
  border-radius: 50%;
  background: none;
  font-size: 1.5rem;
  line-height: 1;
  color: #66708a;
}
.close:hover { background: rgba(29, 42, 68, 0.08); }

/* list dialog */
dialog {
  width: min(560px, calc(100vw - 24px));
  max-height: min(78vh, 720px);
  background: #0f1d36;
  color: var(--cream);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px 22px 18px;
}
dialog::backdrop { background: rgba(5, 10, 22, 0.72); }
dialog .close { color: var(--muted); }
dialog h2 { margin: 0 0 4px; font: 500 1.4rem var(--serif); }
.list-sub { margin: 0 0 14px; color: var(--muted); font-size: 0.85rem; }
#list-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
#list-items li { border-top: 1px solid var(--line); padding-top: 10px; }
#list-items q { font: 1.05rem/1.35 var(--serif); quotes: none; overflow-wrap: anywhere; }
#list-items small { display: block; margin-top: 3px; color: var(--muted); }

.toast {
  position: fixed;
  left: 50%;
  top: 64px;
  transform: translateX(-50%);
  z-index: 9;
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  animation: pop 0.25s ease-out both;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast[hidden] { display: none; }
.nojs { position: fixed; inset: 40% 0 auto; text-align: center; }

@media (max-width: 560px) {
  .top { padding-left: 14px; padding-right: 14px; }
  .brand span { display: none; }
  .chip { padding: 8px 12px; }
  .card { left: 12px !important; right: 12px; top: auto !important; bottom: 12px; width: auto; }
  .dock { bottom: max(12px, env(safe-area-inset-bottom)); }
  h1 { font-size: 1.35rem; }
  body.card-open .dock { opacity: 0; pointer-events: none; }
}

@media (prefers-reduced-motion: reduce) {
  .dock, .card, .toast { animation: none; }
}
