/* ============================================================
   本八幡RECON — layout & components
   ============================================================ */

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--c-text);
  background: var(--c-bg);
  background-image: var(--wash);
  background-attachment: fixed;
  background-repeat: no-repeat;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
h1, h2, h3, p, ol, ul, dl, dd, figure, fieldset { margin: 0; }
ol, ul { padding: 0; list-style: none; }
fieldset { border: 0; padding: 0; min-inline-size: 0; }
button { font: inherit; color: inherit; }
a { color: var(--c-accent-hi); text-underline-offset: 2px; }
strong { font-weight: 700; color: var(--c-text); }
:where(input, button, textarea, select) { font-family: inherit; }
code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--c-surface-2);
  border: 1px solid var(--c-line);
  padding: 0.12em 0.42em;
  border-radius: 6px;
}

/* ---------- a11y ---------- */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
:focus-visible { outline: none; }
:where(a, button, input, [tabindex], summary):focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--r-sm);
}

/* ---------- skyline (decor) ---------- */
.skyline {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: min(38vh, 320px);
  pointer-events: none; z-index: 0;
  opacity: 0.5;
  mask-image: linear-gradient(180deg, transparent, #000 55%);
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 55%);
}
.skyline svg { width: 100%; height: 100%; display: block; }
body[data-screen="game"] .skyline { display: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .skyline { opacity: 0.7; }
}
:root[data-theme="light"] .skyline { opacity: 0.7; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--sp-4);
  padding: 0 max(var(--sp-5), var(--safe-l)) 0 max(var(--sp-5), var(--safe-l));
  padding-top: var(--safe-t);
  border-bottom: 1px solid var(--c-line);
  background: color-mix(in srgb, var(--c-bg) 78%, transparent);
  backdrop-filter: blur(10px) saturate(1.2);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
}
.brand { display: flex; align-items: center; gap: var(--sp-2); font-weight: 800; letter-spacing: var(--tr-tight); }
.brand__mark {
  position: relative;
  width: 24px; height: 24px; border-radius: 8px;
  background:
    radial-gradient(15px 15px at 50% 118%, var(--c-sun) 0 42%, transparent 46%),
    linear-gradient(180deg, #3a2f4d 0%, #1a1524 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.14), var(--shadow-1);
  overflow: hidden;
}
.brand__mark::after {
  content: ""; position: absolute; left: 0; right: 0; top: 58%; height: 1.5px;
  background: linear-gradient(90deg, transparent, rgba(255,180,84,0.9), transparent);
}
.brand__name { font-size: var(--fs-lg); }
.brand__accent {
  background: var(--grad-sunrise-text); -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.brand__tag { color: var(--c-text-faint); font-size: var(--fs-sm); }
body[data-screen="game"] .topbar { display: none; }

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

/* ---------- stage / screens ---------- */
.stage { position: relative; z-index: 1; min-height: calc(100dvh - var(--topbar-h)); }
body[data-screen="game"] .stage { min-height: 100dvh; }

.screen[hidden] { display: none; }
.screen { animation: screen-in var(--dur-slow) var(--ease) both; }
.screen--center {
  min-height: calc(100dvh - var(--topbar-h));
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding:
    max(var(--sp-6), var(--safe-t))
    max(var(--sp-5), var(--safe-r))
    max(var(--sp-8), var(--safe-b))
    max(var(--sp-5), var(--safe-l));
}
/* auto margins centre the panel when it fits and yield to scroll when it doesn't
   (no clipped top on tall summary/setup at short viewports) */
.screen--center > * { max-width: 100%; margin-block: auto; }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- buttons ---------- */
.btn {
  --btn-bg: var(--c-surface-2);
  --btn-fg: var(--c-text);
  --btn-bd: var(--c-line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 44px;
  padding: 0.68em 1.2em;
  border: 1px solid var(--btn-bd);
  border-radius: var(--r-full);
  background: var(--btn-bg); color: var(--btn-fg);
  font-weight: 700; letter-spacing: var(--tr-tight);
  text-align: center; white-space: nowrap;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease),
              opacity var(--dur-fast) var(--ease);
}
.btn:hover { transform: translateY(-1px); background: var(--c-surface-3); }
.btn:active { transform: translateY(0) scale(0.99); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn:focus-visible { box-shadow: var(--focus-ring); }

.btn--primary {
  --btn-bg: var(--grad-primary);
  --btn-fg: var(--c-on-accent);
  --btn-bd: transparent;
  box-shadow: var(--shadow-accent);
}
.btn--primary:hover { background: var(--grad-primary); filter: brightness(1.06); transform: translateY(-1px); }
/* "not ready yet" reads as neutral, not a washed-out pink */
.btn--primary:disabled {
  --btn-bg: var(--c-surface-2);
  --btn-fg: var(--c-text-faint);
  filter: none; box-shadow: none; opacity: 1;
}
.hud__right .btn--primary:disabled { background: var(--scrim-panel); color: #cdd6e2; border: 1px solid var(--c-line-strong); }

.btn--ghost { --btn-bg: transparent; --btn-bd: var(--c-line-strong); }
.btn--ghost:hover { background: color-mix(in srgb, var(--c-text) 8%, transparent); }

.btn--block { width: 100%; }
.btn--lg { min-height: 52px; padding: 0.95em 1.5em; font-size: var(--fs-lg); }
.btn--sm { min-height: 40px; padding: 0.5em 0.95em; font-size: var(--fs-sm); }

/* ---------- loader ---------- */
.loader { text-align: center; display: grid; gap: var(--sp-4); justify-items: center; max-width: 34ch; }
.loader__badge {
  position: relative; width: 84px; height: 84px;
  display: grid; place-items: center;
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, var(--c-surface-2), var(--c-surface));
  border: 1px solid var(--c-line);
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
.loader__badge::before { /* sunrise glow */
  content: ""; position: absolute; left: 50%; bottom: -30%;
  width: 130%; aspect-ratio: 1; transform: translateX(-50%);
  background: radial-gradient(circle at 50% 50%, rgba(255,192,120,0.55), rgba(255,111,159,0.30) 42%, transparent 66%);
  animation: sun-rise 2.6s var(--ease) infinite alternate;
}
.loader__badge::after { /* horizon */
  content: ""; position: absolute; left: 12%; right: 12%; bottom: 34%; height: 2px;
  background: linear-gradient(90deg, transparent, var(--c-line-strong), transparent);
}
@keyframes sun-rise { from { transform: translateX(-50%) translateY(18%); } to { transform: translateX(-50%) translateY(-4%); } }

.loader__ring {
  position: relative; z-index: 1;
  width: 46px; height: 46px; border-radius: 50%;
  border: 3px solid var(--c-line-strong);
  border-top-color: var(--c-accent);
  animation: spin 0.9s linear infinite;
}
.loader__ring--sm { width: 26px; height: 26px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

.loader__msg { font-size: var(--fs-xl); font-weight: 800; letter-spacing: var(--tr-tighter); line-height: var(--lh-snug); }
.loader__sub { color: var(--c-text-faint); font-size: var(--fs-sm); min-height: 1.2em; }
.loader__dots { display: inline-flex; gap: 5px; margin-top: var(--sp-1); }
.loader__dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--c-text-faint); animation: dot 1.2s var(--ease) infinite; }
.loader__dots i:nth-child(2) { animation-delay: 0.15s; }
.loader__dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 0%, 60%, 100% { opacity: 0.25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* ---------- state card (error) ---------- */
#screen-loading.screen--error .loader { display: none; }
.state-card {
  width: min(440px, 100%); text-align: center;
  background: var(--c-surface); border: 1px solid var(--c-line);
  border-radius: var(--r-lg); padding: var(--sp-6);
  display: grid; gap: var(--sp-3); justify-items: center;
  box-shadow: var(--shadow-2);
  animation: pop var(--dur-slow) var(--spring) both;
}
.state-card__icon {
  width: 56px; height: 56px; border-radius: var(--r-md);
  display: grid; place-items: center;
  background: var(--c-accent-soft); color: var(--c-accent);
  border: 1px solid color-mix(in srgb, var(--c-accent) 30%, transparent);
}
.state-card__icon svg { width: 28px; height: 28px; }
.state-card__eyebrow { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: var(--tr-wider); color: var(--c-text-faint); font-weight: 800; }
.state-card__title { font-size: var(--fs-xl); letter-spacing: var(--tr-tighter); }
.state-card__body { color: var(--c-text-soft); font-size: var(--fs-sm); line-height: var(--lh-normal); }
.state-card__actions { width: 100%; margin-top: var(--sp-2); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(0.96); } to { opacity: 1; transform: none; } }

/* ---------- cards / setup ---------- */
.card {
  width: min(460px, 100%);
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-xl);
  padding: clamp(var(--sp-5), 5vw, var(--sp-7));
  box-shadow: var(--shadow-2);
  display: grid; gap: var(--sp-4);
}
.setup__badge {
  width: 48px; height: 48px; border-radius: var(--r-md);
  display: grid; place-items: center;
  background: var(--grad-sunrise-soft);
  border: 1px solid var(--c-line);
  color: var(--c-sun);
}
.setup__badge svg { width: 24px; height: 24px; }
.setup__title { font-size: var(--fs-2xl); letter-spacing: var(--tr-tighter); line-height: var(--lh-snug); }
.setup__body { color: var(--c-text-soft); font-size: var(--fs-sm); line-height: var(--lh-normal); }
.setup__steps {
  display: grid; gap: var(--sp-3); counter-reset: s;
  font-size: var(--fs-sm); color: var(--c-text-soft); line-height: var(--lh-normal);
  background: var(--c-surface-2); border: 1px solid var(--c-line);
  border-radius: var(--r-md); padding: var(--sp-4);
}
.setup__steps li { position: relative; padding-left: 30px; }
.setup__steps li::before {
  counter-increment: s; content: counter(s);
  position: absolute; left: 0; top: 0.05em;
  width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--c-surface-3); color: var(--c-text); font-weight: 800; font-size: 0.7rem;
}
.field { display: grid; gap: var(--sp-2); }
.field__label { font-size: var(--fs-sm); font-weight: 700; color: var(--c-text-soft); }
.field__input {
  width: 100%;
  min-height: 48px;
  padding: 0.8em 1em;
  border-radius: var(--r-md);
  border: 1px solid var(--c-line-strong);
  background: var(--c-bg-1); color: var(--c-text);
  font-size: var(--fs-base);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.field__input::placeholder { color: var(--c-text-faint); }
.field__input:focus-visible { border-color: var(--c-focus); box-shadow: var(--focus-ring); }
.field__input:user-invalid { border-color: var(--c-accent); }
.setup__trust {
  display: flex; gap: var(--sp-2); align-items: center;
  font-size: var(--fs-xs); color: var(--c-text-faint);
}
.setup__trust svg { width: 14px; height: 14px; flex: none; color: var(--c-good); }
.setup__hint { color: var(--c-text-faint); font-size: var(--fs-xs); line-height: var(--lh-normal); }

/* ---------- menu ---------- */
.menu { width: min(600px, 100%); display: grid; gap: var(--sp-5); }
/* title logo: full width on phones, capped on desktop; width/height attrs on the
   <img> reserve the box so the heading below doesn't jump while it loads. */
.menu__logo { display: block; width: 100%; max-width: 520px; overflow: hidden; }
/* The 1200x670 asset carries ~150px of transparent padding above and below the
   artwork (12.5% of its width each); crop it here so the heading isn't pushed down. Percent margins resolve
   against the <picture> width, which equals the image width at every breakpoint.
   Drop these margins if the asset is ever re-exported without the padding. */
.menu__logo img { display: block; width: 100%; height: auto; margin-block: -11.5% -11.5%; }
.menu__play { display: grid; gap: var(--sp-4); }
.menu__eyebrow {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font-size: var(--fs-xs); font-weight: 800; text-transform: uppercase;
  letter-spacing: var(--tr-wider); color: var(--c-text-faint);
}
.menu__eyebrow::before {
  content: ""; width: 22px; height: 2px; border-radius: 2px;
  background: var(--grad-sunrise);
}
.menu__title {
  font-size: clamp(2.1rem, 8.5vw, var(--fs-4xl));
  line-height: var(--lh-tight); letter-spacing: var(--tr-display); font-weight: 800;
}
.menu__title em { font-style: normal; background: var(--grad-sunrise-text); -webkit-background-clip: text; background-clip: text; color: transparent; }
.menu__lede { color: var(--c-text-soft); font-size: var(--fs-lg); line-height: var(--lh-normal); max-width: 46ch; }

.difficulty { display: grid; gap: var(--sp-2); }
.difficulty legend {
  font-size: var(--fs-xs); font-weight: 800; color: var(--c-text-faint);
  text-transform: uppercase; letter-spacing: var(--tr-wider); margin-bottom: var(--sp-2);
}
.difficulty__opt {
  position: relative;
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4);
  border: 1px solid var(--c-line-strong);
  border-radius: var(--r-md);
  background: var(--c-surface);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.difficulty__opt:hover { transform: translateY(-1px); border-color: var(--c-line-strong); background: var(--c-surface-2); }
.difficulty__opt:has(:checked) {
  border-color: var(--c-accent);
  background: var(--c-accent-soft);
  box-shadow: inset 0 0 0 1px var(--c-accent);
}
.difficulty__opt:has(:focus-visible) { box-shadow: var(--focus-ring); }
.difficulty__opt input {
  appearance: none; -webkit-appearance: none;
  flex: none; width: 20px; height: 20px; margin: 0; border-radius: 50%;
  border: 2px solid var(--c-line-strong); background: transparent;
  display: grid; place-content: center;
  transition: border-color var(--dur-fast) var(--ease);
}
.difficulty__opt input::before {
  content: ""; width: 10px; height: 10px; border-radius: 50%;
  background: var(--c-accent); transform: scale(0); transition: transform var(--dur-fast) var(--spring);
}
.difficulty__opt input:checked { border-color: var(--c-accent); }
.difficulty__opt input:checked::before { transform: scale(1); }
.difficulty__body { display: grid; gap: 2px; }
.difficulty__name { font-weight: 800; letter-spacing: var(--tr-tight); }
.difficulty__desc { font-size: var(--fs-sm); color: var(--c-text-faint); }

/* 「開発中」でまだ選べないモード */
.difficulty__opt--soon { opacity: 0.55; cursor: not-allowed; }
.difficulty__opt--soon:hover { transform: none; border-color: var(--c-line-strong); background: var(--c-surface); }
.difficulty__opt--soon input { cursor: not-allowed; }
.difficulty__badge {
  display: inline-block; margin-left: 6px; vertical-align: middle;
  padding: 1px 7px; border-radius: 999px;
  font-size: var(--fs-xs); font-weight: 800; letter-spacing: 0.02em;
  color: var(--c-text-faint);
  background: var(--c-surface-2); border: 1px solid var(--c-line-strong);
}

.menu__how {
  display: grid; gap: var(--sp-3); counter-reset: step;
  color: var(--c-text-soft); font-size: var(--fs-sm);
  border-top: 1px solid var(--c-line); padding-top: var(--sp-5);
}
.menu__how-title { font-size: var(--fs-xs); font-weight: 800; text-transform: uppercase; letter-spacing: var(--tr-wider); color: var(--c-text-faint); }
.menu__how li { position: relative; padding-left: 34px; }
.menu__how li + li { margin-top: var(--sp-2); }
.menu__how li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: -0.05em;
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--c-surface-2); border: 1px solid var(--c-line);
  color: var(--c-text); font-weight: 800; font-size: var(--fs-xs);
}
.menu__how em { font-style: normal; color: var(--c-text); font-weight: 700; }

/* Desktop: two columns so the menu owns the width instead of a lonely strip. */
@media (min-width: 940px) {
  .menu {
    width: min(1060px, 100%);
    grid-template-columns: minmax(0, 1fr) minmax(320px, 400px);
    column-gap: clamp(var(--sp-7), 5.5vw, var(--sp-9));
    row-gap: var(--sp-4);
    align-items: start;
  }
  .menu__logo   { grid-area: 1 / 1; }
  .menu__eyebrow { grid-area: 2 / 1; }
  .menu__title  { grid-area: 3 / 1; }
  .menu__lede   { grid-area: 4 / 1; font-size: var(--fs-xl); }
  .menu__how    { grid-area: 5 / 1; align-self: end; }
  /* play panel lives in column 2; it overflows its row downward into the
     otherwise-empty right column rather than stretching the left rows. */
  .menu__play {
    grid-area: 1 / 2 / 6 / 3;
    align-self: start;
    padding: var(--sp-6);
    background: var(--c-surface);
    border: 1px solid var(--c-line);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-2);
  }
}

/* ---------- game screen ---------- */
.screen--game { position: absolute; inset: 0; overflow: hidden; }
.streetview { position: absolute; inset: 0; background: #05070a; }
.sv-fallback-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* in-panorama loading overlay */
.sv-overlay {
  position: absolute; inset: 0; z-index: 8;
  display: grid; place-content: center; gap: var(--sp-3); justify-items: center;
  padding: var(--sp-5);
  background:
    radial-gradient(60% 60% at 50% 42%, rgba(255,122,86,0.10), transparent 70%),
    var(--scrim-overlay);
  color: var(--c-text-soft); font-size: var(--fs-sm); font-weight: 600;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  text-align: center;
}
.sv-overlay[hidden] { display: none; }

.sv-btn {
  position: absolute;
  left: max(var(--sp-4), var(--safe-l));
  bottom: calc(var(--sp-4) + var(--safe-b));
  z-index: 9;
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--c-line-strong);
  background: var(--scrim-glass);
  color: var(--c-text);
  font-size: 1.2rem; line-height: 1; cursor: pointer;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow-1);
  transition: transform var(--dur) var(--ease), background var(--dur-fast) var(--ease);
}
.sv-btn:hover { transform: rotate(-40deg); background: var(--scrim-panel); }
.sv-btn:focus-visible { box-shadow: var(--focus-ring); }
.sv-btn svg { width: 20px; height: 20px; }

/* HUD */
.hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 10;
  min-height: var(--hud-h);
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-3) max(var(--sp-4), var(--safe-r)) var(--sp-6) max(var(--sp-4), var(--safe-l));
  padding-top: calc(var(--sp-3) + var(--safe-t));
  background: var(--scrim-top);
  pointer-events: none;
}
.hud[hidden] { display: none; }
.hud > * { pointer-events: auto; }
.hud__left, .hud__right { display: flex; align-items: center; gap: var(--sp-2); }
.hud__left { flex-wrap: wrap; }
.hud__chip {
  display: inline-flex; align-items: center;
  padding: 0.44em 0.85em; border-radius: var(--r-full);
  background: var(--scrim-panel);
  border: 1px solid var(--c-line-strong);
  color: #fff;
  font-weight: 800; font-size: var(--fs-sm); letter-spacing: var(--tr-tight);
  font-variant-numeric: tabular-nums;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow-1);
}
.hud__timer {
  font-variant-numeric: tabular-nums; font-weight: 800; font-size: var(--fs-lg);
  padding: 0.3em 0.7em; border-radius: var(--r-full);
  background: var(--scrim-panel);
  border: 1px solid var(--c-line-strong);
  color: #fff;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow-1);
}
.hud__timer[hidden] { display: none; }
.hud__timer--warn {
  color: #fff;
  background: var(--grad-primary);
  border-color: transparent;
  animation: timer-pulse 1s var(--ease) infinite;
}
@keyframes timer-pulse { 0%, 100% { box-shadow: 0 0 0 0 var(--c-accent-ring); } 50% { box-shadow: 0 0 0 8px transparent; } }

.hud__right .btn {
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow-1);
}
.hud__right .btn--ghost { background: var(--scrim-panel); border-color: var(--c-line-strong); color: #fff; }

/* guess map — corner panel that grows on hover (desktop) */
.guessmap-wrap {
  position: absolute;
  right: max(var(--sp-4), var(--safe-r));
  bottom: calc(var(--sp-4) + var(--safe-b));
  z-index: 9;
  width: 300px; height: 200px;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--c-line-strong);
  box-shadow: var(--shadow-3);
  background: var(--c-surface);
  transition: width var(--dur) var(--ease), height var(--dur) var(--ease);
}
.guessmap-wrap:hover,
.guessmap-wrap:focus-within,
.guessmap-wrap[data-expanded="true"] {
  width: min(46vw, 560px); height: min(52vh, 460px);
}
.guessmap-wrap__handle { display: none; }
.guessmap { position: absolute; inset: 0; }
/* map.js renders its own .guessmap__hint / .guessmap__toggle inside #guessmap */

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ============ round-result reveal =========================================
   GeoGuessr-style: the guess map goes full-bleed with the guess -> answer
   line, and the score card docks beside it (desktop) or below it (mobile).
   map.js sets data-result="true" on #guessmap-wrap for the reveal's duration. */
#guessmap-wrap[data-result="true"] {
  position: absolute; inset: 0; z-index: 14;
  width: auto; height: auto;
  border-radius: 0; border: 0; box-shadow: none;
  transition: inset var(--dur) var(--ease);
}
/* the guess-phase chrome is meaningless during the reveal */
#screen-game:has(#guessmap-wrap[data-result="true"]) .hud,
#screen-game:has(#guessmap-wrap[data-result="true"]) .game-prompt,
#screen-game:has(#guessmap-wrap[data-result="true"]) .sv-btn { display: none; }

/* 操作ガイド（この写真の場所を…）。HUDのすぐ下、写真の上に重ねる。
   ストリートビュー（空が明るいことも多い）の上でも読めるよう、
   ローズの不透明ピル＋濃い影＋文字にも影。 */
.game-prompt {
  position: absolute;
  top: max(calc(var(--hud-h) + var(--sp-2)), calc(var(--safe-t) + var(--hud-h)));
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  max-width: calc(100% - var(--sp-5));
  margin: 0;
  padding: 9px 18px;
  border-radius: var(--r-full);
  text-align: center;
  font-size: var(--fs-base);
  font-weight: 800;
  letter-spacing: 0.01em;
  color: #fff;
  background: var(--c-accent-press);
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 6px 20px rgba(30, 10, 25, 0.45), 0 0 0 1px rgba(30, 10, 25, 0.25);
  text-shadow: 0 1px 2px rgba(30, 10, 25, 0.5);
  pointer-events: none;
  animation: fade-in var(--dur) var(--ease);
}
.game-prompt[hidden] { display: none; }
@media (max-width: 720px) {
  .game-prompt { top: calc(var(--safe-t) + 96px); font-size: var(--fs-sm); }
}

/* 「とちゅうでやめる」— 結果パネルの控えめな二次ボタン */
.result__quit { opacity: 0.85; font-size: var(--fs-sm); min-height: 42px; }

.result-host {
  position: absolute; z-index: 16;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  animation: fade-in var(--dur) var(--ease);
}
.result-host[hidden] { display: none; }
.result-panel {
  pointer-events: auto;
  width: min(420px, 100%);
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-xl);
  padding: clamp(var(--sp-4), 4.5vw, var(--sp-6));
  box-shadow: var(--shadow-3);
  display: grid; gap: var(--sp-3);
  text-align: center;
  animation: pop var(--dur-slow) var(--spring) both;
}

@media (min-width: 721px) {
  #guessmap-wrap[data-result="true"] { left: min(460px, 42vw); }
  .result-host {
    inset: 0 auto 0 0;
    width: min(460px, 42vw);
    padding: max(var(--sp-5), var(--safe-t)) var(--sp-4)
             max(var(--sp-5), var(--safe-b)) max(var(--sp-4), var(--safe-l));
  }
  .result-panel { max-height: calc(100dvh - 2 * var(--sp-5)); overflow-y: auto; }
}

@media (max-width: 720px) {
  #guessmap-wrap[data-result="true"] { inset: 0 0 50dvh 0; }
  .result-host { inset: auto 0 0 0; padding: 0; }
  .result-panel {
    width: 100%;
    max-height: 50dvh;
    overflow-y: auto;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    padding-bottom: max(var(--sp-4), var(--safe-b));
  }
}
.result__eyebrow { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: var(--tr-wider); color: var(--c-text-faint); font-weight: 800; }
.result__headline {
  font-size: var(--fs-2xl); letter-spacing: var(--tr-tighter); line-height: var(--lh-snug);
  color: var(--c-accent-hi);
}
:root[data-theme="light"] .result__headline { color: #e05a86; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .result__headline { color: #e05a86; } }
.result__score {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 0.15em 0.35em;
  font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: var(--tr-tighter); line-height: 1;
}
.result__score-value { font-size: var(--fs-3xl); }
.result__score-max { font-size: var(--fs-lg); color: var(--c-text-faint); font-weight: 700; }
/* results.js also emits a redundant colour-coded label span; the <h2> headline
   already carries that word, so keep the panel clean and hide the duplicate. */
.result__score-word { display: none; }

.result__bar { height: 8px; border-radius: var(--r-full); background: var(--c-surface-2); overflow: hidden; box-shadow: inset 0 0 0 1px var(--c-line); }
.result__bar-fill { display: block; height: 100%; width: 2%; border-radius: inherit; background: var(--c-good); transition: width var(--dur-slow) var(--ease); }

.result__reason { font-size: var(--fs-base); color: var(--c-text-soft); }
.result__reason-dist { color: var(--c-text); font-weight: 800; font-variant-numeric: tabular-nums; }
.result__scale { font-size: var(--fs-xs); color: var(--c-text-faint); line-height: var(--lh-normal); }

.result__facts {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3) var(--sp-4);
  margin-top: var(--sp-1); padding-top: var(--sp-3);
  border-top: 1px solid var(--c-line);
  text-align: left;
}
.result__fact dt { font-size: var(--fs-xs); color: var(--c-text-faint); text-transform: uppercase; letter-spacing: var(--tr-wide); font-weight: 700; margin-bottom: 2px; }
.result__fact dd { font-weight: 800; letter-spacing: var(--tr-tight); }
.result__fact:first-child dd { color: var(--c-good); }
.result__hint { font-size: var(--fs-sm); color: var(--c-text-soft); line-height: var(--lh-normal); }
.result__meta { font-size: var(--fs-xs); color: var(--c-text-faint); }
.result-panel .btn { margin-top: var(--sp-2); }

/* ---------- むかしモード: 「むかし ⇄ いま」の切り替え ---------- */
/* 2枚は Street View Static API の画像。Google の帰属表示は画像に焼き込まれて
   いるので、枠の比率を画像と同じ 8:5 にして切り抜かずに出す。 */
.compare {
  display: grid; gap: var(--sp-2);
  margin-top: var(--sp-1); padding-top: var(--sp-3);
  border-top: 1px solid var(--c-line);
  text-align: center;
}
.compare__title { font-size: var(--fs-sm); font-weight: 800; letter-spacing: var(--tr-tight); }
.compare__tabs { display: flex; justify-content: center; gap: var(--sp-2); }
.compare__tab {
  font-size: var(--fs-xs); font-weight: 700; font-variant-numeric: tabular-nums;
  padding: 3px 10px; border-radius: var(--r-full);
  background: var(--c-surface-2); color: var(--c-text-faint);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.compare__tab.is-on { background: var(--c-accent-soft); color: var(--c-accent-hi); }
:root[data-theme="light"] .compare__tab.is-on { color: #e05a86; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .compare__tab.is-on { color: #e05a86; }
}
.compare__frame {
  position: relative; aspect-ratio: 8 / 5; width: 100%;
  border-radius: var(--r-md); overflow: hidden; cursor: pointer;
  background: var(--c-surface-2); box-shadow: inset 0 0 0 1px var(--c-line);
}
.compare__shot {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: contain;
  transition: opacity var(--dur-slow) var(--ease);
}
.compare__frame[data-showing="then"] .compare__shot--now { opacity: 0; }
.compare__frame[data-showing="now"] .compare__shot--then { opacity: 0; }
.compare__toggle { margin-top: 0 !important; min-height: 42px; font-size: var(--fs-sm); }
.compare__note { font-size: var(--fs-xs); color: var(--c-text-faint); line-height: var(--lh-normal); }

@media (prefers-reduced-motion: reduce) {
  .compare__shot, .compare__tab { transition: none; }
}

/* ---------- summary ---------- */
.summary-host { width: min(600px, 100%); }
.summary { display: grid; gap: var(--sp-4); }
.summary__eyebrow { text-align: center; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: var(--tr-wider); color: var(--c-text-faint); font-weight: 800; }
.summary__title {
  text-align: center; font-size: clamp(var(--fs-2xl), 7vw, var(--fs-3xl));
  letter-spacing: var(--tr-tighter); line-height: var(--lh-snug);
}
.summary__total {
  text-align: center;
  display: flex; align-items: baseline; justify-content: center; flex-wrap: wrap; gap: 0.2em;
  font-size: clamp(var(--fs-4xl), 14vw, var(--fs-5xl));
  font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: var(--tr-display);
  line-height: 1;
}
.summary__total-value { background: var(--grad-sunrise-text); -webkit-background-clip: text; background-clip: text; color: transparent; }
.summary__total-max { font-size: var(--fs-lg); color: var(--c-text-faint); font-weight: 700; letter-spacing: var(--tr-tight); }
.summary__grade {
  text-align: center; margin-top: calc(-1 * var(--sp-2));
  font-size: var(--fs-sm); font-weight: 700; color: var(--c-text-soft);
  font-variant-numeric: tabular-nums;
}

.summary__rounds { display: grid; gap: var(--sp-2); }
.summary__round {
  display: grid;
  grid-template-columns: auto 52px minmax(0, 1fr) auto;
  align-items: center; gap: var(--sp-3);
  padding: var(--sp-3);
  background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-md);
  animation: row-in var(--dur-slow) var(--ease) both;
}
.summary__round:nth-child(1) { animation-delay: 40ms; }
.summary__round:nth-child(2) { animation-delay: 90ms; }
.summary__round:nth-child(3) { animation-delay: 140ms; }
.summary__round:nth-child(4) { animation-delay: 190ms; }
.summary__round:nth-child(5) { animation-delay: 240ms; }
@keyframes row-in { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }

.summary__round-no { font-size: var(--fs-xs); font-weight: 800; color: var(--c-text-faint); font-variant-numeric: tabular-nums; }
.summary__thumb {
  width: 52px; height: 40px; border-radius: var(--r-sm);
  background-size: cover; background-position: center; background-color: var(--c-surface-2);
  border: 1px solid var(--c-line);
}
.summary__thumb--empty { display: grid; place-items: center; font-size: var(--fs-xs); color: var(--c-text-faint); font-weight: 800; }

.summary__round-info { display: grid; gap: 5px; min-width: 0; }
.summary__round-name { font-weight: 800; letter-spacing: var(--tr-tight); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.summary__round-meter { display: block; height: 5px; border-radius: var(--r-full); background: var(--c-surface-2); overflow: hidden; }
.summary__round-meter-fill { display: block; height: 100%; border-radius: inherit; background: var(--c-good); }
.summary__round-dist { font-size: var(--fs-xs); color: var(--c-text-faint); font-variant-numeric: tabular-nums; }

.summary__round-pts { font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: var(--tr-tight); white-space: nowrap; }
.summary__round-pts-unit { font-size: var(--fs-xs); color: var(--c-text-faint); font-weight: 700; }

.summary__actions { display: flex; gap: var(--sp-3); justify-content: center; flex-wrap: wrap; margin-top: var(--sp-2); }
.summary__actions .btn { min-width: 140px; }
.summary__empty { text-align: center; color: var(--c-text-faint); font-size: var(--fs-sm); padding: var(--sp-6); }

/* ---------- toast ---------- */
.toast-host {
  position: fixed; left: 50%; bottom: calc(var(--sp-6) + var(--safe-b));
  transform: translateX(-50%); z-index: 60;
  width: max-content; max-width: calc(100vw - var(--sp-6));
}
.toast {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 0.7em 1.15em; border-radius: var(--r-full);
  background: var(--c-surface); border: 1px solid var(--c-line-strong);
  box-shadow: var(--shadow-2); font-weight: 700; font-size: var(--fs-sm);
  animation: toast-in var(--dur) var(--spring) both;
}
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c-text-faint); flex: none; }
.toast--success::before { background: var(--c-good); }
.toast--warn::before { background: var(--c-warn); }
.toast--error::before { background: var(--c-accent); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 860px) {
  .guessmap-wrap:hover:not([data-expanded="true"]),
  .guessmap-wrap:focus-within:not([data-expanded="true"]) {
    width: 300px; height: 200px; /* no hover-grow on touch-ish widths */
  }
}

@media (max-width: 720px) {
  .guessmap-wrap {
    left: max(var(--sp-3), var(--safe-l));
    right: max(var(--sp-3), var(--safe-r));
    bottom: calc(var(--sp-3) + var(--safe-b));
    width: auto; height: 34vh;
  }
  .guessmap-wrap:hover,
  .guessmap-wrap:focus-within { width: auto; height: 34vh; }
  .guessmap-wrap[data-expanded="true"] { width: auto; height: 74vh; }
  /* 候補選択フェーズ（はじめて・ふつう）は画面を占有しすぎない高さに */
  .guessmap-wrap[data-choice="true"][data-expanded="true"]:not([data-result="true"]) {
    height: 46vh;
  }
  #screen-game:has(.guessmap-wrap[data-choice="true"]:not([data-result="true"])) .sv-btn {
    bottom: calc(46vh + var(--sp-3) + var(--safe-b));
  }
  .guessmap-wrap__handle {
    display: block; position: absolute; top: 0; left: 0; right: 0; height: 22px; z-index: 3;
    cursor: grab; background: transparent;
  }
  .guessmap-wrap__handle::after {
    content: ""; position: absolute; top: 7px; left: 50%; transform: translateX(-50%);
    width: 40px; height: 4px; border-radius: 2px;
    background: rgba(255,255,255,0.6);
    box-shadow: 0 0 0 1px rgba(0,0,0,0.15);
  }
  .guessmap-wrap__handle:focus-visible { box-shadow: var(--focus-ring); }

  .hud { flex-wrap: wrap; padding-bottom: var(--sp-8); }
  .hud__right { width: 100%; justify-content: space-between; }
  .hud__right .btn--primary { flex: 1; white-space: normal; }

  .sv-btn { bottom: calc(34vh + var(--sp-3) + var(--safe-b)); }

  .result__facts { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 420px) {
  :root { --fs-3xl: 2.15rem; --fs-4xl: 2.6rem; }
  .result__facts { grid-template-columns: 1fr; gap: var(--sp-2); }
  .summary__actions .btn { flex: 1; min-width: 0; }
  .hud__right .btn--sm { min-height: 44px; }
  .summary__round { grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--sp-2) var(--sp-3); }
  .summary__round .summary__thumb { display: none; }
}

/* short viewports: don't let the result panel clip */
@media (max-height: 560px) {
  .result-panel { gap: var(--sp-2); padding: var(--sp-4); }
  .result__score-value { font-size: var(--fs-2xl); }
  .result__scale { display: none; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  /* the global token rule already forces all animation/transition to ~0ms;
     these just tidy the resting appearance */
  .loader__badge::before { transform: translateX(-50%) translateY(2%); }
  .loader__dots i { opacity: 0.5; }
  .hud__timer--warn { box-shadow: 0 0 0 2px var(--c-accent-ring); }
  .btn:hover, .difficulty__opt:hover, .btn--primary:hover { transform: none; }
}

/* ---------- 初めてモード: 答え合わせ / まとめ ---------- */
.result__headline.is-correct { color: var(--c-good); }
.result__headline.is-wrong { color: var(--c-accent-hi); }
:root[data-theme="light"] .result__headline.is-wrong { color: #e05a86; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .result__headline.is-wrong { color: #e05a86; }
}

.summary__rounds--beginner .summary__round {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: var(--sp-3);
}
.summary__mark {
  font-weight: 800; font-size: var(--fs-lg); line-height: 1;
  width: 1.6em; text-align: center;
}
.summary__mark--ok { color: var(--c-good); }
.summary__mark--ng { color: var(--c-accent-hi); }

/* ---------- 音のコントロール（常時表示・固定） ---------- */
#audio-ctl {
  position: fixed;
  top: max(10px, var(--safe-t));
  right: max(10px, var(--safe-r));
  z-index: 30;
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 4px;
  border-radius: 999px;
  background: var(--scrim-glass, rgba(11, 15, 20, 0.72));
  border: 1px solid var(--c-line-strong);
  box-shadow: var(--shadow-1);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.audio-ctl__btn {
  flex: none;
  width: 36px; height: 36px; padding: 0;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--c-text);
  cursor: pointer;
}
.audio-ctl__btn:focus-visible { box-shadow: var(--focus-ring); }
.audio-ctl__btn svg { width: 20px; height: 20px; display: block; }
#audio-ctl .audio-ctl__x { display: none; }
#audio-ctl[data-muted="true"] .audio-ctl__wave { display: none; }
#audio-ctl[data-muted="true"] .audio-ctl__x { display: block; }
#audio-ctl[data-muted="true"] .audio-ctl__btn { color: var(--c-text-faint); }

.audio-ctl__vol {
  width: 84px; height: 4px; margin-right: 6px;
  accent-color: var(--c-accent);
  transition: width var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
}
/* たたむ: ふだんは細く、hover / フォーカスで開く（デスクトップ）。 */
@media (hover: hover) and (pointer: fine) {
  .audio-ctl__vol { width: 0; opacity: 0; margin-right: 0; pointer-events: none; }
  #audio-ctl:hover .audio-ctl__vol,
  #audio-ctl:focus-within .audio-ctl__vol { width: 84px; opacity: 1; margin-right: 6px; pointer-events: auto; }
}
/* タッチ端末はスライダーを隠し、ミュート切替のみ（ボタンは大きめ）。 */
@media (pointer: coarse) {
  .audio-ctl__vol { display: none; }
  .audio-ctl__btn { width: 42px; height: 42px; }
}

/* ゲーム中は HUD 右側のボタンが音コントロールの下に潜らないよう余白を足す。 */
body[data-screen="game"] .hud__right { padding-right: 46px; }

/* .btn は display を明示しているので、hidden 属性を効かせるには上書きが要る
   （初めてモードで #hud-guess を隠すため）。 */
.btn[hidden] { display: none; }

/* 「やめる」ボタンの2段階目（本当にやめる？） */
#hud-quit.is-armed {
  background: var(--c-accent);
  border-color: var(--c-accent);
  color: #fff;
}

/* ============================================================
   写真だけ全画面モード（宣伝用の画面録画にも使う）
   ------------------------------------------------------------
   ストリートビューを画面いっぱいで見せるモード。#streetview は
   もともと inset:0 の全面要素なので、地図とゲームUIをCSSで隠す
   だけで縦一杯の風景になる。Google純正の fullscreenControl
   （＝ブラウザの全画面API）は iOS Safari で挙動が安定しないため
   使わない。body[data-photo="true"] を game.js が付け外しする。
   ============================================================ */

/* .sv-btn は display:grid を明示しているので hidden 属性が効かない */
.sv-btn[hidden] { display: none; }

.sv-btn--photo { left: calc(max(var(--sp-4), var(--safe-l)) + 52px); }
.sv-btn--photo:hover { transform: none; background: var(--scrim-panel); }
.sv-btn--photo .i-photo-off { display: none; }
body[data-photo="true"] .sv-btn--photo .i-photo-on { display: none; }
body[data-photo="true"] .sv-btn--photo .i-photo-off { display: block; }

/* 地図とゲームUI（ラウンド表示・タイマー・やめる・吹き出し・音）を隠す */
body[data-photo="true"] .hud,
body[data-photo="true"] .game-prompt,
body[data-photo="true"] .guessmap-wrap,
body[data-photo="true"] #sv-recenter,
body[data-photo="true"] #audio-ctl { display: none !important; }

/* 全画面中は右上へ逃がす。画面下の左右は Google のロゴと利用規約リンクの
   定位置なので、そこに戻るボタンを重ねない。 */
body[data-photo="true"] .sv-btn--photo {
  left: auto; bottom: auto;
  right: max(var(--sp-4), var(--safe-r));
  top: max(var(--sp-4), var(--safe-t));
  opacity: 0.45;
  transition: opacity var(--dur) var(--ease);
}
body[data-photo="true"] .sv-btn--photo:hover,
body[data-photo="true"] .sv-btn--photo:focus-visible { opacity: 1; }

/* 録画のじゃまにならないよう、数秒さわらないとボタン自体も消える。
   画面にふれる／マウスを動かすと戻る（Esc でも分割表示に戻れる）。 */
body[data-photo="true"][data-photo-idle="true"] .sv-btn--photo {
  opacity: 0;
  pointer-events: none;
}

/* Google の帰属表示（© Google／ロゴ／利用規約）は全画面でも必ず残す。
   ライセンス要件なので、上のUI非表示ルールに巻き込まれないよう明示する。 */
body[data-photo="true"] #streetview .gm-style-cc,
body[data-photo="true"] #streetview a[href*="maps.google"],
body[data-photo="true"] #streetview img[alt*="Google"] {
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto;
}
