:root {
  --paper: #f7f6f2;
  --ink: #272c28;
  --red: #d47768;
  --red2: #bc574a;
  --sage: #94a28a;
  --line: #d6cec1;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100svh;
  background: var(--paper);
  color: var(--ink);
  font-family: "DM Sans", "Noto Sans TC", sans-serif;
}

button, a { font: inherit; }
button { cursor: pointer; }

button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid var(--red2);
  outline-offset: 5px;
}

.site {
  min-height: 100svh;
  position: relative;
  overflow: hidden;
}

.map-screen {
  max-width: 940px;
  min-height: 100svh;
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 25px;
}

.map-wrap {
  position: relative;
  width: min(100%, 820px);
  min-width: 0;
}

.map {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.region {
  pointer-events: none;
  opacity: .62;
  transition: opacity .35s, transform .35s;
  transform-origin: center;
  transform-box: fill-box;
}

.region.active {
  opacity: 1;
  transform: scale(1.035);
}

.route {
  fill: none;
  stroke: #9b9a90;
  stroke-width: 1.8;
  stroke-dasharray: 5 10;
  stroke-dashoffset: 0;
  opacity: .50;
  pointer-events: none;
  transition: opacity .25s, stroke .25s, stroke-width .25s;
}

.route.active {
  stroke: var(--red2);
  stroke-width: 2.7;
  opacity: 1;
  animation: dash 2.1s linear infinite;
}

@keyframes dash {
  from { stroke-dashoffset: 0; }
  to { stroke-dashoffset: -150; }
}

@keyframes dash-phone {
  from { stroke-dashoffset: 0; }
  to { stroke-dashoffset: -154; }
}

.pin {
  cursor: pointer;
  outline: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.pin:focus-visible .outer { stroke-width: 4; }
.pin .hit,
.pin .label-hit,
.place-label {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.pin .hit { fill: transparent; pointer-events: all; }
.pin .label-hit { fill: transparent; pointer-events: none; }

.pin .outer {
  fill: var(--paper);
  stroke: var(--ink);
  stroke-width: 2.3;
  transition: transform .2s, stroke .2s;
  transform-origin: center;
  transform-box: fill-box;
}

.pin .inner {
  fill: var(--red);
  transition: transform .2s;
  transform-origin: center;
  transform-box: fill-box;
}

.pin:hover .outer,
.pin:focus .outer,
.pin.preview .outer,
.pin.selected .outer {
  stroke: var(--red2);
  transform: scale(1.3);
}

.pin:hover .inner,
.pin.preview .inner,
.pin.selected .inner {
  transform: scale(1.25);
}

.place-label {
  fill: var(--ink);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 1.7px;
  pointer-events: none;
}

.pin.selected .place-label,
.pin.preview .place-label { fill: var(--red2); }

.map-title {
  font-size: 12px;
  letter-spacing: 3px;
  font-weight: 800;
}

.map-small {
  font-size: 10px;
  letter-spacing: 2px;
  fill: #89877c;
}

.compass {
  position: absolute;
  right: 3%;
  top: 6%;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
}

.compass svg {
  display: block;
  width: 24px;
  margin: auto;
}

.hover-note {
  position: absolute;
  z-index: 5;
  width: max-content;
  min-width: 205px;
  max-width: min(360px, calc(100% - 16px));
  background: #fffdf7;
  border: 1px solid var(--line);
  box-shadow: 5px 6px 0 #ded7ca88;
  padding: 15px 16px;
  pointer-events: none;
  opacity: 0;
  word-break: keep-all;
  transform: translate(-50%, -104%) translateY(8px);
  transition: opacity .16s, transform .16s;
}

.hover-note.show {
  opacity: 1;
  transform: translate(-50%, -104%) translateY(0);
}

.hover-note.below { transform: translate(-50%, 18px) translateY(8px); }
.hover-note.below.show { transform: translate(-50%, 18px); }
.hover-note b { display: block; font-size: 14px; }
.hover-note .time { font-weight: 800; font-size: 18px; margin: 7px 0 2px; white-space: nowrap; }
.hover-note small { font-size: 11px; color: #73766d; }
.hover-note .more { font-size: 11px; color: var(--red2); margin-top: 9px; }

.mobile-choice { display: none; }
.choice-ride,
.choice-mode { display: none; }

.detail-screen {
  display: none;
  min-height: 100svh;
  max-width: 960px;
  padding: 26px 28px 70px;
  margin: auto;
  animation: enter .28s ease;
}

.detail-screen.open { display: block; }
.map-screen.hidden { display: none; }

@keyframes enter {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.back {
  box-sizing: border-box;
  width: auto;
  height: 38px;
  margin: 0 0 6px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--red);
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  box-shadow: none;
  appearance: none;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  transition: color 0.2s ease;
}

.back-arrow {
  display: inline-block;
  transition: transform 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
  .back:hover {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    color: var(--red2);
  }

  .back:hover .back-arrow { transform: translateX(-3px); }
}

.detail-top {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin: 22px 0 25px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 24px;
}

.detail-top h1 {
  font-size: clamp(16px, 2.5vw, 29px);
  letter-spacing: .12em;
  margin: 0;
  font-weight: 800;
}

.detail-top .jp { font-size: 14px; color: #77786e; margin-top: 8px; }

.detail-top .line {
  height: 5px;
  width: 90px;
  background: var(--red);
  clip-path: polygon(0 30%, 100% 0, 83% 68%, 0 100%);
  margin-top: 6px;
}

.section-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
  margin: 25px 0 14px;
}

.transport {
  border: 1px solid var(--line);
  background: #fbf8f1;
  padding: 20px 24px;
  transition: transform .2s, border-color .2s;
}

.transport:hover,
.hotel:hover {
  transform: translateY(-2px);
  border-color: var(--red);
}

.transport .time { font-size: clamp(11px, 2vw, 16px); font-weight: 800; }
.transport .line-name { font-size: 13px; color: var(--red2); font-weight: 700; margin: 8px 0; }

.steps {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 15px 0 10px;
  font-size: 14px;
  font-weight: 700;
}

.steps .arrow { color: var(--red2); }
.description, .note { font-size: 12px; line-height: 1.9; color: #72736c; }

.resorts { margin-top: 16px; border-top: 1px solid var(--line); }
.resort-note { margin: 14px 0 0; font-size: 12px; line-height: 1.7; color: #72736c; }
.resort { padding: 16px 0; border-bottom: 1px solid #e4ddd2; }
.resort:last-child { border-bottom: 0; padding-bottom: 4px; }
.resort h3 { margin: 0; font-size: 15px; font-weight: 800; letter-spacing: 0; color: var(--ink); }
.resort-en { margin-top: 3px; font-size: 12px; color: #7c7f78; }
.resort-time { margin-top: 10px; font-size: 15px; font-weight: 800; line-height: 1.4; }
.resort-total { margin-top: 12px; font-size: 14px; font-weight: 800; line-height: 1.5; color: var(--red2); }
.resort-route { margin-top: 10px; }
.resort-stop { font-size: 14px; font-weight: 700; line-height: 1.5; }
.resort-leg { display: flex; align-items: flex-start; gap: 8px; margin: 3px 0; font-size: 12px; line-height: 1.6; color: #72736c; }
.resort-leg .arrow { color: var(--red2); flex: 0 0 auto; }
.resort-leg span:last-child { min-width: 0; }

.fares { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.fare-head, .fare-route { font-size: 12px; line-height: 1.7; color: #72736c; }
.fare-list { list-style: none; margin: 4px 0 0; padding: 0; }
.fare-list li {
  display: grid;
  grid-template-columns: 48px auto;
  column-gap: 12px;
  align-items: baseline;
  min-height: 24px;
}
.fare-type { font-size: 12px; color: #7c7f78; }
.fare-price { font-size: 14px; font-weight: 800; color: #3a3e3a; white-space: nowrap; }
.passes { list-style: none; margin: 8px 0 0; padding: 0; }
.passes li { font-size: 12px; line-height: 1.7; color: #72736c; }
.pass-yes, .pass-part { display: inline-block; width: 1.15em; }
.pass-yes { color: var(--sage); }
.pass-part { color: var(--red); }

.maps {
  display: inline-block;
  margin-top: 12px;
  font-size: 12px;
  font-weight: 800;
  color: var(--red2);
  text-decoration: none;
  border-bottom: 1px solid var(--red2);
  padding-bottom: 3px;
}

.hotel {
  border: 1px solid var(--line);
  background: #faf7ef;
  padding: 22px;
  margin: 14px 0;
  transition: transform .2s, border-color .2s;
}

.hotel h2 { font-size: 17px; margin: 0 0 18px; }
.hotel-title { margin: 0 0 18px; }
.hotel-name-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.hotel-title h2 { margin: 0; }
.hotel-en { margin-top: 3px; font-size: 12px; color: #7c7f78; }
.hotel-links { display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0; }
.booking, .agoda { display: inline-flex; flex-shrink: 0; line-height: 0; color: var(--red2); }
.booking svg, .agoda svg { width: 22px; height: 22px; display: block; }
.booking:hover, .agoda:hover { color: var(--red); }
.date-group { margin-top: 18px; }
.date-head { display: flex; align-items: center; gap: 8px; margin: 0 0 9px; }
.date-group h3 { font-size: 12px; letter-spacing: .1em; margin: 0; color: #7c716b; }

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

.room {
  border: 1px solid #ded4c6;
  background: var(--paper);
  padding: 17px;
  transition: transform .18s, box-shadow .18s, background .18s, border-color .18s;
}

.room.has-photo {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.room-copy { min-width: 0; flex: 1; }

.room.has-rates .meta { margin-top: 3px; color: #7c7f78; line-height: 1.45; }
.room.has-rates .stock { margin-top: 8px; }

.rates {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}

.rates li,
.room-price-row {
  display: grid;
  grid-template-columns: 85px 35px 1fr;
  align-items: center;
  column-gap: 8px;
  min-height: 28px;
  padding: 6px 0;
  border-top: 1px solid #e6dfd4;
}

.rates li:first-child { border-top-color: transparent; }

.rate-price {
  font-size: 16px;
  font-weight: 800;
  color: #3a3e3a;
  white-space: nowrap;
}

.rate-people,
.rate-meal,
.rate-note {
  font-size: 11px;
  color: #7c7f78;
  white-space: nowrap;
}

.rate-plan { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; min-width: 0; }
.rate-plan .rate-note { font-size: 10px; line-height: 1.35; white-space: normal; }
.room-en { margin-top: 2px; font-size: 11px; color: #7c7f78; }
.rate-extra { margin-top: 10px; font-size: 12px; color: #7c7f78; }

.num-gap { display: inline-block; width: 0.28em; }

.room-photo {
  width: 42%;
  max-width: 168px;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border-radius: 12px;
  flex-shrink: 0;
  display: block;
}

.room:hover,
.room:focus-visible {
  transform: translateY(-4px);
  border-color: var(--red);
  background: #fffaf4;
  box-shadow: 4px 5px 0 #dbb3a355;
}

.room .type { font-size: 12px; color: #6b6c63; min-height: 19px; }
.room .price { font-size: 26px; font-weight: 800; margin: 7px 0; }
.room .meta { font-size: 12px; color: #555a53; }

.stock {
  display: inline-block;
  margin-top: 12px;
  border-radius: 3px;
  padding: 5px 9px;
  color: #aa554a;
  background: #f1d8cf;
  font-size: 11px;
  font-weight: 700;
}

.empty {
  border: 1px dashed var(--line);
  padding: 30px 20px;
  text-align: center;
  color: #85867c;
  font-size: 13px;
}

.note { margin-top: 22px; }
.north { width: 30px; height: 48px; }

@media (max-width: 700px), ((hover: none) and (pointer: coarse)) {
  .map-screen { padding-bottom: calc(104px + env(safe-area-inset-bottom)); }
  .back {
    position: relative;
    width: auto;
    min-width: 0;
    height: 38px;
    min-height: 0;
    margin: 0 0 6px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--red);
    font-size: 14px;
    font-weight: 600;
    gap: 8px;
    transform: none;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }
  .back::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    width: 100%;
    height: 44px;
    transform: translateY(-50%);
  }
  .back:hover,
  .back:hover .back-arrow {
    background: transparent;
    color: var(--red);
    transform: none;
  }
  .back:active {
    background: transparent;
    box-shadow: none;
    color: var(--red2);
  }
  .hover-note { display: none; }
  .pin .label-hit,
  .place-label { pointer-events: all; }

  .next {
    width: 50px;
    height: 50px;
    min-width: 50px;
    min-height: 50px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--red);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    appearance: none;
    -webkit-appearance: none;
  }

  .next:hover,
  .next:active {
    background: var(--red2);
    color: #fff;
  }

  .mobile-choice {
    position: fixed;
    bottom: calc(18px + env(safe-area-inset-bottom));
    left: 16px;
    right: 16px;
    background: #fffcf4;
    border: 1px solid var(--line);
    padding: 15px 17px;
    box-shadow: 4px 5px 0 #ded7ca99;
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    z-index: 10;
  }

  .mobile-choice.show { display: flex; }
  .mobile-choice > div { min-width: 0; }
  .mobile-choice strong { font-size: 14px; display: block; }
  .mobile-choice small { font-size: 11px; display: block; margin-top: 5px; color: #6d7068; line-height: 1.5; }
}

@media (max-width: 700px) {
  .rooms:has(.has-rates) { grid-template-columns: 1fr; }
  .rates .room-price-row { grid-template-columns: 72px 22px minmax(0, 1fr); column-gap: 6px; }
  .map-screen { padding: 8px 3px calc(104px + env(safe-area-inset-bottom)); align-items: center; }
  .map-wrap { width: 100%; }
  .compass { right: 4%; top: 5%; }
  .detail-screen { padding: 16px 18px 50px; }
  .detail-top { margin-top: 22px; }
  .detail-top h1 { font-size: 17px; }
  .rooms { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .room { padding: 12px; }
  .room .price { font-size: 22px; }
  .hotel { padding: 14px; }
  .transport { padding: 18px; }
}

@media (max-width: 380px) {
  .room .price { font-size: 19px; }
  .rooms { grid-template-columns: 1fr; }
  .room.has-rates.has-photo { flex-wrap: wrap; }
  .room.has-rates .room-copy { flex: 1 1 100%; }
  .room.has-rates .room-photo { margin-left: auto; }
}

@media (max-width: 767px) {
  .map-screen {
    min-height: 100dvh;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: max(14px, env(safe-area-inset-top)) 0 max(16px, env(safe-area-inset-bottom));
  }

  .map:not(.is-portrait) { visibility: hidden; }

  .map-wrap {
    width: min(95vw, calc(100% - 16px));
    flex: 0 0 auto;
  }

  .compass { top: 8px; right: 10px; font-size: 9px; }
  .compass svg { width: 20.4px; }

  .map.is-portrait {
    --phone-map-unit: calc(400px / min(95vw, 100vw - 16px));
  }
  .map.is-portrait > .region:not(.phone-shape) { display: none; }
  .map.is-portrait .route {
    stroke: #C9C7C0;
    stroke-width: 1.1;
    stroke-dasharray: 3 7;
    opacity: 0.75;
  }
  .map.is-portrait .route.active {
    stroke: #C96F62;
    stroke-width: 1.6;
    stroke-dasharray: 5 6;
    opacity: 1;
    animation: dash-phone 2.1s linear infinite;
  }
  .map.is-portrait .pin .outer { stroke-width: 1.35; }
  .map.is-portrait .pin[data-place="madarao"] .place-label,
  .map.is-portrait .pin[data-place="hakuba"] .place-label {
    font-size: calc(13px * var(--phone-map-unit));
    font-weight: 700;
    letter-spacing: 0.08em;
  }
  .map.is-portrait .pin[data-place="echigo"] .place-label {
    font-size: calc(12px * var(--phone-map-unit));
    font-weight: 700;
    letter-spacing: 0.04em;
  }
  .map.is-portrait .map-title {
    font-size: calc(14px * var(--phone-map-unit));
    font-weight: 700;
    letter-spacing: 0.15em;
  }
  .map.is-portrait .map-small {
    font-size: calc(10px * var(--phone-map-unit));
    font-weight: 500;
    letter-spacing: 0.12em;
    fill: #89877c;
  }

  .map-screen { position: relative; }

  .mobile-choice {
    position: absolute;
    align-self: flex-start;
    width: 260px;
    max-width: calc(100vw - 32px);
    height: auto;
    min-height: 100px;
    margin: 0;
    padding: 14px 16px;
    background: #fffcf4;
    border: 1px solid #DDD8CF;
    border-radius: 0;
    box-shadow: 0 2px 10px rgba(39, 44, 40, 0.08);
    align-items: flex-start;
    z-index: 10;
  }

  .mobile-choice small { display: none; }
  .choice-ride,
  .choice-mode { display: block; }
  .mobile-choice strong {
    display: block;
    min-height: 36px;
    padding-right: 40px;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--ink);
  }
  .choice-ride {
    margin-top: 2px;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.35;
    color: var(--ink);
  }
  .choice-mode {
    margin-top: 4px;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.4;
    color: #6d7068;
  }
  .mobile-choice .next {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 1;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    font-size: 16px;
  }
  .mobile-choice .next::before {
    content: "";
    position: absolute;
    inset: 4px;
    border-radius: 50%;
    background: var(--red);
    z-index: -1;
  }
  .mobile-choice .next:hover,
  .mobile-choice .next:active { background: transparent; }
  .mobile-choice .next:hover::before,
  .mobile-choice .next:active::before { background: var(--red2); }
  .mobile-choice.is-in { animation: choice-in .2s ease-out; }
  .mobile-choice.is-closing {
    display: flex;
    pointer-events: none;
    animation: choice-out .15s ease-out forwards;
  }
}

@keyframes choice-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@keyframes choice-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

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