:root {
  color-scheme: light;
  --ivory: #f8f5ee;
  --paper: #fffdf8;
  --forest: #073d2f;
  --forest-soft: #165744;
  --ink: #10271f;
  --muted: #7d817b;
  --gold: #b58a3a;
  --line: rgba(7, 61, 47, 0.16);
  --shadow: 0 24px 70px rgba(35, 44, 35, 0.11);
  --serif: "Playfair Display", Georgia, serif;
  --sans: "Manrope", system-ui, sans-serif;
  font-family: var(--sans);
  background: var(--ivory);
  color: var(--ink);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--ivory); }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 8% 8%, rgba(255,255,255,.92), transparent 34%),
    radial-gradient(circle at 90% 85%, rgba(212,194,157,.14), transparent 35%),
    var(--ivory);
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .22;
  z-index: 20;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.045'/%3E%3C/svg%3E");
}

.app-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 clamp(24px, 4vw, 68px) 36px;
}

.site-header {
  height: 112px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.wordmark, .dialog-wordmark {
  font-family: var(--serif);
  color: var(--forest);
  letter-spacing: -.035em;
}

.wordmark {
  appearance: none;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: clamp(29px, 3vw, 44px);
  cursor: pointer;
}

.participant {
  border: 0;
  padding: 8px 0 8px 18px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.participant::after { content: "  ·  change"; color: var(--forest); }

.voting-view {
  width: min(1020px, 100%);
  margin: 0 auto;
  padding-top: clamp(28px, 4vw, 52px);
  text-align: center;
  animation: enter .7s cubic-bezier(.2,.7,.2,1) both;
}

.progress-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 22px;
  align-items: center;
  margin-bottom: 18px;
}

.progress-copy {
  min-width: 76px;
  color: var(--muted);
  font-size: 15px;
  letter-spacing: .08em;
}

.progress-copy #currentNumber {
  color: var(--forest);
  font-family: var(--serif);
  font-size: 26px;
  letter-spacing: -.03em;
}

.progress-divider { margin: 0 7px; color: var(--gold); }
.progress-track { height: 1px; background: var(--line); overflow: hidden; }
.progress-fill { width: 1%; height: 100%; background: var(--forest); transition: width .7s cubic-bezier(.2,.7,.2,1); }

.voting-note {
  margin: 0 0 20px;
  text-align: center;
}

.voting-note h2 {
  margin: 0;
  color: var(--forest);
  font-family: var(--serif);
  font-size: clamp(21px, 2.3vw, 28px);
  font-weight: 500;
  letter-spacing: -.025em;
  line-height: 1.15;
}

.voting-note p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .04em;
}

.product-stage {
  position: relative;
  height: min(58vh, 650px);
  min-height: 410px;
  margin: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  border: 1px solid rgba(7,61,47,.08);
  background: #f0ede5;
  box-shadow: var(--shadow);
}

.product-stage img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  display: block;
  object-fit: contain;
  object-position: center center;
  opacity: 0;
  transform: scale(1.018);
  transition: opacity .55s ease, transform .85s cubic-bezier(.2,.7,.2,1);
}

.product-stage img.is-ready { opacity: 1; transform: scale(1); }
.product-stage.is-leaving img { opacity: 0; transform: scale(.985); transition-duration: .25s; }

.image-loader {
  position: absolute;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-top-color: var(--forest);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.image-loader[hidden] { display: none; }

.product-meta { margin: 20px 0 18px; }

.product-link, .skip-button {
  color: var(--forest);
  text-underline-offset: 5px;
  text-decoration-color: var(--gold);
  text-decoration-thickness: 1px;
}

.product-link { font-size: 15px; }
.product-link span { display: inline-block; margin-left: 5px; transition: transform .2s ease; }
.product-link:hover span { transform: translate(2px, -2px); }

.vote-actions {
  display: flex;
  justify-content: center;
  gap: clamp(16px, 4vw, 46px);
}

.vote-button {
  width: min(220px, 42vw);
  min-height: 72px;
  border-radius: 999px;
  border: 1px solid var(--forest);
  background: rgba(255,255,255,.42);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}

.vote-button svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.vote-up { background: var(--forest); color: var(--paper); box-shadow: 0 14px 30px rgba(7,61,47,.18); }
.vote-button:hover { transform: translateY(-2px); box-shadow: 0 14px 28px rgba(7,61,47,.13); }
.vote-button:active { transform: translateY(0) scale(.985); }
.vote-button:focus-visible, .skip-button:focus-visible, .wordmark:focus-visible, .participant:focus-visible, .start-button:focus-visible, input:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
.vote-button:disabled { cursor: wait; opacity: .65; }

.skip-button {
  display: block;
  margin: 14px auto 0;
  padding: 8px 18px;
  border: 0;
  background: transparent;
  text-decoration: underline;
  cursor: pointer;
}

.keyboard-hint { margin: 2px 0 0; color: #a5a39d; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }

.completion-view {
  min-height: calc(100vh - 112px);
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 70px 20px 120px;
  text-align: center;
  animation: enter .8s cubic-bezier(.2,.7,.2,1) both;
}

.completion-mark {
  width: 92px;
  height: 92px;
  display: grid;
  place-items: center;
  border: 1px solid var(--forest);
  border-radius: 50%;
}

.completion-mark svg { width: 48px; fill: none; stroke: var(--forest); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.completion-kicker { margin: 34px 0 10px; color: var(--gold); font-size: 12px; letter-spacing: .16em; text-transform: uppercase; }
.completion-view h1 { margin: 0; color: var(--forest); font-family: var(--serif); font-size: clamp(48px, 8vw, 92px); font-weight: 500; letter-spacing: -.045em; }
.completion-view > p:not(.completion-kicker) { max-width: 480px; margin: 18px 0 36px; color: var(--muted); line-height: 1.7; }

.secondary-button {
  border: 1px solid var(--forest);
  border-radius: 999px;
  padding: 15px 25px;
  background: transparent;
  cursor: pointer;
}

.name-dialog {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 24px;
  border: 0;
  background: rgba(248,245,238,.76);
  backdrop-filter: blur(18px);
}

.name-dialog[open] { display: grid; place-items: center; animation: veil .4s ease both; }
.name-dialog::backdrop { background: rgba(248,245,238,.82); }

.name-card {
  width: min(520px, 100%);
  padding: clamp(36px, 6vw, 64px);
  border: 1px solid var(--line);
  background: rgba(255,253,248,.94);
  box-shadow: var(--shadow);
  animation: cardEnter .65s cubic-bezier(.2,.8,.2,1) both;
}

.dialog-wordmark { margin: 0; font-size: 38px; text-align: center; }
.gold-rule { width: 58px; height: 1px; margin: 26px auto 34px; background: var(--gold); }
.name-card h1 { margin: 0 0 12px; font-family: var(--serif); color: var(--forest); font-size: 42px; font-weight: 500; letter-spacing: -.035em; text-align: center; }
.dialog-copy { margin: 0 auto 32px; max-width: 390px; color: var(--muted); font-size: 14px; line-height: 1.65; text-align: center; }
.name-card label { display: block; margin-bottom: 9px; color: var(--forest); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.name-card input { width: 100%; height: 58px; padding: 0 18px; border: 1px solid var(--line); border-radius: 0; background: var(--paper); color: var(--ink); font-size: 16px; }
.name-card input::placeholder { color: #aaa9a3; }
.form-error { min-height: 20px; margin: 6px 0 0; color: #9b4036; font-size: 12px; }
.start-button { width: 100%; min-height: 58px; border: 0; background: var(--forest); color: white; display: flex; align-items: center; justify-content: center; gap: 22px; cursor: pointer; transition: background .2s ease; }
.start-button:hover { background: var(--forest-soft); }

.save-status { position: fixed; right: 18px; bottom: 16px; display: flex; align-items: center; gap: 7px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,253,248,.88); color: var(--muted); font-size: 11px; opacity: 0; transform: translateY(6px); transition: opacity .25s ease, transform .25s ease; z-index: 30; }
.save-status.is-visible { opacity: 1; transform: translateY(0); }
.save-status span { width: 6px; height: 6px; border-radius: 50%; background: #4b8b64; }
.save-status.is-pending span { background: var(--gold); }
.save-status b { font-weight: 500; }

[hidden] { display: none !important; }

@keyframes enter { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes cardEnter { from { opacity: 0; transform: translateY(18px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes veil { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 720px) {
  .app-shell { padding-inline: 16px; padding-bottom: 20px; }
  .site-header { height: 82px; }
  .wordmark { font-size: 29px; }
  .participant { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
  .participant::after { content: ""; }
  .voting-view { padding-top: 20px; }
  .progress-row { margin-inline: 2px; margin-bottom: 12px; gap: 14px; }
  .voting-note { margin-bottom: 14px; }
  .voting-note h2 { font-size: 20px; }
  .voting-note p { margin-top: 4px; font-size: 11px; }
  .product-stage { height: min(52vh, 480px); min-height: 330px; box-shadow: 0 14px 42px rgba(35,44,35,.1); }
  .product-meta { margin: 15px 0 14px; }
  .vote-actions { gap: 12px; }
  .vote-button { min-height: 66px; }
  .vote-button span { display: none; }
  .vote-button svg { width: 32px; height: 32px; }
  .keyboard-hint { display: none; }
  .skip-button { margin-top: 8px; }
  .name-dialog { padding: 12px; }
  .name-card { padding: 38px 24px; }
  .dialog-wordmark { font-size: 32px; }
  .name-card h1 { font-size: 37px; }
}

@media (max-height: 760px) and (min-width: 721px) {
  .site-header { height: 82px; }
  .voting-view { padding-top: 18px; }
  .product-stage { height: 48vh; min-height: 320px; }
  .vote-button { min-height: 62px; }
  .product-meta { margin: 12px 0; }
  .keyboard-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
