@import url("/theme.css");

    * { box-sizing: border-box; }
    :root { --app-height: 100vh; --header-top: max(8px, env(safe-area-inset-top)); }
    @supports (height: 100svh) { :root { --app-height: 100svh; } }
    @supports (height: 100dvh) { :root { --app-height: 100dvh; } }
    html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #121110; overscroll-behavior: none; }
    body { position: fixed; inset: 0; height: var(--app-height); color: #fff; font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif; font-weight: 400; }
    body::before { content: ""; position: fixed; z-index: 11; left: 0; right: 0; top: 0; height: calc(var(--header-top) + 84px); background: linear-gradient(to bottom, rgba(0,0,0,.38), rgba(0,0,0,.1) 62%, transparent); pointer-events: none; }
    #stage { position: fixed; inset: 0; width: 100%; height: var(--app-height); overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; background: #121110; cursor: grab; }
    #stage.dragging { cursor: grabbing; }
    .panel { position: absolute; inset: 0; overflow: hidden; visibility: hidden; will-change: transform; backface-visibility: hidden; }
    .panel.visible { visibility: visible; }
    .photo { position: absolute; left: 0; top: 50%; width: 100%; height: auto; max-width: none; pointer-events: none; -webkit-user-drag: none; transform-origin: center; will-change: transform; backface-visibility: hidden; }
    #appHeader { position: fixed; z-index: 12; top: var(--header-top); left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right)); display: flex; flex-direction: column; gap: 2px; pointer-events: none; }
    #stationTitle { width: 100%; padding: 2px 2px 0; background: none; font-size: 17px; font-weight: 600; line-height: 1.3; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.6); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; pointer-events: none; }
    #headerActions { width: 100%; display: flex; align-items: center; gap: 2px; pointer-events: auto; }
    #headerActions .header-spacer { flex: 1; }
    #headerActions button { min-height: 44px; min-width: 44px; padding: 8px 8px; border: 0; border-radius: 0; color: #fff; background: none; font-size: 15px; font-weight: 500; line-height: 1; text-shadow: 0 1px 2px rgba(0,0,0,.6); cursor: pointer; -webkit-tap-highlight-color: transparent; }
    #headerActions button:disabled { opacity: .38; }
    #headerActions button, #memoryTools button, .memory-dialog button, .file-button { touch-action: manipulation; font-family: inherit; -webkit-appearance: none; appearance: none; }
    #hint { position: absolute; z-index: 5; left: 50%; top: calc(var(--header-top) + 80px); transform: translateX(-50%); padding: 0; background: none; font-size: 13px; font-weight: 500; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.65); white-space: nowrap; pointer-events: none; }
    #hint.hidden { opacity: 0; }
    #dots { position: absolute; z-index: 5; left: 50%; bottom: max(10px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: center; gap: 7px; padding: 0; background: none; pointer-events: none; }
    .dot { width: 5px; height: 5px; border-radius: 50%; background: #fff; opacity: .28; box-shadow: 0 1px 2px rgba(0,0,0,.45); }
    .dot.active { opacity: .95; width: 7px; height: 7px; }
    body.is-editing #dots { bottom: calc(150px + env(safe-area-inset-bottom)); }
    #zoomStatus { position: absolute; z-index: 7; right: max(10px, env(safe-area-inset-right)); top: auto; bottom: calc(max(10px, env(safe-area-inset-bottom)) + 22px); min-width: 0; padding: 8px; border: 0; background: none; color: #fff; font-size: 13px; font-weight: 500; line-height: 1; text-shadow: 0 1px 2px rgba(0,0,0,.65); opacity: 0; pointer-events: none; }
    #zoomStatus.visible { opacity: 1; pointer-events: auto; }
    body.is-editing #zoomStatus { bottom: calc(158px + env(safe-area-inset-bottom)); }
    #debug { display: none; position: absolute; z-index: 9; left: max(8px, env(safe-area-inset-left)); top: calc(var(--header-top) + 96px); max-width: calc(100vw - 16px); padding: 7px 9px; border-radius: 4px; background: rgba(95,0,0,.82); font: 11px/1.35 ui-monospace, monospace; pointer-events: none; }
    body.debug #debug { display: block; }
    #stationScene { position: absolute; inset: 0; transform-origin: center; }
    #stationVeil { position: absolute; z-index: 8; inset: 0; background: #121110; opacity: 0; pointer-events: none; }
    #stationInteractionShield { position: fixed; z-index: 13; inset: 0; background: transparent; cursor: wait; }
    #stationInteractionShield[hidden] { display: none; }
    #pointLayer { position: absolute; left: 0; top: 50%; width: 100%; transform-origin: center; pointer-events: none; }
    .memory-marker { position: absolute; width: 44px; height: 44px; padding: 0; border: 0; background: none; transform: translate(-50%,-50%); pointer-events: auto; cursor: pointer; display: flex; align-items: center; justify-content: center; -webkit-tap-highlight-color: transparent; }
    .memory-marker::before { content: ""; width: 28px; height: 28px; border: 3px solid #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,.65), 0 0 0 1px rgba(0,0,0,.3); }
    .memory-marker::after { content: ""; position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; border-radius: 50%; background: #c17a4a; transform: translate(-50%,-50%); box-shadow: 0 1px 1px rgba(0,0,0,.4); }
    .navigation-marker { width: 52px; height: 52px; }
    .navigation-marker::before { position: absolute; left: 50%; top: 50%; width: 42px; height: 42px; transform: translate(-50%,-50%); border: 1px solid rgba(255,255,255,.24); background: rgba(24,23,21,.78); box-shadow: 0 2px 4px rgba(0,0,0,.4); }
    .navigation-marker::after { content: none; display: none; }
    .navigation-marker svg { position: relative; z-index: 1; width: 32px; height: 32px; display: block; pointer-events: none; }
    #memoryTools { position: fixed; z-index: 12; left: 0; right: 0; top: auto; bottom: 0; display: none; flex-direction: column; align-items: stretch; background: #f6f3ee; border-top: 1px solid #e6e0d8; padding: 4px 8px max(8px, env(safe-area-inset-bottom)); }
    body.is-editing #memoryTools { display: flex; }
    #memoryTools button, .memory-dialog button, .memory-dialog input, .memory-dialog textarea, .file-button { font: inherit; }
    #memoryTools button { width: 100%; min-height: 44px; padding: 10px 12px; border: 0; border-bottom: 1px solid #ece7e0; border-radius: 0; color: #2c2a27; background: none; font-size: 16px; font-weight: 500; text-align: center; cursor: pointer; -webkit-tap-highlight-color: transparent; }
    #memoryTools button:last-of-type { border-bottom: 0; }
    #memoryTools button[hidden], .memory-dialog [hidden] { display: none !important; }
    #memoryNotice { position: fixed; z-index: 11; bottom: calc(max(10px, env(safe-area-inset-bottom)) + 26px); left: 50%; transform: translateX(-50%); padding: 6px 10px; background: none; color: #fff; font-size: 13px; font-weight: 500; max-width: 90vw; text-align: center; pointer-events: none; text-shadow: 0 1px 2px rgba(0,0,0,.65); }
    body.is-editing #memoryNotice { bottom: calc(158px + env(safe-area-inset-bottom)); }
    #memoryNotice:empty { display: none; }
    .memory-overlay[hidden] { display: none; }
    .memory-overlay { position: fixed; z-index: 20; inset: 0; padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); background: rgba(22,18,14,.42); display: flex; align-items: center; justify-content: center; }
    .memory-overlay.sheet { align-items: flex-end; padding: 0; }
    .memory-dialog { width: min(540px,100%); max-height: 100%; overflow: auto; overscroll-behavior: contain; padding: 18px 18px 16px; border: 0; border-radius: 8px; background: #f6f3ee; color: #2c2a27; font-size: 15px; box-shadow: 0 2px 12px rgba(0,0,0,.12); }
    .memory-overlay.sheet .memory-dialog { width: 100%; max-height: min(86dvh, 100%); border-radius: 8px 8px 0 0; padding: 16px 18px max(16px, env(safe-area-inset-bottom)); box-shadow: 0 -2px 12px rgba(0,0,0,.1); }
    .memory-dialog header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
    .memory-dialog h2 { font-size: 17px; font-weight: 600; margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #2c2a27; }
    #memoryOverlay .memory-dialog h2 { font-size: 23px; font-weight: 600; white-space: normal; line-height: 1.3; }
    .memory-dialog h3 { font-size: 13px; font-weight: 500; margin: 18px 0 8px; color: #5c564f; }
    .memory-dialog .point-lead { margin: 8px 0 0; color: #5c564f; font-size: 13px; font-weight: 400; }
    #pointDescriptionText { margin: 10px 0 14px; font-size: 16px; font-weight: 400; line-height: 1.55; color: #3a3733; }
    .memory-dialog label { display: block; margin: 12px 0; color: #5c564f; font-size: 13px; font-weight: 500; }
    .memory-dialog input:not([type=file]), .memory-dialog textarea { width: 100%; color: #2c2a27; background: #fff; border: 1px solid #d9d2c8; border-radius: 4px; padding: 10px 12px; margin-top: 6px; font-size: 16px; font-weight: 400; }
    .memory-dialog textarea { min-height: 72px; resize: vertical; line-height: 1.5; }
    .memory-dialog button, .file-button { min-height: 44px; padding: 8px 12px; border: 1px solid #d9d2c8; border-radius: 4px; color: #2c2a27; background: #faf8f5; font-size: 15px; font-weight: 500; cursor: pointer; -webkit-tap-highlight-color: transparent; }
    .memory-dialog header button { min-width: 44px; border: 0; background: none; color: #5c564f; box-shadow: none; }
    .memory-dialog img, .memory-dialog video { display: block; width: 100%; max-width: 100%; height: auto; max-height: none; margin: 0; }
    .memory-dialog video { max-height: 70vh; background: #1a1816; }
    .memory-dialog audio { width: 100%; margin-top: 4px; }
    .memory-item { border: 0; padding: 0 0 16px; }
    .memory-item:last-child { padding-bottom: 0; }
    .memory-item-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; font-size: 13px; font-weight: 500; color: #5c564f; }
    .memory-item-name { font-weight: 400; color: #5c564f; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .memory-item p { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 16px; font-weight: 400; line-height: 1.55; color: #3a3733; }
    .memory-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
    .file-button { position: relative; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; }
    .file-button input { position: absolute; inset: 0; opacity: 0; font-size: 16px; cursor: pointer; }
    .move-target { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; min-height: 64px; margin: 0; padding: 10px 0; border: 0; border-bottom: 1px solid #e6e0d8; border-radius: 0; background: none; color: #2c2a27; font-size: 16px; font-weight: 500; cursor: pointer; }
    .move-target img { width: 72px; height: 54px; object-fit: cover; margin: 0; flex: none; border-radius: 2px; }
    .move-target .name { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .nav-candidate { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #e6e0d8; }
    .nav-candidate img { width: 72px; height: 54px; object-fit: cover; margin: 0; border-radius: 2px; }
    .nav-candidate .name { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; font-weight: 500; color: #2c2a27; }
    .nav-candidate button { flex: none; border: 0; background: none; color: #5c564f; min-height: 44px; padding: 8px 10px; font-size: 15px; font-weight: 500; }
    .move-empty { color: #5c564f; padding: 12px 0; font-size: 15px; }
    #imageLightbox { background: rgba(18,17,16,.82); }
    #imageLightbox .memory-dialog { width: auto; max-width: 100%; background: none; border: 0; box-shadow: none; padding: 8px; }
    #imageLightbox .memory-dialog button { color: #fff; background: none; border: 0; text-shadow: 0 1px 2px rgba(0,0,0,.6); margin-bottom: 8px; }
    #imageLightbox img { display: block; max-width: 96vw; max-height: 87dvh; width: auto; margin: 0 auto; object-fit: contain; }
    @media (prefers-reduced-motion: reduce) { #hint { transition: none; } }
  
[hidden]{display:none!important;}
#statusOverlay {position:fixed;z-index:30;inset:0;display:grid;place-items:center;background:#050505;}
.status-card {width:min(480px,90vw);padding:24px;color:#fff;background:#191919;border:1px solid #555;border-radius:14px;}
.status-card label{display:block;margin:12px 0;}
.status-card input{display:block;width:100%;padding:10px;margin-top:5px;background:#333;border:1px solid #777;border-radius:6px;color:white;font:inherit;}
.status-card button{padding:9px 14px;color:white;background:#333;border:1px solid #777;border-radius:9px;font:inherit;}
#statusMessage{white-space:pre-wrap;}
#editMode:disabled{cursor:default;}

/* iPhone幅で操作領域を画面端と重ねない。全画面ジェスチャーはstageに限定する。 */
.turn-controls { position:absolute; z-index:7; left:max(10px,env(safe-area-inset-left)); right:max(10px,env(safe-area-inset-right)); bottom:max(25px,calc(env(safe-area-inset-bottom) + 12px)); display:flex; justify-content:space-between; pointer-events:none; }
.turn-controls button { pointer-events:auto; width:44px; height:44px; border:1px solid rgba(255,255,255,.55); border-radius:50%; background:rgba(20,19,18,.78); color:#fff; font:600 24px/1 system-ui; touch-action:manipulation; }
.turn-controls button:disabled { opacity:.5; pointer-events:none; }
#zoomStatus { bottom:calc(max(25px,env(safe-area-inset-bottom) + 12px) + 48px); min-width:44px; min-height:44px; }
#headerActions { flex-wrap:wrap; }
#headerActions button { white-space:nowrap; }
#headerActions .header-spacer { min-width:0; }
button:focus-visible, a:focus-visible { outline:2px solid #7ca7e8; outline-offset:3px; }
.memory-overlay.sheet .memory-dialog { max-height:min(86dvh,var(--app-height)); padding-left:max(18px,env(safe-area-inset-left)); padding-right:max(18px,env(safe-area-inset-right)); overflow:auto; }
#pointBody { overflow-wrap:anywhere; white-space:pre-wrap; }
@media (max-width:360px) { #headerActions button { padding:6px; font-size:13px; } }
@media (orientation:landscape) and (max-height:430px) {
  .memory-overlay.sheet .memory-dialog { max-height:calc(var(--app-height) - max(8px,env(safe-area-inset-top))); }
  #hint { top:auto; bottom:70px; }
}

/* Photo theme. Solid surfaces keep controls readable over any exported image. */
html,body,#stage { background: var(--ground); }
body{color:var(--text);font-family:system-ui,-apple-system,"Hiragino Sans","Yu Gothic UI",sans-serif}
body::before { background: linear-gradient(#171611cc,transparent); height: 30vh; }
#appHeader { display: grid; gap: .35rem; width: auto; max-width: 42rem; margin: auto; }
.current-place { width: fit-content; max-width: 100%; padding: .34rem .75rem; border-radius: var(--radius); background: var(--veil); }
.current-place span { color: var(--muted); font-size: .875rem; }
#stationTitle { color:var(--text); padding:0; font: 600 clamp(1.15rem,4.7vw,1.75rem)/1.25 var(--serif); text-shadow:none; white-space:normal; overflow-wrap:anywhere; }
#headerActions { gap:.28rem; }
#headerActions button { color:var(--text); background:var(--veil); border:1px solid var(--line); border-radius:var(--radius); text-shadow:none; font-size:.875rem; min-height:44px; min-width:44px; white-space:normal; line-height:1.3; }
#headerActions #moveStation:enabled { color:var(--on-amber); background:var(--amber); font-weight:750; }
#headerActions button:disabled { opacity:1; background:#534534; color:#e5d6bf; }
#headerActions .header-spacer { flex:1 0 0; }
#hint, #zoomStatus { color:var(--text); background:var(--veil); border-radius:var(--radius); text-shadow:none; font-size:.875rem; padding:.35rem .6rem; }
#hint { top:auto; bottom: max(4.5rem,calc(env(safe-area-inset-bottom) + 4rem)); max-width: 70vw; white-space:normal; text-align:center; }
#memoryNotice { bottom:auto; top:50%; transform:translate(-50%,-50%); padding:.6rem .85rem; color:var(--text); background:var(--veil); border-radius:var(--radius); border:1px solid var(--line); font-size:1rem; text-shadow:none; }
.turn-controls button { color:var(--amber); background:var(--veil); border-color:var(--line); }
.turn-controls button:disabled { color:#e5d6bf; background:#534534; opacity:1; }
.navigation-marker::before { border-color:var(--amber); background:var(--veil); }
.memory-overlay { background:#171611bc; }
.memory-dialog,.memory-overlay.sheet .memory-dialog { background:var(--surface); color:var(--text); border:1px solid var(--line); border-radius:var(--radius) var(--radius) 0 0; font-size:1rem; }
.memory-overlay.sheet .memory-dialog { width:min(100%,44rem); }
.memory-dialog h2, #pointDescriptionText, .memory-item p, .move-target { color:var(--text); }
.memory-dialog h2 { white-space:normal; font-family:var(--serif); font-size:1.35rem; }
.memory-dialog .point-lead,.memory-dialog h3,.memory-dialog label,.memory-item-head,.memory-item-name,.move-empty { color:var(--muted); font-size:.875rem; }
.memory-dialog button,.memory-dialog header button { color:var(--text); background:var(--inset); border:1px solid var(--line); border-radius:var(--radius); min-height:44px; min-width:44px; }
.memory-dialog .move-target { justify-content:flex-start; text-align:start; margin-top:.5rem; border-color:var(--line); }
#statusOverlay { background:radial-gradient(ellipse at 25% 15%,#4a3928,var(--ground) 64%); overflow:auto; }
.status-card { color:var(--text); background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); }
.status-card #login,.status-card button { display:inline-flex; align-items:center; min-width:44px; min-height:44px; padding:.55rem .8rem; border-radius:var(--radius); background:var(--amber); color:var(--on-amber); font-weight:700; }
.move-current { color: var(--amber); font-size: .875rem; margin-inline-start: auto; }
#headerActions #editMode, #saveEdit { color:var(--on-amber); background:var(--amber); font-weight:750; }
#familyStatus { width:fit-content; max-width:100%; margin:0; padding:.35rem .65rem; border-radius:var(--radius); background:var(--veil); color:var(--muted); font-size:.875rem; }
#familyStatus[data-warning="true"], #editorMessage { color:var(--amber); }
#memoryTools { width:min(100%,44rem); margin-inline:auto; padding:.3rem max(.65rem,env(safe-area-inset-right)) max(.45rem,env(safe-area-inset-bottom)) max(.65rem,env(safe-area-inset-left)); gap:.18rem; background:var(--surface); border-color:var(--line); border-radius:var(--radius) var(--radius) 0 0; }
#memoryTools button { color:var(--text); border-color:var(--line); text-align:start; }
#memoryTools #addPoint, #memoryTools #cancelPlacement { color:var(--amber); }
body.is-editing #stage { cursor:default; }
body.is-editing #turnControls, body.is-editing #zoomStatus, body.is-editing #hint { display:none; }
body.is-placing #stage { cursor:crosshair; }
body.is-placing .memory-marker { pointer-events:none; }
#editNotice { margin:.3rem .65rem; font-size:.93rem; }
#editorOverlay form { margin-top:.65rem; }
#editorOverlay label input:not([type=file]), #editorOverlay textarea { background:var(--inset); color:var(--text); border-color:var(--line); border-radius:var(--radius); }
#editorOverlay input[type=file] { display:block; width:100%; padding:.35rem 0; color:var(--text); }
#editorOverlay input[type=file]::file-selector-button { min-height:44px; margin-right:.5rem; padding:.25rem .65rem; border:1px solid var(--line); border-radius:var(--radius); background:var(--inset); color:var(--text); font:inherit; }
#editTargets { display:grid; gap:.32rem; }
#editorOverlay button:disabled, #memoryTools button:disabled { opacity:.65; }
#editThisPoint { margin-top:.6rem; }
#editProgress { width:100%; accent-color:var(--amber); }
#pointDescriptionText { white-space:pre-wrap; overflow-wrap:anywhere; }
.memory-marker[data-draft="true"]::before { border-color:var(--amber); border-style:dashed; }
