:root {
    --panel: rgba(20, 26, 34, 0.82);
    --panel2: rgba(30, 38, 50, 0.92);
    --accent: #38d15a;
    --accent2: #ffcf3f;
    --danger: #ff5d5d;
    --text: #eef3f8;
    --muted: #9fb0c0;
    --line: rgba(255,255,255,0.08);
  }
  * { box-sizing: border-box; }
  html, body { margin: 0; height: 100%; overflow: hidden; background: #9fd0ea;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text); -webkit-user-select: none; user-select: none; }
  #app { position: fixed; inset: 0; }
  canvas { display: block; }

  #hud { position: fixed; top: 12px; left: 12px; z-index: 10; display: flex; gap: 8px; flex-wrap: wrap; align-items: stretch; }
  .chip { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; backdrop-filter: blur(8px); min-width: 78px; box-shadow: 0 6px 18px rgba(0,0,0,0.25); }
  .chip .k { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
  .chip .v { font-size: 18px; font-weight: 700; margin-top: 2px; }
  .chip.money .v { color: var(--accent2); }

  #title { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 9;
    font-weight: 800; letter-spacing: .02em; text-shadow: 0 2px 8px rgba(0,0,0,.35);
    background: var(--panel); padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line); font-size: 15px; }
  #title small { color: var(--muted); font-weight: 600; }

  #right { position: fixed; top: 12px; right: 12px; z-index: 10; width: 260px;
    background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
    padding: 14px; backdrop-filter: blur(8px); box-shadow: 0 10px 30px rgba(0,0,0,0.3); }
  #right h3 { margin: 0 0 8px; font-size: 13px; letter-spacing: .04em; color: var(--muted); text-transform: uppercase; }
  .valrow { display: flex; justify-content: space-between; align-items: baseline; margin: 4px 0; font-size: 14px; }
  .valrow .big { font-size: 22px; font-weight: 800; }
  #stars { color: var(--accent2); letter-spacing: 2px; font-size: 18px; }
  .design { font-weight: 700; color: var(--accent); }
  .pos { color: var(--accent); font-weight: 700; }
  .neg { color: var(--danger); font-weight: 700; }
  hr { border: none; border-top: 1px solid var(--line); margin: 10px 0; }
  #reqs { list-style: none; margin: 6px 0 10px; padding: 0; font-size: 12px; }
  #reqs li { padding: 3px 0; color: var(--muted); }
  #reqs li.met { color: var(--accent); }
  #reqs li.unmet { color: var(--muted); }
  #sellBtn { width: 100%; padding: 12px; border: none; border-radius: 12px; cursor: pointer;
    font-size: 15px; font-weight: 800; color: #06210f; background: var(--accent);
    box-shadow: 0 6px 16px rgba(56,209,90,.35); transition: transform .05s, filter .1s; }
  #sellBtn:hover { filter: brightness(1.06); }
  #sellBtn:active { transform: translateY(1px); }
  #sellBtn:disabled { background: #33404d; color: #78889a; box-shadow: none; cursor: not-allowed; }

  #challenge { margin-top: 12px; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 12px; }
  #challenge .ch-t { color: var(--accent2); font-weight: 700; margin-bottom: 4px; }
  #challenge .ch-desc { margin-bottom: 2px; }
  #challenge .ch-meta { display: flex; justify-content: space-between; margin-top: 5px; color: var(--muted); font-size: 11px; }
  #challenge .ch-next { margin-top: 6px; color: var(--accent); font-size: 11px; }
  #challenge .wh { margin-top: 6px; color: var(--muted); font-size: 10.5px; line-height: 1.5; }
  .bar { height: 8px; background: rgba(255,255,255,.1); border-radius: 999px; overflow: hidden; margin-top: 6px; }
  .bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent2), #ff9f3f); width: 0%; transition: width .3s; }

  #bottom { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 10;
    background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
    padding: 10px 12px; backdrop-filter: blur(8px); box-shadow: 0 -6px 24px rgba(0,0,0,0.25); max-height: 44vh; overflow-y: auto; }
  #hint { font-size: 12.5px; color: var(--muted); min-height: 16px; margin-bottom: 6px; }
  #catalog { display: flex; flex-direction: column; gap: 4px; }
  .cat-title { font-size: 11px; letter-spacing: .05em; color: var(--muted); text-transform: uppercase; margin: 4px 2px 0; }
  .cat-row { display: flex; gap: 6px; flex-wrap: wrap; }
  .item { display: flex; flex-direction: column; align-items: center; justify-content: center;
    width: 78px; padding: 7px 4px; gap: 1px; cursor: pointer;
    background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; color: var(--text);
    transition: transform .05s, border-color .1s, background .1s; }
  .item:hover { border-color: rgba(255,255,255,.28); }
  .item.active { border-color: var(--accent); background: rgba(56,209,90,.16); }
  .item .emoji { font-size: 22px; line-height: 1; }
  .item .lbl { font-size: 10.5px; text-align: center; }
  .item .price { font-size: 10px; color: var(--accent2); font-weight: 700; }
  .item.locked { opacity: .5; cursor: not-allowed; filter: grayscale(.6); }
  .item.locked:hover { border-color: var(--line); }
  .item .lock { font-size: 9.5px; color: #8fa0b2; font-weight: 700; }

  #actions { position: fixed; left: 12px; bottom: calc(44vh + 20px); z-index: 11; display: flex; gap: 6px; flex-wrap: wrap; }
  .abtn { background: var(--panel2); border: 1px solid var(--line); color: var(--text);
    padding: 8px 12px; border-radius: 10px; cursor: pointer; font-size: 12.5px; font-weight: 600; backdrop-filter: blur(8px); }
  .abtn:hover { border-color: rgba(255,255,255,.28); }
  .abtn.active { border-color: var(--accent2); background: rgba(255,207,63,.18); color: var(--accent2); }
  #bulldozeBtn.active { border-color: var(--danger); background: rgba(255,93,93,.18); color: var(--danger); }
  .floorseg { display: inline-flex; gap: 6px; align-items: center; padding-right: 6px; margin-right: 2px; border-right: 1px solid var(--line); }
  .floorlabel { min-width: 62px; text-align: center; font-weight: 800; color: var(--accent); background: rgba(56,209,90,.14);
    border: 1px solid var(--line); border-radius: 10px; padding: 8px 6px; font-size: 12.5px; }
  .abtn:disabled { opacity: .38; cursor: not-allowed; }

  body.walking #bottom, body.walking #actions, body.walking #right { opacity: .25; pointer-events: none; }

  #toast { position: fixed; bottom: calc(44vh + 64px); left: 50%; transform: translateX(-50%) translateY(20px);
    background: rgba(0,0,0,.82); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px;
    opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 30; }
  #toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

  #useprompt { position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%); z-index: 36;
    background: rgba(10,14,20,.82); color: #fff; padding: 10px 18px; border-radius: 12px;
    font-size: 15px; font-weight: 600; border: 1px solid var(--line); display: none; box-shadow: 0 6px 20px rgba(0,0,0,.35); }
  #useprompt.show { display: block; }
  #useprompt kbd { background: #10161e; border: 1px solid var(--line); border-radius: 6px; padding: 1px 8px; margin: 0 3px; font-weight: 700; }

  #talkPanel { position: fixed; bottom: 92px; left: 50%; transform: translateX(-50%); z-index: 37; width: 470px; max-width: 94vw;
    background: rgba(16,20,28,.93); border: 1px solid var(--line); border-radius: 16px; padding: 12px 16px; display: none; box-shadow: 0 10px 30px rgba(0,0,0,.45); }
  #talkPanel.show { display: block; }
  #talkPanel .tp-head { display: flex; align-items: center; gap: 10px; }
  #talkPanel .tp-face { font-size: 30px; }
  #talkPanel .tp-name { font-weight: 800; font-size: 15px; }
  #talkPanel .tp-sub { font-size: 12px; color: var(--muted); }
  #talkPanel .tp-line { margin: 8px 0 10px; font-size: 14px; color: #eaf1f8; font-style: italic; }
  #talkPanel .tp-btns { display: flex; flex-wrap: wrap; gap: 6px; }
  #talkPanel .tp-btns button { flex: 1 1 auto; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer;
    background: var(--panel2); color: var(--text); font-weight: 700; font-size: 12.5px; }
  #talkPanel .tp-btns button:hover { border-color: var(--accent); }
  #talkPanel .tp-btns #sayHiBtn { background: var(--accent); color: #06210f; border: none; }

  #bigmsg { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 40; pointer-events: none; opacity: 0; transition: opacity .3s; }
  #bigmsg.show { opacity: 1; }
  #bigmsg .card { background: var(--panel2); border: 1px solid var(--line); border-radius: 20px; padding: 26px 40px;
    text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.5); transform: scale(.9); transition: transform .3s; max-width: 90vw; }
  #bigmsg.show .card { transform: scale(1); }
  #bigmsg .bt { font-size: 30px; font-weight: 900; }
  #bigmsg .bs { font-size: 15px; color: var(--muted); margin-top: 8px; }

  /* ---------- Modals (help / designs / buyers) ---------- */
  .modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 50; display: none; align-items: center; justify-content: center; }
  .modal.show { display: flex; }
  .modal .card { background: var(--panel2); border: 1px solid var(--line); border-radius: 18px; padding: 24px 28px;
    max-width: 480px; width: 90%; box-shadow: 0 20px 60px rgba(0,0,0,.5); max-height: 86vh; overflow-y: auto; }
  .modal h2 { margin: 0 0 8px; }
  .modal .sub { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
  #helpModal ul { margin: 0; padding-left: 18px; line-height: 1.7; font-size: 14px; color: #dbe6f0; }
  #helpModal kbd, .modal kbd { background: #10161e; border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; font-size: 12px; }
  .modal .closebtn { margin-top: 14px; padding: 9px 16px; border: none; border-radius: 10px; cursor: pointer; background: var(--accent); color: #06210f; font-weight: 700; }
  #helpBtn { position: fixed; right: 12px; bottom: 16px; z-index: 11; }

  .design-card, .buyer-card { display: flex; gap: 12px; align-items: center; background: var(--panel); border: 1px solid var(--line);
    border-radius: 14px; padding: 12px; margin-bottom: 10px; }
  .dc-emoji, .by-emoji { font-size: 34px; }
  .dc-body, .by-body { flex: 1; }
  .dc-name, .by-name { font-weight: 800; font-size: 15px; }
  .dc-lock { font-size: 11px; color: #8fa0b2; font-weight: 700; }
  .dc-desc, .by-cmt { font-size: 12px; color: var(--muted); margin: 2px 0 4px; }
  .dc-nums, .by-num { font-size: 12px; color: var(--text); }
  .dc-btn, .by-btn { padding: 9px 14px; border: none; border-radius: 10px; cursor: pointer; font-weight: 800;
    background: var(--accent); color: #06210f; white-space: nowrap; }
  .dc-btn:disabled { background: #33404d; color: #78889a; cursor: not-allowed; }
  .by-best { font-size: 10px; background: var(--accent2); color: #3a2a00; border-radius: 6px; padding: 1px 6px; margin-left: 6px; font-weight: 800; vertical-align: middle; }
  .by-loyal { font-size: 10px; background: #7c5cff; color: #fff; border-radius: 6px; padding: 1px 6px; margin-left: 6px; font-weight: 800; vertical-align: middle; }
  .by-note { font-size: 11px; color: #b79bff; font-weight: 700; margin: 0 0 4px; }
  #buyersValue { font-size: 12px; color: var(--muted); margin: 0 0 12px; }

  @media (max-width: 640px) { #right { width: 200px; } #title { display: none; } .item { width: 66px; } }
