  * { box-sizing: border-box; }
  html, body { margin: 0; padding: 0; height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: #262626; color: #eee; }
  #app { display: grid; grid-template-rows: auto 1fr auto; height: 100%; }
  header { display: flex; align-items: center; gap: 18px; padding: 10px 16px; background: #11131a; border-bottom: 1px solid #2a2d36; position: relative; }
  header .brand { display: flex; flex-direction: column; line-height: 1.05; }
  header h1 { margin: 0; font-family: Georgia, serif; font-size: 22px; font-weight: 700; }
  header .tagline { font-family: Georgia, serif; font-style: italic; font-size: 11px; color: #8a8f9c; margin-top: 2px; }
  header .stat { font-size: 14px; color: #aaa; }
  header .stat b { color: #fff; }
  main { display: grid; grid-template-columns: 1.4fr 1fr; min-height: 0; }
  #viewer-wrap { position: relative; background: #000; display: flex; flex-direction: column; min-height: 0; }
  #viewer { flex: 1; min-height: 0; position: relative; overflow: hidden; }
  #viewer .imgscroll { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
  #viewer .imgscroll img { max-width: 100%; max-height: 100%; width: auto; height: auto; display: block; }
  /* Very wide images: fill the viewer height and crop to the center (static --
     no panning). The centered flex child overflows equally on both sides and
     overflow:hidden clips it, so the middle of the image is what shows. */
  #viewer.zoomed .imgscroll { overflow: hidden; }
  #viewer.zoomed .imgscroll img { height: 100%; max-width: none; }
  /* Per-image credit sits in the footer bar on desktop; on mobile (footer
     hidden) it shows as a small line below the thumbnails instead. */
  #mobile-credit { display: none; }
  #pannellum-container { width: 100%; height: 100%; }
  /* While pannellum decodes the equirectangular + builds its WebGL texture it
     shows its own "Loading..." box. We instead paint the already-cached flat
     best-frame underneath and hide pannellum's box, so there's no flash. */
  #viewer .pnlm-load-box { display: none !important; }
  #viewer .pano-placeholder { position: absolute; inset: 0; width: 100%; height: 100%;
    object-fit: contain; background: #000; z-index: 1;
    transition: opacity 0.2s ease; pointer-events: none; }
  .viewer-loading { position: absolute; inset: 0; display: flex; align-items: center;
    justify-content: center; color: #888; font-size: 15px;
    animation: loading-pulse 1.2s ease-in-out infinite; }
  @keyframes loading-pulse { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }
  .img-failed { display: flex; align-items: center; justify-content: center;
    height: 100%; padding: 0 24px; text-align: center; color: #aaa; font-size: 14px; }
  @media (prefers-reduced-motion: reduce) {
    .viewer-loading { animation: none; opacity: 1; }
  }
  #thumbs { display: flex; gap: 4px; padding: 4px; background: #0c0d12; }
  #thumbs button { flex: 1; height: 70px; padding: 0; border: 2px solid transparent; background: #000 center/cover no-repeat; cursor: pointer; opacity: 0.6; }
  #thumbs button.active { border-color: #f2994a; opacity: 1; }
  #map-wrap { display: flex; flex-direction: column; min-height: 0; }
  #map { flex: 1; min-height: 0; background: #1a1c22; overflow: hidden; cursor: default; }
  #map-overlay { padding: 10px 16px; background: #0c0d12; border-top: 1px solid #2a2d36; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
  #map-overlay button { padding: 8px 16px; background: #f2994a; color: #000; font-weight: 600; border: 0; border-radius: 4px; cursor: pointer; }
  #map-overlay button:disabled { background: #444; color: #777; cursor: not-allowed; }
  #map-overlay .msg { font-size: 14px; flex: 1; min-width: 200px; }
  #map-overlay .phase-pill { display: inline-block; padding: 3px 10px; border-radius: 12px; background: #2a2d36; font-size: 12px; color: #ddd; }
  #map-overlay .phase-pill.active { background: #f2994a; color: #000; }
  .badge { display: inline-block; padding: 2px 8px; border-radius: 10px; background: #2a2d36; font-size: 11px; color: #aaa; }
  .badge.pano { background: #1a5276; color: #fff; }
  footer { padding: 6px 16px; font-size: 12px; color: #9a9a9a; background: #11131a; border-top: 1px solid #2a2d36;
    display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
  #footer-credit { color: #888; white-space: nowrap; }

  /* Auth + leaderboard chrome */
  header .header-btn { padding: 4px 10px; background: #2a2d36; color: #ddd; border: 0; border-radius: 4px; cursor: pointer; font-size: 13px; white-space: nowrap; }
  header .header-btn:hover { background: #3a3d46; }
  header .user-pill { font-size: 13px; color: #ddd; }
  header .user-pill b { color: #f2994a; }

  /* Hamburger + dropdown (both platforms). Leaderboard/Stats live only here;
     the game line and sign in/out items are menu-only on mobile, since the
     desktop header already shows the G number and the auth button. */
  #menu-panel { display: none; position: absolute; top: 100%; right: 8px; z-index: 10000;
    min-width: 160px; background: #1b1d22; border: 1px solid #2a2d36; border-radius: 6px;
    padding: 4px 0; box-shadow: 0 6px 18px rgba(0,0,0,0.5); }
  #menu-panel.open { display: block; }
  #menu-panel .menu-game { padding: 8px 14px; font-size: 12px; color: #8a8f9c;
    border-bottom: 1px solid #2a2d36; }
  #menu-panel .menu-item { display: block; width: 100%; padding: 10px 14px; text-align: left;
    background: none; border: 0; font-size: 14px; color: #ddd; text-decoration: none;
    cursor: pointer; box-sizing: border-box; font-family: inherit; }
  #menu-panel .menu-item:hover { background: #2a2d36; }
  #menu-panel .menu-game, #menu-panel #menu-auth { display: none; }
  .modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center; z-index: 9999; }
  .modal { background: #1b1d22; border: 1px solid #2a2d36; border-radius: 6px; padding: 24px; min-width: 320px; max-width: 480px; max-height: 80vh; overflow: auto; }
  .modal h3 { margin: 0 0 14px; font-family: Georgia, serif; font-size: 20px; }
  .modal label { display: block; font-size: 12px; color: #aaa; margin-top: 10px; }
  .modal input { width: 100%; padding: 8px; background: #11131a; border: 1px solid #2a2d36; color: #eee; border-radius: 4px; box-sizing: border-box; }
  .modal .err { color: #e57373; font-size: 12px; margin-top: 8px; min-height: 16px; }
  .modal .actions { margin-top: 16px; display: flex; gap: 8px; justify-content: flex-end; }
  .modal .actions button { padding: 8px 16px; background: #f2994a; color: #000; font-weight: 600; border: 0; border-radius: 4px; cursor: pointer; }
  .modal .actions button.secondary { background: #2a2d36; color: #ddd; }
  .modal .switch-mode { font-size: 12px; color: #aaa; text-align: center; margin-top: 12px; }
  .modal .switch-mode a { color: #f2994a; cursor: pointer; }
  .lb-table { width: 100%; border-collapse: collapse; font-size: 13px; }
  .lb-table th, .lb-table td { padding: 6px 8px; text-align: left; border-bottom: 1px solid #2a2d36; }
  .lb-table th { color: #888; font-weight: normal; font-size: 11px; text-transform: uppercase; }
  .lb-table tr.me { background: #2a2d36; }

  /* ===== mobile (single-column, taller buttons, no side-by-side) ===== */
  @media (max-width: 700px) {
    #app { grid-template-rows: auto 1fr; }
    header { padding: 8px 12px; gap: 10px; }
    header h1 { font-size: 18px; }
    header .tagline { display: none; }
    header .stat { font-size: 13px; }
    header .header-btn { padding: 6px 12px; font-size: 13px; }
    /* Header slims down to brand + round; everything else moves into the menu */
    header .desktop-only { display: none; }
    #menu-btn { font-size: 16px; line-height: 1; }
    #menu-panel .menu-game { display: block; }
    #menu-panel #menu-auth { display: block; }
    main {
      grid-template-columns: 1fr;
      grid-template-rows: 45vh 1fr;
    }
    #viewer-wrap { min-height: 0; }
    #thumbs button { height: 56px; }
    /* Left-aligned so the ©/author (the required attribution) is always
       visible; a long tail truncates with a proper ellipsis. text-align:right
       + text-overflow:ellipsis would instead clip the tail with no ellipsis. */
    #mobile-credit { display: block; padding: 3px 8px; font-size: 9px; line-height: 1.4;
      color: #888; background: #0c0d12; text-align: left; max-width: 100%;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    #map-wrap { min-height: 0; }
    #map { touch-action: none; }
    #map-overlay { padding: 10px 12px; gap: 8px; }
    #map-overlay button { padding: 12px 18px; font-size: 15px; flex-shrink: 0; }
    #map-overlay .msg { font-size: 13px; line-height: 1.3; }
    #map-overlay .phase-pill { padding: 4px 10px; font-size: 11px; }
    footer { display: none; }   /* desktop helper text not useful on touch */
    .modal { min-width: 0; width: calc(100vw - 32px); }
  }
