/* Little Worlds: home, build and play layouts. Tokens live in app.css. */
#app, .screen, .screen[class] { position: fixed; inset: 0; }
.stage { position: absolute; inset: 0; }
.stage canvas { display: block; }
body.dragging, body.dragging * { cursor: grabbing !important; }
h1, h2 { font-family: "Fraunces", Georgia, serif; font-weight: 700; letter-spacing: -.02em; margin: 0; font-optical-sizing: auto; }
.link { border: 0; background: none; color: var(--accent); cursor: pointer; font-size: 13px; padding: 0; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* loading */
.loading { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--muted); }
.dots { display: flex; gap: 8px; } .dots span { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); opacity: .3; animation: dot 1s var(--ease) infinite; }
.dots span:nth-child(2) { animation-delay: .15s; } .dots span:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 50% { opacity: 1; transform: translateY(-3px); } }
.soon { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 16px; color: var(--muted); }

/* ---------- home ---------- */
.home .home-stage { inset: 0; }
.home .home-stage::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(90deg, rgba(247, 241, 232, .9) 0%, rgba(247, 241, 232, .55) 34%, rgba(247, 241, 232, 0) 58%); }
.home-card { position: absolute; left: 32px; top: 50%; transform: translateY(-58%); width: 400px; padding: 28px; z-index: 2; border-color: var(--line); }
.home-card h1 { font-size: 44px; line-height: 1; }
.home-card .tag { color: var(--muted); margin: 10px 0 22px; font-size: 16px; }
.modes { display: grid; gap: 10px; }
.mode { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper-2); cursor: pointer; text-align: left;
  transition: border-color .15s var(--ease), transform .15s var(--ease), background-color .15s var(--ease); }
.mode:hover { border-color: var(--accent-line); transform: translateY(-1px); background: var(--paper); }
.mode .mi { width: 52px; height: 52px; flex: none; border-radius: 12px; background: var(--paper); border: 1px solid var(--line); display: grid; place-items: center; }
.mode .mi svg { width: 40px; height: 40px; }
.mode .mt { display: flex; flex-direction: column; gap: 2px; }
.mode b { font-size: 17px; font-weight: 650; } .mode small { color: var(--muted); font-size: 13px; }
.btn.me img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; background: var(--paper-2); margin-left: -6px; }
.home-row { position: absolute; left: 32px; right: 32px; bottom: 24px; z-index: 2; }
.row-h { display: flex; align-items: baseline; gap: 16px; } .row-h .sec-h { margin-bottom: 8px; }
.worlds { display: flex; gap: 12px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; }
.worlds::-webkit-scrollbar { display: none; }
.wcard { position: relative; flex: none; width: 168px; height: 118px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: var(--paper); cursor: pointer; transition: transform .15s var(--ease), border-color .15s var(--ease); padding: 0; }
.wcard:hover { transform: translateY(-2px); border-color: var(--line-2); }
.wcard img, .wcard .wph { width: 100%; height: 100%; object-fit: cover; display: block; background: var(--paper-2); }
.wcard .wn { position: absolute; left: 8px; bottom: 8px; background: var(--paper); border: 1px solid var(--line); padding: 3px 8px; border-radius: 8px; font-size: 12px; font-weight: 600; max-width: calc(100% - 16px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wcard.new { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--muted); border-style: dashed; background: rgba(255, 253, 249, .85); font-weight: 600; font-size: 14px; }
.wcard.new svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; }
.wdel { position: absolute; top: 6px; right: 6px; opacity: 0; transition: opacity .15s var(--ease); }
.wcard:hover .wdel, .wdel:focus-visible { opacity: 1; }
@media (hover: none) { .wdel { opacity: .9; } }

/* place picker + photos */
.places-screen, .photos-screen { overflow: auto; background: var(--bg); }
.places-wrap { max-width: 1120px; margin: 0 auto; padding: 80px 24px 48px; }
.places-wrap h2 { font-size: 34px; } .places-wrap .tag { color: var(--muted); margin: 8px 0 24px; }
.place-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.place { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 10px 10px 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); cursor: pointer; transition: transform .15s var(--ease), border-color .15s var(--ease); }
.place:hover { transform: translateY(-2px); border-color: var(--accent-line); }
.place .ph { aspect-ratio: 48/34; border-radius: 10px; background: var(--paper-2) center/cover no-repeat; margin-bottom: 8px; opacity: .5; transition: opacity .3s var(--ease); }
.place .ph.in { opacity: 1; }
.place b { font-size: 16px; padding: 0 4px; } .place small { color: var(--muted); padding: 0 4px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.photo { margin: 0; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 10px 10px 12px; position: relative; }
.photo img { width: 100%; border-radius: 6px; display: block; } .photo figcaption { font-family: var(--hand); font-size: 22px; margin-top: 6px; }
.ph-acts { position: absolute; top: 16px; right: 16px; display: flex; gap: 6px; }

/* modal pieces */
.m-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; } .m-h h2 { font-size: 24px; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 18px; }
.pick { border: 1px solid var(--line); border-radius: 12px; background: var(--paper-2); padding: 6px 6px 8px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; transition: border-color .15s var(--ease); }
.pick:hover { border-color: var(--accent-line); } .pick img, .pick .wph { width: 100%; aspect-ratio: 3/2; object-fit: cover; border-radius: 8px; background: var(--paper); }

/* ---------- shared top bar pieces ---------- */
.topbar .btn, .topbar .ib, .seg, .wname { box-shadow: 0 1px 0 rgba(42, 35, 32, .04); }
.pill-group { display: flex; gap: 4px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 12px; padding: 3px; background: var(--paper); }
.seg button { border: 0; background: transparent; height: 32px; padding: 0 11px; border-radius: 9px; cursor: pointer; color: var(--muted); font-size: 13px; transition: color .15s var(--ease), background-color .15s var(--ease); }
.seg button.on { background: var(--paper-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.wname { height: 40px; border: 1px solid var(--line); background: var(--paper); border-radius: 12px; padding: 0 12px; font-weight: 600; width: 190px; }
.wname:focus { outline: none; border-color: var(--accent-line); }

/* ---------- build ---------- */
.b-panel { position: absolute; left: 16px; top: 72px; bottom: 16px; width: 316px; z-index: 5; display: flex; flex-direction: column; overflow: hidden; }
.b-tabs { display: flex; gap: 4px; padding: 12px 12px 0; }
.b-tabs button { flex: 1; min-width: 0; padding: 7px 6px 8px; display: flex; flex-direction: column; align-items: center; gap: 3px; line-height: 1.1; border: 1px solid var(--line); background: transparent; border-radius: 10px; cursor: pointer; color: var(--muted); font-weight: 600; transition: color .15s var(--ease), border-color .15s var(--ease), background-color .15s var(--ease); }
.b-tabs small { font-size: 11px; font-weight: 500; letter-spacing: 0; color: var(--muted); white-space: nowrap; }
.b-tabs button.on { color: var(--ink); border-color: var(--ink); background: var(--paper-2); }
.b-pane { flex: 1; min-height: 0; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.b-pane[data-pane=things] { overflow: hidden; }
.b-pane .search { flex: none; }
.b-pane .cats { flex: none; padding-bottom: 2px; }
.b-pane .grid { flex: 1; overflow: auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; align-content: start; padding-bottom: 8px; }
.b-pane .tile { padding: 6px 4px 8px; cursor: grab; }
.b-pane .tile img { background: radial-gradient(circle at 50% 60%, #fff 0%, var(--paper-2) 70%); border-radius: 8px; }
.empty { color: var(--muted); font-size: 13px; grid-column: 1/-1; }
.rsec { padding-bottom: 14px; border-bottom: 1px solid var(--line); } .rsec:last-child { border: 0; }
.sub { font-size: 12px; color: var(--muted); margin: 12px 0 6px; } .note { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.places { display: flex; flex-wrap: wrap; gap: 6px; }
.place-chip { height: 30px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: transparent; cursor: pointer; font-size: 13px; transition: border-color .15s var(--ease), background-color .15s var(--ease); }
.place-chip:hover { border-color: var(--line-2); } .place-chip.on { border-color: var(--accent-line); background: var(--accent-weak); color: var(--accent); }
.pats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.pat { display: flex; flex-direction: column; gap: 4px; padding: 0; border: 0; background: none; cursor: pointer; font-size: 11px; color: var(--muted); text-align: center; line-height: 1.15; }
.pat img { width: 100%; aspect-ratio: 1; border-radius: 9px; border: 1px solid var(--line); transition: border-color .15s var(--ease), transform .15s var(--ease); }
.pat:hover img { transform: translateY(-1px); border-color: var(--line-2); }
.pat.on img { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); } .pat.on { color: var(--ink); }
.tog-row { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-top: 12px; cursor: pointer; } .tog-row input { accent-color: var(--accent); width: 16px; height: 16px; }
.sws .chip.sm { height: 28px; }

/* context toolbar: one row, never wraps, never overlaps itself */
.ctx { position: absolute; left: 0; top: 0; z-index: 8; display: flex; flex-wrap: nowrap; align-items: center; gap: 4px; padding: 5px; background: var(--paper); border: 1px solid var(--line-2); border-radius: 14px; white-space: nowrap; box-shadow: 0 6px 18px rgba(42, 35, 32, .08); }
.ctx-name { font-size: 12px; font-weight: 600; color: var(--muted); padding: 0 6px 0 8px; max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
.ctx .ib.sm { width: 34px; height: 34px; border-color: transparent; background: transparent; }
.ctx .ib.sm:hover { border-color: var(--line); background: var(--paper-2); transform: none; }
.ctx .ib.sm.on { color: var(--accent); background: var(--accent-weak); }
.ctx .danger:hover { color: var(--accent); }
.pop { position: absolute; left: 0; top: 0; z-index: 9; width: 270px; background: var(--paper); border: 1px solid var(--line-2); border-radius: 14px; padding: 4px 14px 14px; box-shadow: 0 8px 22px rgba(42, 35, 32, .1); }
.pop .sws .sw { width: 24px; height: 24px; }
.hint { position: absolute; left: 348px; bottom: 24px; z-index: 6; max-width: 330px; background: rgba(254, 243, 199, .96); border: 1px solid rgba(42, 35, 32, .08); border-radius: 12px; padding: 10px 14px; font-size: 14px; }

/* photo mode */
.build.photo-on .b-panel, .build.photo-on .b-top, .build.photo-on .ctx, .build.photo-on .pop, .build.photo-on .hint { display: none; }
.shutter { position: absolute; inset: 0; z-index: 20; pointer-events: none; }
.shutter-bar { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; align-items: center; gap: 16px; background: var(--paper); border: 1px solid var(--line-2); border-radius: 18px; padding: 10px 14px; pointer-events: auto; max-width: calc(100% - 24px); }
.shutter .filters { flex-wrap: nowrap; overflow-x: auto; }
.shoot { width: 58px; height: 58px; flex: none; border-radius: 50%; border: 4px solid var(--paper); box-shadow: 0 0 0 2px var(--ink); background: var(--accent); cursor: pointer; transition: transform .12s var(--ease); }
.shoot:active { transform: translateY(1px); }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 30; }
.flash.go { animation: flash .35s var(--ease); }
@keyframes flash { 0% { opacity: .85; } 100% { opacity: 0; } }
.toast-a { border: 0; background: none; color: var(--accent-weak); color: #f7c3cd; font-weight: 600; cursor: pointer; margin-left: 10px; padding: 0; }

/* ---------- play ---------- */
.p-title { font-weight: 650; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; height: 40px; display: flex; align-items: center; padding: 0 12px; }
.p-help { position: absolute; left: 50%; top: 72px; transform: translateX(-50%); background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; font-size: 14px; color: var(--muted); z-index: 5; transition: opacity .3s var(--ease); text-align: center; max-width: calc(100% - 32px); }
.p-help.gone { opacity: 0; pointer-events: none; }
.p-act { position: absolute; left: 50%; bottom: 32px; transform: translateX(-50%); z-index: 6; display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 18px 0 8px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--paper); font-weight: 600; cursor: pointer; transition: transform .15s var(--ease), border-color .15s var(--ease); }
.p-act:hover { transform: translate(-50%, -1px); border-color: var(--accent-line); }
.p-act kbd { font: 600 12px var(--font); width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; background: var(--ink); color: var(--paper); }
.p-act:not(:has(kbd)) { padding-left: 18px; }
.joy { position: absolute; left: 28px; bottom: 32px; width: 124px; height: 124px; border-radius: 50%; background: rgba(255, 253, 249, .7); border: 1px solid var(--line-2); z-index: 6; touch-action: none; }
.joy-knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: var(--paper); border: 1px solid var(--line-2); box-shadow: 0 2px 6px rgba(42, 35, 32, .12); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .topbar .btn .lbl { display: none; } .topbar .btn:has(.lbl) { padding: 0; width: 40px; }
  .seg button { padding: 0 8px; }
}
@media (max-width: 860px) {
  .home .home-stage::after { background: linear-gradient(180deg, rgba(247, 241, 232, 0) 0%, rgba(247, 241, 232, .85) 55%); }
  .home-card { left: 16px; right: 16px; top: auto; bottom: 170px; transform: none; width: auto; padding: 20px; }
  .home-card h1 { font-size: 34px; } .home-card .tag { margin: 6px 0 14px; font-size: 14px; }
  .modes { grid-template-columns: 1fr 1fr; gap: 8px; } .mode { padding: 10px; gap: 10px; } .mode .mi { width: 40px; height: 40px; } .mode .mi svg { width: 30px; height: 30px; } .mode small { display: none; }
  .home-row { left: 16px; right: 16px; bottom: 16px; } .wcard { width: 140px; height: 100px; }
  .btn.me span { display: none; } .btn.me { padding: 0 10px; } .btn.me img { margin: 0; }
}
@media (max-width: 720px) {
  .topbar { gap: 6px; padding: 0 10px; }
  .wname { width: 120px; }
  .time-seg { position: absolute; top: 58px; left: 10px; }
  .b-panel { left: 0; right: 0; top: auto; bottom: 0; width: auto; height: 42dvh; border-radius: 18px 18px 0 0; border-bottom: 0; }
  .b-pane .grid { grid-template-columns: repeat(4, 1fr); }
  .ctx.dock { left: 50%; top: auto; bottom: calc(42dvh + 10px); transform: translateX(-50%) !important; }
  .pop { left: 50% !important; top: auto !important; bottom: calc(42dvh + 64px); transform: translateX(-50%) !important; width: min(300px, calc(100% - 24px)); }
  .ctx-name { display: none; }
  .hint { left: 12px; right: 12px; bottom: calc(42dvh + 12px); max-width: none; }
  .p-act { bottom: 40px; left: auto; right: 16px; transform: none; } .p-act:hover { transform: translateY(-1px); }
  .places-wrap { padding-top: 72px; } .places-wrap h2 { font-size: 26px; }
  .place-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .shutter-bar { flex-wrap: wrap; justify-content: center; }
}
@media (max-width: 420px) { .modes { grid-template-columns: 1fr 1fr; } .mode b { font-size: 15px; } }
@media (max-width: 420px) {
  .b-top .ib, .b-top .btn:has(.lbl) { width: 36px; min-width: 36px; height: 36px; }
  .b-top { gap: 4px; }
  .wname { width: 84px; height: 36px; padding: 0 8px; font-size: 14px; }
  .time-seg { top: 54px; }
}

/* walk mode extras */
.look-btn { padding: 0 14px 0 6px; }
.look-av { width: 30px; height: 30px; border-radius: 50%; background: var(--paper-2) center 18%/150% no-repeat; border: 1px solid var(--line); flex: none; }
.fade { position: absolute; inset: 0; background: var(--bg); opacity: 0; pointer-events: none; z-index: 40; transition: opacity .35s var(--ease); }
.fade.on { opacity: 1; }
@media (max-width: 1100px) { .topbar .btn.look-btn { width: auto; padding: 0 6px; } }

.zoom-ctl { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.zoom-ctl input { width: 120px; }

.home-card h1 { display: inline-flex; align-items: flex-start; gap: 4px; }
.h-heart { width: .5em; height: .46em; flex: none; margin-top: -.02em; fill: #d6536d; stroke: #d6536d; stroke-width: 3; stroke-linejoin: round; transform: rotate(8deg); }

/* First-visit walkthrough (tour.js): the hole's giant shadow dims everything but the part being explained */
.tour { position: fixed; inset: 0; z-index: 95; animation: tourIn .18s var(--ease); }
.tour.dim { background: rgba(42, 35, 32, .38); }
.tour.out { opacity: 0; transition: opacity .18s var(--ease); }
.tour-hole { position: fixed; border-radius: 16px; box-shadow: 0 0 0 200vmax rgba(42, 35, 32, .38); border: 1px solid var(--accent-line); pointer-events: none;
  transition: left .2s var(--ease), top .2s var(--ease), width .2s var(--ease), height .2s var(--ease), opacity .15s var(--ease); }
.tour-card { position: fixed; padding: 20px 20px 16px; box-shadow: 0 1px 0 var(--line); opacity: 0; transform: translateY(4px); transition: opacity .18s var(--ease), transform .18s var(--ease); }
.tour-card.in { opacity: 1; transform: none; }
.tour-x { position: absolute; top: 12px; right: 12px; border: 0; background: transparent; color: var(--muted); }
.tour-n { margin: 0 0 6px; min-height: 13px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.tour-card h2 { margin: 0 32px 6px 0; font: italic 600 24px/1.15 'Fraunces', Georgia, serif; letter-spacing: -.01em; }
.tour-b { margin: 0 0 16px; color: var(--muted); font-size: 15px; line-height: 1.45; }
.tour-acts { display: flex; align-items: center; gap: 8px; }
@keyframes tourIn { from { opacity: 0; } }
.tour-card:focus { outline: none; }
