:root {
  --ink: #202124;
  --muted: #626b76;
  --line: rgba(32, 33, 36, 0.12);
  --paper: rgba(255, 255, 255, 0.92);
  --paper-solid: #ffffff;
  --blue: #2368d1;
  --blue-dark: #174c9c;
  --teal: #0f8b8d;
  --orange: #e7662f;
  --green: #247d59;
  --shadow: 0 14px 42px rgba(24, 31, 39, 0.14);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #eef3ef;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 12%, rgba(47, 156, 149, 0.12), transparent 26%),
    radial-gradient(circle at 86% 8%, rgba(239, 111, 97, 0.1), transparent 24%),
    linear-gradient(135deg, #f7f8f2 0%, #eef3ef 48%, #f6f2ea 100%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

.page {
  width: min(100%, 1180px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px calc(24px + env(safe-area-inset-bottom));
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 2px 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(30px, 8vw, 48px);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

.content {
  display: grid;
  gap: 14px;
}

.panel,
.wheel-dock,
.modal-card,
.result-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.panel {
  padding: 16px;
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.section-heading::before {
  width: 4px;
  height: 18px;
  border-radius: 4px;
  background: var(--blue);
  content: "";
}

.section-heading.split {
  justify-content: space-between;
}

.section-heading.split::before {
  order: -1;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field.stacked {
  margin-bottom: 14px;
}

.field input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.field input:focus {
  border-color: rgba(35, 104, 209, 0.7);
  box-shadow: 0 0 0 3px rgba(35, 104, 209, 0.12);
}

.input-with-unit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.input-with-unit span {
  color: var(--muted);
  font-size: 13px;
}

.primary-button,
.secondary-button,
.text-button,
.small-action,
.spin-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 800;
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.primary-button {
  width: 100%;
  background: var(--blue);
  color: #fff;
  box-shadow: 0 10px 22px rgba(35, 104, 209, 0.2);
}

.primary-button:hover {
  background: var(--blue-dark);
}

.spin-button:hover {
  background: #111418;
}

.secondary-button {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.text-button {
  min-height: 34px;
  padding: 0 10px;
  background: rgba(15, 139, 141, 0.1);
  color: var(--teal);
}

.small-action {
  min-height: 34px;
  padding: 0 10px;
  background: rgba(231, 102, 47, 0.12);
  color: #a8441f;
}

.icon-button {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  padding: 0;
  background: rgba(255, 255, 255, 0.86);
  border-color: var(--line);
  color: var(--ink);
}

.icon-button.light {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}

button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

button:active {
  transform: translateY(1px);
}

.hint-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: -4px 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 92px;
  color: var(--muted);
}

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid rgba(35, 104, 209, 0.16);
  border-top-color: var(--blue);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

.restaurant-list {
  display: grid;
  gap: 8px;
}

.load-more-button {
  width: 100%;
  min-height: 42px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  font-weight: 800;
}

.load-more-button:hover {
  background: #fff;
}

.restaurant-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 70px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
  text-align: left;
}

.restaurant-item.selected {
  border-color: rgba(35, 104, 209, 0.65);
  background: rgba(232, 241, 255, 0.95);
}

.restaurant-name {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  margin-bottom: 4px;
  font-size: 15px;
  font-weight: 850;
}

.restaurant-name span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.distance {
  flex: 0 0 auto;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.restaurant-address {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.restaurant-meta {
  margin-top: 6px;
  color: #a8441f;
  font-size: 12px;
  font-weight: 800;
}

.color-chip {
  width: 18px;
  height: 42px;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.empty-state {
  padding: 34px 0 18px;
  text-align: center;
}

.empty-state p {
  margin-bottom: 14px;
  color: var(--muted);
}

.wheel-dock {
  display: grid;
  gap: 10px;
  align-self: start;
  width: 100%;
  margin-top: 14px;
  padding: 8px 14px 16px;
  background: rgba(255, 255, 255, 0.94);
  scroll-margin-bottom: 18px;
}

.wheel-handle {
  display: grid;
  width: 100%;
  min-height: 26px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  touch-action: none;
}

.wheel-handle span {
  display: block;
  width: 42px;
  height: 3px;
  border-radius: 999px;
  background: rgba(98, 107, 118, 0.28);
}

.wheel-dock-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  margin-top: -2px;
}

.wheel-dock-header strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: #f5f7f8;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(32, 33, 36, 0.08);
}

.wheel-body {
  display: grid;
  gap: 14px;
  overflow: hidden;
  transition: max-height 220ms ease, opacity 180ms ease;
}

.wheel-dock.collapsed .wheel-body {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

.wheel-dock:not(.collapsed) .wheel-body {
  max-height: 430px;
  opacity: 1;
}

.wheel-wrap {
  position: relative;
  width: min(70vw, 280px);
  aspect-ratio: 1;
  margin: 10px auto 0;
  border-radius: 999px;
  filter: drop-shadow(0 12px 24px rgba(28, 34, 40, 0.12));
}

.wheel-wrap::before {
  position: absolute;
  inset: -10px;
  z-index: 0;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid rgba(32, 33, 36, 0.1);
  box-shadow: 0 10px 28px rgba(32, 33, 36, 0.1);
  content: "";
}

.wheel-wrap::after {
  position: absolute;
  inset: -2px;
  z-index: 1;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  pointer-events: none;
  content: "";
}

.wheel {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 8px solid #ffffff;
  border-radius: 999px;
  background: #edf1f2;
  box-shadow: inset 0 0 0 1px rgba(32, 33, 36, 0.08);
  transition: transform 4200ms cubic-bezier(0.18, 0.82, 0.16, 1);
  will-change: transform;
}

.wheel::before {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  background: radial-gradient(circle, transparent 0 68%, rgba(255, 255, 255, 0.16) 100%);
  pointer-events: none;
  content: "";
}

.wheel-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  color: #46515c;
  font-weight: 800;
  text-align: center;
}

.wheel-label {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  width: 0;
  height: 0;
  transform-origin: center center;
}

.wheel-label span {
  position: absolute;
  left: 0;
  top: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 82px;
  min-height: 26px;
  padding: 4px 7px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  color: #1f2933;
  font-size: 11px;
  font-weight: 850;
  line-height: 1.15;
  overflow: hidden;
  overflow-wrap: anywhere;
  text-align: center;
  box-shadow: 0 4px 10px rgba(22, 27, 33, 0.1);
  transform: translate(-50%, -50%);
}

.pointer {
  position: absolute;
  top: -13px;
  left: 50%;
  z-index: 4;
  width: 26px;
  height: 34px;
  border: 1px solid rgba(32, 33, 36, 0.12);
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 6px 14px rgba(22, 27, 33, 0.14);
  transform: translateX(-50%);
}

.pointer::after {
  position: absolute;
  right: 7px;
  bottom: -8px;
  left: 7px;
  height: 14px;
  background: #202124;
  clip-path: polygon(50% 100%, 0 0, 100% 0);
  content: "";
}

.wheel-center {
  position: absolute;
  inset: 50% auto auto 50%;
  z-index: 3;
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border: 8px solid #ffffff;
  border-radius: 999px;
  background: #f5f7f8;
  box-shadow: 0 8px 18px rgba(22, 27, 33, 0.12);
  transform: translate(-50%, -50%);
}

.wheel-center span {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #202124;
}

.spin-button {
  width: 100%;
  min-height: 48px;
  background: #202124;
  color: #fff;
  box-shadow: 0 10px 22px rgba(32, 33, 36, 0.18);
}

.spin-button:disabled {
  background: #a8b0b6;
  box-shadow: none;
}

.modal,
.result-sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal[hidden],
.result-sheet[hidden],
.loading[hidden],
.empty-state[hidden],
.toast[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 15, 22, 0.52);
}

.modal-card,
.result-card {
  position: relative;
  z-index: 1;
  width: min(100%, 420px);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: var(--teal);
  color: #fff;
}

.modal-body {
  padding: 16px;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 16px 16px;
}

.result-card {
  padding: 26px 24px 24px;
  text-align: center;
}

.result-card h2 {
  margin-bottom: 10px;
  font-size: 20px;
}

.result-card p#resultName {
  margin-bottom: 22px;
  color: var(--orange);
  font-size: 28px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 18px;
  z-index: 80;
  width: fit-content;
  max-width: calc(100% - 36px);
  margin: 0 auto;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(32, 33, 36, 0.92);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

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

@media (min-width: 900px) {
  .page {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    padding-bottom: 28px;
  }

  .app-header,
  .content,
  .wheel-dock {
    grid-column: 1 / -1;
  }

  .wheel-dock {
    width: min(100%, 720px);
    justify-self: center;
    margin-top: 0;
  }

  .wheel-wrap {
    width: 300px;
  }

  .toast {
    bottom: 24px;
  }
}

@media (max-width: 520px) {
  .page {
    padding-right: 12px;
    padding-left: 12px;
  }

  .config-grid {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 14px;
  }

  .restaurant-item {
    min-height: 66px;
    padding: 10px;
  }

  .modal-actions {
    grid-template-columns: 1fr;
  }

}
