:root {
  --ink: #14161b; --sub: #5b616e; --line: rgba(20, 22, 27, .1); --panel: rgba(255, 255, 255, .88); --accent: #e5484d; --accent-ink: #fff;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px); --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #14161b; color: var(--ink); font-family: var(--font); overscroll-behavior: none; }
body { position: fixed; inset: 0; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
svg { width: 22px; height: 22px; display: block; }
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#touch { position: fixed; inset: 0; touch-action: none; }
[hidden] { display: none !important; }

/* 名前の札 */
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.lb { position: absolute; left: 0; top: 0; white-space: nowrap; transform-origin: 50% 100%; will-change: transform; font-weight: 700; }
.lb--land { font-size: 12px; color: #fff; padding: 3px 8px; border-radius: 99px; background: rgba(20, 22, 27, .55); letter-spacing: .02em; }
.lb--spot { font-size: 12px; color: var(--ink); padding: 4px 9px; border-radius: 99px; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.lb--spot.is-done { opacity: .6; }
.lb--name { font-size: 12px; color: #fff; padding: 2px 7px; border-radius: 6px; background: rgba(20, 22, 27, .62); }
.lb--name.is-me { background: var(--accent); }
.lb--say { font-size: 13px; font-weight: 600; color: var(--ink); background: #fff; padding: 6px 10px; border-radius: 12px; box-shadow: 0 3px 10px rgba(0,0,0,.18); max-width: 220px; white-space: normal; }
.lb--say::after { content: ""; position: absolute; left: 50%; bottom: -6px; margin-left: -6px; border: 6px solid transparent; border-bottom: 0; border-top-color: #fff; }

/* 上の帯 */
.bar { position: fixed; top: calc(var(--sat) + 10px); left: calc(var(--sal) + 10px); right: calc(var(--sar) + 10px); display: flex; align-items: center; gap: 8px; pointer-events: none; }
.bar > * { pointer-events: auto; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px 0 10px; border-radius: 99px; background: var(--panel); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); font-size: 14px; font-weight: 700; box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.chip svg { color: var(--accent); }
.chip b { font-size: 16px; color: var(--accent); }
.place { flex: 1; min-width: 0; font-size: 12px; font-weight: 700; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.55); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; pointer-events: none; }
.round { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--panel); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: 0 2px 10px rgba(0,0,0,.14); transition: transform .12s; }
.round:active, .chip:active, .jump:active { transform: scale(.94); }
.round.sm { width: 44px; height: 44px; }

/* 小さい地図 */
.mini { position: fixed; top: calc(var(--sat) + 60px); right: calc(var(--sar) + 10px); width: 104px; height: 104px; border-radius: 50%; overflow: hidden; padding: 0; border: 3px solid rgba(255,255,255,.92); box-shadow: 0 3px 14px rgba(0,0,0,.25); background: #2b2e35; }
.mini canvas { width: 100%; height: 100%; display: block; }
.mini__n { position: absolute; top: 3px; left: 50%; transform: translateX(-50%); font-style: normal; font-size: 10px; font-weight: 800; color: #fff; text-shadow: 0 0 3px #000; }
.online { position: fixed; top: calc(var(--sat) + 170px); right: calc(var(--sar) + 10px); font-size: 11px; font-weight: 700; color: #fff; background: rgba(20,22,27,.55); padding: 3px 8px; border-radius: 99px; }
.online::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #3ddc84; margin-right: 5px; vertical-align: 1px; }
.online.is-off::before { background: #9aa0a6; }
.chatlog { position: fixed; left: calc(var(--sal) + 10px); top: calc(var(--sat) + 62px); width: min(62vw, 300px); display: flex; flex-direction: column; gap: 4px; pointer-events: none; }
.chatlog p { margin: 0; font-size: 12px; color: #fff; background: rgba(20,22,27,.5); padding: 4px 9px; border-radius: 10px; width: fit-content; max-width: 100%; transition: opacity .6s; }
.chatlog b { color: #ffd1d2; margin-right: 6px; }

/* 下の操作(右手) */
.pad { position: fixed; right: calc(var(--sar) + 14px); bottom: calc(var(--sab) + 18px); display: grid; grid-template-columns: 44px 76px; grid-template-rows: 44px 44px 44px; gap: 10px 12px; align-items: end; }
.pad #btnPhoto { grid-column: 1; grid-row: 1; }
.pad #btnChat { grid-column: 1; grid-row: 2; }
.pad #btnEmote { grid-column: 1; grid-row: 3; }
.jump { grid-column: 2; grid-row: 2 / 4; width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--accent); box-shadow: 0 6px 18px rgba(229,72,77,.45); transition: transform .12s; }
.jump svg { width: 34px; height: 34px; }
.action { position: fixed; left: 50%; bottom: calc(var(--sab) + 120px); transform: translateX(-50%); height: 48px; padding: 0 22px; border-radius: 99px; background: var(--ink); color: #fff; font-size: 15px; font-weight: 700; box-shadow: 0 6px 20px rgba(0,0,0,.3); white-space: nowrap; animation: pop .35s cubic-bezier(.2,1.4,.4,1); }
.action:active { transform: translateX(-50%) scale(.96); }
.action kbd { font: inherit; font-size: 12px; padding: 1px 6px; margin-right: 8px; border-radius: 5px; background: rgba(255,255,255,.2); }
@keyframes pop { from { transform: translateX(-50%) scale(.7); opacity: 0; } }
.ride { position: fixed; left: 50%; bottom: calc(var(--sab) + 120px); transform: translateX(-50%); display: flex; align-items: center; gap: 10px; background: var(--panel); backdrop-filter: blur(10px); padding: 8px 8px 8px 16px; border-radius: 99px; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.ride__bar { width: 120px; height: 6px; border-radius: 3px; background: rgba(20,22,27,.12); overflow: hidden; }
.ride__bar i { display: block; height: 100%; width: 0; background: var(--accent); }
.ride button { height: 36px; padding: 0 16px; border-radius: 99px; background: var(--ink); color: #fff; font-weight: 700; font-size: 14px; }

/* しぐさ・ことば */
.sheet { position: fixed; left: calc(var(--sal) + 10px); right: calc(var(--sar) + 10px); bottom: calc(var(--sab) + 192px); margin-left: auto; max-width: 420px; background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-radius: 18px; padding: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.25); display: grid; gap: 8px; }
.sheet__row { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.sheet__row button { flex: none; height: 38px; padding: 0 13px; border-radius: 99px; background: #fff; border: 1px solid var(--line); font-size: 13px; font-weight: 700; }
.sheet__row button:active { background: #f1f1f3; }
.sheet__chat { display: flex; gap: 6px; }
.sheet__chat input { flex: 1; min-width: 0; height: 40px; border-radius: 12px; border: 1px solid var(--line); padding: 0 12px; font: inherit; font-size: 16px; background: #fff; }
.sheet__chat button { height: 40px; padding: 0 16px; border-radius: 12px; background: var(--ink); color: #fff; font-weight: 700; }

/* スティック */
.stick { position: fixed; left: 0; top: 0; width: 124px; height: 124px; margin: -62px 0 0 -62px; border-radius: 50%; background: rgba(255,255,255,.18); border: 2px solid rgba(255,255,255,.55); pointer-events: none; opacity: 0; transition: opacity .15s; }
.stick i { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; background: rgba(255,255,255,.92); box-shadow: 0 3px 10px rgba(0,0,0,.25); }
.stick.is-on { opacity: 1; }
.stick.is-idle { opacity: .55; }
.hint { position: fixed; left: calc(var(--sal) + 14px); bottom: calc(var(--sab) + 30px); max-width: 52vw; margin: 0; font-size: 12px; font-weight: 700; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,.6); line-height: 1.6; pointer-events: none; transition: opacity .8s; }
.toast { position: fixed; left: 50%; top: calc(var(--sat) + 70px); transform: translate(-50%, -10px); opacity: 0; pointer-events: none; background: var(--ink); color: #fff; font-size: 14px; font-weight: 700; padding: 10px 16px; border-radius: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.3); transition: opacity .25s, transform .25s; display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 40px); }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast img { width: 40px; height: 40px; animation: stampIn .5s cubic-bezier(.2,1.6,.4,1); }
@keyframes stampIn { from { transform: scale(2.2) rotate(-20deg); opacity: 0; } }
.attr { position: fixed; right: calc(var(--sar) + 4px); bottom: calc(var(--sab) + 2px); font-size: 9px; color: rgba(255,255,255,.75); text-decoration: none; text-shadow: 0 0 2px #000; }

/* はじめの画面 */
.start { position: fixed; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding: calc(var(--sat) + 28px) calc(var(--sar) + 16px) calc(var(--sab) + 16px) calc(var(--sal) + 16px); background: linear-gradient(180deg, rgba(10,12,18,.55), rgba(10,12,18,0) 38%, rgba(10,12,18,0) 50%, rgba(10,12,18,.5)); }
.start__head { color: #fff; text-shadow: 0 2px 12px rgba(0,0,0,.45); }
.start h1 { margin: 0; font-size: 34px; letter-spacing: .04em; font-weight: 800; }
.start__head p { margin: 6px 0 0; font-size: 14px; font-weight: 700; }
.card { background: var(--panel); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-radius: 22px; padding: 16px; box-shadow: 0 12px 40px rgba(0,0,0,.3); display: grid; gap: 10px; width: 100%; max-width: 420px; margin: 0 auto; }
.field { display: flex; align-items: center; gap: 10px; }
.field span, .swatches > span { width: 44px; flex: none; font-size: 13px; font-weight: 700; color: var(--sub); }
.field input { flex: 1; min-width: 0; height: 44px; border-radius: 12px; border: 1px solid var(--line); padding: 0 12px; font: inherit; font-size: 16px; background: #fff; }
.swatches { display: flex; align-items: center; gap: 10px; }
.swatches > div { display: flex; gap: 7px; overflow-x: auto; padding: 3px; scrollbar-width: none; }
.swatches button { flex: none; width: 30px; height: 30px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }
.swatches button[aria-pressed="true"] { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ink); }
.primary { height: 52px; border-radius: 16px; background: var(--accent); color: var(--accent-ink); font-size: 17px; font-weight: 800; margin-top: 4px; box-shadow: 0 6px 18px rgba(229,72,77,.4); }
.primary:active { transform: scale(.98); }
.note { margin: 0; text-align: center; font-size: 12px; color: var(--sub); }
.loading { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; background: #14161b; color: #fff; transition: opacity .5s; }
.loading h1 { margin: 0; font-size: 28px; letter-spacing: .04em; }
.loading__bar { width: 200px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.15); overflow: hidden; }
.loading__bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.loading p { margin: 0; font-size: 13px; color: rgba(255,255,255,.7); }
.loading.is-gone { opacity: 0; pointer-events: none; }

/* ダイアログ */
.dlg { border: 0; padding: 0; width: min(100vw - 20px, 520px); max-height: calc(100dvh - var(--sat) - var(--sab) - 30px); border-radius: 22px; background: #fff; color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.4); overflow: auto; overscroll-behavior: contain; }
.dlg::backdrop { background: rgba(10,12,18,.45); }
.dlg header { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 8px 18px; background: #fff; }
.dlg h2 { margin: 0; font-size: 17px; }
.x { width: 40px; height: 40px; border-radius: 50%; font-size: 22px; line-height: 1; background: #f1f1f3; }
.dlg__note { margin: 0 18px 10px; font-size: 12px; color: var(--sub); }
.map { margin: 0 12px; border-radius: 14px; overflow: hidden; background: #2b2e35; aspect-ratio: 1; touch-action: manipulation; }
.map canvas { width: 100%; height: 100%; display: block; cursor: crosshair; }
.spots { list-style: none; margin: 12px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.spots button { width: 100%; text-align: left; padding: 9px 10px; border-radius: 12px; background: #f5f5f7; font-size: 13px; font-weight: 700; display: flex; gap: 8px; align-items: center; }
.spots i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.card-grid { list-style: none; margin: 4px 12px 16px; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.card-grid button { width: 100%; display: grid; grid-template-columns: 52px 1fr; gap: 10px; align-items: center; text-align: left; padding: 10px; border-radius: 14px; background: #f5f5f7; }
.card-grid img { width: 52px; height: 52px; filter: grayscale(1) opacity(.35); }
.card-grid .is-done img { filter: none; }
.card-grid b { display: block; font-size: 13px; }
.card-grid small { display: block; font-size: 11px; color: var(--sub); line-height: 1.45; margin-top: 2px; }
.menu { padding: 4px 18px 18px; display: grid; gap: 12px; }
.menu__row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14px; font-weight: 700; }
.seg { display: inline-flex; background: #f1f1f3; border-radius: 12px; padding: 3px; }
.seg button { height: 34px; padding: 0 12px; border-radius: 9px; font-size: 13px; font-weight: 700; color: var(--sub); }
.seg button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.menu__btn { height: 44px; border-radius: 12px; background: #f1f1f3; font-weight: 700; }
.howto { font-size: 13px; line-height: 1.7; }
.howto summary { font-weight: 700; cursor: pointer; }
.howto p { margin: 6px 0 0; color: var(--sub); }
.menu__credit { margin: 0; font-size: 11px; color: var(--sub); }
.menu__credit a { color: inherit; }

@media (min-width: 900px) and (pointer: fine) {
  .mini { width: 168px; height: 168px; top: auto; bottom: 24px; right: 24px; }
  .online { top: calc(var(--sat) + 60px); }
  .pad { right: 210px; bottom: 24px; }
  .hint { max-width: 420px; }
  .sheet { right: 210px; bottom: 120px; }
}
