:root {
  --teal: #0e9aa7;
  --teal-d: #0b7c86;
  --pink: #f0689b;
  --pink-d: #d94f82;
  --orange: #f5a623;
  --lime: #a8c83a;
  --blue: #4a7fd4;
  --green: #3aa86a;
  --cream: #fffaf2;
  --ink: #3d3a50;
  --font: "Zen Maru Gothic", "Hiragino Sans", "Noto Sans JP", sans-serif;
}

html, body { margin: 0; height: 100%; font-family: var(--font); color: var(--ink); overflow: hidden; }
#map { position: absolute; inset: 0; }
.parking-notice { margin: 10px 0 0; padding: 9px 10px; background: #fff0d4; border-radius: 12px; color: #754514; font-size: 12px; line-height: 1.6; font-weight: 700; }
#map-status { position: absolute; bottom: 120px; left: 10%; right: 10%; z-index: 20; background: var(--cream); padding: 18px; border-radius: 16px; }

/* ============ タイトルバッジ ============ */
#badge {
  position: absolute; top: 14px; left: 14px; z-index: 10;
  width: 210px; padding: 16px 18px 14px;
  background: var(--cream);
  border-radius: 26px;
  box-shadow: 0 6px 0 rgba(61,58,80,.08), 0 12px 30px rgba(61,58,80,.18);
  overflow: hidden;
}
.badge-kicker {
  margin: 0 0 2px; font-size: 11px; font-weight: 900; letter-spacing: .12em;
  color: var(--pink);
}
#badge h1 {
  margin: 0; font-size: 27px; font-weight: 900; line-height: 1.25;
  color: var(--teal-d);
}
.badge-date-row { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.badge-date {
  margin: 0; display: inline-block; white-space: nowrap;
  font-weight: 900; font-size: 22px; color: #fff;
  background: linear-gradient(120deg, var(--pink), var(--orange));
  border-radius: 999px; padding: 3px 14px 4px;
}
.badge-date span { font-size: 11px; vertical-align: 3px; margin-right: 4px; opacity: .85; }
.badge-date em { font-style: normal; font-size: 13px; margin-left: 4px; opacity: .9; }

.badge-note { margin-top: 10px; }
.note-tag {
  display: inline-block; margin: 0 0 4px;
  font-size: 11px; font-weight: 900; color: #fff;
  background: #9a93ad; border-radius: 999px; padding: 2px 10px;
}
.badge-disclaimer { font-size: 11px; line-height: 1.55; margin: 0 0 8px; color: #7a7490; }
#badge-toggle { display: none; align-items: center; justify-content: center; flex-shrink: 0; width: 32px; height: 32px; border: 1px solid #dbcdbb; border-radius: 9px; background: white; color: var(--teal-d); padding: 0; font-size: 18px; font-weight: 700; cursor: pointer; }
#badge-details[hidden] { display: none; }
.badge-links { display: flex; gap: 6px; margin: 0; }
.badge-links a {
  flex: 1; text-align: center; text-decoration: none;
  font-size: 13px; font-weight: 900; color: #fff;
  background: linear-gradient(135deg, var(--teal), var(--teal-d));
  border-radius: 999px; padding: 7px 0;
  box-shadow: 0 3px 0 rgba(11,124,134,.3);
  transition: transform .15s;
}
.badge-links a:hover { transform: translateY(-2px) scale(1.04); }

/* 紙吹雪 */
.confetti i {
  position: absolute; width: 8px; height: 8px; border-radius: 2px; opacity: .5;
  animation: confetti-float 6s ease-in-out infinite;
}
.confetti i:nth-child(1) { background: var(--pink); top: 10px; right: 20px; animation-delay: 0s; }
.confetti i:nth-child(2) { background: var(--orange); top: 34px; right: 44px; border-radius: 50%; animation-delay: -1s; }
.confetti i:nth-child(3) { background: var(--lime); top: 14px; right: 70px; animation-delay: -2s; }
.confetti i:nth-child(4) { background: var(--teal); top: 52px; right: 14px; border-radius: 50%; animation-delay: -3s; }
.confetti i:nth-child(5) { background: var(--blue); top: 60px; right: 60px; animation-delay: -4s; }
.confetti i:nth-child(6) { background: var(--pink); top: 90px; right: 30px; border-radius: 50%; width: 6px; height: 6px; animation-delay: -2.5s; }
.confetti i:nth-child(7) { background: var(--lime); top: 120px; right: 12px; width: 6px; height: 6px; animation-delay: -1.5s; }
.confetti i:nth-child(8) { background: var(--orange); top: 110px; right: 78px; border-radius: 50%; width: 5px; height: 5px; animation-delay: -.5s; }
@keyframes confetti-float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(6px) rotate(20deg); }
}

/* ============ 右上FAB ============ */
#fab { position: absolute; top: 14px; right: 14px; z-index: 10; display: flex; gap: 10px; }
.fab-btn {
  width: 46px; height: 46px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--cream); color: var(--ink);
  box-shadow: 0 3px 0 rgba(61,58,80,.08), 0 8px 20px rgba(61,58,80,.18);
  display: grid; place-items: center;
  transition: transform .15s;
}
.fab-btn:hover { transform: scale(1.1) rotate(-4deg); }
.fab-btn.candy { background: linear-gradient(135deg, var(--pink), var(--orange)); color: #fff; }
.fab-btn.candy.live { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 3px 0 rgba(61,58,80,.08), 0 0 0 0 rgba(240,104,155,.5); }
  50% { box-shadow: 0 3px 0 rgba(61,58,80,.08), 0 0 0 12px rgba(240,104,155,0); }
}
#layers-pop {
  position: absolute; top: 54px; right: 0;
  background: var(--cream); border-radius: 18px; padding: 10px 14px;
  box-shadow: 0 8px 24px rgba(61,58,80,.2); min-width: 200px;
}
.pop-title { margin: 0 0 6px; font-size: 12px; font-weight: 900; color: var(--pink); }
#layer-toggles { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 700; }
#layer-toggles label { display: flex; gap: 7px; align-items: center; cursor: pointer; }
#layer-toggles input { accent-color: var(--teal); width: 15px; height: 15px; }

/* ============ 下部デッキ ============ */
#deck {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: 34px; z-index: 10; width: min(920px, calc(100vw - 16px));
  background: var(--cream); border-radius: 24px;
  padding: 20px 16px 10px;
  box-shadow: 0 6px 0 rgba(61,58,80,.08), 0 14px 34px rgba(61,58,80,.22);
  display: flex; gap: 14px; align-items: stretch;
}
#deck-handle {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 90px; height: 16px; cursor: ns-resize; touch-action: none;
}
#deck-handle::before {
  content: ""; position: absolute; top: 5px; left: 50%; transform: translateX(-50%);
  width: 46px; height: 5px; border-radius: 999px; background: #e6d7bc;
}
#deck-handle:hover::before { background: var(--teal); }

/* 展開時: カードを縦スクロール一覧に */
#deck.expanded { min-height: 240px; }
#deck.expanded .deck-main { min-height: 0; }
#deck.expanded #cards {
  flex: 1 1 auto; min-height: 0;
  flex-direction: column; overflow-y: auto; overflow-x: hidden;
  scrollbar-width: thin; padding-right: 4px;
}
#deck.expanded #cards::-webkit-scrollbar { display: block; width: 6px; }
#deck.expanded #cards::-webkit-scrollbar-thumb { background: #e6d7bc; border-radius: 999px; }
#deck.expanded .card {
  display: flex; align-items: baseline; gap: 12px;
  min-width: 0; max-width: none; width: 100%;
  border-top: 0; border-left: 5px solid var(--teal); border-radius: 12px;
}
#deck.expanded .card.parade { border-left-color: var(--blue); }
#deck.expanded .card.park { border-left-color: var(--green); }
#deck.expanded .card.town { border-left-color: var(--orange); }
#deck.expanded .card .c-name { font-size: 13px; }
#deck.expanded .card.now { transform: none; animation: none; }
#clock { flex: 0 0 auto; display: flex; flex-direction: column; justify-content: center; padding-right: 12px; border-right: 3px dotted #ead9c2; }
#time-display {
  font-size: 38px; font-weight: 900; line-height: 1;
  color: var(--teal-d); font-variant-numeric: tabular-nums;
}
#clock-label { font-size: 10px; font-weight: 700; color: #9a93ad; margin-top: 4px; letter-spacing: .08em; }

.deck-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* スケジュールカードのパレード */
#cards {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 8px;
  scroll-behavior: smooth;
  scrollbar-width: none;
}
#cards::-webkit-scrollbar { display: none; }
.card {
  flex: 0 0 auto; min-width: 118px; max-width: 170px;
  background: #fff; border-radius: 16px; padding: 7px 10px 8px;
  box-shadow: 0 2px 8px rgba(61,58,80,.12);
  cursor: pointer; border-top: 4px solid var(--teal);
  transition: transform .18s, box-shadow .18s, opacity .18s;
  user-select: none;
}
.card:hover { transform: translateY(-4px) rotate(-1deg); }
.card .c-time { font-size: 15px; font-weight: 900; font-variant-numeric: tabular-nums; }
.card .c-name { font-size: 11px; font-weight: 700; line-height: 1.35; margin-top: 2px; color: #5b5670; }
.card.parade { border-top-color: var(--blue); }
.card.parade .c-time { color: var(--blue); }
.card.park { border-top-color: var(--green); }
.card.park .c-time { color: var(--green); }
.card.town { border-top-color: var(--orange); }
.card.town .c-time { color: var(--orange); }
.card.now {
  transform: translateY(-4px);
  box-shadow: 0 0 0 3px rgba(240,104,155,.45), 0 6px 14px rgba(61,58,80,.2);
  animation: card-bounce 2s ease-in-out infinite;
}
.card.past { opacity: .4; }
@keyframes card-bounce {
  0%, 100% { transform: translateY(-4px); }
  50% { transform: translateY(-7px); }
}

/* スクラブバー */
#scrub { position: relative; padding: 6px 2px 0; }
#scrub-track {
  position: relative; height: 8px; border-radius: 999px;
  background: #efe4d3;
}
#scrub-fill {
  position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--teal), var(--pink));
  width: 0%;
}
#scrub-flag {
  position: absolute; top: -14px; width: 22px; height: 22px;
  transform: translateX(-50%);
  pointer-events: none;
}
#scrub-flag::before {
  content: ""; position: absolute; inset: 0;
  background: var(--pink); border-radius: 50% 50% 50% 4px;
  transform: rotate(-45deg); border: 2px solid #fff;
  box-shadow: 0 2px 5px rgba(61,58,80,.3);
}
#time-slider {
  position: absolute; inset: -10px 0 0; width: 100%; height: 26px;
  appearance: none; -webkit-appearance: none; background: transparent;
  margin: 0; cursor: pointer;
}
#time-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; background: transparent; }
#time-slider::-moz-range-thumb { width: 26px; height: 26px; background: transparent; border: 0; }

#live-toast {
  position: absolute; bottom: 150px; left: 50%; transform: translateX(-50%);
  z-index: 11; font-size: 12px; font-weight: 900; color: #fff;
  background: rgba(61,58,80,.85); border-radius: 999px; padding: 5px 14px;
  animation: toast-in .3s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ============ パレード先頭バルーン ============ */
.parade-balloon { pointer-events: none; }
.parade-balloon .b {
  width: 26px; height: 26px; border-radius: 50% 50% 50% 4px;
  background: linear-gradient(135deg, var(--blue), var(--teal));
  transform: rotate(-45deg); border: 3px solid #fff;
  box-shadow: 0 3px 8px rgba(61,58,80,.4);
  animation: balloon-bob 2s ease-in-out infinite;
}
@keyframes balloon-bob {
  0%, 100% { transform: rotate(-45deg) translate(0,0); }
  50% { transform: rotate(-45deg) translate(2px,-2px); }
}

/* ============ ポップアップ ============ */
.maplibregl-popup-content {
  font-family: var(--font); font-size: 13px; max-width: 320px;
  background: var(--cream); border-radius: 18px; padding: 12px 16px;
  box-shadow: 0 8px 24px rgba(61,58,80,.25);
}
.maplibregl-popup-content h3 { font-size: 15px; font-weight: 900; margin: 0 0 4px; color: var(--teal-d); }
.maplibregl-popup-content .time { color: var(--pink-d); font-weight: 900; margin: 0 0 4px; }
.maplibregl-popup-content .desc { margin: 0 0 6px; color: #5b5670; line-height: 1.6; }
.maplibregl-popup-content a { color: var(--teal); font-weight: 700; }
.maplibregl-popup-close-button { font-size: 15px; padding: 5px 9px; color: #9a93ad; }
.maplibregl-popup-tip { border-top-color: var(--cream) !important; }

@media (max-width: 720px) {
  #badge { width: 170px; padding: 12px 14px; max-height: calc(100dvh - 150px); overflow-y: auto; overscroll-behavior: contain; }
  #badge-toggle { display: inline-flex; }
  #badge-details:not([data-expanded="true"]) { display: none; }
  #badge h1 { font-size: 18px; }
  .badge-date { font-size: 16px; padding-left: 8px; padding-right: 8px; }
  #deck { flex-direction: column; gap: 6px; padding: 10px 12px 8px; }
  #clock { flex-direction: row; align-items: baseline; gap: 8px; border-right: 0; border-bottom: 3px dotted #ead9c2; padding: 0 0 4px; }
  #time-display { font-size: 30px; }
}

/* MapLibreコントロール位置調整（FAB・デッキとの重なり回避） */
.maplibregl-ctrl-top-right { top: 72px; right: 4px; }
.maplibregl-ctrl-top-right .maplibregl-ctrl { margin: 0 10px 10px 0; }

.note-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 5px 8px; margin-bottom: 5px; }
.note-heading .note-tag { margin: 0; }
#contact-open { border: 0; padding: 5px 0; background: none; font-size: 12px; color: var(--teal-d); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
#contact-dialog { box-sizing: border-box; width: min(580px, calc(100vw - 24px)); max-width: none; max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; padding: 24px; border: 0; border-radius: 24px; background: var(--cream); color: var(--ink); box-shadow: 0 24px 90px #26344166; }
#contact-dialog::backdrop { background: #24344299; backdrop-filter: blur(5px); }
.contact-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.contact-header h2 { color: var(--teal-d); font-size: 21px; margin: 0; }
#contact-close { flex-shrink: 0; border: 1px solid #dbcdbb; border-radius: 999px; background: white; padding: 9px 12px; color: var(--ink); cursor: pointer; }
#contact-intro { font-size: 14px; line-height: 1.7; }
#contact-form { display: grid; gap: 9px; }
#contact-form label { font-size: 14px; font-weight: 700; }
#contact-form label span { font-size: 12px; color: #70677b; }
#contact-form input:not([type="hidden"]), #contact-form textarea { box-sizing: border-box; width: 100%; min-width: 0; border: 1px solid #cbbda8; border-radius: 10px; padding: 10px; font: inherit; font-size: 16px; color: var(--ink); background: white; margin-bottom: 6px; }
#contact-form textarea { resize: vertical; }
.contact-honeypot { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.contact-privacy { font-size: 12px; line-height: 1.7; color: #70677b; margin: 2px 0 8px; }
#contact-submit { border: 0; border-radius: 999px; padding: 12px; background: var(--teal-d); color: white; font-weight: 900; cursor: pointer; }
#contact-status { font-size: 14px; line-height: 1.6; margin: 0; }
button, select, input { font: inherit; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid var(--pink-d); outline-offset: 4px; }
button:disabled { opacity: .5; cursor: wait; }
#map-toolbar {
  position: absolute; bottom: max(38px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  z-index: 10; display: flex; align-items: center; gap: 14px; padding: 10px 12px 10px 20px;
  background: var(--cream); border-radius: 999px; box-shadow: 0 8px 28px #3d3a5033; white-space: nowrap;
}
.map-clock { font-size: 13px; }
.map-clock strong { font-size: 22px; color: var(--teal-d); margin-left: 6px; }
#schedule-open, .map-link {
  border: 0; border-radius: 999px; background: var(--teal-d); color: white; cursor: pointer;
  padding: 12px 20px; font-weight: 900; font-size: 15px;
}
#schedule-open { background: linear-gradient(120deg, #bd3869, #c96810); }
#schedule-dialog {
  border: 0; border-radius: 28px; padding: 0; width: min(1060px, calc(100vw - 40px));
  max-width: none; height: min(850px, calc(100dvh - 48px)); max-height: calc(100dvh - 48px);
  background: var(--cream); color: var(--ink); box-shadow: 0 24px 90px #26344166;
}
#schedule-dialog::backdrop { background: #24344299; backdrop-filter: blur(5px); }
.schedule-shell { height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.schedule-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 24px 28px 18px; }
.schedule-kicker { color: var(--pink-d); font-size: 12px; font-weight: 900; margin: 0 0 4px; letter-spacing: .1em; }
.schedule-header h2 { color: var(--teal-d); font-size: clamp(22px, 3vw, 32px); margin: 0; }
#schedule-close { flex-shrink: 0; border: 1px solid #dbcdbb; border-radius: 999px; padding: 10px 15px; background: white; color: var(--ink); cursor: pointer; }
.time-panel { display: flex; align-items: center; gap: 30px; padding: 16px 28px; background: #f1eadc; }
#clock { border: 0; padding: 0; gap: 3px; flex-direction: column; align-items: flex-start; }
#clock-label { font-size: 13px; color: #686075; letter-spacing: 0; margin: 0; }
#time-display { font-size: 38px; }
.time-mode { display: flex; align-items: center; gap: 5px; font-size: 13px; white-space: nowrap; }
.time-mode input { accent-color: var(--teal-d); }
#time-slider:disabled { opacity: .35; }
.schedule-filters label:has(input:disabled) { opacity: .5; }
.time-controls { flex: 1; min-width: 0; padding-top: 12px; }
.time-ticks { display: flex; justify-content: space-between; font-size: 12px; color: #686075; padding-top: 12px; }
.schedule-filters { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; padding: 14px 28px; font-size: 14px; border-bottom: 1px solid #e8ddce; }
.schedule-filters label { display: flex; align-items: center; gap: 8px; }
.schedule-filters select { padding: 7px 10px; border: 1px solid #cbbda8; border-radius: 12px; background: white; color: var(--ink); }
.schedule-filters input { width: 18px; height: 18px; accent-color: var(--teal-d); }
.schedule-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 8px 28px 28px; }
.schedule-notices, .schedule-help { font-size: 13px; line-height: 1.7; }
.schedule-notices { background: #fff0d4; border-radius: 14px; padding: 12px 16px; }
#cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; overflow: visible; padding: 8px 3px; scrollbar-width: auto; }
.card { min-width: 0; max-width: none; padding: 18px; cursor: default; user-select: auto; border-top-width: 5px; border-radius: 20px; }
.card:hover, .card.now { transform: none; animation: none; }
.card[hidden] { display: none; }
.card.now { box-shadow: 0 0 0 2px var(--pink), 0 6px 16px #3d3a5018; }
.card-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.card .c-time { font-size: 17px; }
.event-status { color: #70677b; font-size: 12px; }
.card.now .event-status { background: #ffe5ef; color: #9c2e57; padding: 3px 8px; border-radius: 999px; }
.card h3 { margin: 12px 0 5px; font-size: 19px; line-height: 1.45; }
.card p { font-size: 14px; line-height: 1.7; margin: 6px 0; }
.card .venue { color: var(--teal-d); font-weight: 700; }
.card .verification, .verification { font-size: 12px; color: #855716; line-height: 1.65; }
.popup-links { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.popup-links a { display: inline-block; padding: 8px 0; color: var(--teal-d); font-weight: 700; text-underline-offset: 3px; }
.map-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.map-link { padding: 9px 15px; font-size: 14px; text-align: left; }
.maplibregl-popup-content { max-height: min(380px, 50dvh); overflow-y: auto; font-size: 14px; }
#live-toast { bottom: 112px; max-width: calc(100vw - 50px); text-align: center; }
@media (max-width: 720px) {
  #schedule-dialog { width: calc(100vw - 16px); height: calc(100dvh - 24px); max-height: calc(100dvh - 24px); border-radius: 22px; }
  .schedule-header { padding: 18px 16px 14px; }
  .schedule-kicker { font-size: 9px; }
  #schedule-close { padding: 8px 10px; font-size: 13px; }
  .time-panel { gap: 20px; padding: 14px 16px; }
  #time-display { font-size: 30px; }
  .schedule-filters { padding: 10px 16px; font-size: 13px; gap: 10px; }
  .schedule-scroll { padding: 6px 16px 20px; }
  #cards { grid-template-columns: minmax(0, 1fr); }
  #map-toolbar { gap: 10px; padding: 8px 10px 8px 14px; }
  #schedule-open { font-size: 13px; padding: 12px 14px; }
  .map-clock { font-size: 11px; }
  .map-clock strong { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
