@import url('https://fonts.googleapis.com/css2?family=Special+Elite&display=swap');

:root {
  --background: #fbf7e8;
  --paper: #fffaf0;
  --ink: #191812;
  --muted-ink: #655f50;
  --stamp: #8f3d2e;
  --soft-gold: #e9ddb8;
  --line: rgb(25 24 18 / 58%);
  --font-typewriter: 'Special Elite', 'Courier New', 'FangSong', 'STFangsong', monospace;
  --ease-spring: cubic-bezier(.2, .85, .25, 1.12);
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--background);
  color: var(--ink);
  font-family: var(--font-typewriter);
}

button,
input { font: inherit; }

button {
  appearance: none;
  cursor: pointer;
}

button:disabled { cursor: not-allowed; opacity: .45; }

[hidden] { display: none !important; }

.counter-page {
  isolation: isolate;
  position: relative;
  display: grid;
  grid-template-rows: 48px minmax(0, 1fr);
  width: 100%;
  height: 100svh;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 14%, rgb(255 255 255 / 66%), transparent 30%),
    radial-gradient(circle at 78% 76%, rgb(155 126 68 / 5%), transparent 35%),
    var(--background);
}

.pattern-overlay,
.paper-grain {
  pointer-events: none;
  position: absolute;
  inset: 0;
}

.pattern-overlay {
  z-index: 0;
  background: url('./assets/eau-de-click-pattern.png') center / cover no-repeat;
  opacity: .16;
  mix-blend-mode: multiply;
}

.paper-grain {
  z-index: -1;
  opacity: .14;
  background-image:
    repeating-linear-gradient(8deg, transparent 0 4px, rgb(31 29 20 / 5%) 5px),
    repeating-linear-gradient(96deg, transparent 0 7px, rgb(255 255 255 / 12%) 8px);
  mix-blend-mode: multiply;
}

.site-header {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  padding: max(7px, env(safe-area-inset-top)) 14px 6px;
  border-bottom: 1px solid var(--line);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .11em;
}

.site-header p { overflow: hidden; margin: 0; text-overflow: ellipsis; white-space: nowrap; }

.sound-toggle {
  display: inline-flex;
  min-width: 44px;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 3px 7px;
  border: 1px solid rgb(25 24 18 / 68%);
  border-radius: 1px;
  background: rgb(255 250 240 / 55%);
  color: var(--ink);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .08em;
  box-shadow: 2px 2px 0 rgb(25 24 18 / 10%);
}

.sound-toggle:hover { background: var(--paper); }

.sound-toggle:focus-visible,
.shelf-perfume:focus-visible,
.hero-edit-button:focus-visible,
.add-perfume-button:focus-visible,
.modal-close:focus-visible,
.bottle-button:focus-visible,
.bottle-submit:focus-visible,
.style-option:focus-within,
.name-field input:focus-visible {
  outline: 2px dashed var(--stamp);
  outline-offset: 3px;
}

.counter-stage {
  position: relative;
  z-index: 2;
  display: grid;
  min-height: 0;
  grid-template-rows: auto minmax(155px, 1fr) auto auto;
  align-items: center;
  justify-items: center;
  gap: clamp(3px, 1vh, 9px);
  padding: clamp(8px, 1.6vh, 14px) 12px max(10px, env(safe-area-inset-bottom));
}

.counter-copy { z-index: 4; text-align: center; }

.eyebrow {
  max-width: 82vw;
  overflow: hidden;
  margin: 0 0 clamp(10px, 2vh, 16px);
  font-size: clamp(9px, 2.7vw, 11px);
  font-weight: 700;
  letter-spacing: .18em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.counter-copy h1 {
  margin: 0;
  font-size: clamp(42px, 8vh, 72px);
  font-weight: 400;
  letter-spacing: -.055em;
  line-height: .9;
  font-variant-numeric: lining-nums tabular-nums;
}

.counter-note {
  margin: 4px 0 0;
  color: var(--stamp);
  font-size: clamp(8px, 2.2vw, 10px);
  letter-spacing: .03em;
  transform: rotate(-.6deg);
}

.hero-bottle {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 0;
  place-items: center;
  overflow: visible;
}

.bottle-scene {
  position: relative;
  display: grid;
  width: min(54vw, 232px);
  max-height: 100%;
  place-items: center;
  transform-origin: 50% 86%;
}

.bottle-button {
  position: relative;
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  transition: transform 140ms ease;
  -webkit-tap-highlight-color: transparent;
}

.bottle-button::after {
  content: '';
  position: absolute;
  right: 17%;
  bottom: 2%;
  left: 17%;
  z-index: -1;
  height: 7%;
  border-radius: 50%;
  background: rgb(33 30 19 / 18%);
  filter: blur(7px);
}

.bottle-button:hover { transform: rotate(.45deg) translateY(-2px); }
.bottle-button.is-pressed { transform: translateY(4px) scale(.985); }

.bottle-button img {
  display: block;
  width: 100%;
  max-height: min(42vh, 330px);
  height: auto;
  object-fit: contain;
  user-select: none;
  filter: saturate(.76) contrast(1.03);
}

.bottle-label-text {
  pointer-events: none;
  position: absolute;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 3px;
  color: #17150f;
  font-size: clamp(7px, 2vw, 11px);
  font-weight: 700;
  letter-spacing: .05em;
  line-height: 1.12;
  overflow-wrap: anywhere;
  text-align: center;
  text-transform: uppercase;
  text-wrap: balance;
  transform: rotate(-.45deg);
}

.bottle-classic .bottle-label-text { top: 50%; left: 22.5%; width: 55%; height: 18.5%; }
.bottle-cylinder_01 .bottle-label-text { top: 39%; left: 34%; width: 32%; height: 33%; }
.bottle-cylinder_02 .bottle-label-text { top: 47%; left: 18%; width: 64%; height: 29%; }
.bottle-square_01 .bottle-label-text { top: 42%; left: 30%; width: 40%; height: 36%; }
.bottle-square_02 .bottle-label-text { top: 49%; left: 14%; width: 72%; height: 22%; }

.hero-sync {
  display: inline-flex;
  min-width: 156px;
  min-height: 18px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted-ink);
  font-size: 7px;
  font-weight: 700;
  letter-spacing: .09em;
  line-height: 1.2;
  white-space: nowrap;
}

.hero-sync.sync-waiting,
.hero-sync.sync-syncing { color: var(--stamp); }

.sync-symbol { font-size: 10px; }

.shelf-block {
  width: min(100%, 560px);
  min-width: 0;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

.shelf-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
  color: var(--muted-ink);
  font-size: 7px;
  font-weight: 700;
  letter-spacing: .12em;
}

.perfume-shelf {
  position: relative;
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: flex-end;
  gap: 5px;
  padding: 1px 2px 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-color: rgb(25 24 18 / 25%) transparent;
  scrollbar-width: thin;
}

.perfume-shelf::after {
  content: '';
  position: absolute;
  right: 0;
  bottom: 4px;
  left: 0;
  height: 4px;
  border-top: 1px solid rgb(25 24 18 / 58%);
  border-bottom: 1px solid rgb(143 61 46 / 20%);
  transform: rotate(-.18deg);
  pointer-events: none;
}

.shelf-loading {
  display: grid;
  min-width: 150px;
  min-height: 76px;
  place-items: center;
  color: var(--muted-ink);
  font-size: 7px;
  letter-spacing: .1em;
}

.shelf-item,
.add-perfume-button {
  position: relative;
  display: flex;
  min-width: 66px;
  min-height: 76px;
  flex: 0 0 66px;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 0 2px 4px;
  scroll-snap-align: center;
}

.shelf-perfume {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 72px;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 1px;
  padding: 2px 1px 3px;
  border: 0;
  background: transparent;
  color: var(--ink);
  transition: transform 180ms var(--ease-spring), filter 180ms ease;
}

.shelf-perfume:hover,
.add-perfume-button:hover { transform: translateY(-2px) rotate(-.4deg); }

.shelf-perfume.is-selected {
  transform: translateY(-3px) rotate(-.5deg);
  filter: drop-shadow(2px 3px 0 rgb(143 61 46 / 15%));
}

.shelf-perfume.is-selected::after {
  content: '';
  position: absolute;
  right: 7px;
  bottom: 0;
  left: 7px;
  height: 7px;
  border-bottom: 2px solid var(--stamp);
  border-radius: 50%;
  transform: rotate(-2deg);
}

.mini-bottle {
  position: relative;
  display: grid;
  width: 38px;
  height: 47px;
  place-items: end center;
}

.mini-bottle img {
  display: block;
  max-width: 38px;
  max-height: 47px;
  object-fit: contain;
  filter: saturate(.72) contrast(1.04);
}

.mini-bottle .bottle-label-text {
  padding: 1px;
  font-size: 3px;
  letter-spacing: 0;
}

.mini-name {
  width: 100%;
  overflow: hidden;
  font-size: 6px;
  font-weight: 700;
  letter-spacing: .03em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.mini-count {
  color: var(--stamp);
  font-size: 7px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.hero-edit-button {
  position: absolute;
  z-index: 8;
  top: 6px;
  right: max(8px, calc(50% - 150px));
  display: inline-flex;
  min-width: 48px;
  height: 44px;
  align-items: center;
  justify-content: center;
  padding: 2px 8px 0;
  border: 1px solid rgb(25 24 18 / 72%);
  border-radius: 0;
  background: rgb(255 250 240 / 78%);
  color: var(--ink);
  font-family: var(--font-typewriter);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .13em;
  box-shadow: 3px 3px 0 rgb(25 24 18 / 10%);
  transform: rotate(1.5deg);
  transition: transform 150ms var(--ease-spring), background 150ms ease, color 150ms ease;
}

.hero-edit-button:hover {
  background: var(--ink);
  color: var(--paper);
  transform: rotate(-1deg) translateY(-2px);
}

.add-perfume-button {
  gap: 2px;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--stamp);
  transition: transform 160ms var(--ease-spring);
}

.add-plus {
  position: relative;
  display: block;
  width: 34px;
  height: 34px;
  border: 1px dashed currentColor;
  border-radius: 50%;
}

.add-plus::before,
.add-plus::after {
  position: absolute;
  top: 50%;
  left: 50%;
  display: block;
  width: 14px;
  height: 1px;
  background: currentColor;
  content: '';
  transform: translate(-50%, -50%);
}

.add-plus::after {
  transform: translate(-50%, -50%) rotate(90deg);
}

.add-perfume-button small { font-size: 6px; font-weight: 700; letter-spacing: .12em; }

.bottle-scene.bottle-exit-left { animation: bottle-exit-left 190ms cubic-bezier(.55, .05, .7, .25) both; }
.bottle-scene.bottle-exit-right { animation: bottle-exit-right 190ms cubic-bezier(.55, .05, .7, .25) both; }
.bottle-scene.bottle-enter-left { animation: bottle-enter-left 470ms var(--ease-spring) both; }
.bottle-scene.bottle-enter-right { animation: bottle-enter-right 470ms var(--ease-spring) both; }

.spray-burst {
  pointer-events: none;
  position: absolute;
  z-index: 6;
  top: 7%;
  left: 55%;
  width: 18px;
  height: 18px;
}

.mist-particle,
.mist-cloud { position: absolute; display: block; border-radius: 50%; opacity: 0; }

.mist-particle {
  width: var(--mist-size);
  height: var(--mist-size);
  background: rgb(183 175 150 / 30%);
  animation: mist-particle 720ms ease-out var(--mist-delay) both;
}

.mist-cloud { background: rgb(224 219 198 / 28%); filter: blur(4px); animation: mist-cloud 620ms ease-out both; }
.mist-cloud-one { width: 52px; height: 16px; }
.mist-cloud-two { width: 72px; height: 24px; animation-delay: 70ms; }

.modal-backdrop {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: grid;
  padding: 12px;
  place-items: center;
  background: rgb(25 24 18 / 38%);
  backdrop-filter: blur(3px);
  animation: backdrop-in 180ms ease both;
}

.add-panel {
  position: relative;
  width: min(100%, 520px);
  max-height: calc(100svh - 24px);
  overflow-y: auto;
  padding: 22px 16px 18px;
  border: 1px solid var(--ink);
  background:
    linear-gradient(90deg, transparent 0 49.9%, rgb(25 24 18 / 4%) 50%, transparent 50.1%),
    var(--paper);
  box-shadow: 7px 7px 0 rgb(25 24 18 / 22%);
  animation: panel-in 320ms var(--ease-spring) both;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgb(25 24 18 / 45%);
  background: transparent;
  color: var(--ink);
  font-size: 22px;
}

.bottle-form { margin: 0; }

.form-title-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  margin: 4px 50px 18px 0;
  gap: 16px;
}

.section-kicker {
  margin: 0 0 5px;
  color: var(--stamp);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .17em;
}

.form-title-row h2 { margin: 0; font-size: clamp(23px, 7vw, 34px); font-weight: 400; letter-spacing: -.04em; }

.form-title-row > span {
  padding: 4px 6px;
  border: 1px solid var(--stamp);
  color: var(--stamp);
  font-size: 9px;
  transform: rotate(2deg);
}

.name-field {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  margin-bottom: 18px;
  gap: 7px;
}

.name-field > span,
.style-picker legend {
  grid-column: 1 / -1;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .11em;
}

.name-field input {
  min-width: 0;
  height: 44px;
  padding: 5px 2px;
  border: 0;
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 18px;
}

.name-field small { color: var(--muted-ink); font-size: 8px; }

.style-picker { margin: 0; padding: 0; border: 0; }
.style-picker legend { margin-bottom: 9px; }

.style-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.style-option {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 98px;
  grid-template-columns: 56px 1fr;
  align-items: center;
  padding: 7px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgb(248 241 217 / 30%);
}

.style-option:hover { background: rgb(233 221 184 / 24%); }
.style-option.is-selected { background: rgb(233 221 184 / 46%); box-shadow: inset 0 0 0 2px var(--stamp); }
.style-option input { position: absolute; opacity: 0; pointer-events: none; }

.style-art { position: relative; display: block; width: 50px; }
.style-art img { display: block; width: 100%; max-height: 80px; height: auto; object-fit: contain; }
.style-art .bottle-label-text { padding: 1px; font-size: 3px; letter-spacing: 0; }
.style-copy { display: flex; min-width: 0; flex-direction: column; gap: 4px; }
.style-copy strong { font-size: 7px; letter-spacing: .06em; }
.style-copy small { color: var(--muted-ink); font-size: 6px; letter-spacing: .07em; }
.style-check { position: absolute; top: 7px; right: 7px; color: var(--stamp); font-size: 12px; }

.form-actions { display: flex; margin-top: 16px; flex-direction: column; align-items: stretch; gap: 8px; }

.bottle-submit {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--ink);
  color: var(--paper);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .09em;
  box-shadow: 3px 3px 0 rgb(143 61 46 / 32%);
}

.delete-perfume {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border: 0;
  border-bottom: 1px dashed var(--stamp);
  background: transparent;
  color: var(--stamp);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .09em;
}

.delete-perfume:hover { background: rgb(143 61 46 / 7%); }
.delete-perfume.is-confirming {
  border-color: var(--stamp);
  background: var(--stamp);
  color: var(--paper);
  box-shadow: 3px 3px 0 rgb(25 24 18 / 16%);
}
.delete-perfume:focus-visible { outline: 2px dashed var(--stamp); outline-offset: 3px; }

.form-message { min-height: 26px; color: var(--muted-ink); font-size: 8px; line-height: 1.45; text-align: center; }
.form-message.message-saved { color: #4c6332; }
.form-message.message-error { color: var(--stamp); }

.toast {
  position: fixed;
  z-index: 40;
  right: 14px;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 14px;
  display: flex;
  max-width: 420px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  gap: 7px;
  padding: 9px 12px;
  border: 1px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font-size: 8px;
  box-shadow: 4px 4px 0 rgb(25 24 18 / 18%);
  animation: toast-in 300ms var(--ease-spring) both;
}

noscript {
  position: fixed;
  z-index: 99;
  right: 12px;
  bottom: 12px;
  left: 12px;
  padding: 12px;
  border: 1px solid var(--stamp);
  background: var(--paper);
  color: var(--stamp);
  font-size: 12px;
  text-align: center;
}

@keyframes bottle-exit-left {
  to { opacity: 0; transform: translateX(-72%) translateY(-6px) rotate(-12deg) scale(.74); }
}

@keyframes bottle-exit-right {
  to { opacity: 0; transform: translateX(72%) translateY(-6px) rotate(12deg) scale(.74); }
}

@keyframes bottle-enter-left {
  0% { opacity: 0; transform: translateX(-75%) translateY(-10px) rotate(-11deg) scale(.72); }
  72% { opacity: 1; transform: translateX(4%) translateY(1px) rotate(1.2deg) scale(1.025); }
  100% { opacity: 1; transform: none; }
}

@keyframes bottle-enter-right {
  0% { opacity: 0; transform: translateX(75%) translateY(-10px) rotate(11deg) scale(.72); }
  72% { opacity: 1; transform: translateX(-4%) translateY(1px) rotate(-1.2deg) scale(1.025); }
  100% { opacity: 1; transform: none; }
}

@keyframes mist-particle {
  0% { opacity: 0; transform: translate(0, 0) scale(.25); }
  16% { opacity: .72; }
  100% { opacity: 0; transform: translate(var(--mist-x), var(--mist-y)) scale(1.25); }
}

@keyframes mist-cloud {
  0% { opacity: 0; transform: translateX(0) scale(.2, .5); }
  22% { opacity: .28; }
  100% { opacity: 0; transform: translateX(95px) scale(1.2, 1.5); }
}

@keyframes backdrop-in { from { opacity: 0; } }

@keyframes panel-in {
  from { opacity: 0; transform: translateY(18px) rotate(.8deg) scale(.96); }
  to { opacity: 1; transform: none; }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(18px) scale(.96); }
  to { opacity: 1; transform: none; }
}

@media (min-width: 700px) {
  .counter-page { grid-template-rows: 56px minmax(0, 1fr); }
  .site-header { padding-right: 28px; padding-left: 28px; font-size: 9px; }
  .counter-stage { grid-template-rows: auto minmax(180px, 1fr) auto auto; padding-right: 20px; padding-left: 20px; }
  .bottle-scene { width: min(30vw, 260px); }
  .shelf-block { width: min(80vw, 620px); }
  .shelf-item, .add-perfume-button { min-width: 74px; flex-basis: 74px; min-height: 82px; }
  .add-panel { padding: 28px 24px 22px; }
}

@media (max-height: 700px) {
  .counter-page { grid-template-rows: 42px minmax(0, 1fr); }
  .site-header { padding-top: 5px; padding-bottom: 4px; }
  .counter-stage { grid-template-rows: auto minmax(120px, 1fr) auto auto; gap: 2px; padding-top: 5px; padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .counter-copy h1 { font-size: clamp(36px, 7vh, 48px); }
  .counter-note { margin-top: 2px; }
  .bottle-scene { width: min(47vw, 190px); }
  .bottle-button img { max-height: 35vh; }
  .shelf-block { padding-top: 4px; }
  .shelf-heading { margin-bottom: 3px; }
  .shelf-item, .add-perfume-button { min-width: 60px; min-height: 68px; flex-basis: 60px; padding-top: 3px; }
  .mini-bottle { width: 32px; height: 39px; }
  .mini-bottle img { max-width: 32px; max-height: 39px; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .counter-stage {
    grid-template-columns: minmax(120px, .75fr) minmax(150px, 1fr) minmax(220px, 1.3fr);
    grid-template-rows: 1fr auto auto;
    column-gap: 14px;
  }
  .counter-copy { grid-column: 1; grid-row: 1 / 3; }
  .hero-bottle { grid-column: 2; grid-row: 1 / 4; }
  .press-instruction { grid-column: 1; grid-row: 3; }
  .hero-sync { grid-column: 3; grid-row: 2; }
  .shelf-block { grid-column: 3; grid-row: 1; align-self: end; }
  .bottle-scene { width: min(20vw, 120px); }
}

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