:root {
  --bg: #dde3e8;
  --paper: #f7f5f0;
  --ink: #1c2b45;
  --ink-soft: #46566e;
  --line: #b7c0cb;
  --stamp: #a8841f;
  --stamp-bg: #f1e6c4;
  --alert: #7a1f1f;
  --alert-bg: #f3dede;
  --focus: #1c2b45;
  --win: #1f6d4a;
  --win-bg: #e8f3ec;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161d;
    --paper: #1b212b;
    --ink: #e4e8ee;
    --ink-soft: #a3aebd;
    --line: #333d4b;
    --stamp: #e0c987;
    --stamp-bg: #3a3320;
    --alert: #e08a8a;
    --alert-bg: #3a2323;
    --focus: #e4e8ee;
    --win: #7fd6ab;
    --win-bg: #163226;
  }
}
:root[data-theme="dark"] {
  --bg: #12161d;
  --paper: #1b212b;
  --ink: #e4e8ee;
  --ink-soft: #a3aebd;
  --line: #333d4b;
  --stamp: #e0c987;
  --stamp-bg: #3a3320;
  --alert: #e08a8a;
  --alert-bg: #3a2323;
  --focus: #e4e8ee;
  --win: #7fd6ab;
  --win-bg: #163226;
}
* { box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: Georgia, 'Times New Roman', serif;
  margin: 0;
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}
.mono { font-family: 'Courier New', Courier, monospace; letter-spacing: 0.02em; }
.card { background: var(--paper); border: 1px solid var(--line); }
a, button { font-family: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.stamp { border: 2px solid var(--stamp); color: var(--stamp); background: var(--stamp-bg); }
.field-label {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}
.btn-primary { background: var(--ink); color: var(--paper); border: 1px solid var(--ink); }
.btn-secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.dodge { transition: transform 0.14s ease-out; }
@media (prefers-reduced-motion: reduce) { .dodge { transition: none; } }
.toast-enter { animation: slideIn 0.25s ease-out; }
@keyframes slideIn { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.breadcrumb a { text-decoration: underline; text-underline-offset: 3px; }
::selection { background: var(--stamp-bg); color: var(--ink); }

/* iPhone / touch friendliness */
button, .btn-primary, .btn-secondary {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
input[type="text"], select {
  font-size: 16px; /* prevents iOS Safari auto-zoom on focus */
}
input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
#chatBubble {
  bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
  right: calc(1.25rem + env(safe-area-inset-right, 0px));
}
#consentLayer {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
#toastLayer {
  top: calc(1rem + env(safe-area-inset-top, 0px));
}
#modalLayer {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (max-width: 480px) {
  .ticker-track { animation-duration: 16s; }
}

/* ticker */
.ticker-track {
  display: flex;
  white-space: nowrap;
  animation: ticker 22s linear infinite;
}
@media (prefers-reduced-motion: reduce) { .ticker-track { animation: none; } }
@keyframes ticker { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* win overlay */
#cv1-win-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(10, 20, 15, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}
.win-card {
  background: var(--win-bg);
  border: 1px solid var(--win);
  color: var(--ink);
  max-width: 26rem;
  width: 100%;
  padding: 1.75rem;
  font-family: Georgia, serif;
  text-align: left;
}
.win-eyebrow {
  font-family: 'Courier New', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--win);
  margin: 0 0 0.5rem 0;
}
.win-card h2 { margin: 0 0 0.75rem 0; color: var(--win); font-size: 1.4rem; }
.win-card p { margin: 0 0 1rem 0; font-size: 0.9rem; color: var(--ink-soft); }
.win-label { display: block; font-family: 'Courier New', monospace; font-size: 0.7rem; letter-spacing: 0.06em; color: var(--ink-soft); margin-bottom: 0.25rem; }
.win-card input[type="text"] {
  width: 100%; padding: 0.5rem; margin-bottom: 1rem;
  border: 1px solid var(--win); background: transparent; color: var(--ink); font-size: 0.9rem;
}
.win-card div:has(button) {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
}
.win-card button {
  font-size: 0.85rem; padding: 0.6rem 1.1rem; min-height: 44px; margin-top: 0.25rem; cursor: pointer;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
#cv1-win-download { background: var(--win); color: var(--win-bg); border: 1px solid var(--win); }
#cv1-win-close { background: transparent; color: var(--ink); border: 1px solid var(--line); }

/* confetti */
#cv1-confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
  overflow: hidden;
}
#cv1-confetti span {
  position: absolute;
  top: -10px;
  opacity: 0.9;
  border-radius: 1px;
}
@keyframes cv1-fall {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 0.9; }
  100% { transform: translate(var(--drift, 0px), 110vh) rotate(var(--spin, 360deg)); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  #cv1-confetti { display: none; }
}
