:root {
  color-scheme: light;
  --bg: #f5eee4;
  --bg-glow: #fcf7f0;
  --surface: #fffbf6;
  --surface-sunk: #f0e6d9;
  --text: #2b1a1e;
  --muted: #6f5b5f;
  --line: #e4d6c6;
  --accent: #7b1e3c;
  --accent-strong: #62162f;
  --on-accent: #fff8f1;
  --gold: #99763f;
  --focus: #b6476d;
  --shadow: 0 1px 2px rgb(70 25 35 / 0.06), 0 14px 36px -14px rgb(70 25 35 / 0.22);

  --wine-red: #7a1a33;
  --wine-white: #e8cf7c;
  --wine-rose: #f0a08f;
  --wine-sparkling: #efd98c;
  --wine-sweet: #c7862c;

  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 18px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #160f11;
    --bg-glow: #2a181d;
    --surface: #1f1518;
    --surface-sunk: #150d10;
    --text: #f3e9e1;
    --muted: #b8a4a5;
    --line: #3b2a2f;
    --accent: #d0648a;
    --accent-strong: #e07b9e;
    --on-accent: #1a0c11;
    --gold: #d2b07a;
    --focus: #e890ad;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 14px 36px -14px rgb(0 0 0 / 0.7);
    --wine-red: #a8274c;
  }
}

body[data-style="red"] { --wine: var(--wine-red); }
body[data-style="white"] { --wine: var(--wine-white); }
body[data-style="rose"] { --wine: var(--wine-rose); }
body[data-style="sparkling"] { --wine: var(--wine-sparkling); }
body[data-style="sweet"] { --wine: var(--wine-sweet); }

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 560px at 50% -8%, var(--bg-glow), transparent 70%),
    var(--bg);
  color: var(--text);
  font: 400 16px/1.55 var(--sans);
}

.page {
  max-width: 680px;
  margin: 0 auto;
  padding: 20px 16px 32px;
}

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

/* ——— Language picker ——— */

.topbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.lang-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.lang-picker svg {
  position: absolute;
  left: 11px;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.6;
  pointer-events: none;
}

.lang-picker select {
  appearance: none;
  padding: 7px 30px 7px 33px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: 500 0.9rem/1.2 var(--sans);
  cursor: pointer;
}

.lang-picker select:hover {
  border-color: var(--muted);
}

.lang-picker::after {
  content: "";
  position: absolute;
  right: 13px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-right: 1.6px solid var(--muted);
  border-bottom: 1.6px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

/* ——— Masthead ——— */

.masthead {
  display: flex;
  align-items: center;
  gap: 18px;
}

.glass {
  width: 54px;
  height: 81px;
  flex: none;
}

.glass .outline {
  fill: none;
  stroke: var(--text);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.85;
}

.glass .wine {
  fill: var(--wine);
  transition: fill 0.5s ease;
}

.glass .bubbles {
  fill: rgb(255 255 255 / 0.85);
  opacity: 0;
  transition: opacity 0.3s ease;
}

body[data-style="sparkling"] .glass .bubbles {
  opacity: 1;
}

.glass .bubbles circle {
  animation: rise 2.4s ease-in infinite;
}

.glass .bubbles circle:nth-child(2) { animation-delay: 0.6s; }
.glass .bubbles circle:nth-child(3) { animation-delay: 1.2s; }
.glass .bubbles circle:nth-child(4) { animation-delay: 1.8s; }

@keyframes rise {
  0% { transform: translateY(4px); opacity: 0; }
  25% { opacity: 1; }
  100% { transform: translateY(-18px); opacity: 0; }
}

h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2.5rem, 1.9rem + 3vw, 3.5rem);
  line-height: 1;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.lede {
  margin: 26px 0 28px;
  max-width: 58ch;
  color: var(--muted);
  font-size: 1.05rem;
}

/* ——— Panels ——— */

.panel,
.result {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.panel {
  display: grid;
  gap: 22px;
}

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.field-label {
  padding: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.select {
  position: relative;
  display: block;
}

.select select {
  appearance: none;
  width: 100%;
  padding: 13px 44px 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-sunk);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.select::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 18px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.levels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-sunk);
}

.level {
  position: relative;
}

.level input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.level span {
  display: block;
  padding: 10px 6px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 500;
  text-align: center;
  transition: background 0.2s ease, color 0.2s ease;
}

.level input:hover + span {
  color: var(--text);
}

.level input:checked + span {
  background: var(--surface);
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.1);
}

.level input:focus-visible + span {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.level-blurb {
  min-height: 1.5em;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-style: italic;
}

/* ——— Buttons ——— */

.btn {
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: 600 0.95rem/1 var(--sans);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.btn:hover {
  border-color: var(--muted);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  padding: 16px 20px;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 1.05rem;
}

.btn-primary:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

select:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ——— Result ——— */

.result {
  margin-top: 20px;
}

.result-meta {
  margin: 0 0 12px;
  color: var(--gold);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.quote {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.4rem, 1.15rem + 1.1vw, 1.75rem);
  font-weight: 500;
  line-height: 1.4;
  text-wrap: pretty;
}

.tip {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 22px 0 0;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-size: 0.95rem;
}

.tip-label {
  flex: none;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.footer {
  margin-top: 32px;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.enter {
  animation: pour 0.45s ease-out;
}

@keyframes pour {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

@media (max-width: 480px) {
  .page {
    padding-top: 14px;
  }

  .panel,
  .result {
    padding: 18px;
  }

  .actions .btn {
    flex: 1;
  }
}

@media (max-width: 400px) {
  .levels {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .enter,
  .glass .bubbles circle {
    animation: none;
  }

  .glass .wine {
    transition: none;
  }
}
