body {
  margin: 0;
  overflow: hidden;
  background: #ececec;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

canvas {
  display: block;
}

#infoPanel {
  position: fixed;
  top: 0;
  right: 0;
  width: 280px;
  height: 100vh;
  background: #ffffff;
  box-shadow: -2px 0 8px rgba(0,0,0,0.15);
  padding: 12px 14px;
  box-sizing: border-box;
  font-size: 13px;
  line-height: 1.4;
  display: none; /* hidden by default */
  overflow-y: auto;
  z-index: 10;
}

#infoPanel h2 {
  margin: 0 0 8px;
  font-size: 16px;
  border-bottom: 1px solid #ddd;
  padding-bottom: 4px;
}

#infoPanel h3 {
  margin: 10px 0 4px;
  font-size: 14px;
}

#infoPanel p {
  margin: 2px 0;
}

#infoPanel code {
  background: #f3f3f8;
  padding: 0 3px;
  border-radius: 3px;
}

/* === WINDOW SYSTEM (Amiga-like) === */

.amiga-window {
  position: absolute;
  border: 2px solid #222;
  background-color: #c5b28c;
  box-shadow: 2px 2px 0 #000;
  min-width: 100px;
  min-height: 100px;
  top: 40px;
  left: 100px;
  z-index: 100; /* ensure on top of canvas */
}

.title-bar {
  background: linear-gradient(to bottom, #5d85b4, #3f5f8f);
  color: white;
  padding: 2px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: bold;
  font-size: 14px;
  cursor: move;
  user-select: none;
}

.title-left {
  display: flex;
  align-items: center;
}

.title-left img {
  width: 16px;
  height: 16px;
  margin-right: 6px;
}

.buttons {
  display: flex;
  gap: 2px;
}

.buttons button {
  width: 16px;
  height: 16px;
  background-color: #d0d0d0;
  border: 1px solid #444;
  font-size: 10px;
  color: black;
  padding: 0;
  cursor: pointer;
}

.window-content {
  padding: 10px;
}

/* Resize handles */

.resize-handle {
  position: absolute;
  z-index: 2;
}

.resize-top    { top: -2px;    left: 0; right: 0; height: 5px; cursor: ns-resize; }
.resize-bottom { bottom: -2px; left: 0; right: 0; height: 5px; cursor: ns-resize; }
.resize-left   { top: 0; bottom: 0; left: -2px; width: 5px; cursor: ew-resize; }
.resize-right  { top: 0; bottom: 0; right: -2px; width: 5px; cursor: ew-resize; }
.resize-tl     { top: -2px; left: -2px; width: 10px; height: 10px; cursor: nwse-resize; }
.resize-tr     { top: -2px; right: -2px; width: 10px; height: 10px; cursor: nesw-resize; }
.resize-bl     { bottom: -2px; left: -2px; width: 10px; height: 10px; cursor: nesw-resize; }
.resize-br     { bottom: -2px; right: -2px; width: 10px; height: 10px; cursor: nwse-resize; }

/* Minimized window icons container */

.window-icons {
  position: fixed;
  bottom: 8px;
  left: 8px;
  display: flex;
  gap: 6px;
  align-items: center;
  z-index: 1000;
}

.window-icon {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* -----------------------------------------------------------------------------
   Life Aside UI (scoped) — Actionbar version
   - All selectors prefixed with "la_"
   - Safe to append to an existing global CSS (no body/html styling)
   - Recommended wrapper: <div id="la_ui_root"> ... </div>
----------------------------------------------------------------------------- */

#la_ui_root{
  /* Theme tokens (scoped, not :root) */
  --la_stroke:#ffffff1a;
  --la_stroke2:#ffffff12;
  --la_text:#e5e7eb;
  --la_muted:#94a3b8;
  --la_shadow: 0 20px 60px rgba(0,0,0,.55);
  --la_radius:16px;
  --la_icon:56px;
  --la_barw:92px;
  --la_gap:12px;

  position:fixed;
  inset:0;
  width:100%;
  height:100%;
  pointer-events:none;

  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial;
  color:var(--la_text);
}

/* Contained box-sizing reset */
#la_ui_root, #la_ui_root *{ box-sizing:border-box; }

/* ---------- LAYOUT ROOT ---------- */
.la_stage{ position:relative; width:100%; height:100%; }

.la_ui{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:flex-start;
  padding-left:22px;
  pointer-events:none;
}

.la_actionbar_wrap{
  position:relative;
  display:flex;
  gap:14px;
  pointer-events:none;
}

/* ---------- ACTIONBAR ---------- */
.la_actionbar{
  width:var(--la_barw);
  max-height:calc(100vh - 40px);
  background:linear-gradient(180deg,#0e1626cc,#0b1220cc);
  border:1px solid var(--la_stroke);
  border-radius:var(--la_radius);
  box-shadow:var(--la_shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding:14px 12px;
  display:flex;
  flex-direction:column;
  gap:var(--la_gap);
  pointer-events:auto;
}

.la_actionbar.la_full{
  height:calc(100vh - 40px);
  max-height:calc(100vh - 40px);
}

.la_actionbar_scroll{
  display:flex;
  flex-direction:column;
  gap:var(--la_gap);
  overflow:visible;
  padding-right:2px;
}

/* Button slot: ensures perfect horizontal centering */
.la_actionbar_scroll > .la_section .la_btn{
  margin-left:auto;
  margin-right:auto;
}

.la_actionbar.la_full .la_actionbar_scroll{
  overflow:auto;
}

/* ---------- AVATAR ---------- */
.la_avatar{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:6px;
  padding-bottom:8px;
  border-bottom:1px solid var(--la_stroke2);
}

.la_avatar_pic{
  width:58px;
  height:58px;
  border-radius:50%;
  background:radial-gradient(circle at 30% 30%,#9bdcff,#1e3a8a 60%, #0b1220 100%);
  box-shadow:0 0 0 3px #ffffff10, 0 0 22px #5ad7ff44;
  border:1px solid #ffffff18;
}

.la_status{
  display:flex;
  align-items:center;
  gap:6px;
  font-size:12px;
  color:var(--la_muted);
  user-select:none;
}

.la_dot{
  width:8px;
  height:8px;
  border-radius:50%;
  background:#37d67a;
  box-shadow:0 0 0 3px #37d67a33;
}

.la_money{
  font-size:12px;
  color:#cbd5e1;
  user-select:none;
}

/* ---------- SEARCH ---------- */
.la_search{
  position:relative;
  padding-bottom:10px;
  margin-bottom:6px;
  border-bottom:1px solid var(--la_stroke2);
}

/* Default: icon centered, no placeholder text visible */
.la_search input{
  width:100%;
  height:38px;
  border-radius:12px;
  border:1px solid var(--la_stroke2);
  background:#0a1020aa;
  color:var(--la_text);

  /* idle: icon centered, so no left padding */
  padding:0 12px;

  outline:none;
  transition:
    width .18s ease,
    transform .18s ease,
    box-shadow .18s ease,
    border-color .18s ease,
    padding .18s ease;
}

/* Placeholder hidden by default */
.la_search input::placeholder{
  color:#94a3b866;
  opacity:0;
  transition: opacity .12s ease;
}

/* Icon centered horizontally by default */
.la_search .la_icon{
  position:absolute;
  left:50%;
  top:0;
  bottom:0;
  margin:auto 0;

  width:22px;
  height:22px;
  display:flex;
  align-items:center;
  justify-content:center;

  font-size:18px;
  line-height:1;
  opacity:.85;
  font-family:"Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji",system-ui,sans-serif;

  user-select:none;
  pointer-events:none;

  /* keep the SAME vertical correction in all states */
  transform: translateX(-50%) translateY(-5px);

  transition:
    left .18s ease,
    transform .18s ease,
    opacity .18s ease;
}

/* Active state: hover OR focus-within
   - icon moves left (same Y correction)
   - input gets left padding (no overlap)
   - placeholder becomes visible
*/
.la_search:hover input,
.la_search:focus-within input{
  padding:0 12px 0 34px;
}

.la_search:hover input::placeholder,
.la_search:focus-within input::placeholder{
  opacity:1;
}

.la_search:hover .la_icon,
.la_search:focus-within .la_icon{
  left:12px;
  transform: translateX(0) translateY(-5px);
  opacity:.8;
}

/* Expand search on hover/focus */
#la_ui_root .la_search:hover input,
#la_ui_root .la_search:focus-within input{
  width:320px;
  transform:translateX(6px);
  border-color:#5ad7ff66;
  box-shadow:
    0 0 0 4px #5ad7ff22,
    0 0 22px #5ad7ff1f;
}

/* Keep legacy focus expansion for now (cleanup later) */
.la_actionbar_wrap.la_focus_search .la_search input{
  width:320px;
  transform:translateX(6px);
  border-color:#5ad7ff66;
  box-shadow:0 0 0 4px #5ad7ff22, 0 0 22px #5ad7ff1f;
}

/* ---------- SECTIONS & SEPARATORS ---------- */
.la_section{
  padding-top:6px;
  border-top:0; /* avoid double separators: keep .la_actionbar_sep only */
}

.la_section_title{
  font-size:10px;
  text-transform:uppercase;
  letter-spacing:.18em;
  color:#94a3b866;
  text-align:center;
  margin:2px 0 10px;
  user-select:none;
}

#la_ui_root .la_actionbar_sep{
  height:1px;
  width:100%;
  background:var(--la_stroke2);
  margin:8px 0;
  border-radius:1px;
  opacity:1;
}

/* ---------- ICON BUTTON ---------- */
.la_btn{
  width:var(--la_icon);
  height:var(--la_icon);
  border-radius:16px;
  border:1px solid var(--la_stroke2);
  background:#0b1220aa;
  display:grid;
  place-items:center;
  cursor:pointer;
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
  position:relative;
  user-select:none;
}

.la_btn:hover{
  transform:translateY(-1px);
  border-color:#ffffff33;
  box-shadow:0 0 0 4px #ffffff08;
}

.la_btn.la_active{
  border-color:#5ad7ff66;
  box-shadow:0 0 0 4px #5ad7ff22, 0 0 22px #5ad7ff1f;
}

.la_glyph{ font-size:20px; }

.la_tip{
  position:absolute;
  left:calc(100% + 10px);
  top:50%;
  transform:translateY(-50%);
  background:#0e1626ee;
  border:1px solid var(--la_stroke);
  padding:6px 10px;
  border-radius:10px;
  font-size:12px;
  white-space:nowrap;
  opacity:0;
  transition:opacity .1s ease;
  pointer-events:none;
  box-shadow: 0 18px 60px rgba(0,0,0,.4);
}

.la_btn:hover .la_tip{ opacity:1; }

/* ---------- PANEL ---------- */
.la_panel{
  width:320px;
  max-height:calc(100vh - 40px);
  background:#0e1626cc;
  border:1px solid var(--la_stroke);
  border-radius:var(--la_radius);
  box-shadow:var(--la_shadow);
  backdrop-filter:blur(10px);
  -webkit-backdrop-filter: blur(10px);
  overflow:hidden;
  display:none;
  flex-direction:column;
  pointer-events:auto;
}

.la_panel.la_open{ display:flex; }

.la_panel_header{
  padding:12px;
  border-bottom:1px solid var(--la_stroke2);
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
}

.la_panel_header strong{
  font-size:13px;
  letter-spacing:.02em;
}

.la_xbtn{
  width:32px;
  height:32px;
  border-radius:10px;
  border:1px solid var(--la_stroke2);
  background:#0a1020aa;
  color:#cbd5e1;
  cursor:pointer;
}

.la_xbtn:hover{ border-color:#ffffff33; }

.la_panel_body{
  padding:12px;
  overflow:auto;
  font-size:13px;
  color:var(--la_muted);
  display:flex;
  flex-direction:column;
  gap:10px;
}

.la_item{
  border:1px solid var(--la_stroke2);
  border-radius:14px;
  padding:10px;
  background:#0a102055;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

.la_item b{ color:var(--la_text); font-weight:600; }

.la_pill{
  font-size:11px;
  color:#cbd5e1;
  border:1px solid #ffffff22;
  border-radius:999px;
  padding:4px 8px;
  background:#0b1220aa;
}

/* ---------- HUD WINDOW ---------- */
.la_hud_window{
  position:absolute;
  top:110px;
  left:380px;
  width:360px;
  height:240px;
  background:#0e1626cc;
  border:1px solid var(--la_stroke);
  border-radius:var(--la_radius);
  box-shadow:var(--la_shadow);
  display:none;
  overflow:hidden;
  pointer-events:auto;
  backdrop-filter:blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.la_hud_window.la_open{ display:block; }

.la_win_bar{
  height:44px;
  padding:0 12px;
  border-bottom:1px solid var(--la_stroke2);
  display:flex;
  align-items:center;
  justify-content:space-between;
  cursor:grab;
  user-select:none;
}

.la_win_bar:active{ cursor:grabbing; }

.la_win_title{
  font-size:13px;
  color:var(--la_text);
  display:flex;
  align-items:center;
  gap:10px;
  letter-spacing:.02em;
}

.la_win_body{
  padding:12px;
  font-size:13px;
  color:var(--la_muted);
  height:calc(100% - 44px);
  overflow:auto;
  display:flex;
  flex-direction:column;
  gap:10px;
}

/* ---------- Helper hint ---------- */
.la_hint{
  position:absolute;
  left:18px;
  bottom:18px;
  color:#9aa7bbcc;
  font-size:12px;
  line-height:1.35;
  pointer-events:none;
  max-width:560px;
}

/* ---------- PATCHES (kept, but grouped) ---------- */
#la_ui_root > .la_stage{
  position:relative;
  width:100%;
  height:100%;
}

#la_ui_root > .la_stage > .la_ui{
  position:absolute;
  inset:0;
}

/* Compact HUD window title bar */
#la_ui_root .la_win_bar{
  height:28px;
  padding:0 8px;
  border-bottom:1px solid var(--la_stroke2);
  align-items:center;
}

#la_ui_root .la_win_title{
  font-size:12px;
  line-height:1;
  padding:0;
  margin:0;
}

#la_ui_root .la_win_body{
  height:calc(100% - 28px);
  padding:10px 12px;
}

/* Compact panel title bar */
#la_ui_root .la_panel_header{
  padding:6px 8px;
  gap:8px;
  min-height:0;
  background: linear-gradient(180deg, #1a2234cc, #141c2bcc);
}

#la_ui_root .la_panel_header strong{
  font-size:12px;
  line-height:1;
  margin:0;
  padding:0;
}

#la_ui_root .la_xbtn{
  width:24px;
  height:24px;
  border-radius:8px;
  padding:0;
  line-height:1;
}
