:root {
  --bg: #F7F6F2;
  --surface: #FFFFFF;
  --surface-soft: #F7F3E6;
  --surface-muted: #EFECE3;
  --ink: #24231F;
  --ink-muted: #65625A;
  --ink-subtle: #8C887D;
  --accent: #FF7A93;
  --accent-hover: #F7637F;
  --accent-soft: #FFEEF1;
  --border: #DDD9CE;
  --border-strong: #24231F;
  --correct: #1E8E5A;
  --correct-bg: #ECFDF3;
  --wrong: #D63B3B;
  --wrong-bg: #FEF2F2;
  --wrong-border: #E05252;
  --link: #1C56B5;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --shadow-card: 0 2px 0 #24231F;
  --shadow-hard: 3px 3px 0 #24231F;
  --container-max: 1280px;
  --header-h: 58px;
  --font-sans: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", "Meiryo", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

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

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

body {
  margin: 0;
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.page-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding-inline: 16px;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background-color: var(--surface);
  border-bottom: 2px solid var(--border-strong);
}

.header-inner {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  text-decoration: none;
  min-width: 0;
}

.brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background-color: var(--accent);
  border: 1.8px solid var(--border-strong);
  box-shadow: 2px 2px 0 var(--border-strong);
  flex-shrink: 0;
}

.brand-name {
  font-size: 1.08rem;
  font-weight: 900;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* Header ad button (opens the center-screen HisatorNotebook ad) */
.ad-header-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px 3px 4px;
  border-radius: 999px;
  border: 1.5px solid #0E1F3D;
  background-color: #12264A;
  background-image: linear-gradient(135deg, #0E1F3D 0%, #1B3A6B 100%);
  color: #FFFFFF;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
  flex-shrink: 0;
  transition: filter 0.15s ease;
}

.ad-header-btn:hover {
  filter: brightness(1.15);
}

.ad-header-logo {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 1.5px rgba(214, 170, 92, 0.9);
}

.ad-header-tag {
  padding: 0 5px;
  border-radius: 4px;
  background-color: rgba(255, 255, 255, 0.18);
  color: #F1DDB0;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

@media (max-width: 460px) {
  .ad-header-name {
    display: none;
  }
}

/* Layout */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(340px, 420px) 1fr;
  gap: 18px;
  padding-top: 16px;
  padding-bottom: 24px;
  align-items: start;
}

.sidebar {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.map-col {
  position: sticky;
  top: calc(var(--header-h) + 16px);
  height: calc(100vh - var(--header-h) - 32px);
  height: calc(100dvh - var(--header-h) - 32px);
  min-height: 420px;
}

.map {
  width: 100%;
  height: 100%;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-hard);
  overflow: hidden;
  background-color: var(--surface-muted);
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 12px;
    padding-top: 12px;
  }

  /* On phones the map sits between the search controls and the list */
  .sidebar {
    display: contents;
  }

  .controls {
    order: 1;
  }

  .map-col {
    order: 2;
    position: relative;
    top: auto;
    height: 46vh;
    height: 46dvh;
    min-height: 280px;
  }

  .results-head {
    order: 3;
  }

  .event-list {
    order: 4;
  }

  .sample-note {
    order: 5;
  }
}

/* Cards & controls */
.card {
  background-color: var(--surface);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-hard);
  padding: 14px;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.place-form {
  display: flex;
  gap: 8px;
}

.form-input,
.form-select {
  width: 100%;
  min-width: 0;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1.8px solid var(--border-strong);
  background-color: var(--surface);
  font-size: 0.95rem;
}

.form-input:focus,
.form-select:focus {
  outline: 3px solid var(--accent-soft);
  outline-offset: 0;
  border-color: var(--accent-hover);
}

.locate-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.center-label {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 0.86rem;
  font-weight: 700;
}

.center-label-key {
  padding: 1px 7px;
  border-radius: 6px;
  background-color: var(--surface-muted);
  font-size: 0.72rem;
  color: var(--ink-muted);
}

#center-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 14em;
}

.hint {
  margin: -6px 0 0;
  font-size: 0.76rem;
  color: var(--ink-subtle);
}

.radius-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-weight: 800;
}

.radius-head output {
  font-size: 1.2rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  margin: 6px 0 8px;
  accent-color: var(--accent-hover);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  padding: 4px 11px;
  border-radius: 999px;
  border: 1.5px solid var(--border-strong);
  background-color: var(--surface);
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.4;
}

.chip:hover {
  background-color: var(--accent-soft);
}

.chip.is-active,
.chip[aria-pressed="true"] {
  background-color: var(--accent);
  box-shadow: 1.5px 1.5px 0 var(--border-strong);
}

.filter-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.select-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1.8px solid var(--border-strong);
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color 0.14s ease, transform 0.1s ease, box-shadow 0.14s ease;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.6;
  cursor: progress;
}

.btn-primary {
  background-color: var(--ink);
  color: #FFFFFF;
  box-shadow: 2px 2px 0 rgba(36, 35, 31, 0.25);
}

.btn-primary:hover {
  background-color: #393731;
}

.btn-secondary {
  background-color: var(--surface);
  color: var(--ink);
  box-shadow: 2px 2px 0 var(--border-strong);
}

.btn-secondary:hover {
  background-color: var(--accent-soft);
}

.btn-danger {
  background-color: #FFFFFF;
  color: var(--wrong);
  border-color: var(--wrong-border);
}

.btn-danger:hover {
  background-color: var(--wrong-bg);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.82rem;
  border-width: 1.5px;
  border-radius: 8px;
  box-shadow: none;
}

/* Results */
.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 2px 0;
}

.results-title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 900;
}

.results-title strong {
  font-size: 1.3rem;
  color: var(--accent-hover);
  font-variant-numeric: tabular-nums;
}

.event-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.event-card {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  padding: 12px;
  background-color: var(--surface);
  border: 1.8px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.14s ease;
}

.event-card:hover {
  background-color: #FFFCF7;
}

.event-card.is-selected {
  background-color: var(--accent-soft);
  box-shadow: var(--shadow-hard);
  transform: translate(-1px, -1px);
}

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

.date-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60px;
  border-radius: 10px;
  border: 1.5px solid var(--border-strong);
  background-color: var(--accent);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.date-badge.is-weekend {
  background-color: #FFD3DC;
}

.date-month {
  font-size: 0.68rem;
  font-weight: 800;
}

.date-day {
  font-size: 1.36rem;
  font-weight: 900;
}

.date-dow {
  font-size: 0.66rem;
  font-weight: 800;
}

.event-main {
  min-width: 0;
}

.event-meta-top {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 3px;
}

.cat-tag {
  padding: 0 8px;
  border-radius: 999px;
  border: 1.2px solid var(--border-strong);
  background-color: var(--surface-soft);
  font-size: 0.7rem;
  font-weight: 800;
}

.distance-tag {
  font-size: 0.76rem;
  font-weight: 900;
  color: var(--accent-hover);
  font-variant-numeric: tabular-nums;
}

.event-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 900;
  line-height: 1.4;
}

.event-facts {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 2px;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.event-facts li {
  display: flex;
  gap: 6px;
}

.event-facts .k {
  flex-shrink: 0;
  min-width: 2.6em;
  font-weight: 800;
  color: var(--ink-subtle);
}

.price {
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  font-weight: 700;
}

.event-desc {
  margin: 8px 0 0;
  font-size: 0.82rem;
  color: var(--ink);
}

.event-card:not(.is-selected) .event-desc {
  display: none;
}

.event-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.event-card:not(.is-selected) .event-actions {
  display: none;
}

.empty-state {
  padding: 22px 16px;
  text-align: center;
  background-color: var(--surface);
  border: 1.8px dashed var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--ink-muted);
  font-size: 0.9rem;
}

.empty-state .btn {
  margin-top: 10px;
}

.sample-note {
  margin: 4px 2px 0;
  font-size: 0.76rem;
  color: var(--ink-subtle);
}

/* Map pins */
.pin {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background-color: var(--accent);
  border: 2px solid var(--border-strong);
  box-shadow: 1.5px 1.5px 0 var(--border-strong);
}

.pin span {
  transform: rotate(45deg);
  font-size: 0.72rem;
  font-weight: 900;
  color: var(--ink);
}

.pin.is-selected {
  background-color: var(--ink);
}

.pin.is-selected span {
  color: #FFFFFF;
}

.center-pin {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background-color: #2F6FE4;
  border: 3px solid #FFFFFF;
  box-shadow: 0 0 0 2px #2F6FE4, 0 0 0 9px rgba(47, 111, 228, 0.2);
}

.leaflet-popup-content {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  line-height: 1.5;
}

.popup-title {
  display: block;
  font-weight: 900;
  font-size: 0.88rem;
}

/* Footer */
.site-footer {
  border-top: 2px solid var(--border-strong);
  background-color: var(--surface);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-block: 14px;
}

.footer-brand {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 800;
}

.footer-links {
  display: flex;
  gap: 4px 14px;
  flex-wrap: wrap;
}

.footer-link-btn {
  padding: 0;
  border: 0;
  background: none;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.footer-link-btn:hover {
  color: var(--ink);
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 140;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 10px;
  border: 1.8px solid var(--border-strong);
  background-color: var(--ink);
  color: #FFFFFF;
  font-size: 0.86rem;
  font-weight: 700;
  box-shadow: var(--shadow-hard);
}

/* Modals / Dialogs */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background-color: rgba(36, 35, 31, 0.54);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal-panel {
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 36px);
  max-height: calc(100dvh - 36px);
  display: flex;
  flex-direction: column;
  background-color: var(--surface);
  border: 2px solid var(--border-strong);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.24);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background-color: var(--accent);
  border-bottom: 1.8px solid var(--border-strong);
  padding: 14px 20px;
}

.modal-title {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 900;
  color: var(--ink);
}

.modal-title:focus {
  outline: none;
}

.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  background-color: var(--surface);
  color: var(--ink);
  flex-shrink: 0;
}

.modal-close:hover {
  background-color: var(--ink);
  color: #FFFFFF;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Ad-free (HisatorNotebook UID) */
.license-status-card {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1.5px solid #E3DCC6;
  background-color: #FAF9F4;
  margin-bottom: 14px;
}

.license-status-card.is-pro {
  background-color: var(--correct-bg);
  border-color: #9ADBB8;
}

.license-status-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.license-plan-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 900;
  background-color: #E3DFD3;
  color: var(--ink-muted);
}

.license-status-card.is-pro .license-plan-badge {
  background-color: var(--correct);
  color: #FFFFFF;
}

.license-status-desc {
  margin: 8px 0 0;
  font-size: 0.84rem;
  color: var(--ink);
  line-height: 1.55;
}

.license-meta-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.8rem;
  color: var(--ink-muted);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-label {
  font-size: 0.86rem;
  font-weight: 800;
}

.field-hint {
  font-size: 0.76rem;
  color: var(--ink-muted);
}

.auth-message {
  margin: 0;
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 0.84rem;
  font-weight: 700;
}

.auth-message.is-error {
  background-color: var(--wrong-bg);
  color: var(--wrong);
  border: 1px solid var(--wrong-border);
}

.auth-message.is-success {
  background-color: var(--correct-bg);
  color: var(--correct);
  border: 1px solid #9ADBB8;
}

/* ------------------------------------------------------------------ */
/* 30-minute ad — centered interstitial                                */
/* ------------------------------------------------------------------ */
.ad-overlay {
  z-index: 120;
  align-items: center;
  justify-content: center;
  background-color: rgba(24, 23, 20, 0.66);
}

.ad-modal-panel {
  max-width: 460px;
  animation: ad-pop-in 0.22s ease-out;
}

@keyframes ad-pop-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ad-modal-panel {
    animation: none;
  }
}

.ad-hero {
  padding: 14px 18px 18px;
  color: #FFFFFF;
  background-color: #12264A;
  background-image: radial-gradient(circle at 92% -10%, rgba(214, 170, 92, 0.22) 0 20%, transparent 21%),
    linear-gradient(135deg, #0E1F3D 0%, #1B3A6B 100%);
  border-bottom: 1.8px solid var(--border-strong);
}

.ad-hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ad-label {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background-color: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #FFFFFF;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.ad-hero-brand {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.ad-hero-logo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(214, 170, 92, 0.85), 0 6px 18px rgba(0, 0, 0, 0.35);
}

.ad-promo-eyebrow {
  display: block;
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: #E3C27E;
}

.ad-hero-name {
  margin: 0;
  font-size: 1.22rem;
  font-weight: 900;
  line-height: 1.2;
  color: #FFFFFF;
}

#dialog-ad-popup .ad-promo-title {
  margin: 12px 0 0;
  font-size: 1.16rem;
  font-weight: 900;
  line-height: 1.4;
  color: #FFFFFF;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.ad-body {
  padding: 18px;
}

.ad-promo-desc {
  margin: 0 0 12px;
  font-size: 0.9rem;
  color: var(--ink);
  line-height: 1.65;
}

.ad-features {
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ad-features li {
  padding: 4px 11px;
  border-radius: 999px;
  background-color: #EEF2F8;
  border: 1px solid #C9D4E6;
  font-size: 0.78rem;
  font-weight: 800;
  color: #12264A;
}

.ad-promo-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ad-promo-actions .btn {
  width: 100%;
  text-decoration: none;
  text-align: center;
}

.ad-promo-note {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 9px;
  background-color: var(--surface-soft);
  border: 1px solid #E6E1D3;
  font-size: 0.78rem;
  color: var(--ink-muted);
  line-height: 1.55;
}

.ad-popup-footer {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 460px) {
  .ad-hero {
    padding: 12px 14px 14px;
  }

  .ad-body {
    padding: 14px;
  }

  #dialog-ad-popup .ad-promo-title {
    font-size: 1.08rem;
  }
}
