:root {
  --bg: #f7f5f2;
  --surface: #ffffff;
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --soft: #a0a0a0;
  --accent: #d2451e;
  --accent-soft: #fbeae3;
  --warn: #b87000;
  --border: #e8e4df;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-focus: 0 0 0 3px rgba(210,69,30,0.25);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Hiragino Sans',
               'PingFang TC', 'Noto Sans CJK TC', sans-serif;
  background: var(--bg);
  color: var(--fg);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

main, .page-header {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Header */
.page-header {
  padding-top: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.page-header h1 {
  margin: 0 0 0.25rem 0;
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}
.stale-warning {
  margin: 0.5rem 0 0 0;
  color: var(--warn);
  font-weight: 500;
  font-size: 0.85rem;
}

/* Section labels */
.section-label {
  margin: 0 0 0.75rem 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--fg);
}

/* Lottery picker */
.picker-section {
  margin-bottom: 2rem;
}
.lottery-picker {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: 0.5rem;
  margin: 0 -1rem;
  padding-left: 1rem;
  padding-right: 1rem;
  -webkit-overflow-scrolling: touch;
}
.lottery-picker::-webkit-scrollbar { height: 6px; }
.lottery-picker::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

@media (min-width: 720px) {
  .lottery-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    overflow: visible;
    padding: 0;
    margin: 0;
  }
}

.lottery-card {
  flex: 0 0 140px;
  scroll-snap-align: start;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.5rem;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  text-align: left;
  font: inherit;
  color: inherit;
  outline: none;
}
.lottery-card:hover {
  border-color: var(--soft);
  box-shadow: var(--shadow-sm);
}
.lottery-card:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}
.lottery-card.selected {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  background: var(--accent-soft);
}
.lottery-card .img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.lottery-card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.lottery-card .name {
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.1em;
}
.lottery-card .date {
  font-size: 0.72rem;
  color: var(--muted);
}

.picker-empty {
  padding: 1rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Filters */
.filters {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 2rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.field-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.filters select {
  padding: 0.65rem 0.75rem;
  font: inherit;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--fg);
  min-height: 44px;
}
.filters select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}
.filters select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.btn {
  flex: 1 1 auto;
  min-height: 44px;
  padding: 0.6rem 1rem;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
}
.btn-primary:hover:not(:disabled) { background: #b9381a; border-color: #b9381a; }
.btn-secondary {
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn.success {
  background: #2f7d32;
  color: #fff;
  border-color: #2f7d32;
}
.actions-hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

/* Results */
.status {
  margin: 0 0 0.75rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.shop-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.shop-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto auto;
  gap: 0.15rem 0.75rem;
  align-items: start;
}
.shop-card .name {
  grid-column: 1;
  grid-row: 1;
  font-weight: 600;
  font-size: 0.97rem;
  line-height: 1.4;
}
.shop-card .address {
  grid-column: 1;
  grid-row: 2;
  color: var(--muted);
  font-size: 0.85rem;
}
.shop-card .release {
  grid-column: 1;
  grid-row: 3;
  color: var(--soft);
  font-size: 0.78rem;
  margin-top: 0.15rem;
}
.shop-card .map-link {
  grid-column: 2;
  grid-row: 1 / span 3;
  align-self: center;
  display: inline-block;
  padding: 0.5rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 999px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.shop-card .map-link:hover,
.shop-card .map-link:focus-visible {
  background: var(--accent);
  color: #fff;
  outline: none;
}

@media (max-width: 480px) {
  .shop-card {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto;
  }
  .shop-card .map-link {
    grid-column: 1;
    grid-row: 4;
    margin-top: 0.5rem;
    align-self: start;
    justify-self: end;
  }
}

/* How-to / tutorial */
.howto {
  margin-top: 2.5rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.howto .section-label {
  margin-top: 0;
  margin-bottom: 0.75rem;
}
.howto-steps {
  margin: 0;
  padding-left: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--fg);
}
.howto-steps li::marker { color: var(--accent); font-weight: 700; }
.howto-steps a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.howto-steps strong { font-weight: 600; }
.howto-note {
  margin: 0.9rem 0 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

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