:root {
  --bg: #ffffff;
  --ink: #222326;
  --muted: #6b6f76;
  --line: #e6e7ea;
  --panel: #ffffff;
  --shadow: 0 10px 32px rgba(17, 24, 39, 0.12);
  --primary: #1d4ed8;
  --primary-ink: #ffffff;
  --tap: 48px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP",
    "Yu Gothic", "YuGothic", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.65;
}

body {
  min-height: 100dvh;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

.site-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.site-brand {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.site-nav {
  display: flex;
  gap: 14px;
  color: var(--muted);
  font-size: 12px;
}

.site-main {
  position: relative;
  z-index: 2;
  max-width: 40rem;
  padding: 28px 20px 240px;
}

.kicker {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
}

.site-main h1 {
  margin: 0 0 16px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.3;
}

.site-main p {
  margin: 0 0 12px;
  font-size: 16px;
}

.muted {
  color: var(--muted);
}

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

.falling-cookie {
  position: absolute;
  top: 0;
  left: var(--x);
  display: flex;
  flex-direction: column;
  align-items: center;
  width: var(--size);
  animation: cookie-fall var(--duration) linear forwards;
  will-change: transform;
  user-select: none;
}

.cookie-face {
  position: relative;
  overflow: hidden;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  animation: cookie-spin var(--spin) linear infinite;
  box-shadow:
    inset -6px -8px 12px rgba(0, 0, 0, 0.16),
    inset 5px 6px 10px rgba(255, 255, 255, 0.28),
    0 6px 10px rgba(0, 0, 0, 0.08);
}

.cookie-shine {
  position: absolute;
  top: 16%;
  left: 20%;
  width: 28%;
  height: 18%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.38);
  transform: rotate(-18deg);
}

.is-choco {
  background: radial-gradient(circle at 32% 28%, #f0c57a, #d28a3a 55%, #a86a28);
}

.is-choco::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 36%, #3d2314 0 5px, transparent 6px),
    radial-gradient(circle at 64% 28%, #4a2a16 0 4px, transparent 5px),
    radial-gradient(circle at 48% 62%, #3d2314 0 4.5px, transparent 5.5px),
    radial-gradient(circle at 72% 58%, #2f1a0e 0 3.5px, transparent 4.5px),
    radial-gradient(circle at 24% 68%, #4a2a16 0 3px, transparent 4px);
}

.is-butter {
  background: radial-gradient(circle at 32% 28%, #ffe9b0, #f2c96a 55%, #d9a63c);
}

.is-butter::before {
  content: "";
  position: absolute;
  inset: 12% 18% auto auto;
  width: 34%;
  height: 10%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.35);
}

.is-matcha {
  background: radial-gradient(circle at 32% 28%, #d4e88a, #86b04a 55%, #5f862c);
}

.is-matcha::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 40%, #f7f1d4 0 3.5px, transparent 4.5px),
    radial-gradient(circle at 62% 32%, #fff8de 0 3px, transparent 4px),
    radial-gradient(circle at 56% 66%, #f3ebd0 0 3.2px, transparent 4.2px);
}

.is-tea {
  background: radial-gradient(circle at 32% 28%, #e0a56a, #c06e38 55%, #8f4a1e);
}

.is-tea::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 34%, #7a3516 0 3px, transparent 4px),
    radial-gradient(circle at 66% 48%, #6b2e12 0 2.6px, transparent 3.6px),
    radial-gradient(circle at 46% 68%, #8a431c 0 3.4px, transparent 4.4px);
}

.cookie-static {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: none;
}

.result-panel {
  position: fixed;
  top: max(72px, calc(env(safe-area-inset-top, 0px) + 64px));
  left: 50%;
  z-index: 30;
  width: min(calc(100vw - 32px), 360px);
  padding: 16px 16px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  text-align: center;
  transform: translateX(-50%);
}

.result-line {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.5;
}

.result-line-delay {
  color: #374151;
  font-size: 15px;
  font-weight: 600;
}

.cookie-banner {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  padding: 16px 16px calc(16px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 -8px 28px rgba(17, 24, 39, 0.08);
}

.banner-title {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
  color: #111827;
}

.banner-copy p {
  margin: 0 0 14px;
  color: #374151;
  font-size: 14px;
  line-height: 1.6;
}

.banner-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 10px 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

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

.btn-primary {
  background: var(--primary);
  color: var(--primary-ink);
}

.btn-secondary,
.btn-ghost,
.btn-retry {
  background: #fff;
  border-color: #d1d5db;
  color: #111827;
}

.btn-retry {
  width: 100%;
  margin-top: 8px;
  background: #111827;
  border-color: #111827;
  color: #fff;
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.38);
}

.modal {
  position: relative;
  width: min(100%, 440px);
  max-height: min(92dvh, 720px);
  overflow: auto;
  padding: 18px 18px calc(18px + var(--safe-bottom));
  border-radius: 20px 20px 0 0;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.modal-chrome {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.modal h2 {
  margin: 0 0 16px;
  font-size: 18px;
  line-height: 1.45;
}

.pref-form {
  display: grid;
  gap: 8px;
}

.pref-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafafa;
}

.pref-item input {
  width: 22px;
  height: 22px;
  accent-color: var(--primary);
}

.pref-swatch {
  position: relative;
  overflow: hidden;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 50%;
  box-shadow: inset -2px -3px 5px rgba(0, 0, 0, 0.14);
  pointer-events: none;
}

.pref-swatch::before {
  pointer-events: none;
}

.pref-name {
  font-size: 16px;
  font-weight: 700;
}

.modal-actions {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

@keyframes cookie-fall {
  from {
    transform: translate3d(0, -8vh, 0);
  }
  to {
    transform: translate3d(var(--drift), 112vh, 0);
  }
}

@keyframes cookie-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 359px) {
  .banner-actions {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 420px) {
  .btn {
    font-size: 15px;
    padding: 10px 14px;
  }

  .modal-root {
    align-items: center;
    padding: 20px;
  }

  .modal {
    border-radius: 16px;
    padding-bottom: 18px;
  }
}

@media (min-width: 768px) {
  .site-main {
    padding-top: 40px;
    padding-left: 48px;
  }

  .site-header {
    padding-left: 48px;
    padding-right: 48px;
  }

  .cookie-banner {
    left: 50%;
    right: auto;
    bottom: 24px;
    width: min(720px, calc(100vw - 48px));
    border: 1px solid var(--line);
    border-radius: 16px;
    transform: translateX(-50%);
    box-shadow: var(--shadow);
  }
}

@media (prefers-reduced-motion: reduce) {
  .falling-cookie,
  .cookie-face {
    animation: none !important;
  }
}
