:root {
  --bg: #f7f7f7;
  --tile-border: #d0d4da;
  --tile-empty-bg: #ffffff;
  --tile-empty-text: #9CA3AF;
  --tile-cold-bg: #EEF2F7;
  --tile-cold-border: #CBD5E1;
  --tile-cold-text: #1F2937;
  --tile-warm-bg: #E6F0FA;
  --tile-warm-border: #B6D4F0;
  --tile-warm-text: #1F2937;
  --tile-spicy-bg: #EAF7D8;
  --tile-spicy-border: #B8E986;
  --tile-spicy-text: #1F2937;
  --tile-hot-bg: #D7F5C8;
  --tile-hot-border: #7ED957;
  --tile-hot-text: #1F2937;
  --tile-win-bg: #CFF3D2;
  --tile-win-border: #22C55E;
  --tile-win-text: #1F2937;
  --text-main: #222326;
  --text-muted: #5c6470;
  --accent: #1363df;
  --accent-muted: #dde2eb;
  --radius: 6px;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text-main);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
}

.app {
  width: 100%;
  max-width: 480px;
  padding: 16px 12px 32px;
  overflow-x: clip;
}

header {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  margin-bottom: 16px;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 18px;
  text-align: center;
  grid-column: 2;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--tile-border);
  background: var(--tile-empty-bg);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 600;
  padding: 0;
}

.icon-btn:focus-visible,
.buy-link:focus-visible,
.product-name-link:focus-visible,
.modal-x:focus-visible,
.guess-btn:focus-visible,
.keep-btn:focus-visible,
.share-btn:focus-visible,
.sheet-share-btn:focus-visible,
.price-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.menu-btn { grid-column: 1; justify-self: start; }
.info-btn { grid-column: 3; justify-self: end; }
.menu-btn svg, .info-btn svg { width: 18px; height: 18px; }
.menu-wrap { position: relative; grid-column: 1; justify-self: start; }

.menu-dropdown {
  position: absolute;
  top: 42px;
  left: 0;
  min-width: 220px;
  background: #ffffff;
  border: 1px solid var(--tile-border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.15);
  padding: 6px;
  display: none;
  z-index: 20;
}

.menu-dropdown.open { display: block; }

.menu-dropdown button,
.menu-dropdown a {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 7px 10px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-main);
  cursor: pointer;
  text-decoration: none;
}

.menu-dropdown button:hover,
.menu-dropdown a:hover { background: var(--accent-muted); }

.menu-section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #9aa0aa;
  padding: 6px 10px 2px;
}

.menu-category-btn {
  position: relative;
  justify-content: space-between;
}

.menu-category-btn.active {
  background: var(--accent-muted);
  font-weight: 700;
}

.menu-category-btn.active::after {
  content: "✓";
  color: var(--accent);
  font-weight: 700;
}

.menu-divider {
  height: 1px;
  background: var(--tile-border);
  margin: 4px 2px;
}

.product-card {
  text-align: center;
  margin-bottom: 16px;
}

.mode-label {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.practice-streak-pill {
  min-height: 24px;
  padding: 4px 9px;
  border: 1px solid var(--tile-border);
  border-radius: 999px;
  background: #ffffff;
  gap: 5px;
  line-height: 1;
  white-space: nowrap;
}

.practice-streak-separator {
  margin: 0 -2px;
  color: #9aa0aa;
}

.practice-streak-count {
  display: inline-block;
  color: var(--text-main);
}

.practice-streak-float {
  position: absolute;
  left: 50%;
  top: -18px;
  transform: translateX(-50%);
  color: var(--accent);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0;
  pointer-events: none;
  animation: practice-streak-float 720ms ease-out forwards;
}

.practice-streak-pill--pulse .practice-streak-count {
  animation: practice-streak-count-pulse 520ms ease-out;
}

.practice-streak-pill--milestone {
  animation: practice-streak-pill-milestone 720ms ease-out;
}

@keyframes practice-streak-float {
  from {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
  }
}

@keyframes practice-streak-count-pulse {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(1.18); }
}

@keyframes practice-streak-pill-milestone {
  0%, 100% {
    box-shadow: 0 0 0 rgba(19, 99, 223, 0);
    transform: scale(1);
  }
  45% {
    box-shadow: 0 0 0 4px rgba(19, 99, 223, 0.12);
    transform: scale(1.04);
  }
}

.product-image-frame {
  width: 220px;
  height: 220px;
  margin: 0 auto 8px;
  border-radius: 12px;
  border: 1px solid var(--tile-border);
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
}

.product-image-frame img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.product-name-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0 0;
  max-width: 100%;
}

.product-name-link {
  font-weight: 600;
  font-size: 16px;
  color: var(--text-main);
  padding: 0;
  text-decoration: none;
  font-family: inherit;
}

.guess-row {
  display: grid;
  /* Three equal tracks fill the same centered width as the input + lock button. */
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 16px 0 12px;
}

.tile {
  height: 56px;
  border-radius: var(--radius);
  border: 2px solid var(--tile-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  text-align: center;
  padding: 4px;
  background-color: var(--tile-empty-bg);
  color: var(--text-main);
}

.tile span { display: block; }
.tile .tile-index { line-height: 1; }
.tile .tile-emoji { font-size: 14px; line-height: 1.1; }
.tile .tile-price {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.15;
}
.tile--empty { background-color: var(--tile-empty-bg); color: var(--tile-empty-text); }
.tile--cold {
  background-color: var(--tile-cold-bg);
  border-color: var(--tile-cold-border);
  color: var(--tile-cold-text);
}
.tile--warm {
  background-color: var(--tile-warm-bg);
  border-color: var(--tile-warm-border);
  color: var(--tile-warm-text);
}
.tile--spicy {
  background-color: var(--tile-spicy-bg);
  border-color: var(--tile-spicy-border);
  color: var(--tile-spicy-text);
}
.tile--hot {
  background-color: var(--tile-hot-bg);
  border-color: var(--tile-hot-border);
  color: var(--tile-hot-text);
}
.tile--win {
  background-color: var(--tile-win-bg);
  border-color: var(--tile-win-border);
  color: var(--tile-win-text);
}

.controls {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  width: 100%;
}

.price-input {
  flex: 1;
  min-height: 48px;
  border-radius: var(--radius);
  border: 2px solid var(--tile-border);
  padding: 0 10px;
  font-size: 18px;
  background: var(--tile-empty-bg);
  color: var(--text-main);
}

.price-input::placeholder { color: #9aa0aa; }

.guess-btn,
.share-btn {
  min-height: 48px;
  border-radius: var(--radius);
  border: none;
  background: var(--accent);
  color: #ffffff;
  font-weight: 600;
  cursor: pointer;
}

.guess-btn { min-width: 110px; }

.guess-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.feedback {
  min-height: 32px;
  font-size: 14px;
  margin-bottom: 12px;
}

.feedback:empty {
  min-height: 0;
  margin-bottom: 0;
}

.feedback-emoji {
  font-size: 20px;
  margin-right: 6px;
}

.game-resolution {
  margin-top: 4px;
}

.resolution-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

.resolution-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.reveal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  color: var(--text-muted);
}

.result-banner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  min-height: 35px;
  padding: 7px 13px;
  border-radius: 999px;
  font-family: inherit;
  font-size: clamp(15.5px, 4.4vw, 17.5px);
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  margin: 0 auto;
}

.result-banner--win {
  background: #dff5e5;
  color: #1f5130;
}

.result-banner--animate {
  animation: result-banner-win-pop 820ms cubic-bezier(0.2, 0.9, 0.28, 1);
  transform-origin: center;
  will-change: transform, opacity;
}

.result-banner--loss {
  background: #eceff3;
  color: #4b5563;
}

@keyframes result-banner-win-pop {
  0% {
    transform: scale(0.85);
    opacity: 0;
  }
  46% {
    transform: scale(1.4);
    opacity: 1;
  }
  76% {
    transform: scale(0.96);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@media (max-width: 420px) {
  .resolution-stack {
    gap: 8px;
  }

  .result-banner {
    min-height: 33px;
    padding: 6px 11px;
  }

  @keyframes result-banner-win-pop {
    0% {
      transform: scale(0.85);
      opacity: 0;
    }
    46% {
      transform: scale(1.28);
      opacity: 1;
    }
    76% {
      transform: scale(0.96);
      opacity: 1;
    }
    100% {
      transform: scale(1);
      opacity: 1;
    }
  }
}

.reveal-label {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}

.reveal-price {
  color: var(--text-main);
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}

.buy-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 34px;
    padding: 0 12px;
    border-radius: var(--radius);
    border: 1px solid #b7cffa;
    background: #edf4ff;
    color: var(--accent);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    animation: buy-link-bg-glow 2.4s ease-in-out infinite;
    transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.buy-link i { font-size: 12px; }

.buy-link:hover {
    background: #e4efff;
    border-color: #97bbfb;
    color: #175fcc;
}

@keyframes buy-link-bg-glow {
  0%, 100% { background-color: #edf4ff; }
  50% { background-color: #c7ddff; }
}

.share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 34px;
    padding: 0 12px;
    background: #edf4ff;
    border: 1px solid #b7cffa;
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    flex: 1 1 0;
}

.share-btn:hover {
    background: #e4efff;
    border-color: #97bbfb;
    color: #175fcc;
}

#buyLinkMount {
  flex: 1 1 0;
}

#buyLinkMount .buy-link {
  width: 100%;
}

.keep-btn {
  width: 100%;
  min-height: 44px;
  margin-bottom: 4px;
  border-radius: var(--radius);
  border: none;
  background: var(--accent);
  color: #ffffff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.keep-btn:hover { filter: brightness(0.96); }

.footer {
  margin-top: 8px;
  text-align: center;
  font-size: 14px;
  color: #9aa0aa;
}

.footer-stats {
  width: 100%;
  margin-top: 18px;
  text-align: center;
  font-size: 14px;
  line-height: 1.35;
  color: var(--text-main);
}

.modal-backdrop,
.image-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 30;
}

.image-backdrop { align-items: center; }
.modal-backdrop.open, .image-backdrop.open { display: flex; }

.modal {
  position: relative;
  width: 100%;
  max-width: 480px;
  background: #ffffff;
  border-radius: 16px 16px 0 0;
  padding: 16px 16px 24px;
  border-top: 2px solid var(--tile-border);
  box-shadow: 0 -10px 30px rgba(15, 23, 42, 0.18);
}

.modal h2 { margin: 0 0 8px; font-size: 16px; font-weight: 500; }
.modal p, .modal li { font-size: 14px; color: #4b5563; }
.modal ul { padding-left: 18px; margin: 4px 0 0; }

.modal-x {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #6b7280;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.modal-close {
  margin-top: 12px;
  width: 100%;
  min-height: 40px;
  border-radius: var(--radius);
  border: none;
  background: var(--accent-muted);
  color: var(--text-main);
  font-weight: 600;
  cursor: pointer;
}

.image-modal {
  max-width: 90vw;
  max-height: 80vh;
  background: #ffffff;
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.image-modal img {
  max-width: 100%;
  max-height: 60vh;
  object-fit: contain;
  display: block;
}

.image-modal button {
  margin-top: 4px;
  min-height: 32px;
  border-radius: var(--radius);
  border: none;
  background: var(--accent-muted);
  color: var(--text-main);
  font-weight: 600;
  cursor: pointer;
  padding: 4px 10px;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.28);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 35;
}

.sheet-backdrop.open { display: flex; }

.form-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 36;
}

.form-backdrop.open { display: flex; }

.form-modal {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: min(92vh, 760px);
  overflow-y: auto;
  background: #ffffff;
  border-radius: 16px 16px 0 0;
  padding: 20px 16px 24px;
  border-top: 2px solid var(--tile-border);
  box-shadow: 0 -10px 30px rgba(15, 23, 42, 0.18);
}

.form-modal h2 { margin: 0 36px 4px 0; font-size: 20px; }
.form-intro { margin: 0 0 16px; font-size: 14px; color: var(--text-muted); }
.form-modal form { display: flex; flex-direction: column; gap: 7px; }
.form-modal label { font-size: 13px; font-weight: 650; color: var(--text-main); }
.form-modal label span { color: var(--text-muted); font-weight: 400; }
.form-modal input,
.form-modal select,
.form-modal textarea {
  width: 100%;
  border: 1px solid var(--tile-border);
  border-radius: var(--radius);
  padding: 10px;
  background: #fff;
  color: var(--text-main);
  font: inherit;
}
.form-modal textarea { resize: vertical; }
.form-modal input:focus,
.form-modal select:focus,
.form-modal textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
#messageFields, #suggestionFields { display: flex; flex-direction: column; gap: 7px; }
#messageFields[hidden], #suggestionFields[hidden] { display: none !important; }
.honeypot-field { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.turnstile-wrap { margin-top: 7px; min-height: 65px; }
.form-error { min-height: 20px; margin: 2px 0 0; color: #b42318; font-size: 13px; }
.form-submit {
  min-height: 44px;
  margin-top: 2px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
.form-submit:disabled { cursor: default; opacity: 0.6; }
.form-success { min-height: 20px; margin: 2px 0 0; color: #137333; font-size: 13px; }

.contact-page { padding-top: 16px; }
.contact-header { grid-template-columns: 1fr; margin-bottom: 20px; }
.contact-header .brand { grid-column: 1; grid-row: 1; }
.return-game {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
  z-index: 1;
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  font-family: inherit;
  font-weight: 600;
}
.return-game:hover { text-decoration: underline; }
.contact-card {
  background: #fff;
  border: 1px solid var(--tile-border);
  border-radius: 12px;
  padding: 18px;
}
.contact-card h1 { margin: 0 0 4px; font-size: 22px; }
.contact-card form { display: flex; flex-direction: column; gap: 7px; }
.contact-card label { font-size: 13px; font-weight: 650; color: var(--text-main); }
.contact-card input,
.contact-card select,
.contact-card textarea {
  width: 100%;
  border: 1px solid var(--tile-border);
  border-radius: var(--radius);
  padding: 10px;
  background: #fff;
  color: var(--text-main);
  font: inherit;
}
.contact-card textarea { resize: vertical; }
.contact-card input:focus,
.contact-card select:focus,
.contact-card textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.privacy-link { margin: 2px 0 0; text-align: center; font-size: 12px; }
.privacy-link a { color: var(--text-muted); }
.privacy-card {
  background: #fff;
  border: 1px solid var(--tile-border);
  border-radius: 12px;
  padding: 18px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.55;
}
.privacy-card h1 { margin: 0 0 8px; color: var(--text-main); font-size: 22px; }
.privacy-card h2 { margin: 18px 0 5px; color: var(--text-main); font-size: 14px; }
.privacy-card p { margin: 0 0 9px; }
.privacy-card ul { margin: 0 0 9px; padding-left: 18px; }
.about-card { max-width: 680px; }
.about-card h2 { margin-top: 24px; font-size: 18px; }
.about-card h3 { margin: 18px 0 5px; color: var(--text-main); font-size: 15px; }
.about-card p { margin-bottom: 11px; }
.about-card .about-cta { margin-top: 20px; }
.about-card .about-cta a { color: var(--accent); font-weight: 700; }
.landing-card { max-width: 480px; }
.landing-card .keep-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 18px 0 22px;
  color: #fff;
  text-decoration: none;
}
.landing-card h3 { margin: 16px 0 4px; color: var(--text-main); font-size: 15px; }

.share-sheet {
  width: 100%;
  max-width: 480px;
  background: #ffffff;
  border-radius: 16px 16px 0 0;
  padding: 14px 12px 18px;
  box-shadow: 0 -10px 30px rgba(15, 23, 42, 0.14);
}

.share-sheet-title {
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 12px;
}

.share-sheet-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.sheet-share-btn {
  min-height: 56px;
  border-radius: 12px;
  border: 1px solid var(--tile-border);
  background: #ffffff;
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.sheet-share-btn i {
  font-size: 16px;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: #222326;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 40;
  max-width: 90vw;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  .buy-link {
    animation: none;
    transition: none;
  }
  .result-banner--animate { animation: none; }
  .practice-streak-float,
  .practice-streak-pill--pulse .practice-streak-count,
  .practice-streak-pill--milestone {
    animation: none;
  }
}
