:root{
  --bg:#2b2f33;
  --panel:#101214cc;
  --text:#e6eef6;
}
html,body{height:100%;margin:0;font-family:Inter,Segoe UI,Arial,sans-serif;background:var(--bg);color:var(--text)}
#hud{position:absolute;left:8px;top:8px;z-index:10}
#topbar{background:var(--panel);padding:8px 12px;border-radius:6px;margin-bottom:6px}
#info{background:var(--panel);padding:6px 10px;border-radius:6px}
#testCanvas{display:block;width:100vw;height:100vh}

#editorCanvas{display:block;width:100vw;height:100vh}
.hidden{display:none}

/* Editor sidebar */
#editorSidebar{position:fixed;left:0;top:0;bottom:0;width:200px;background:var(--panel);padding:10px;border-radius:0;z-index:40;color:var(--text);overflow:auto;box-sizing:border-box}

/* Editor canvas should occupy area to the right of the fixed sidebar */
#editorCanvas{position:fixed;left:200px;top:0;right:0;bottom:0;z-index:5;width:auto;height:auto}
#editorSidebar .side-header{font-weight:600;margin-bottom:8px}
#editorSidebar .category{font-weight:700;margin-top:10px;margin-bottom:6px;color:#cfe3ff}
#editorSidebar .tool{background:#2e3440;padding:8px;border-radius:6px;margin-bottom:8px;cursor:pointer;text-align:center}
#editorSidebar .tool:hover{background:#3b4252}
#editorSidebar .tool.active{outline:2px solid #8ab4ff}

#menu{position:absolute;left:50%;top:24%;transform:translateX(-50%);background:var(--panel);padding:18px;border-radius:8px;z-index:20;text-align:center}
#menu h2{margin:0 0 8px 0}
#menu button{margin:6px;padding:8px 12px;border-radius:6px;border:0;background:#2b7cff;color:white;cursor:pointer}

/* Modal HUD styles */
#modalHUD{pointer-events:none;font-family:Inter,Segoe UI,Arial,sans-serif}
.modalHUD{pointer-events:none;font-family:Inter,Segoe UI,Arial,sans-serif}
.hud-topright{position:absolute;top:12px;right:12px;display:flex;gap:10px;pointer-events:auto}
.hud-res-item{background:rgba(0,0,0,0.6);padding:6px 8px;border-radius:6px;color:#fff;display:flex;align-items:center;gap:8px;border:1px solid rgba(255,255,255,0.06)}
.hud-icon{width:18px;height:18px;display:inline-block}
.hud-topleft{position:absolute;top:12px;left:12px;display:flex;gap:10px;pointer-events:auto}
.hud-bottom{position:absolute;left:12px;right:12px;bottom:12px;height:80px;pointer-events:auto;display:flex;align-items:flex-end;gap:10px;background:rgba(40,40,40,0.65);border-radius:8px;padding:6px}
.hud-bottom-left{display:flex;flex-direction:column;gap:6px;align-items:flex-start;width:auto;min-width:100px;max-width:40%}
.hud-portrait{height:48px;width:auto;min-width:48px;background:rgba(0,0,0,0.5);border-radius:6px;border:1px solid rgba(255,255,255,0.04);display:flex;align-items:center;gap:6px;padding:4px;box-sizing:border-box}
/* portrait image inside top-left HUD */
.hud-portrait-img{width:100%;height:100%;object-fit:contain;display:block;border-radius:6px}
.hud-portrait-fallback{width:100%;height:100%;border-radius:6px}
/* stats next to portrait */
.hud-portrait-stats{color:#fff;display:flex;flex-direction:column;justify-content:center;font-size:11px;line-height:1.2}
.hud-portrait-stats .hps-line{opacity:0.95}
.hud-portrait-inner{width:48px;height:48px;flex:0 0 48px}

/* zombie stats box next to portrait */
.hud-zombie{min-width:140px;background:rgba(0,0,0,0.55);padding:6px;border-radius:6px;color:#fff;display:flex;flex-direction:column;justify-content:center;gap:6px;border:1px solid rgba(255,255,255,0.04);box-sizing:border-box}
.hud-zombie .zline{font-size:12px}
.hud-zombie .zsmall{font-size:11px;opacity:0.9}
.hud-zombie .zbar{width:120px;height:8px;background:rgba(255,255,255,0.06);border-radius:6px;overflow:hidden}
.hud-zombie .zbar .fill{height:100%;background:#8b5a2b}

/* header + icon */
.hud-zombie .zheader{display:flex;align-items:center;gap:8px}
.hud-zombie .zicon{display:none}
.hud-zombie .zicon-img{width:18px;height:18px;object-fit:contain;flex:0 0 18px}
.hud-zombie .ztitle{font-weight:700;font-size:12px}
.hud-zombie .zline{font-size:12px}
.hud-zombie .zline-inline{display:flex;gap:10px;align-items:center;margin-top:4px}
.hud-zombie .zstat{font-size:12px}
.hud-minimap{height:90px;width:130px;max-width:100%;background:rgba(0,0,0,0.5);border-radius:6px;border:1px solid rgba(255,255,255,0.04);box-sizing:border-box}
/* make minimap canvas fill the minimap area */
.hud-minimap canvas{width:100%;height:100%;display:block;border-radius:6px}
.hud-bottom-center{flex:1;display:flex;align-items:flex-end;justify-content:center}
  .hud-selected{background:transparent;padding:0;border:none;width:100%;height:100%;box-sizing:border-box;display:flex;align-items:center;justify-content:flex-start;gap:8px;margin:0}
#hud-selected{background:rgba(0,0,0,0.6);padding:6px;border-radius:6px;color:#fff;border:1px solid rgba(255,255,255,0.06);width:100%;height:64px;box-sizing:border-box;display:flex;align-items:center;justify-content:flex-start;gap:8px;margin:0}
  .hud-selected-list{display:flex;flex-direction:row;flex-wrap:nowrap;gap:6px;align-items:center;overflow:hidden;flex:0 0 auto;justify-content:flex-start;max-height:56px;min-width:0}
.hud-selected-large{width:40px;height:40px;display:flex;align-items:center;justify-content:center;border-radius:6px;background:rgba(0,0,0,0.08);overflow:hidden;flex:0 0 40px}
.hud-selected-large img{width:40px;height:40px;object-fit:contain;display:block}
.hud-selected-name{
  margin-left:10px;
  color:#fff;
  font-size:14px;
  line-height:40px;
  flex:1 1 auto;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.hud-selected-large-fallback{width:36px;height:36px;border-radius:6px}
.hud-unit{width:auto;display:flex;flex-direction:column;align-items:center}
.hud-unit-icon{width:24px;height:24px;border-radius:6px;display:block;margin:0 0 4px;object-fit:cover;background:rgba(255,255,255,0.02)}
/* larger icon for hero units in selected HUD */
.hud-unit-icon.hero{width:30px;height:30px}
.hud-unit-hp{width:64%;height:6px;background:rgba(0,0,0,0.4);border-radius:4px;overflow:hidden}
.hud-unit-hp-fill{height:100%;background:#2ecc71}
.hud-bottom-right{width:260px}
.hud-actions{height:72px;background:rgba(0,0,0,0.5);border-radius:6px;border:1px solid rgba(255,255,255,0.04);display:grid;grid-template-columns:repeat(4,1fr);gap:8px;padding:6px;box-sizing:border-box}
.hud-actions{transition:opacity 160ms ease, transform 160ms ease}

/* small FPS indicator */
.hud-fps{background:rgba(0,0,0,0.55);padding:6px 8px;border-radius:6px;color:#dfe9f8;font-weight:600;font-size:12px;margin-left:8px;border:1px solid rgba(255,255,255,0.04)}
.hud-action-slot{background:rgba(255,255,255,0.03);border:1px solid rgba(255,255,255,0.04);border-radius:6px;display:flex;align-items:center;justify-content:center;min-height:48px;cursor:default;pointer-events:none;opacity:0;transform:translateY(6px)}
.hud-action-slot:hover{background:rgba(255,255,255,0.05)}
.hud-action-slot .action-icon{width:32px;height:32px;object-fit:contain}
.hud-action-slot.active{outline:2px solid rgba(100,180,255,0.9);box-shadow:0 2px 10px rgba(100,180,255,0.08)}

/* By default the actions panel does not accept pointer events so it won't block the canvas. */
.hud-actions{pointer-events:none}
.hud-actions.active{pointer-events:auto}
.hud-actions.active .hud-action-slot{pointer-events:auto;opacity:1;transform:translateY(0)}

.hud-action-slot{transition:opacity 160ms ease, transform 160ms ease}

/* Building action buttons (shown when opening building UI) */
.hud-actions{position:relative}

/* building actions overlayed inside the action panel */
.hud-building-actions{position:absolute;left:8px;right:8px;top:8px;bottom:8px;display:flex;gap:8px;align-items:center;justify-content:center;pointer-events:none;z-index:1001}
.hud-building-actions:not(.hidden){pointer-events:auto}
.building-action-slot{width:64px;height:64px;background:rgba(255,255,255,0.03);border:1px solid rgba(255,255,255,0.04);border-radius:6px;display:flex;flex-direction:column;align-items:center;justify-content:center;cursor:default;padding:4px;box-sizing:border-box}
.building-action-slot:hover{background:rgba(255,255,255,0.05)}
.building-action-slot img{max-width:34px;max-height:34px;object-fit:contain}
.building-action-price{display:flex;flex-direction:column;gap:2px;align-items:center;margin-top:4px}
.building-action-price .res{display:flex;align-items:center;gap:6px}
.building-action-price .res-icon{width:12px;height:12px;display:inline-block}
.building-action-price .res-qty{font-size:11px;color:#dfe9f8;line-height:1}
.hidden{display:none}


/* ensure HUD inner elements accept pointer events when needed */
#modalHUD .hud-res-item, #modalHUD .hud-portrait, #modalHUD .hud-minimap, #modalHUD .hud-selected { pointer-events: auto }
.modalHUD .hud-res-item, .modalHUD .hud-portrait, .modalHUD .hud-minimap, .modalHUD .hud-selected { pointer-events: auto }

/* Make canvases touch-friendly and prevent default browser gestures */
canvas{ touch-action: none; -webkit-user-select: none; user-select: none; }

/* Top overlay that sits above canvases from top to middle */
#topOverlayContainer{
  position:fixed;
  left:0;
  right:0;
  top:0;
  height:35vh; /* top to 35% */
  pointer-events:none; /* allow clicks to pass through by default */
  z-index:12000; /* above canvases and HUDs */
}

/* layout for three flex boxes inside the top overlay */
#topOverlayContainer{
  display:flex;
  gap:12px;
  padding:10px;
  justify-content:center;
  align-items:center;
}

#topOverlayContainer .overlay-box{
  flex:1 1 0;
  max-width:33.333%;
  min-width:110px;
  background:rgba(255,255,255,0.02);
  border:1px solid rgba(255,255,255,0.04);
  border-radius:8px;
  min-height:60px;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:8px;
  box-sizing:border-box;
  color:var(--text);
}

/* Ensure container children are fully hidden when container is hidden */
#topOverlayContainer.hidden,
#topOverlayContainer.hidden * {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Controls box: compact text and icons */
.controls-box{display:flex;flex-direction:column;align-items:flex-start;justify-content:center;padding:10px;pointer-events:auto}
.controls-box .controls-title{font-weight:700;margin-bottom:6px;font-size:13px}
.controls-box .controls-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:6px;width:100%}
.controls-box .controls-list li{display:flex;align-items:center;gap:8px;font-size:12px;line-height:1.1;color:var(--text);}
.controls-box .controls-list .icon{flex:0 0 22px;width:22px;height:22px;display:inline-flex;align-items:center;justify-content:center;font-size:16px}
.controls-box .controls-list .controls-icon{flex:0 0 22px;width:22px;height:22px;display:inline-block;object-fit:contain}

/* Buildings box styling */
.buildings-box{display:flex;flex-direction:column;align-items:flex-start;justify-content:center;padding:10px;pointer-events:auto}
.buildings-box .buildings-title{font-weight:700;margin-bottom:6px;font-size:13px}
.buildings-box .buildings-list{list-style:none;margin:0;padding:0;display:grid;grid-template-columns:repeat(2, minmax(0,1fr));gap:6px 12px;width:100%}
.buildings-box .buildings-list li{display:flex;align-items:center;gap:8px;font-size:12px;line-height:1.1;color:var(--text);min-width:0}
.buildings-box .building-icon{flex:0 0 22px;width:22px;height:22px;display:inline-block;object-fit:contain}
.controls-box .controls-list strong{font-weight:600;font-size:12px}

/* Helper class to place elements inside the overlay that should receive pointer events */
.overlay-panel{pointer-events:auto}

/* Inline-play: container that holds two equal panes for canvases */
#inlinePlayContainer.inline-play-container{
  position: fixed;
  left: 0;
  right: 0;
  top: 35vh; /* pushed below top overlay by JS */
  height: calc(65vh);
  display: flex;
  gap: 0;
  z-index: 10000;
  box-sizing: border-box;
}
.inline-play-pane{ flex: 1 1 0; position: relative; overflow: hidden; min-width: 0; }
.inline-play-pane-left{ flex: 0 0 50% !important; }
.inline-play-pane-right{ flex: 0 0 50% !important; }
.inline-play-pane canvas{ position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; box-sizing: border-box; }

/* Visual separation between side-by-side canvases to show each canvas boundary */
.inline-play-pane-left {
  border-right: 2px solid rgba(255,255,255,0.06);
}
.inline-play-pane-left::after{
  content: "";
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  pointer-events: none;
}
.inline-play-pane canvas {
  outline: 1px solid rgba(255,255,255,0.03);
}

/* make sure inline HUDs sit above canvases */
#inlinePlayContainer.inline-play-container .modalHUD{ z-index: 10002; }

/* Stronger rules to override legacy #testCanvas sizing when inline-play is active */
#inlinePlayContainer.inline-play-container .inline-play-pane canvas {
  position: absolute !important;
  left: 0 !important;
  top: 0 !important;
  width: 100% !important;
  height: 100% !important;
  box-sizing: border-box !important;
}
#inlinePlayContainer.inline-play-container .inline-play-pane-left canvas { z-index: 2 !important; }
#inlinePlayContainer.inline-play-container .inline-play-pane-right canvas { z-index: 1 !important; }

/* Ensure right pane canvas is visible and pane widths are enforced */
#inlinePlayContainer.inline-play-container .inline-play-pane-right{ display: block !important; }
#inlinePlayContainer.inline-play-container .inline-play-pane-left{ display: block !important; }
#inlinePlayContainer.inline-play-container{ display:flex !important; flex-direction:row !important; }

