    * { box-sizing: border-box; margin: 0; padding: 0; }
    :root {
      /* 「駅の案内サイン」をモチーフにした配色。地図・AR映像が主役なので、周りのUIは
         紙色(--paper)とインク(--ink)、罫線(--line)だけで構成し、色は要所の signal(バーミリオン)
         だけに絞る。カード風の丸み・ドロップシャドウの多用はやめ、線で区切る。 */
      --ink:           #14181F;
      --ink-soft:       #4B5563;
      --paper:          #F6F6F2;
      --line:           #DBDCD4;
      --line-strong:    #C3C5BB;
      --accent:             #E8501E; /* signal: 主要アクション・選択状態にのみ使う */
      --accent-dark:        #B93C14;
      --accent-darker:      #7A2A0D;
      --accent-light:       #FCEEE7;
      --accent-border-light: #F0C3AE;
      --transit-blue:   #1B3A6B; /* 地図・現在地まわりの構造色 */
      --go:             #1E7145; /* 到着・成功状態 */
    }
    /* イベントモード (?event=1): アクセントを祭りの金へ切り替える（案内サインの通常色と混同しないため） */
    body.event-mode {
      --accent:             #A8720A;
      --accent-dark:        #7C5407;
      --accent-darker:      #543905;
      --accent-light:       #FBF1D9;
      --accent-border-light: #E6CB8C;
    }
    html { height: 100%; overscroll-behavior: none; }
    body {
      height: 100%; overflow: hidden;
      overscroll-behavior: none;
      background: var(--paper);
      color: var(--ink);
      font-family: 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', 'Yu Gothic', 'Helvetica Neue', Arial, sans-serif;
      display: flex;
      flex-direction: column; /* mobile: stacked */
    }
    button, a, select, input, label {
      touch-action: manipulation; /* ダブルタップズームを無効化 */
    }

    /* ================================================================
       Mobile layout — sidebar dissolves via display:contents;
       children participate directly in body's flex flow via order.
    ================================================================ */
    #sidebar { display: contents; }

    #app-header  { display: none; } /* mobile: hidden */

    #search-panel {
      order: 1;
      background: var(--paper);
      padding: 0;
      border-bottom: 1px solid var(--line);
      flex-shrink: 0;
      z-index: 100;
    }
    #search-header {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 8px 10px;
    }
    #btn-home {
      flex-shrink: 0;
      width: 28px; height: 28px;
      border: 1px solid var(--line-strong); border-radius: 6px;
      background: #fff;
      display: flex; align-items: center; justify-content: center;
      color: var(--ink-soft); font-size: 15px; line-height: 1;
      text-decoration: none;
      -webkit-tap-highlight-color: transparent;
    }
    #btn-home:active { background: var(--line); }
    #search-toggle {
      flex-shrink: 0;
      width: 28px; height: 28px;
      border: 1px solid var(--line-strong); border-radius: 6px;
      background: #fff;
      display: flex; align-items: center; justify-content: center;
      cursor: pointer; color: var(--ink-soft); font-size: 13px;
      -webkit-tap-highlight-color: transparent;
    }
    #search-chevron {
      display: inline-block;
      transition: transform 0.3s ease;
      line-height: 1;
    }
    #search-chevron.open { transform: rotate(180deg); }
    #search-content {
      display: grid;
      grid-template-rows: 0fr;
      transition: grid-template-rows 0.3s ease;
    }
    #search-content.open { grid-template-rows: 1fr; }
    .search-content-inner {
      overflow: hidden;
      padding: 0 10px 8px;
    }
    #map-area {
      order: 2;
      flex: 1;
      position: relative;
      overflow: hidden;
      min-height: 0;
    }
    #ar-area {
      order: 4;
      flex: 1;
      background: #1B1F24;
      position: relative;
      overflow: hidden;
      min-height: 0;
    }

    /* ================================================================
       Desktop layout (>= 768px) — sidebar + map side by side
    ================================================================ */
    @media (min-width: 768px) {
      body { flex-direction: row; }

      #sidebar {
        display: flex;
        flex-direction: column;
        width: 340px;
        flex-shrink: 0;
        height: 100%;
        background: var(--paper);
        border-right: 1px solid var(--line);
        /* no overflow:hidden — needed so suggestions can overflow */
      }

      #app-header {
        display: flex;
        align-items: center;
        gap: 10px;
        height: 52px;
        padding: 0 18px;
        border-bottom: 1px solid var(--line);
        flex-shrink: 0;
        background: var(--paper);
      }
      #app-header .hdr-title {
        font-size: 15px;
        font-weight: 800;
        color: var(--ink);
        letter-spacing: 0.01em;
        text-decoration: none;
      }
      #app-header .hdr-title:hover { color: var(--transit-blue); }
      #app-header .hdr-badge {
        font-size: 11px;
        color: var(--accent-dark);
        background: var(--accent-light);
        padding: 2px 9px;
        border-radius: 4px;
        font-weight: 700;
      }

      #search-panel {
        order: 0;
        border-bottom: 1px solid var(--line);
        padding: 0;
        flex-shrink: 0;
      }
      #search-header { padding: 14px 16px 8px; }
      #search-toggle { display: none; }
      #btn-home      { display: none; } /* desktop: app-header にリンクがあるため不要 */
      #search-content { display: block; }
      .search-content-inner { overflow: visible; padding: 0 16px 14px; }

      #ar-area {
        order: 0;
        flex: 1;
        min-height: 0;
      }

      #map-area {
        flex: 1;
        min-width: 0;
      }
    }

    /* ================================================================
       Search Panel internals
    ================================================================ */
    .search-tabs { display: flex; gap: 4px; flex: 1; border-bottom: 1px solid var(--line); }
    .search-tab {
      flex: 1; height: 34px;
      border: none; border-bottom: 2px solid transparent;
      background: none; font-size: 13px; font-weight: 600;
      color: var(--ink-soft); cursor: pointer; transition: color 0.15s, border-color 0.15s;
    }
    .search-tab.active { color: var(--ink); border-bottom-color: var(--accent); }

    .route-row {
      display: flex;
      align-items: center;
      gap: 6px;
      margin-bottom: 6px;
    }
    .route-label {
      font-size: 12px;
      font-weight: 700;
      color: var(--ink-soft);
      width: 28px;
      flex-shrink: 0;
      text-align: center;
    }
    .building-select {
      height: 38px;
      padding: 0 3px;
      border: 1px solid var(--line-strong);
      border-radius: 4px;
      font-size: 12px;
      color: var(--ink);
      background: #fff;
      width: 76px;
      flex-shrink: 0;
      cursor: pointer;
    }
    .building-select:focus { outline: none; border-color: var(--transit-blue); }

    .ac-wrap { flex: 1; position: relative; }
    .ac-wrap input {
      width: 100%;
      height: 38px;
      padding: 0 12px;
      border: 1px solid var(--line-strong);
      border-radius: 4px;
      font-size: 15px;
      color: var(--ink);
      outline: none;
      -webkit-appearance: none;
      background: #fff;
    }
    .ac-wrap input:focus { border-color: var(--transit-blue); }

    .suggestions {
      display: none;
      position: absolute;
      top: calc(100% + 3px);
      left: 0; right: 0;
      background: #fff;
      border: 1px solid var(--line-strong);
      border-radius: 4px;
      max-height: 180px;
      overflow-y: auto;
      z-index: 200;
      box-shadow: 0 4px 14px rgba(20,24,31,0.14);
    }
    .suggestions .item {
      padding: 9px 12px;
      font-size: 14px;
      color: var(--ink);
      cursor: pointer;
      border-bottom: 1px solid var(--line);
    }
    .suggestions .item:last-child { border-bottom: none; }
    .suggestions .item:active,
    .suggestions .item:hover { background: var(--accent-light); color: var(--accent-dark); }

    .bottom-row {
      display: flex;
      align-items: center;
      gap: 10px;
    }
    .ev-label {
      display: flex;
      align-items: center;
      gap: 5px;
      font-size: 13px;
      color: var(--ink-soft);
      white-space: nowrap;
      cursor: pointer;
      flex-shrink: 0;
    }
    .ev-label input[type="checkbox"] {
      width: 16px;
      height: 16px;
      accent-color: var(--accent);
      cursor: pointer;
    }
    #btn-search {
      flex: 1;
      height: 40px;
      border: none;
      border-radius: 4px;
      background: var(--accent);
      color: white;
      font-size: 15px;
      font-weight: 700;
      cursor: pointer;
      transition: background 0.15s;
    }
    #btn-search:hover { background: var(--accent-dark); }

    .category-tabs { display: flex; gap: 4px; flex: 1; border-bottom: 1px solid var(--line); }
    .category-tab {
      flex: 1; height: 34px;
      border: none; border-bottom: 2px solid transparent;
      background: none; font-size: 13px; font-weight: 600;
      color: var(--ink-soft); cursor: pointer; transition: color 0.15s, border-color 0.15s;
    }
    .category-tab.active { color: var(--ink); border-bottom-color: var(--accent); }

    /* イベントモード (?event=1) のときだけ表示されるバッジ */
    #event-badge {
      display: none;
      align-items: center;
      font-size: 11px; font-weight: 700;
      color: var(--accent-dark); background: var(--accent-light);
      border: 1px solid var(--accent-border-light);
      padding: 3px 8px; border-radius: 4px;
      white-space: nowrap; flex-shrink: 0;
    }
    #btn-fac-search {
      flex: 1; height: 40px; border: none; border-radius: 4px;
      background: var(--accent);
      color: white; font-size: 15px; font-weight: 700;
      cursor: pointer; transition: background 0.15s;
    }
    #btn-fac-search:hover { background: var(--accent-dark); }

    .gps-wrapper {
      border: 1px solid var(--line-strong); border-radius: 4px;
      margin-bottom: 6px; overflow: hidden;
    }
    .gps-row {
      display: flex; gap: 8px; align-items: center;
      padding: 8px 12px; background: var(--paper);
    }
    .gps-row span { flex: 1; font-size: 13px; color: var(--ink-soft); word-break: break-all; }
    .btn-gps {
      height: 32px; padding: 0 14px; border: none; border-radius: 4px;
      background: var(--transit-blue); color: white; font-size: 13px;
      font-weight: 600; cursor: pointer; white-space: nowrap; flex-shrink: 0;
    }
    .btn-swap {
      display: block; width: 28px; height: 28px;
      margin: 0 0 4px 0;
      background: #fff; border: 1px solid var(--line-strong); border-radius: 6px;
      font-size: 16px; line-height: 1; cursor: pointer; color: var(--ink-soft);
      transition: background 0.15s, color 0.15s, border-color 0.15s;
    }
    .btn-swap:hover { background: var(--accent-light); color: var(--accent-dark); border-color: var(--accent-border-light); }

    #accuracy-warn,
    #fac-accuracy-warn {
      display: none;
      padding: 6px 12px; font-size: 12px; line-height: 1.6;
    }
    #accuracy-warn.warn-low,  #fac-accuracy-warn.warn-low  { background: #FBF1D9; color: #543905; }
    #accuracy-warn.warn-high, #fac-accuracy-warn.warn-high { background: #FBEAE6; color: #7A2A0D; }

    /* ================================================================
       Map / SVG
    ================================================================ */
    #map { width: 100%; height: 100%; }

    #svg-area {
      display: none; width: 100%; height: 100%;
      position: absolute; inset: 0; background: var(--paper); overflow: hidden;
    }
    #svg-container {
      width: 100%; height: 100%;
      touch-action: none;        /* ブラウザスクロール抑制（ドラッグ用） */
      user-select: none;
      cursor: grab;
    }
    #svg-container:active { cursor: grabbing; }
    #svg-container svg { width: 100%; height: 100%; overflow: visible; }

    .err-box {
      width: 100%; height: 100%; min-height: 180px;
      display: flex; flex-direction: column;
      align-items: center; justify-content: center;
      gap: 10px; padding: 24px; text-align: center;
      color: var(--ink-soft);
    }
    .err-box .err-title { font-size: 15px; font-weight: 700; color: var(--ink); }
    .err-box .err-desc  { font-size: 13px; line-height: 1.7; }
    .err-box .err-hint  {
      font-size: 12px; color: var(--ink-soft);
      background: #fff; border: 1px solid var(--line); padding: 8px 16px; border-radius: 4px; margin-top: 4px;
    }

    #floor-badge {
      position: absolute; top: 10px; left: 10px; z-index: 10;
      background: var(--ink); border-radius: 4px; padding: 6px 14px;
      font-size: 13px; font-weight: 700; color: #fff;
      font-variant-numeric: tabular-nums;
      box-shadow: 0 2px 8px rgba(20,24,31,0.28);
    }

    /* ================================================================
       Step navigation — AR画像上のオーバーレイ
    ================================================================ */
    .nav-arrow {
      position: absolute; top: 50%; transform: translateY(-50%);
      width: 46px; height: 46px; border-radius: 50%;
      border: none; background: rgba(255,255,255,0.92);
      font-size: 18px; cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      color: var(--ink-soft); z-index: 20;
      box-shadow: 0 2px 10px rgba(0,0,0,0.35);
      -webkit-tap-highlight-color: transparent;
      transition: background 0.12s, opacity 0.12s;
    }
    #prev-btn { left: 10px; }
    #next-btn { right: 10px; }
    .nav-arrow:not(:disabled):hover  { background: white; }
    .nav-arrow:not(:disabled):active { transform: translateY(-50%) scale(0.92); }
    .nav-arrow:disabled { opacity: 0.35; cursor: not-allowed; }

    #step-info {
      position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
      max-width: calc(100% - 20px);
      z-index: 20; text-align: center;
      background: rgba(20,24,31,0.72); color: rgba(255,255,255,0.96);
      padding: 5px 16px; border-radius: 4px;
      backdrop-filter: blur(4px);
      pointer-events: none;
    }
    #step-label {
      font-size: 13px; font-weight: 700;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    #step-count { font-size: 11px; color: rgba(255,255,255,0.75); margin-top: 1px; font-variant-numeric: tabular-nums; }

    @media (min-width: 768px) {
      #step-label { font-size: 14px; }
      .nav-arrow  { width: 50px; height: 50px; }
    }

    /* ================================================================
       AR Area
    ================================================================ */
    .ar-cached-img {
      display: none;
      position: absolute;
      inset: 0;
      width: 100%; height: 100%;
      object-fit: cover;
    }
    .ar-cached-img.active { display: block; }
    #ar-placeholder {
      width: 100%; height: 100%;
      display: flex; flex-direction: column;
      align-items: center; justify-content: center;
      gap: 8px;
      color: #fff;
    }
    #ar-placeholder .ph-text {
      font-size: 12px;
      color: rgba(255,255,255,0.55);
      letter-spacing: 0.1em;
    }
    #ar-placeholder.arrival {
      background: linear-gradient(160deg, var(--go) 0%, #133F27 100%);
      gap: 12px;
    }
    #ar-placeholder.arrival .arrival-icon {
      font-size: 48px;
      line-height: 1;
    }
    #ar-placeholder.arrival .arrival-title {
      font-size: 18px; font-weight: 800; color: #fff;
    }
    #ar-placeholder.arrival .arrival-desc {
      font-size: 13px; color: rgba(255,255,255,0.85); text-align: center; line-height: 1.6;
    }
    #ar-label {
      display: none;
      position: absolute; bottom: 10px; left: 10px;
      background: rgba(20,24,31,0.72);
      color: rgba(255,255,255,0.9);
      font-size: 12px; font-weight: 600;
      padding: 4px 12px; border-radius: 4px;
      backdrop-filter: blur(4px);
      pointer-events: none;
    }
    #direction-arrow {
      display: none;
      position: absolute;
      left: 50%;
      /* ↓ 矢印の縦位置: 値を大きくすると画面下（手前）に移動 / 小さくすると奥に移動 */
      top: 80%;
      transform: translate(-50%, -50%);
      /* ↓ 矢印のサイズ: clamp(最小, 基準, 最大) — 基準値を変えると全体的なサイズが変わる */
      width: clamp(130px, 50vmin, 220px);
      height: auto;
      opacity: 0.90;
      pointer-events: none;
      z-index: 10;
      filter: drop-shadow(0 3px 10px rgba(0,0,0,0.65));
    }
    /* 最終区間（目的地エッジ上）で矢印の代わりに出すバッジ */
    #near-goal-badge {
      display: none;
      position: absolute;
      left: 50%;
      top: 80%;
      transform: translate(-50%, -50%);
      background: rgba(30, 113, 69, 0.94);
      color: #fff;
      font-size: 16px; font-weight: 700;
      padding: 10px 22px; border-radius: 4px;
      white-space: nowrap;
      pointer-events: none;
      z-index: 10;
      box-shadow: 0 3px 10px rgba(0,0,0,0.45);
    }

    /* ================================================================
       Completion modal
    ================================================================ */
    #completion-modal {
      display: none;
      position: fixed; inset: 0; z-index: 600;
      align-items: center; justify-content: center;
      padding: 20px;
      background: rgba(20, 24, 31, 0.55);
      backdrop-filter: blur(6px);
      -webkit-backdrop-filter: blur(6px);
      animation: modalFadeIn 0.25s ease both;
    }
    #completion-modal.show { display: flex; }

    #completion-box {
      background: #fff;
      border-radius: 6px;
      padding: 36px 32px 28px;
      max-width: 360px;
      width: 100%;
      box-shadow: 0 24px 64px rgba(20,24,31,0.28);
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 8px;
      text-align: center;
      animation: modalSlideUp 0.3s cubic-bezier(0.22,1,0.36,1) both;
    }

    .modal-icon {
      width: 60px; height: 60px;
      border-radius: 50%;
      background: #E9F4EE;
      color: var(--go);
      display: flex; align-items: center; justify-content: center;
      font-size: 26px;
      margin-bottom: 4px;
    }
    .modal-title {
      font-size: 20px; font-weight: 800;
      color: var(--ink); letter-spacing: -0.01em;
      margin-bottom: 2px;
    }
    .modal-desc {
      font-size: 14px; color: var(--ink-soft);
      line-height: 1.65; margin-bottom: 12px;
    }
    .modal-btn-survey {
      width: 100%; height: 48px;
      border: none; border-radius: 4px;
      background: var(--accent);
      color: white; font-size: 15px; font-weight: 700;
      cursor: pointer; transition: background 0.15s;
      text-decoration: none;
      display: flex; align-items: center; justify-content: center;
      gap: 6px;
    }
    .modal-btn-survey:hover { background: var(--accent-dark); }
    .modal-btn-continue {
      width: 100%; height: 44px;
      border: 1px solid var(--line-strong); border-radius: 4px;
      background: #fff; color: var(--ink-soft);
      font-size: 14px; font-weight: 600;
      cursor: pointer; transition: background 0.15s;
      margin-top: 4px;
    }
    .modal-btn-continue:hover { background: var(--paper); }

    @keyframes modalFadeIn {
      from { opacity: 0; } to { opacity: 1; }
    }
    @keyframes modalSlideUp {
      from { opacity: 0; transform: translateY(24px) scale(0.97); }
      to   { opacity: 1; transform: translateY(0)    scale(1); }
    }

    /* ================================================================
       Loading overlay
    ================================================================ */
    #loading {
      display: none; position: fixed; inset: 0; z-index: 500;
      background: rgba(20,24,31,0.5);
      align-items: center; justify-content: center;
    }
    #loading.show { display: flex; }
    #loading-box {
      background: #fff; border-radius: 6px; padding: 22px 36px;
      font-size: 16px; font-weight: 600; color: var(--ink);
      box-shadow: 0 10px 40px rgba(20,24,31,0.24);
    }

    /* ================================================================
       AR Outdoor Elements
    ================================================================ */
    #ar-bg-video {
      display: none;
      position: absolute; inset: 0;
      width: 100%; height: 100%;
      object-fit: cover; z-index: 1;
    }
    #ar-gl-canvas {
      display: none;
      position: absolute; inset: 0;
      width: 100%; height: 100%;
      z-index: 2; pointer-events: none;
    }
