/* Pixelstad – menyernas pixeltypsnitt (assets/fonts, byggs med tools/pixelfont/build.mjs): spelets egna
   5×7-bokstäver + gemener. Storlekarna var(--f1..f4) (≈12/24/36/48 px) räknas ut i index.html så att en
   bokstavspixel alltid blir hela skärmpixlar – då är texten knivskarp på datorn och på mobilen. */
@font-face { font-family: "Pixelstad"; src: url("../assets/fonts/pixelstad.otf") format("opentype"); font-weight: 400; font-display: block; }
@font-face { font-family: "Pixelstad"; src: url("../assets/fonts/pixelstad-fet.otf") format("opentype"); font-weight: 700; font-display: block; }
/* Snabbfilen – basen (knappar, modal, toasts, avatar-editor) är utbruten ur
   Pixelverkstan; HUD:en och scenytan är egna. */
:root {
  --ink: #17151a;
  --paper: #f1ebe0;
  --paper2: #e3dac9;
  --red: #9e1b22;
  --red2: #c9323a;
  --green: #2f8f46;
  --green2: #45b964;
  --gold: #e8b230;
  --blue: #2c6fb7;
  --muted: #6d6660;
  --shadow: 4px 4px 0 var(--ink);
  --font: "Pixelstad", "VT323", ui-monospace, monospace;
  --f1: 12px; --f2: 24px; --f3: 36px; --f4: 48px;
  --head: "Pixelstad", "Jersey 10", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #1c1a22; color: var(--ink); font-family: var(--font); overflow: hidden; line-height: 1.25; font-synthesis: none; -webkit-font-smoothing: none; }
body { -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; touch-action: manipulation; display: flex; flex-direction: column; }
.hidden { display: none !important; }
canvas { image-rendering: pixelated; display: block; }

/* ---------- HUD ---------- */
#hud {
  flex: none; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--ink); color: var(--paper); padding: 5px 12px;
  font-size: var(--f2); line-height: 1; border-bottom: 3px solid #000;
}
#hud-face canvas { display: block; border: 2px solid var(--paper); }
#hud-name { font-family: var(--head); font-size: var(--f2); color: #7ee8fa; }
#hud-money.debt { color: #ff6a6a; }
.meter { display: inline-flex; align-items: center; gap: 5px; }
.meter .bar { display: inline-block; width: 64px; height: 12px; background: #34303a; border: 2px solid var(--paper); }
.meter .bar i { display: block; height: 100%; background: var(--green2); transition: width .3s; }
.meter .bar i.mid { background: var(--gold); }
.meter .bar i.low { background: var(--red2); }
.hud-btns { margin-left: auto; display: flex; gap: 6px; }
.hud-btns .btn { font-size: var(--f1); padding: 2px 7px; }

/* emote-raden syns när någon annan är på samma plats */
#emotes { position: fixed; right: 14px; bottom: 14px; display: flex; gap: 6px; z-index: 40; }
#emotes .btn { font-size: var(--f2); padding: 4px 8px; }

/* möblera hemma: knapp nere till vänster + förrådspanel */
#decor-btn { position: fixed; left: 14px; bottom: 14px; z-index: 40; }
#decor-panel { position: fixed; right: 14px; top: 60px; bottom: 60px; width: 168px; z-index: 45;
  background: var(--paper); border: 3px solid var(--ink); box-shadow: 5px 5px 0 var(--ink);
  display: flex; flex-direction: column; }
#decor-panel .dp-head { background: var(--red); color: #fff; font: var(--f2) var(--head); padding: 5px 8px; border-bottom: 3px solid var(--ink); }
#decor-storage { flex: 1; overflow-y: auto; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.dp-item { display: grid; grid-template-columns: 52px minmax(0, 1fr); align-items: center; gap: 6px; font: var(--f1) var(--font); line-height: 1; background: #fff;
  border: 2px solid var(--ink); padding: 3px 6px 3px 3px; cursor: pointer; text-align: left; }
.dp-item:hover { background: #fffbe8; }
.dp-item.on { background: #fff4c7; outline: 3px solid var(--gold); outline-offset: -1px; }
.dp-item canvas { image-rendering: pixelated; justify-self: center; }
.dp-empty { color: var(--muted); font-size: var(--f1); padding: 6px; }
#decor-panel .dp-foot { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; border-top: 3px solid var(--ink); background: var(--paper2); }
#decor-panel .dp-foot .btn { flex: 1 1 40%; }
#decor-panel #decor-done { flex-basis: 100%; }
.dp-item small { display: block; color: var(--muted); font-size: var(--f1); margin-top: 2px; }

/* ---------- köp-/måladialogen för möbler ---------- */
.dlg.dlg-furn { width: min(700px, 100%); }
.fb-top { display: grid; grid-template-columns: 272px minmax(0, 1fr); gap: 14px; align-items: start; }
.fb-top.solo { grid-template-columns: 272px; justify-content: center; }
.fb-stage { width: 272px; height: 200px; display: flex; align-items: center; justify-content: center;
  border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink);
  background: repeating-conic-gradient(#fbf8f1 0 25%, #eee7d8 0 50%) 0 0 / 16px 16px; }
.fb-stage canvas, .fb-model canvas { image-rendering: pixelated; display: block; }
.fb-lbl { font: var(--f2) var(--head); text-transform: uppercase; letter-spacing: 1px; color: var(--red); }
.fb-side .fb-lbl { display: block; margin-bottom: 4px; }
.fb-models { display: flex; flex-wrap: wrap; gap: 8px; }
.fb-model { position: relative; min-width: 50px; min-height: 50px; padding: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  background: #fbf8f1; border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); }
.fb-model:hover { background: #fffbe8; }
.fb-model:active { transform: translate(2px, 2px); box-shadow: none; }
.fb-model.on { background: #fff4c7; outline: 3px solid var(--gold); outline-offset: -1px; }
.fb-model.on::after { content: "✓"; position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; font: var(--f1)/18px var(--head); text-align: center;
  background: var(--green2); color: #fff; border: 2px solid var(--ink); }
.fb-model:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.fb-colhead { display: flex; align-items: center; gap: 10px; margin: 14px 0 6px; }
.fb-now { display: inline-flex; align-items: center; gap: 6px; font-size: var(--f2); line-height: 1; }
.fb-chip { display: inline-block; width: 22px; height: 22px; background: var(--c, #fff); border: 2px solid var(--ink);
  box-shadow: inset 2px 2px 0 rgba(255,255,255,.35), inset -2px -2px 0 rgba(0,0,0,.18); }
.fb-sws { margin-bottom: 0; }
.fb-orig { display: flex; align-items: center; justify-content: center; }
.fb-orig b { font: var(--f2) var(--head); line-height: 1; color: #fff; pointer-events: none;
  text-shadow: 1px 1px 0 var(--ink), -1px -1px 0 var(--ink), 1px -1px 0 var(--ink), -1px 1px 0 var(--ink); }
.fb-info { font-size: var(--f2); line-height: 1.1; margin: 12px 0 0; }
.fb-info .sp { color: var(--muted); font-size: var(--f1); }
@media (max-width: 639px) {
  .fb-top, .fb-top.solo { grid-template-columns: minmax(0, 1fr); }
  .fb-stage { width: 100%; height: 180px; }
  .fb-models { gap: 6px; }
}

/* ---------- scenytan ---------- */
#app { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
/* Möblera-läget: förrådspanelen (168 px + 14 px kant + skugga) ligger fixed till höger –
   #app lämnar plats så att canvasen (fit() i main.js) aldrig hamnar under den */
@media (min-width: 700px) { body.decor-on #app { padding-right: 192px; } }
#scene { touch-action: none; box-shadow: 0 0 0 3px #000; }

/* ---------- Knappar ---------- */
.btn {
  font: var(--f2) var(--head); letter-spacing: .5px; color: var(--ink); background: var(--paper);
  border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink);
  padding: 7px 12px; cursor: pointer; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: #fff; }
.btn:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-go { background: var(--green2); color: #fff; text-shadow: 2px 2px 0 #1d5a2c; }
.btn-go:hover:not(:disabled) { background: #56cc75; }
.btn-red { background: var(--red2); color: #fff; text-shadow: 2px 2px 0 #5a0f14; }
.btn-red:hover:not(:disabled) { background: #de4a52; }
.btn-gold { background: var(--gold); }
.btn-small { font-size: var(--f1); padding: 4px 8px; box-shadow: 2px 2px 0 var(--ink); border-width: 2px; }

/* ---------- Modal ---------- */
#modal { position: fixed; inset: 0; background: rgba(15, 12, 20, .62); display: flex; align-items: center; justify-content: center; padding: 14px; z-index: 50; }
/* Dialogen är en kolumn: rubriken och knappraden står still, bara innehållet rullar – så syns
   knapparna (Köp, Stäng …) alltid, även på den minsta mobilen (iPhone 13 mini liggande) */
.dlg { background: var(--paper); border: 4px solid var(--ink); box-shadow: 8px 8px 0 var(--ink); width: min(620px, 100%); max-height: 100%; overflow: hidden; display: flex; flex-direction: column; }
.dlg > .dlg-head, .dlg > .dlg-foot { flex: none; }
.dlg > .dlg-body { flex: 1 1 auto; min-height: 0; overflow: auto; }
.dlg-head { background: var(--red); color: #fff; padding: 10px 14px; display: flex; gap: 12px; align-items: center; border-bottom: 4px solid var(--ink); }
.dlg-head h2 { margin: 0; font: var(--f3) var(--head); letter-spacing: .5px; text-shadow: 2px 2px 0 #4d0c10; }
.dlg-head .x { margin-left: auto; font-size: var(--f2); }
.dlg-body { padding: 14px; }
.dlg-foot { padding: 0 14px 14px; display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.who { display: flex; gap: 12px; align-items: flex-start; }
.who canvas { width: 60px; height: 72px; background: #d8cdb8; border: 3px solid var(--ink); flex: none; }

.plist { display: flex; flex-direction: column; gap: 6px; }
.prow { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; background: #fff; border: 2px solid var(--ink); padding: 4px 8px 4px 4px; }
.prow .nm { font-size: var(--f2); line-height: 1.05; }
.prow .sp { color: var(--muted); font-size: var(--f1); line-height: 1.05; }
.ok { color: var(--green); } .bad { color: var(--red2); }
.shoprow { grid-template-columns: 44px 1fr auto auto; }
.prow.here { background: #fff8d6; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; left: 50%; top: 52px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 90; pointer-events: none; align-items: center; }
.toast { background: var(--ink); color: #fff; padding: 5px 12px; font-size: var(--f2); border: 3px solid #fff; animation: toast 3s forwards; white-space: nowrap; }
.toast.good { background: #1f6b35; } .toast.bad { background: #8a1a20; }
@keyframes toast { 0% { opacity: 0; transform: translateY(-8px); } 8% { opacity: 1; transform: none; } 85% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- Avatarredigerare (från Pixelverkstan) ---------- */
.dlg.dlg-avatar { width: min(980px, 100%); height: min(760px, 100%); display: flex; flex-direction: column; overflow: hidden; }
.dlg-avatar .dlg-head, .dlg-avatar .dlg-foot { flex: none; }
.dlg-avatar .dlg-body { flex: 1; min-height: 0; padding: 12px 14px; }
.dlg-avatar .dlg-foot { padding-top: 10px; border-top: 3px solid var(--ink); background: var(--paper2); padding-bottom: 10px; }
.dlg-avatar .dlg-foot .av-reset { margin-right: auto; }
.av { height: 100%; display: grid; grid-template-columns: 252px minmax(0, 1fr); gap: 16px; }
.av-side { display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 0 4px 4px 0; }
.av-stage { position: relative; align-self: flex-start; border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); background: #eae1d0; line-height: 0; }
.av-cv { cursor: pointer; }
.av-tag { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); max-width: calc(100% - 12px); overflow: hidden; text-overflow: ellipsis;
  font: var(--f2) var(--head); line-height: 1; letter-spacing: .5px; padding: 3px 8px 1px; border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); white-space: nowrap; pointer-events: none; }
.av-ctrl { display: flex; gap: 6px; }
.av-ctrl .btn { flex: 1; font-size: var(--f2); padding: 2px 0; }
.av-id { display: flex; gap: 10px; align-items: flex-start; }
.av-face canvas { width: 80px; height: 96px; border: 3px solid var(--ink); display: block; }
.av-namebox { flex: 1; min-width: 0; }
.av-lbl { display: block; font: var(--f2) var(--head); text-transform: uppercase; letter-spacing: 1px; color: var(--red); margin-bottom: 3px; }
.av-namerow { display: flex; gap: 6px; }
.av-namerow input { flex: 1; min-width: 0; width: 100%; font: var(--f2) var(--font); border: 3px solid var(--ink); padding: 2px 6px; background: #fff; color: var(--ink); user-select: text; -webkit-user-select: text; }
.av-namerow input.bad { border-color: var(--red2); background: #ffe3e3; }
.av-namerow .btn { flex: none; font-size: var(--f2); }
.av-err { color: var(--red2); font-size: var(--f2); line-height: 1; min-height: 17px; margin-top: 3px; }
.av-mk { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.av-mk .av-sw { width: 100%; height: 26px; }

.av-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.av-tabs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; flex: none; }
.av-tab { font: var(--f1) var(--head); letter-spacing: .3px; color: var(--ink); background: var(--paper2); border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink);
  padding: 3px 2px 2px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 0; }
.av-tab i { font-style: normal; font-size: var(--f2); line-height: 1.1; }
.av-tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.av-tab:hover { background: #fffbe8; }
.av-tab.on { background: var(--gold); transform: translate(2px, 2px); box-shadow: none; }
.av-panel { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; margin-top: 10px; border: 3px solid var(--ink); background: #f7f2ea; padding: 2px 12px 14px; }
.av-sec h4 { font: var(--f2) var(--head); font-weight: 400; text-transform: uppercase; letter-spacing: 1px; color: var(--red); margin: 10px 0 6px; }
.av-hint { margin: -4px 0 6px; font-size: var(--f2); line-height: 1; color: var(--muted); }
.av-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; margin-bottom: 8px; }
.av-tiles.tall { grid-template-columns: repeat(auto-fill, minmax(84px, 110px)); }
.av-tile { position: relative; font: var(--f1) var(--font); line-height: 1; color: var(--ink); background: #fff; border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink);
  padding: 4px 2px 3px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; }
.av-tile canvas { width: 60px; height: 60px; background: #ece4d5; }
.av-tiles.tall .av-tile canvas { width: 48px; height: 82px; background: none; }
.av-tile span { max-width: 100%; text-align: center; line-height: .9; hyphens: manual; -webkit-hyphens: manual; overflow-wrap: normal; }
.av-tile:hover:not(:disabled) { background: #fffbe8; }
.av-tile:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: none; }
.av-tile.on { background: #fff4c7; outline: 3px solid var(--gold); outline-offset: -1px; }
.av-tile.on::after { content: "✓"; position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; font: var(--f1)/18px var(--head); text-align: center;
  background: var(--green2); color: #fff; border: 2px solid var(--ink); }
.av-tile:disabled { opacity: .4; cursor: not-allowed; }
.av-tile.locked { opacity: .8; }
.av-tile.locked canvas { filter: grayscale(1) brightness(.8); }
.av-tile .lk { position: absolute; top: 2px; right: 2px; font-size: var(--f1); }
.av-sws { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 6px; }
.av-sws.dim { opacity: .55; }
.av-sw { position: relative; width: 34px; height: 34px; padding: 0; cursor: pointer; background: var(--c); border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink), inset 2px 2px 0 rgba(255,255,255,.35), inset -2px -2px 0 rgba(0,0,0,.18); }
.av-sw:hover { transform: translateY(-2px); }
.av-sw.on { outline: 3px solid var(--gold); outline-offset: 1px; box-shadow: 2px 2px 0 var(--ink), inset 0 0 0 3px #fff; }
.av-own { display: flex; align-items: center; justify-content: center; overflow: hidden;
  background: conic-gradient(from 45deg, #ff4d4d, #ffd23f, #8ee03c, #3fc4ff, #a66bff, #ff5dc8, #ff4d4d); }
.av-own.on { background: var(--c); }
.av-own b { font: var(--f2) var(--head); color: #fff; text-shadow: 1px 1px 0 var(--ink), -1px -1px 0 var(--ink), 1px -1px 0 var(--ink), -1px 1px 0 var(--ink); pointer-events: none; }
.av-own input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.av-sw:focus-visible, .av-tile:focus-visible, .av-tab:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

@media (max-width: 639px) {
  #modal:has(.dlg-avatar) { padding: 6px; }
  .dlg-avatar .dlg-head { padding: 5px 8px; }
  .dlg-avatar .dlg-head h2 { font-size: var(--f2); }
  .dlg-avatar .dlg-head .x { padding: 1px 7px; }
  .dlg-avatar .dlg-body { padding: 7px; }
  .dlg-avatar .dlg-foot { gap: 6px; padding: 7px; flex-wrap: nowrap; }
  .dlg-avatar .dlg-foot .btn { font-size: var(--f1); padding: 5px 7px; min-width: 0; }
  .dlg-avatar .dlg-foot .av-ico { display: none; }
  .av { display: flex; flex-direction: column; gap: 7px; }
  .av-side { flex: none; display: grid; grid-template-columns: auto auto minmax(0, 1fr); grid-template-rows: auto auto 1fr;
    grid-template-areas: "stage face name" "stage face ctrl" "stage mk mk"; gap: 5px 7px; overflow: visible; padding: 0; }
  .av-stage { grid-area: stage; box-shadow: 2px 2px 0 var(--ink); }
  .av-tag { font-size: var(--f1); bottom: 5px; padding: 2px 5px 0; box-shadow: 1px 1px 0 var(--ink); }
  .av-id { display: contents; }
  .av-face { grid-area: face; }
  .av-face canvas { width: 50px; height: 60px; border-width: 2px; }
  .av-namebox { grid-area: name; }
  .av-marker { grid-area: mk; }
  .av-ctrl { grid-area: ctrl; gap: 4px; }
  .av-ctrl .btn { font-size: var(--f1); padding: 1px 0; }
  .av-lbl { font-size: var(--f1); margin-bottom: 1px; letter-spacing: .5px; }
  .av-namerow { gap: 4px; }
  .av-namerow input { font-size: var(--f2); padding: 0 4px; border-width: 2px; }
  .av-namerow .btn { font-size: var(--f1); padding: 1px 4px; }
  .av-err { min-height: 0; margin: 0; font-size: var(--f1); }
  .av-err:empty { display: none; }
  .av-mk { gap: 5px; }
  .av-mk .av-sw { height: 24px; border-width: 2px; }
  .av-tabs { gap: 4px; }
  .av-tab { font-size: var(--f1); padding: 1px 1px 0; box-shadow: 1px 1px 0 var(--ink); }
  .av-tab i { font-size: var(--f1); }
  .av-panel { margin-top: 6px; padding: 0 7px 10px; border-width: 2px; }
  .av-sec h4 { font-size: var(--f1); margin: 7px 0 4px; }
  .av-hint { font-size: var(--f1); }
  .av-tiles { grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 6px; }
  .av-tile { font-size: var(--f1); padding: 3px 1px 2px; }
  .av-tile canvas { width: 54px; height: 54px; }
  .av-tiles.tall { grid-template-columns: repeat(auto-fill, minmax(74px, 96px)); }
  .av-sw { width: 34px; height: 34px; }
}
@media (max-height: 540px) and (min-width: 640px) {
  #modal:has(.dlg-avatar) { padding: 6px; }
  .dlg-avatar .dlg-head { padding: 3px 10px; border-bottom-width: 3px; }
  .dlg-avatar .dlg-head h2 { font-size: var(--f2); }
  .dlg-avatar .dlg-head .x { padding: 0 6px; font-size: var(--f1); }
  .dlg-avatar .dlg-body { padding: 6px 10px; }
  .dlg-avatar .dlg-foot { padding: 5px 10px; }
  .dlg-avatar .dlg-foot .btn { font-size: var(--f1); padding: 3px 8px; }
  .av { grid-template-columns: 136px minmax(0, 1fr); gap: 10px; }
  .av-side { gap: 6px; }
  .av-id { flex-direction: column; gap: 4px; }
  .av-namebox { width: 100%; }
  .av-face canvas { width: 50px; height: 60px; border-width: 2px; }
  .av-tag { font-size: var(--f1); bottom: 5px; padding: 2px 5px 0; }
  .av-tabs { grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 3px; }
  .av-tab { padding: 2px 0; }
  .av-tab span { display: none; }
  .av-panel { margin-top: 6px; padding: 0 8px 8px; }
  .av-sec h4 { font-size: var(--f1); margin: 6px 0 4px; }
}

/* ---------- Avatarväljare ---------- */
.av-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.av-card { position: relative; border: 3px solid var(--ink); background: #fff; box-shadow: 4px 4px 0 var(--pc, var(--ink)); display: flex; flex-direction: column; }
.av-card.on { background: #fff8d6; }
.av-card-main { border: 0; background: none; padding: 10px 6px 6px; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; font: inherit; }
.av-card-main canvas { width: 64px; height: 64px; image-rendering: pixelated; border: 2px solid var(--ink); }
.av-card-main b { font: var(--f2) var(--head); border-bottom: 3px solid var(--pc, var(--ink)); }
.av-card-tools { display: flex; justify-content: center; gap: 4px; padding: 0 6px 8px; }
.av-card-tools .btn { padding: 2px 6px; font-size: var(--f1); }
.av-new { align-items: center; justify-content: center; cursor: pointer; min-height: 150px; font: inherit; background: var(--paper2); box-shadow: 4px 4px 0 var(--ink); }
.av-new span { font: var(--f4) var(--head); line-height: 1; }
.av-new b { font: var(--f2) var(--head); }

/* tangentbrickor på knappar som har en genväg */
kbd {
  display: inline-block; min-width: 1.15em; padding: 0 4px; margin-left: 3px; font: var(--f1) var(--font, monospace); line-height: 1.3; text-align: center;
  color: var(--ink); background: #fff; border: 2px solid var(--ink); border-bottom-width: 3px; vertical-align: 2px; text-shadow: none; opacity: .9;
}
@media (hover: none) { kbd { display: none; } }

/* Versionsnumret i HUD:en och nyhetsrutan (js/core/version-ui.js) */
.hud-btns .hud-version { font: var(--f1) var(--font); letter-spacing: 0; padding: 2px 6px; background: #2b2733; color: #cfc7ba; border-color: #cfc7ba; box-shadow: 2px 2px 0 #000; }
.toast.wrap { white-space: normal; max-width: min(92vw, 560px); text-align: center; line-height: 1.05; }
.hud-btns .hud-version.ny { background: var(--gold); color: var(--ink); border-color: var(--ink); animation: ver-ny 1.2s steps(2) 6; }
@keyframes ver-ny { 50% { background: #fff4c7; } }
.nyheter section { border-bottom: 2px dashed #cbbfa8; padding: 6px 0 8px; }
.nyheter section:last-child { border-bottom: 0; }
.nyheter section.nu { background: #fff4c7; margin: 0 -8px; padding: 6px 8px 8px; }
.nyheter h3 { margin: 0; font: var(--f2) var(--head); letter-spacing: .3px; }
.nyheter .ver { display: inline-block; background: var(--ink); color: var(--gold); font: var(--f2) var(--font); padding: 0 6px; margin-right: 4px; vertical-align: 2px; }
.nyheter .du { font: var(--f1) var(--font); color: var(--green); }
.nyheter .datum { font-size: var(--f1); color: var(--muted); margin: 1px 0 2px; }
.nyheter ul { margin: 2px 0 0; padding-left: 20px; font-size: var(--f2); line-height: 1.15; }
.nyheter li { margin: 2px 0; }
.nyheter code { font: inherit; background: #e3dac9; padding: 0 3px; }

/* Ny version: banderoll längst ner (js/core/version-ui.js) */
#sf-update { position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 95; display: flex; align-items: center; gap: 10px;
  max-width: min(94vw, 720px); background: var(--ink); color: #fff; border: 3px solid var(--gold); box-shadow: 4px 4px 0 #000; padding: 6px 10px; font-size: var(--f2); line-height: 1.1; }
#sf-update .sub { color: #cfc7ba; font-size: var(--f2); }
#sf-update .btn { flex: none; }
.nyheter section.backup ul { list-style: none; padding-left: 0; }
.nyheter section.backup li { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: var(--f2); }

/* 👥-listan: version och var man är */
.prow .old { font: var(--f1) var(--font); color: #fff; background: var(--red2); padding: 0 4px; vertical-align: 2px; }
.world-diag { font-size: var(--f1); color: var(--muted); margin: 8px 0 0; }
.plist .prow { grid-template-columns: 44px 1fr auto auto; }
/* knapparna i 👥-raden: en grupp till höger som radbryts (Jobba ihop, Gå dit, Åk hem till, Flytta ihop, Blockera, Anmäl) */
.prow .pbtns { grid-column: 3 / -1; display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }

/* ---------- Huvudmenyn / pausmenyn (js/core/menu.js) ---------- */
#menu { position: fixed; inset: 0; z-index: 45; /* under #modal (50): dialoger från menyn (redigeraren, bekräftelser, nyheter) ligger alltid överst */ display: flex; align-items: center; justify-content: center; padding: 12px; background: rgba(10, 8, 14, .28); overflow: auto; }
.menu-panel { width: min(560px, 100%); max-height: 100%; overflow: auto; background: var(--paper); border: 4px solid var(--ink); box-shadow: 8px 8px 0 var(--ink); padding: 14px 16px 12px; }
.menu-title { text-align: center; font: var(--f4) var(--head); letter-spacing: 2px; color: var(--red2); text-shadow: 3px 3px 0 var(--ink); line-height: .9; }
.menu-title small { display: block; font: var(--f2) var(--font); color: var(--muted); letter-spacing: 1px; text-shadow: none; margin-top: 4px; }
.menu-btns { display: flex; flex-direction: column; gap: 8px; margin: 14px auto 0; width: min(330px, 100%); }
.menu-main { font-size: var(--f3); padding: 8px 12px; }
.menu-settings { margin: 12px auto 0; width: min(330px, 100%); background: #fff; border: 2px solid var(--ink); padding: 6px 10px; }
.menu-row { display: flex; justify-content: space-between; align-items: center; font-size: var(--f2); padding: 3px 0; gap: 10px; }
.menu-sub { font: var(--f2) var(--head); margin: 14px 0 6px; letter-spacing: .5px; }
.menu-cards { display: flex; flex-direction: column; gap: 7px; }
.menu-card { display: grid; grid-template-columns: 60px 1fr auto; gap: 10px; align-items: center; background: #fff; border: 3px solid var(--ink); padding: 4px 8px 4px 4px; cursor: pointer; box-shadow: 3px 3px 0 var(--ink); }
.menu-card:hover { background: #fffbef; }
.menu-card.on { background: #fff4c7; outline: 3px solid var(--gold); outline-offset: -1px; }
.menu-card canvas { border: 2px solid var(--pc, var(--ink)); display: block; }
.menu-card-txt { min-width: 0; }
.menu-card-txt b { font: var(--f2) var(--head); display: block; letter-spacing: .3px; }
.menu-card-txt small { font-size: var(--f1); color: var(--muted); display: block; line-height: 1.05; }
.menu-card .nu { font: var(--f1) var(--font); color: #fff; background: var(--green); padding: 0 5px; vertical-align: 3px; font-style: normal; margin-left: 4px; }
.menu-card-tools { display: flex; gap: 4px; }
.menu-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; font-size: var(--f1); color: var(--muted); }
body.menu-open #emotes, body.menu-open #decor-btn { display: none !important; }
@media (max-width: 639px) {
  .menu-panel { padding: 10px; }
  .menu-title { font-size: var(--f4); }
  .menu-card { grid-template-columns: 48px 1fr auto; gap: 6px; }
  .menu-card-tools .btn { padding: 2px 5px; font-size: var(--f1); }
  .menu-card-txt b { font-size: var(--f2); }
}

/* Pixelmätarna (js/core/hud-pix.js): HUD-raden krymper till bara knapparna */
body.hud-pix #hud > :not(.hud-btns) { display: none; }
body.hud-pix #hud { padding: 3px 8px; }
/* startmenyn: bara knapparna i HUD-raden, staden fyller hela bakgrunden */
body.menu-boot #hud > :not(.hud-btns) { display: none; }
body.menu-boot #app { overflow: hidden; }
@media (max-width: 639px) { .menu-card canvas { width: 44px; height: 53px; } .menu-card { grid-template-columns: 46px 1fr auto; } }

/* Namnrutan ovanpå avatarredigeraren (Spara utan namn) */
.dlg-avatar { position: relative; }
.av-nameask { position: absolute; inset: 0; background: rgba(15, 12, 20, .55); display: flex; align-items: center; justify-content: center; z-index: 5; padding: 12px; }
.av-nameask-box { background: var(--paper); border: 4px solid var(--ink); box-shadow: 6px 6px 0 var(--ink); padding: 14px 16px; width: min(380px, 100%); }
.av-nameask-box h3 { margin: 0 0 4px; font: var(--f3) var(--head); letter-spacing: .5px; }
.av-nameask-box p { margin: 0 0 10px; font-size: var(--f2); color: var(--muted); line-height: 1.1; }
.av-nameask-box input { width: 100%; font: var(--f3) var(--font); padding: 5px 10px; border: 3px solid var(--ink); background: #fff; box-shadow: inset 2px 2px 0 #e3dac9; }
.av-nameask-err { min-height: 22px; color: var(--red2); font-size: var(--f2); margin: 4px 0 6px; }
.av-nameask-btns { display: flex; gap: 8px; justify-content: flex-end; }

/* Pixelmätarnas remsa ovanför spelbilden (js/core/hud-pix.js) */
body.hud-pix #app { flex-direction: column; gap: 0; }
#hudpix { display: block; image-rendering: pixelated; box-shadow: 0 0 0 3px #000; }
body.menu-boot #hudpix { display: none; }

/* Bostadsbyråns annonsdialog: planschbilder i pixelskala */
.prow.homerow { grid-template-columns: auto 1fr auto; }
canvas.homepic { width: 128px; height: auto; image-rendering: pixelated; border: 2px solid var(--ink); display: block; }
@media (max-width: 639px) { canvas.homepic { width: 64px; } }

/* Chatten (js/core/chat.js): inmatningsraden längst ner */
#chat { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 45; display: flex; gap: 6px; align-items: center;
  width: min(92vw, 520px); background: var(--paper); border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); padding: 6px; }
#chat input { flex: 1; min-width: 0; font: var(--f2) var(--font); padding: 4px 8px; border: 2px solid var(--ink); background: #fff; }
/* chattens emojiväljare */
#chat { flex-wrap: wrap; }
#chat .chat-emojis { flex-basis: 100%; order: -1; max-height: 190px; overflow: auto; background: #fff; border: 2px solid var(--ink); padding: 4px 6px; }
#chat .chat-cat b { display: block; font: var(--f1) var(--font); color: var(--muted); margin: 2px 0; }
#chat .chat-cat div { display: flex; flex-wrap: wrap; gap: 2px; }
#chat .chat-cat button { font-size: var(--f2); line-height: 1; padding: 2px; background: none; border: 0; cursor: pointer; }
#chat .chat-cat button:hover { background: #fff4c7; }

/* Veckosammanfattningen (js/core/week.js): sju fönster ut mot staden */
.dlg.dlg-week { width: min(1120px, 100%); }
.dlg-week .dlg-head h2 { font-size: var(--f3); }
.wk { font-size: var(--f2); }
.wk h3 { font: var(--f3) var(--head); margin: 0 0 6px; letter-spacing: .5px; }
.wk-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.wk-day { background: var(--paper2); border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); padding: 6px 3px 7px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; }
.wk-day b { font: var(--f3) var(--head); letter-spacing: .5px; line-height: 1; }
.wk-day .wk-n { font-size: var(--f1); color: var(--muted); line-height: 1; }
.wk-win { display: block; image-rendering: pixelated; image-rendering: crisp-edges; margin: 3px 0 2px; }
.wk-day.past { background: #cfcac2; color: #6d6660; box-shadow: none; }
.wk-day.past b { color: #6d6660; }
.wk-day.today { background: #fff4c7; outline: 4px solid var(--gold); outline-offset: -2px; }
.wk-day.rentday { border-color: var(--red2); }
.wk-day i { font: var(--f1) var(--font); font-style: normal; padding: 0 5px; line-height: 1.2; }
.wk-now { background: var(--gold); color: var(--ink); }
.wk-done { color: #fff; background: #8a847c; }
.wk-next { visibility: hidden; }
.wk-rent { background: var(--red2); color: #fff; font-size: var(--f1); line-height: 1.1; padding: 1px 4px; }
.wk-paid { background: #6d6660; color: #fff; font-size: var(--f1); line-height: 1.1; padding: 1px 4px; }
.wk-ok { font-size: var(--f2); margin: 8px 0; color: var(--green); }
.wk-bad { font-size: var(--f2); margin: 8px 0; color: var(--red2); }
.wk-ok b, .wk-bad b { color: var(--ink); }
.wk-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.wk-cols > div { background: #fff; border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); padding: 8px 12px 10px; }
.wk-todo { list-style: none; margin: 0; padding: 0; font-size: var(--f2); }
.wk-todo li { display: flex; gap: 8px; padding: 3px 0; }
.wk-todo li span { width: 20px; flex: none; }
.wk-todo li.ok { color: var(--muted); }
.wk-todo li.ok span { color: var(--green); }
.wk-stats { display: grid; grid-template-columns: 1fr; gap: 4px 16px; font-size: var(--f2); }
.wk-stats > div.wide { grid-column: 1 / -1; }
.wk-stats > div { display: flex; justify-content: space-between; align-items: center; gap: 10px; border-bottom: 2px dotted var(--paper2); padding-bottom: 2px; }
.wk-stats span { color: var(--muted); }
.wk-stats b { font-weight: normal; }
.wk-bar { flex: 0 0 46%; height: 14px; background: #34303a; border: 2px solid var(--ink); }
.wk-bar i { display: block; height: 100%; background: var(--green2); }
.wk-bar.hu i { background: #e8923a; }
.wk-tip { font-size: var(--f2); color: var(--muted); margin: 12px 0 0; }
.wk-bar.gl i { background: #e85d9a; }

/* ---------- 🎯 livsmålen (js/core/livsmal.js) ---------- */
.dlg-goals { max-width: 760px; }
.lm-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: center; background: #fff; border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); padding: 8px 10px; margin: 0 0 10px; }
.lm-row.ok { background: #effae9; }
.lm-name { font-size: var(--f2); line-height: 1.05; min-width: 0; }
.lm-name small, .lm-prog small { display: block; font-size: var(--f1); color: var(--muted); margin-top: 3px; line-height: 1.1; }
.lm-prog { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: var(--f2); min-width: 0; }
.lm-prog .lm-bar { flex: 1 1 120px; }
.lm-prog small { flex: 1 1 100%; margin-top: 0; }
.lm-bar { display: inline-block; height: 14px; background: #34303a; border: 2px solid var(--ink); vertical-align: middle; }
.lm-bar i { display: block; height: 100%; background: var(--gold); }
.lm-bar.done i { background: var(--green2); }
.lm-chips { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.lm-chip { font: var(--f1) var(--font); line-height: 1.05; color: var(--ink); background: #fff; border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); padding: 6px 3px; cursor: pointer; min-width: 0; }
.lm-chip:hover { background: #fffbe8; }
.lm-chip:active { transform: translate(2px, 2px); box-shadow: none; }
.lm-chip.on { background: #fff4c7; outline: 3px solid var(--gold); outline-offset: -1px; }
.lm-presets { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.lm-tip { font-size: var(--f2); color: var(--muted); margin: 4px 0 0; }
.lm-mini { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 10px 0 0; }
.lm-mini > span { display: flex; align-items: center; gap: 5px; font-size: var(--f1); background: #fff; border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); padding: 4px 6px; min-width: 0; }
.lm-mini > span.ok { background: #effae9; }
.lm-mini .lm-bar { flex: 1 1 30px; min-width: 20px; height: 10px; }
.lm-mini b { white-space: nowrap; font-weight: normal; }
.lm-natt { font-size: var(--f2); margin: 8px 0; }
.lm-natt .up { color: var(--green); }
.lm-natt .down { color: var(--red2); }

/* ---------- 🍳 köket: spisen och receptboken (js/scenes/kok.js) ---------- */
.dlg-kok { max-width: 820px; }
.kok-tabs { display: flex; gap: 6px; margin: 0 0 8px; }
.kok-tabs .av-tab.on { background: #fff4c7; outline: 3px solid var(--gold); outline-offset: -1px; }
.kok-note { font-size: var(--f2); margin: 4px 0 10px; }
.kok-port { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 0 0 6px; }
.kok-dish { display: block; image-rendering: pixelated; image-rendering: crisp-edges; border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); background: #faf2ea; }
.kok-list { display: grid; gap: 8px; }
.kok-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; background: #fff; border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); padding: 6px 8px; }
.kok-row.ready { background: #effae9; }
.kok-row .kok-dish { width: 96px; height: 64px; }
.kok-txt { font-size: var(--f2); line-height: 1.1; min-width: 0; }
.kok-txt p { font-size: var(--f1); margin: 4px 0; line-height: 1.2; }
.kok-txt small { display: block; font-size: var(--f1); color: var(--muted); margin-top: 4px; }
.kok-stars { color: #d89a10; letter-spacing: 1px; }
.kok-ings { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.kok-ing { font-size: var(--f1); line-height: 1; padding: 3px 5px; border: 2px solid var(--ink); background: #effae9; }
.kok-ing.no { background: #ffe6e0; color: var(--red2); }
.kok-book { display: grid; gap: 10px; }
.kok-page { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: start; background: #fffaf0; border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); padding: 8px 10px; }
.kok-page.kan { background: #f4fbef; }
.kok-pic { position: relative; }
.kok-pic .kok-dish { width: 144px; height: 96px; }
.kok-no { position: absolute; right: 4px; bottom: 4px; font-size: var(--f1); background: #fffaf0; border: 2px solid var(--ink); padding: 1px 4px; }
.kok-kan { font-size: var(--f1); color: var(--green); margin-top: 6px; }
.kok-page .btn { margin-top: 6px; }
.kok-res .kok-dish { width: 144px; height: 96px; margin: 0 0 8px; }
@media (max-width: 760px) {
  .kok-row { grid-template-columns: auto minmax(0, 1fr); }
  .kok-row .btn { grid-column: 1 / -1; }
  .kok-page { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .lm-row { grid-template-columns: 1fr; gap: 6px; }
  .lm-mini { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .wk-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .wk-day b { font-size: var(--f2); }
  .wk-cols { grid-template-columns: 1fr; }
  .wk-stats { grid-template-columns: 1fr; }
}

/* ---------- mobilfyllning: spelet fyller hela skärmen ---------- */
html, body { height: 100dvh; }
body { padding-bottom: env(safe-area-inset-bottom); }
#hud { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
#app { overflow: hidden; }
@media (max-width: 700px) {
  #hud { gap: 8px; font-size: var(--f2); }
  .meter .bar { width: 48px; }
  #hud-name { font-size: var(--f1); }
}

/* ---------- vänd på mobilen (stående läge på liten pekskärm) ---------- */
#rotate { position: fixed; inset: 0; z-index: 70; background: rgba(10, 8, 14, .82); display: flex; align-items: center; justify-content: center; padding: 20px; }
.rot-box { background: var(--paper); border: 4px solid var(--ink); box-shadow: 6px 6px 0 var(--ink); padding: 22px 20px; text-align: center; width: min(340px, 100%); }
.rot-box b { font: var(--f3) var(--head); display: block; margin: 12px 0 4px; }
.rot-box p { margin: 0 0 14px; font-size: var(--f2); color: var(--muted); line-height: 1.15; }
.rot-phone { width: 30px; height: 52px; margin: 6px auto 2px; border: 4px solid var(--ink); border-radius: 5px; background: #7ee8fa; position: relative; animation: rot-vand 2.2s ease-in-out infinite; }
.rot-phone::after { content: ""; position: absolute; left: 50%; bottom: 3px; width: 8px; height: 3px; margin-left: -4px; background: var(--ink); }
@keyframes rot-vand { 0%, 25% { transform: rotate(0); } 55%, 100% { transform: rotate(90deg); } }
/* hörnknapparna (möblera, emotes) och chatten: kvar i hörnen, ovanför mobilens hemindikator/notch */
#decor-btn { left: max(14px, env(safe-area-inset-left)); bottom: max(14px, env(safe-area-inset-bottom)); }
#emotes { right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); }
#chat { bottom: max(14px, env(safe-area-inset-bottom)); max-width: min(560px, calc(100vw - 20px)); }

/* ---------- zoomval (fyll skärmen inne i rum/butiker) ---------- */
#app { position: relative; }
#hudpix { z-index: 2; }
/* Telefonen i liggande läge (html.desk-mobil): knapparna ligger i den tunna mätarremsan (en rad,
   hud-pix.js) i stället för på en egen rad ovanför – mer höjd till spelet, figuren syns större */
html.desk-mobil body.hud-pix #hud { position: absolute; top: 0; right: 0; z-index: 7; background: none; border: 0; padding: 2px max(4px, env(safe-area-inset-right)) 2px 4px; } /* (rundade hörn/kameran i appen) */
html.desk-mobil body.hud-pix .hud-btns { gap: 4px; }
html.desk-mobil body.hud-pix .hud-btns .btn { padding: 1px 5px; }

/* ---------- innehallsruta: pixelmönster bakom spelbilden (band ser avsiktliga ut) ---------- */
#app { background: repeating-conic-gradient(#100e15 0% 25%, #151221 0% 50%) 0 0 / 16px 16px; }

/* 👁 Titta in (bostadsbyrån): knappen under planschen och förhandsbilden inifrån */
.homepic-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.homelook { font-size: var(--f1); padding: 2px 6px; }
.look-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.homelook-pic { background: #17151a; border: 3px solid #17151a; line-height: 0; }
.homelook-canvas { width: 100%; height: auto; image-rendering: pixelated; image-rendering: crisp-edges; display: block; }

/* 🎙️ Röstchatten (js/net/voice-ui.js): knappen i verktygsraden och panelen */
#hud-voice.voice-off { opacity: 0.6; }
#hud-voice.voice-on { background: #2f7d45; color: #fff; }
#hud-voice.voice-muted { background: #7d2f2f; color: #fff; }
#hud-voice.voice-talk { box-shadow: 0 0 0 2px var(--gold), 2px 2px 0 var(--ink); }
.vbox { background: #fff; border: 2px solid var(--ink); padding: 6px 8px; margin: 8px 0; }
.vhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: var(--f2); margin-bottom: 2px; }
.vbox .sp { color: var(--muted); font-size: var(--f1); line-height: 1.1; }
.vlist { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.vrow { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-top: 1px dashed #cfc7ba; padding-top: 4px; }
.vrow .nm { font-size: var(--f2); line-height: 1.05; }

/* 📱 Korta liggande skärmar (mobilen): huvudmenyn i två spalter så att "Vem spelar?" syns
   direkt, och tätare dialogrutor (Carl: menyerna var för stora för mobilen) */
@media (max-height: 540px) and (min-width: 560px) {
  #menu { padding: 6px; align-items: stretch; }
  .menu-panel { width: min(900px, 100%); display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); grid-template-areas: "title sub" "btns cards" "set cards" "foot cards"; grid-template-rows: auto auto auto 1fr; column-gap: 18px; align-content: start; padding: 10px 12px; box-shadow: 5px 5px 0 var(--ink); }
  .menu-title { grid-area: title; font-size: var(--f4); text-align: left; }
  .menu-title small { font-size: var(--f1); margin-top: 2px; }
  .menu-btns { grid-area: btns; margin: 8px 0 0; width: 100%; gap: 6px; }
  .menu-main { font-size: var(--f2); padding: 5px 10px; }
  .menu-settings { grid-area: set; margin: 8px 0 0; width: 100%; }
  .menu-row { font-size: var(--f2); }
  .menu-sub { grid-area: sub; margin: 0 0 4px; align-self: end; font-size: var(--f2); }
  .menu-cards { grid-area: cards; overflow: auto; max-height: calc(100dvh - 76px); align-self: start; padding: 0 4px 4px 0; }
  .menu-foot { grid-area: foot; margin-top: 8px; align-self: end; }
  .menu-card { grid-template-columns: 42px 1fr auto; gap: 6px; box-shadow: 2px 2px 0 var(--ink); }
  .menu-card .menu-face, .menu-card canvas { width: 38px !important; height: 46px !important; }
  .menu-card .menu-face { display: block; overflow: hidden; }
  .menu-card-txt b { font-size: var(--f2); }
  .menu-card-txt small { font-size: var(--f1); }
  .menu-card-tools .btn { padding: 1px 5px; font-size: var(--f1); }
  #modal { padding: 6px; }
  .dlg { box-shadow: 5px 5px 0 var(--ink); border-width: 3px; }
  .dlg-head { padding: 4px 10px; border-bottom-width: 3px; }
  .dlg-head h2 { font-size: var(--f2); }
  .dlg-body { padding: 8px 10px; }
  .dlg-foot { padding: 0 10px 8px; gap: 6px; }
  .dlg-foot .btn { font-size: var(--f2); padding: 4px 10px; }
}
/* 🚲 GARAGET: köpdialogen (js/scenes/shop-fordon.js) */
.fd { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.fd-big { width: 288px; height: 168px; image-rendering: pixelated; border: 2px solid var(--ink); background: #f4f1ea; flex: none; }
.fd-side { display: flex; flex-direction: column; gap: 6px; }
.fd-sws { display: flex; flex-wrap: wrap; gap: 6px; }
.fd-sw { width: 28px; height: 28px; border: 2px solid var(--ink); cursor: pointer; padding: 0; box-shadow: 2px 2px 0 #000; }
.fd-sw.on { outline: 3px solid var(--gold); outline-offset: 1px; }
@media (max-width: 560px) { .fd { flex-direction: column; } .fd-big { width: 192px; height: 112px; } }

/* ---------- 🧭 startguiden: första dagens att göra-lista (js/core/startguide.js) ---------- */
/* nere till höger: på datorn utanför spelrutan, på mobilen över golvet (inte över dörrar och skyltar) –
   och ovanför emoji-raden när kompisar är i närheten (--sg-bottom sätts i startguide.js) */
#startguide { position: fixed; right: max(10px, env(safe-area-inset-right)); bottom: max(var(--sg-bottom, 10px), env(safe-area-inset-bottom)); z-index: 30; width: min(250px, 40vw);
  background: var(--paper); border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); font: var(--f1) var(--font); line-height: 1.2; }
#startguide .sg-head { display: flex; background: var(--red); border-bottom: 3px solid var(--ink); }
#startguide .sg-head button { font: var(--f1) var(--font); color: #fff; background: none; border: 0; padding: 4px 6px; cursor: pointer; }
#startguide .sg-fold { flex: 1; text-align: left; }
#startguide .sg-x { border-left: 2px solid var(--ink) !important; color: #ffd8d0 !important; }
#startguide ol { list-style: none; margin: 0; padding: 5px 6px 2px; display: flex; flex-direction: column; gap: 3px; }
#startguide li { display: flex; gap: 5px; align-items: center; color: var(--muted); }
#startguide li i { flex: none; width: 10px; height: 10px; border: 2px solid var(--ink); background: #fff; }
#startguide li.ok { text-decoration: line-through; }
#startguide li.ok i { background: var(--green2); box-shadow: inset 0 0 0 2px #fff; }
#startguide li.nu { color: var(--ink); }
#startguide li.nu i { background: var(--gold); animation: sg-blink 1s steps(2) infinite; }
#startguide .sg-tip { margin: 2px 6px 6px; color: var(--ink); background: #fff4c7; border: 2px solid var(--ink); padding: 3px 5px; }
@keyframes sg-blink { 50% { background: #fff; } }
.btn.sg-pulse { animation: sg-pulse 0.9s steps(2) infinite; }
@keyframes sg-pulse { 50% { outline: 3px solid var(--gold); outline-offset: 2px; } }

/* ---------- 📱 mobilen (js/core/mobilen.js) – Carl 2026-10-10: knapparna samlas i figurens mobil ---------- */
/* raden överst visar bara mätarna; de gamla knapparna finns kvar dolda (mobilens appar trycker på dem) */
#hud .hud-btns { display: none !important; }
:root { --mob-r: max(12px, env(safe-area-inset-right)); --mob-b: max(12px, env(safe-area-inset-bottom)); --mob-k: 54px; }
.pix-ik { image-rendering: pixelated; display: block; }
#hud-mobil { position: fixed; right: var(--mob-r); bottom: var(--mob-b); width: var(--mob-k); height: var(--mob-k); z-index: 42; padding: 0;
  display: grid; place-items: center; background: var(--paper); border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); }
#hud-mobil .pix-ik { width: 32px; height: 32px; }
#hud-mobil.on { background: var(--gold); }
.mob-badge { position: absolute; min-width: 18px; height: 18px; padding: 0 4px; border: 2px solid var(--ink); color: #fff;
  font: var(--f1) var(--font); line-height: 14px; text-align: center; pointer-events: none; }
#hud-mobil .mob-badge.kompis { top: -9px; left: -9px; background: var(--green2); }
#hud-mobil .mob-badge.ny { top: -9px; right: -9px; background: #e04848; }
#hud-snabb { position: fixed; right: var(--mob-r); bottom: calc(var(--mob-b) + var(--mob-k) + 12px); z-index: 41; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
#hud-snabb .btn { font-size: var(--f2); min-width: 46px; min-height: 42px; padding: 2px 8px; box-shadow: 3px 3px 0 var(--ink); }
#mobilen-skugga { position: fixed; inset: 0; z-index: 43; background: rgba(12,10,20,.35); }
#mobilen { position: fixed; z-index: 44; right: calc(var(--mob-r) + var(--mob-k) + 10px); bottom: var(--mob-b); width: 286px; max-height: calc(100vh - 24px);
  background: #2a2632; border: 4px solid #000; box-shadow: 5px 5px 0 #000, inset 3px 3px 0 #4a4452; padding: 8px 8px 6px; display: grid; gap: 5px; }
#mobilen .mob-topp { display: flex; justify-content: space-between; color: #c8c4cf; font: var(--f1) var(--font); padding: 0 2px; }
#mobilen .mob-skarm { background: linear-gradient(#4a8de0, #a8d4ff 70%, #f1ebe0); border: 3px solid #000; overflow: auto; }
#mobilen .mob-status { display: flex; justify-content: space-between; gap: 6px; padding: 2px 6px; background: rgba(23,21,26,.78); color: #fff; font: var(--f1) var(--font); white-space: nowrap; }
#mobilen .mob-appar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px 4px; padding: 8px 4px 10px; }
#mobilen .mob-app { display: grid; justify-items: center; gap: 3px; background: none; border: 0; padding: 0; cursor: pointer; color: var(--ink); font: var(--f1) var(--font); }
#mobilen .mob-ruta { position: relative; width: 46px; height: 46px; display: grid; place-items: center; background: var(--paper); border: 3px solid #000; box-shadow: 2px 2px 0 rgba(0,0,0,.45); }
#mobilen .mob-app:hover .mob-ruta, #mobilen .mob-app:focus-visible .mob-ruta { background: #fff4c7; }
#mobilen .mob-app:active .mob-ruta { transform: translate(2px, 2px); box-shadow: none; }
#mobilen .mob-ruta .pix-ik { width: 32px; height: 32px; }
#mobilen .mob-ruta .mob-badge { top: -8px; right: -10px; background: #e04848; }
#mobilen .mob-ruta .mob-badge[data-badge="kompisar"], #mobilen .mob-ruta .mob-badge[data-badge="rost"] { background: var(--green2); }
#mobilen .mob-namn { background: rgba(241,235,224,.88); padding: 0 3px; white-space: nowrap; }
#mobilen .mob-hem { justify-self: center; width: 44px; height: 7px; background: #4a4452; border: 2px solid #000; }
body.menu-open #hud-mobil, body.menu-open #hud-snabb, body.menu-open #mobilen, body.menu-open #mobilen-skugga { display: none !important; }
/* det som förut stod nere till höger flyttar åt vänster om mobilen */
#emotes { right: calc(var(--mob-r) + var(--mob-k) + 12px) !important; }
#startguide { right: calc(var(--mob-r) + var(--mob-k) + 12px); }
/* telefonen i liggande läge (sidan ritas 1218 px bred, 2 skärmpixlar per CSS-pixel): större mobil, så att
   knappen blir ≥ 44 pt och etiketterna läsbara – 3 kolumner, 18 px-etiketter (skarpa: 3 skärmpixlar/bokstavspixel) */
html.desk-mobil { --mob-k: 76px; }
html.desk-mobil #hud-mobil .pix-ik { width: 48px; height: 48px; }
html.desk-mobil .mob-badge { min-width: 26px; height: 26px; line-height: 22px; font-size: var(--f15); }
html.desk-mobil #hud-snabb .btn { min-width: 66px; min-height: 60px; }
html.desk-mobil #mobilen { width: 560px; padding: 10px 10px 8px; }   /* (fyra kolumner: 13 appar = fyra rader, ryms på iPhone 13 mini liggande) */
html.desk-mobil #mobilen .mob-topp, html.desk-mobil #mobilen .mob-status, html.desk-mobil #mobilen .mob-app { font-size: var(--f15); }
html.desk-mobil #mobilen .mob-appar { grid-template-columns: repeat(4, 1fr); gap: 12px 6px; padding: 10px 6px 12px; }
html.desk-mobil #mobilen .mob-ruta { width: 68px; height: 68px; }
html.desk-mobil #mobilen .mob-ruta .pix-ik { width: 48px; height: 48px; }

/* 🧭 startguiden pekar på en app i mobilen (Jobb/Hem) */
#mobilen .mob-app.sg-pulse .mob-ruta { animation: sg-pulse 0.9s steps(2) infinite; }

#mobilen .mob-app[hidden] { display: none; }   /* (KBK-appen syns bara på svenska eller när man är avstämd) */

/* 💎 BLING BLING (js/scenes/shop-bling.js, från Pixelskolan): korten i montrarna (klick = klädaffärens provdialog),
   ateljén med provfiguren, närbilden och priset, spegeln */
.bl-sp { font-size: var(--f2); margin: 0 0 8px; }
.bl-lbl { font: var(--f2) var(--head); margin: 8px 0 4px; }
.bl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.bl-card { display: flex; flex-direction: column; align-items: center; gap: 4px; background: #fff; border: 3px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); padding: 6px 4px; text-align: center; font: inherit; color: inherit; cursor: pointer; }
.bl-card:hover, .bl-card:focus-visible { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); outline: none; }
.bl-card.on { background: #fde7f1; border-color: #b83a78; }
.bl-card b { font-size: var(--f2); line-height: 1; hyphens: manual; overflow-wrap: anywhere; }
.bl-tag { font-size: var(--f2); line-height: 1; background: #f0d048; border: 2px solid var(--ink); padding: 1px 5px 0; }
.bl-card.own .bl-tag { background: #45b964; color: #fff; }
.bl-card.on .bl-tag { background: #f07ab0; color: #fff; }
.bl-pre canvas { display: block; max-width: 100%; image-rendering: pixelated; background: linear-gradient(#fbe6ef, #f3cfe0); border: 2px solid var(--ink); }
.dlg.bl-wide { width: min(1000px, 100%); container-type: inline-size; }
.bl-design { display: grid; grid-template-columns: auto minmax(0, 288px) minmax(0, 1fr); gap: 12px; align-items: start; }
.bl-try, .bl-show { position: sticky; top: 0; display: flex; flex-direction: column; gap: 6px; }
.bl-stage { display: flex; align-items: flex-end; justify-content: center; gap: 6px; padding: 10px 12px 0; border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); background: linear-gradient(#fbe6ef 0 72%, #e8b84a 72% 73%, #f3cfe0 73% 100%); }
.bl-fig { display: flex; flex-direction: column; align-items: center; }
.bl-fig canvas { display: block; image-rendering: pixelated; }
.bl-fig small { font-size: var(--f1); line-height: 1; background: var(--ink); color: #fff; padding: 2px 6px 1px; margin-bottom: 6px; white-space: nowrap; }
.bl-arrow { font-size: var(--f2); padding-bottom: 40px; }
.bl-turn { display: flex; gap: 6px; align-items: center; justify-content: center; }
.bl-view { font-size: var(--f1); min-width: 74px; text-align: center; }
.bl-canvas canvas { display: block; width: auto; height: auto; max-width: 100%; max-height: 34vh; image-rendering: pixelated; border: 3px solid var(--ink); }
.bl-sum { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; background: #2a1a2e; color: #ffd23f; padding: 4px 8px; border: 3px solid var(--ink); }
.bl-sum b { font: var(--f3) var(--head); line-height: 1; }
.bl-sum .bl-sp { color: #f3cfe0; margin: 0; }
.bl-list { list-style: none; margin: 0; padding: 0; font-size: var(--f1); }
.bl-list li { display: flex; justify-content: space-between; gap: 6px; border-bottom: 1px dashed var(--paper2); padding: 1px 0; }
.bl-pick { min-width: 0; }
.bl-grp:first-child .bl-lbl { margin-top: 0; }
.bl-opts, .bl-mine { display: flex; flex-wrap: wrap; gap: 5px; }
.bl-opts .btn { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; }
.bl-opts .btn small { font-size: var(--f1); opacity: .75; }
.bl-opts .btn i { display: block; width: 14px; height: 8px; border: 2px solid var(--ink); }
.bl-mine { margin-bottom: 4px; }
.bl-mirror { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.bl-mir-r { flex: 1 1 220px; min-width: 0; }
html.desk-mobil .bl-list { display: none; }
html.desk-mobil .bl-opts .btn small, html.desk-mobil .bl-fig small, html.desk-mobil .bl-view { font-size: var(--f15); }
@media (max-height: 520px) { .bl-list { display: none; } .bl-sum b { font-size: var(--f2); } .bl-canvas canvas { max-height: 30vh; } .bl-stage { padding-top: 6px; } .bl-arrow { padding-bottom: 24px; } }
@container (max-width: 760px) { .bl-design { grid-template-columns: auto minmax(0, 1fr); } .bl-show { grid-column: 1; position: static; } .bl-pick { grid-column: 2; grid-row: 1 / span 2; } .bl-canvas canvas { max-height: 24vh; } }
