:root {
  --cream: #f6ede2;
  --cream-2: #fffaf3;
  --ink: #2f1d13;
  --ink-soft: #6b4c3b;
  --coffee: #6f4e37;
  --accent: #c96f3b;
  --accent-dark: #a9552a;
  --line: rgba(47, 29, 19, 0.1);
  --shadow: 0 18px 40px -18px rgba(60, 35, 20, 0.35);
  --radius: 24px;
}

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

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  min-height: 100dvh;
  font-family: ui-rounded, "SF Pro Rounded", "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--cream);
  overflow-x: hidden;
}

body.has-result {
  overflow: hidden;
}

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

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(10px);
  opacity: 0.55;
}

.blob--1 {
  width: 60vmax;
  height: 60vmax;
  top: -30vmax;
  left: -25vmax;
  background: radial-gradient(circle, #f3d7b8, transparent 65%);
}

.blob--2 {
  width: 50vmax;
  height: 50vmax;
  top: 18%;
  right: -20vmax;
  background: radial-gradient(circle, #e7c3a3, transparent 65%);
  opacity: 0.35;
}

.blob--3 {
  width: 45vmax;
  height: 45vmax;
  bottom: -25vmax;
  left: 10%;
  background: radial-gradient(circle, #d9b08c, transparent 65%);
  opacity: 0.4;
}

.app {
  position: relative;
  z-index: 1;
  width: min(100%, 560px);
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom));
}

/* ---------- Hero ---------- */

.hero {
  padding: 6px 8px 18px;
  text-align: center;
}

.hero__logo {
  display: grid;
  width: 68px;
  height: 68px;
  margin: 0 auto 10px;
  place-items: center;
  font-size: 34px;
  background: var(--cream-2);
  border: 1px solid var(--line);
  border-radius: 50%;
  box-shadow: var(--shadow), inset 0 0 0 6px rgba(255, 255, 255, 0.45);
}

h1 {
  margin: 0;
  font-size: clamp(2.15rem, 9vw, 3.2rem);
  font-weight: 900;
  line-height: 0.98;
  letter-spacing: -0.045em;
}

.hero__tagline {
  max-width: 30ch;
  margin: 10px auto 0;
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--ink-soft);
}

/* ---------- Cards ---------- */

.card {
  padding: 18px;
  background: rgba(255, 250, 243, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.card + .card {
  margin-top: 16px;
}

.card__title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

/* ---------- Add café ---------- */

.add-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 12px;
}

.add-form__input {
  width: 100%;
  min-height: 58px;
  padding: 0 16px;
  font: inherit;
  font-size: 1.08rem;
  font-weight: 600;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 16px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.add-form__input::placeholder {
  font-weight: 500;
  color: #a88d7b;
}

.add-form__input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(201, 111, 59, 0.15);
}

.add-form__input:disabled {
  background: #f4ede6;
  color: #a88d7b;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 56px;
  padding: 0 18px;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  border: 0;
  border-radius: 16px;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.btn--add {
  min-height: 58px;
  padding-inline: 20px;
  color: #fff8f0;
  background: var(--ink);
  box-shadow: 0 8px 18px -10px rgba(47, 29, 19, 0.8);
}

.btn--add:hover:not(:disabled) {
  background: #43291a;
}

.btn--clear {
  min-height: 40px;
  padding: 0 12px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
  background: transparent;
  border-radius: 999px;
}

.btn--clear:hover:not(:disabled) {
  background: rgba(47, 29, 19, 0.06);
}

.hint {
  min-height: 1.2em;
  margin: 10px 2px 0;
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--ink-soft);
}

.hint strong {
  color: var(--ink);
}

.hint--center {
  text-align: center;
}

.hint[data-tone="error"] {
  color: #a33a2b;
}

.hint[data-tone="success"] {
  color: #2f6b45;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.suggestions__label {
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #9b7e6a;
  text-transform: uppercase;
}

.chip {
  min-height: 42px;
  padding: 0 14px;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  background: var(--cream-2);
  border: 1.5px solid rgba(47, 29, 19, 0.16);
  border-radius: 999px;
  transition: transform 0.12s ease, background 0.15s ease;
}

.chip:active:not(:disabled) {
  transform: scale(0.97);
}

.chip:hover:not(:disabled) {
  background: #fff;
}

.chip:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ---------- Wheel card ---------- */

.wheel-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.count-badge {
  display: inline-grid;
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  font-size: 0.8rem;
  font-weight: 800;
  color: #fff8f0;
  background: var(--ink);
  border-radius: 999px;
  place-items: center;
}

.cafe-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 168px;
  padding: 0;
  margin: 14px 0 4px;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
}

.cafe-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 5px 5px 5px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 4px 10px -8px rgba(47, 29, 19, 0.5);
}

.cafe-pill::before {
  flex: none;
  width: 10px;
  height: 10px;
  content: "";
  background: var(--dot, var(--accent));
  border-radius: 50%;
}

.cafe-pill__name {
  max-width: 200px;
  overflow: hidden;
  font-size: 0.95rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cafe-pill__remove {
  display: grid;
  flex: none;
  width: 36px;
  height: 36px;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--ink-soft);
  cursor: pointer;
  background: rgba(47, 29, 19, 0.06);
  border: 0;
  border-radius: 50%;
  place-items: center;
}

.cafe-pill__remove:hover:not(:disabled) {
  color: #a33a2b;
  background: rgba(163, 58, 43, 0.12);
}

.cafe-pill__remove:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.empty-state {
  padding: 14px;
  margin: 16px 0 4px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink-soft);
  text-align: center;
  background: rgba(255, 255, 255, 0.55);
  border: 1px dashed var(--line);
  border-radius: 16px;
}

.wheel-wrap {
  position: relative;
  width: min(100%, 360px);
  margin: 14px auto 18px;
  aspect-ratio: 1;
}

.wheel {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  filter: drop-shadow(0 18px 20px rgba(47, 29, 19, 0.22));
}

.pointer {
  position: absolute;
  top: 50%;
  right: -4px;
  z-index: 3;
  width: 0;
  height: 0;
  border-top: 16px solid transparent;
  border-right: 30px solid var(--ink);
  border-bottom: 16px solid transparent;
  filter: drop-shadow(-3px 0 2px rgba(0, 0, 0, 0.18));
  transform: translateY(-50%);
}

.wheel-hub {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  width: 23%;
  aspect-ratio: 1;
  font-size: clamp(20px, 6.5vw, 30px);
  pointer-events: none;
  background: var(--cream-2);
  border: 3px solid rgba(47, 29, 19, 0.9);
  border-radius: 50%;
  box-shadow: 0 4px 14px rgba(47, 29, 19, 0.25), inset 0 0 0 4px rgba(255, 255, 255, 0.8);
  transform: translate(-50%, -50%);
  place-items: center;
}

.wheel-empty {
  position: absolute;
  inset: 0;
  display: grid;
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1.25;
  color: #8a6d5a;
  text-align: center;
  pointer-events: none;
  place-items: center;
}

.btn--spin {
  width: 100%;
  min-height: 76px;
  font-size: clamp(1.35rem, 6vw, 1.7rem);
  letter-spacing: 0.1em;
  color: #fff8f0;
  background: linear-gradient(180deg, #d97c45, #b4532a);
  border-radius: 20px;
  box-shadow: 0 14px 24px -12px rgba(180, 83, 42, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.btn--spin:hover:not(:disabled) {
  background: linear-gradient(180deg, #e0864c, #b95a2e);
}

.btn--spin:disabled {
  background: linear-gradient(180deg, #c9ac97, #b0927c);
  box-shadow: none;
}

.btn--spin.is-spinning .btn--spin__icon {
  animation: wobble 0.6s ease-in-out infinite;
}

.btn--spin__icon {
  font-size: 1.25em;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.2));
}

@keyframes wobble {
  0%,
  100% {
    transform: rotate(-8deg);
  }
  50% {
    transform: rotate(8deg);
  }
}

.footer {
  padding: 20px 8px 4px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #9b7e6a;
  text-align: center;
}

/* ---------- Result overlay ---------- */

.result-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom));
}

.result-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(35, 20, 12, 0.6);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: fade-in 0.25s ease both;
}

.confetti {
  position: fixed;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.result-card {
  position: relative;
  z-index: 2;
  width: min(100%, 420px);
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  padding: 26px 22px 22px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  text-align: center;
  background: var(--cream-2);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 30px;
  box-shadow: 0 40px 80px -20px rgba(0, 0, 0, 0.5);
  animation: pop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.result-card__emoji {
  margin-bottom: 8px;
  font-size: 3rem;
  line-height: 1;
  animation: bounce 1s ease infinite alternate;
}

.result-card__label {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  color: #a3623a;
  text-transform: uppercase;
}

.result-card__name {
  margin: 6px 0 4px;
  font-size: clamp(2.2rem, 11vw, 3.3rem);
  font-weight: 900;
  line-height: 1.02;
  letter-spacing: -0.04em;
  overflow-wrap: anywhere;
}

.result-card__sub {
  margin: 0 0 20px;
  font-weight: 600;
  color: var(--ink-soft);
}

.btn--again {
  position: static;
  min-height: 68px;
  margin-bottom: 10px;
}

.btn--ghost {
  width: 100%;
  min-height: 54px;
  color: var(--ink-soft);
  background: transparent;
  border: 1.5px solid var(--line);
}

.btn--ghost:hover:not(:disabled) {
  background: rgba(47, 29, 19, 0.05);
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.85) translateY(18px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes bounce {
  from {
    transform: translateY(0) rotate(-4deg);
  }
  to {
    transform: translateY(-6px) rotate(4deg);
  }
}

/* ---------- Small screens ---------- */

@media (max-width: 380px) {
  .hero__logo {
    width: 58px;
    height: 58px;
    font-size: 30px;
  }

  .card {
    padding: 15px;
  }

  .add-form {
    grid-template-columns: 1fr;
  }

  .btn--add {
    width: 100%;
  }

  .cafe-pill__name {
    max-width: 150px;
  }
}

@media (min-width: 480px) {
  .app {
    padding-inline: 22px;
  }

  .card {
    padding: 22px;
  }

  .wheel-wrap {
    width: min(100%, 380px);
  }
}

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