:root {
  --pine: #0f2e24;
  --pine-2: #17402f;
  --cranberry: #b3263a;
  --cranberry-dark: #8c1b2c;
  --amber: #f2a33a;
  --amber-soft: #fbd38d;
  --foam: #fff7e6;
  --ink: #2b1d14;
  --muted: #7a6a5c;
  --card: #fffdf8;
  --line: #ecdcc4;
  --ok: #2f7d4f;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  color-scheme: light;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 50% -200px, #2a5a45 0%, transparent 70%),
    linear-gradient(180deg, var(--pine) 0%, #0a211a 100%) fixed;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

h1, h2 { font-family: Georgia, "Times New Roman", serif; margin: 0; }
h2 { font-size: 1.25rem; margin-bottom: 0.5rem; }

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

/* Gentle snowfall made of layered radial gradients. */
.snow {
  pointer-events: none;
  position: fixed; inset: 0;
  background-image:
    radial-gradient(2px 2px at 20px 30px, #fff, transparent),
    radial-gradient(2px 2px at 140px 80px, rgba(255,255,255,.8), transparent),
    radial-gradient(3px 3px at 60px 160px, rgba(255,255,255,.7), transparent),
    radial-gradient(2px 2px at 200px 220px, #fff, transparent),
    radial-gradient(1.5px 1.5px at 100px 260px, rgba(255,255,255,.9), transparent);
  background-size: 240px 280px;
  opacity: 0.35;
  animation: snow 18s linear infinite;
}
@keyframes snow { to { background-position: 40px 280px; } }
@media (prefers-reduced-motion: reduce) { .snow { animation: none; } }

.top {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 640px; margin: 0 auto; padding: 20px 16px 8px;
  color: var(--foam);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid; place-items: center;
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--amber); font-size: 26px;
  box-shadow: 0 0 0 4px rgba(242, 163, 58, 0.25);
}
.top h1 { font-size: 1.5rem; letter-spacing: 0.01em; }
.hello { margin: 2px 0 0; color: var(--amber-soft); font-size: 0.95rem; }

main { position: relative; max-width: 640px; margin: 0 auto; padding: 8px 12px 40px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin: 12px 0;
  box-shadow: var(--shadow);
  border-top: 4px solid var(--cranberry);
}
.card:nth-of-type(even) { border-top-color: var(--amber); }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

.locked { text-align: center; padding: 32px 20px; }
.big-emoji { font-size: 48px; }

/* Progress: eight bottle caps */
.progress-head { display: flex; align-items: baseline; justify-content: space-between; }
.count { font-weight: 700; font-size: 1.1rem; color: var(--cranberry); }
.caps { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin: 10px 0 6px; }
.cap {
  aspect-ratio: 1; border-radius: 50%;
  border: 2px dashed var(--line);
  background: #fbf3e4;
}
.cap.filled {
  border: 3px solid var(--amber);
  background: radial-gradient(circle at 35% 30%, #ffd98a, var(--amber) 55%, #c97a12 100%);
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.15);
}

/* Door grid */
.doors {
  list-style: none; padding: 0; margin: 12px 0 0;
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px;
}
.door {
  position: relative;
  aspect-ratio: 3 / 4;
  display: grid; place-items: center;
  border-radius: 10px;
  font-weight: 700; font-family: Georgia, serif; font-size: 1.05rem;
  background: #f4ead9; color: #b9a78f;
}
.door.mine {
  background: linear-gradient(160deg, var(--cranberry) 0%, var(--cranberry-dark) 100%);
  color: var(--foam);
  box-shadow: inset 0 0 0 2px rgba(255, 215, 140, 0.6);
}
.door.mine::after {
  content: "★"; position: absolute; top: 3px; right: 5px;
  font-size: 0.65rem; color: var(--amber-soft);
}
.door.today { outline: 3px solid var(--amber); outline-offset: 1px; }

/* Search */
.search { display: flex; gap: 8px; }
.combo { position: relative; flex: 1; }
input {
  width: 100%;
  font: inherit; font-size: 16px; /* prevents iOS zoom */
  padding: 12px 14px;
  border: 2px solid var(--line); border-radius: 12px;
  background: #fff; color: var(--ink);
}
input:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px rgba(242,163,58,.25); }

.suggestions {
  position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 4px);
  list-style: none; margin: 0; padding: 4px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 24px rgba(0,0,0,.18);
  max-height: 280px; overflow-y: auto;
}
.suggestions li {
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
}
.suggestions li[aria-selected="true"], .suggestions li:hover { background: #fdf0d8; }
.suggestions .sub { display: block; font-size: 0.8rem; color: var(--muted); }

button {
  font: inherit; font-weight: 600;
  min-height: 44px; padding: 10px 16px;
  border-radius: 12px; border: 2px solid transparent;
  cursor: pointer;
  touch-action: manipulation;
}
button:disabled { opacity: .55; cursor: progress; }
button.primary { background: var(--cranberry); color: #fff; }
button.primary:hover { background: var(--cranberry-dark); }
button.secondary { background: var(--amber); color: var(--ink); }
button.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.top button.ghost { color: var(--foam); border-color: rgba(255,255,255,.3); }
button.small { min-height: 36px; padding: 6px 12px; font-size: 0.875rem; }
button.danger { background: transparent; color: var(--cranberry); border-color: #f0c7cd; }
button:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }

.results { margin-top: 12px; display: grid; gap: 8px; }
.results:empty { display: none; }
.results h3 { margin: 8px 0 0; font-size: 0.85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.beer {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: #fff;
}
.beer .info { min-width: 0; }
.beer .title { font-weight: 650; overflow-wrap: anywhere; }
.beer .sub { font-size: 0.85rem; color: var(--muted); overflow-wrap: anywhere; }
.beer .actions { display: flex; gap: 6px; flex-shrink: 0; align-items: center; }

.chip {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  font-size: 0.8rem; font-weight: 700; white-space: nowrap;
}
.chip.available { background: #e3f3e8; color: var(--ok); }
.chip.taken { background: #efe7dc; color: #8b7a66; }
.chip.yours { background: #fdf0d8; color: #9a5b00; }

.manual-cta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 14px 0 0; color: var(--muted); }

.attribution { font-size: 0.8rem; opacity: 0.85; }
.attribution a { color: inherit; }

.stack { display: grid; gap: 12px; }
.stack label { display: grid; gap: 4px; font-weight: 600; font-size: 0.95rem; }
.field { display: grid; gap: 4px; }
.field > label { font-weight: 600; font-size: 0.95rem; }
/* Brewery dropdown: full-size touch targets, and short enough to stay above a phone keyboard. */
.field .suggestions { max-height: min(280px, 40vh); overscroll-behavior: contain; }
.field .suggestions li { min-height: 44px; display: flex; align-items: center; overflow-wrap: anywhere; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }

.notice {
  padding: 12px; border-radius: 12px; background: #fdf0d8; border: 1px solid #f5d79e;
  display: grid; gap: 8px;
}
.notice.error { background: #fbe6e9; border-color: #f0c0c7; color: #7a1626; }
.notice ul { margin: 0; padding-left: 18px; }

.mine { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 8px; }

.foot { text-align: center; color: rgba(255, 247, 230, .7); padding: 12px 8px; }
.foot p { margin: 0 0 6px; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  background: var(--ink); color: var(--foam);
  padding: 12px 18px; border-radius: 999px;
  box-shadow: var(--shadow); z-index: 20;
}
.toast.error { background: var(--cranberry-dark); }

@media (max-width: 380px) {
  .doors { grid-template-columns: repeat(4, 1fr); }
  .search { flex-direction: column; }
  .beer { flex-direction: column; align-items: stretch; }
  .beer .actions { justify-content: flex-end; }
}
