:root { --red: #c62828; --ink: #222; --bg: #fff; --line: #d8d8d8; font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; color: var(--ink); -webkit-text-size-adjust: 100%; }
#map { position: fixed; inset: 0; }
body.editing #map { bottom: 58%; }
[hidden] { display: none !important; }

.btn { font: inherit; font-size: 16px; min-height: 44px; padding: 0 18px; border-radius: 22px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; font-weight: 700; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: default; }

.banner { position: fixed; top: max(12px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); max-width: calc(100% - 24px); background: rgba(255,255,255,.95); border-radius: 18px; padding: 10px 18px; font-weight: 700; font-size: 18px; text-align: center; box-shadow: 0 2px 10px rgba(0,0,0,.25); z-index: 5; }
.shared { position: fixed; top: calc(max(12px, env(safe-area-inset-top)) + 64px); left: 12px; right: 12px; margin: auto; max-width: 560px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; background: #fff8e1; border: 1px solid #f0c36d; border-radius: 14px; padding: 8px 12px; font-size: 14px; z-index: 5; }
.bar { position: fixed; left: 0; right: 0; bottom: max(28px, calc(env(safe-area-inset-bottom) + 20px)); display: flex; gap: 10px; justify-content: center; z-index: 5; }
body.editing .bar, body.editing .banner, body.editing .shared { display: none; }
.attrib { position: fixed; right: 4px; bottom: 2px; font-size: 11px; background: rgba(255,255,255,.8); padding: 1px 6px; border-radius: 4px; z-index: 6; }
body.editing .attrib { bottom: calc(58% + 2px); }
.maplibregl-ctrl-bottom-right { bottom: 22px; }

.sheet { position: fixed; left: 0; right: 0; bottom: 0; height: 58%; background: var(--bg); border-top: 1px solid var(--line); display: flex; flex-direction: column; z-index: 10; }
.sheet-body { flex: 1; overflow-y: auto; padding: 14px 16px; max-width: 640px; width: 100%; margin: 0 auto; }
.sheet-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 10px 16px max(10px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); max-width: 640px; width: 100%; margin: 0 auto; }
.sheet h2 { margin: 0 0 6px; font-size: 20px; }
.sheet h3 { margin: 18px 0 8px; font-size: 16px; }
.hint { color: #666; font-size: 13px; margin: 4px 0 8px; }
.seg { display: flex; gap: 8px; margin: 6px 0; }
.seg label { flex: 1; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 10px 6px; border: 1px solid var(--line); border-radius: 12px; font-size: 14px; cursor: pointer; }
.seg input:checked + span { background: #e8f5e9; border-color: #2e7d32; font-weight: 700; }
.seg label:nth-child(2) input:checked + span { background: #ffebee; border-color: var(--red); }
.coords { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: #555; margin-bottom: 8px; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; font-size: 14px; }
.field input { font: inherit; font-size: 16px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.present-row { display: flex; align-items: center; gap: 12px; min-height: 64px; margin-bottom: 8px; }
.present-row img { max-height: 80px; max-width: 120px; background: repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 0 0 / 14px 14px; border-radius: 8px; }
.error { color: #c62828; font-size: 14px; min-height: 1.2em; margin: 10px 0 0; }

.toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); background: rgba(30,30,30,.92); color: #fff; padding: 10px 18px; border-radius: 20px; z-index: 50; font-size: 14px; max-width: calc(100% - 32px); text-align: center; }

/* 地図の上の印 */
.santa { width: 56px; height: 56px; cursor: pointer; filter: drop-shadow(0 2px 3px rgba(0,0,0,.4)); }
.santa svg { width: 100%; height: 100%; display: block; }

/* プレゼントの箱の演出 */
.gift { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 30; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 18px; padding: 16px; }
.gift .box { position: relative; width: 200px; height: 200px; cursor: pointer; }
.gift .box .body { position: absolute; left: 10px; right: 10px; bottom: 0; height: 130px; background: #2e7d32; border-radius: 6px; }
.gift .box .body::after { content: ""; position: absolute; left: calc(50% - 14px); width: 28px; top: 0; bottom: 0; background: #ffd54f; }
.gift .box .lid { position: absolute; left: 0; right: 0; top: 30px; height: 50px; background: #388e3c; border-radius: 6px; transform-origin: left bottom; transition: transform .7s ease, opacity .5s ease .5s; }
.gift .box .lid::after { content: ""; position: absolute; left: calc(50% - 14px); width: 28px; top: 0; bottom: 0; background: #ffd54f; }
.gift.open .box .lid { transform: translate(-40px, -70px) rotate(-70deg); opacity: 0; }
.gift .img { max-width: min(80vw, 420px); max-height: 52vh; opacity: 0; transform: scale(.3); transition: opacity .6s .35s, transform .7s .35s cubic-bezier(.2,1.4,.4,1); display: none; }
.gift.open .img { opacity: 1; transform: scale(1); }
.gift.open .box { display: none; }
.gift.open .img, .gift.open .secret { display: block; }
.gift .secret { color: #fff; font-size: 20px; font-weight: 700; display: none; opacity: 0; transition: opacity .6s .35s; }
.gift.open .secret { opacity: 1; }
.gift .tap { color: #fff; font-size: 16px; }
.gift.open .tap { display: none; }

/* 切り取りの画面 */
.crop { position: fixed; inset: 0; z-index: 40; background: #111; color: #fff; display: flex; flex-direction: column; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.crop .top, .crop .bottom { display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
.crop .top h2 { flex: 1; margin: 0; font-size: 18px; }
.crop .tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 4px 12px; }
.crop .chip { font: inherit; font-size: 14px; padding: 6px 14px; border-radius: 16px; border: 1px solid #666; background: transparent; color: #fff; cursor: pointer; }
.crop .chip.on { background: #fff; color: #111; font-weight: 700; }
.crop .sw { display: flex; align-items: center; gap: 6px; font-size: 14px; margin-left: auto; }
.crop .view { flex: 1; min-height: 0; position: relative; touch-action: none; }
.crop canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.crop .msg { font-size: 13px; color: #ccc; padding: 4px 12px; min-height: 1.4em; }
.crop .bottom { justify-content: flex-end; }
.crop .btn { background: #333; color: #fff; border-color: #555; }
.crop .btn.primary { background: var(--red); border-color: var(--red); }
.crop .busy { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.5); font-size: 16px; z-index: 2; }
@media (min-width: 900px) { .sheet-body, .sheet-foot { padding-left: 24px; padding-right: 24px; } }
